react-modern-gantt
Version:
A modern, customizable Gantt chart component for React applications with export functionality
1 lines • 59.5 kB
JavaScript
import e,{useRef as t,useState as r,useEffect as n,forwardRef as a,useImperativeHandle as o,useCallback as i}from"react";import{differenceInDays as s,differenceInYears as l,differenceInQuarters as c,differenceInMonths as u,differenceInWeeks as d,format as g,isValid as f,getWeek as m,startOfDay as h,endOfDay as v,isWithinInterval as p,startOfYear as D,addYears as w,startOfQuarter as M,addQuarters as E,addDays as y,addHours as k,addMinutes as T}from"date-fns";var b,x,N=function(){return N=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},N.apply(this,arguments)};function H(e,t,r,n){return new(r||(r=Promise))(function(a,o){function i(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,s)}l((n=n.apply(e,t||[])).next())})}function A(e,t){var r,n,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(a=o.trys,(a=a.length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){o.label=s[1];break}if(6===s[0]&&o.label<a[1]){o.label=a[1],a=s;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(s);break}a[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function Y(e,t,r){if(r||2===arguments.length)for(var n,a=0,o=t.length;a<o;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}function C(e,t){return void 0===t&&(t="default"),e.toLocaleString(t,{month:"short"})}function R(e,t,r){if(void 0===t&&(t=x.FULL_DATE),void 0===r&&(r="default"),!(e instanceof Date)||isNaN(e.getTime()))return"Invalid date";switch(t){case x.MONTH_YEAR:return e.toLocaleString(r,{month:"short",year:"2-digit"});case x.SHORT_DATE:return e.toLocaleString(r,{month:"short",day:"numeric"});case x.FULL_DATE:default:return e.toLocaleString(r,{month:"short",day:"numeric",year:"numeric"})}}function F(e,t){var r=[];if(!(e instanceof Date)||!(t instanceof Date)||isNaN(e.getTime())||isNaN(t.getTime()))return[];for(var n=e.getFullYear(),a=e.getMonth(),o=t.getFullYear(),i=t.getMonth(),s=n;s<=o;s++)for(var l=s===o?i:11,c=s===n?a:0;c<=l;c++)r.push(new Date(s,c,1));return r}function U(e,t){return new Date(e,t+1,0).getDate()}function O(e,t,r){void 0===r&&(r=b.MONTH);try{if(!(e instanceof Date)||!(t instanceof Date)||isNaN(e.getTime())||isNaN(t.getTime()))return{value:0,unit:"days"};var n=e<t?e:t,a=e<t?t:e;switch(r){case b.MINUTE:var o=Math.round((a.getTime()-n.getTime())/6e4);return{value:o,unit:1===o?"minute":"minutes"};case b.HOUR:var i=Math.round((a.getTime()-n.getTime())/36e5);return{value:i,unit:1===i?"hour":"hours"};case b.DAY:var g=s(a,n)+1;return{value:g,unit:1===g?"day":"days"};case b.WEEK:var f=d(a,n)+1;return{value:f,unit:1===f?"week":"weeks"};case b.MONTH:var m=u(a,n)+1;return{value:m,unit:1===m?"month":"months"};case b.QUARTER:var h=c(a,n)+1;return{value:h,unit:1===h?"quarter":"quarters"};case b.YEAR:var v=l(a,n)+1;return{value:v,unit:1===v?"year":"years"};default:var p=s(a,n)+1;return{value:p,unit:1===p?"day":"days"}}}catch(e){return console.error("Error calculating duration:",e),{value:0,unit:"days"}}}function I(e,t,r){if(void 0===r&&(r="default"),!(e instanceof Date)||!(t instanceof Date)||isNaN(e.getTime())||isNaN(t.getTime()))return"Invalid date range";var n=R(e,x.SHORT_DATE,r),a=R(t,x.SHORT_DATE,r);return"".concat(n," - ").concat(a)}function P(e,t){var r;if(!(e instanceof Date)||!(t instanceof Date)||isNaN(e.getTime())||isNaN(t.getTime()))return 0;e>t&&(e=(r=[t,e])[0],t=r[1]);var n=Math.abs(t.getTime()-e.getTime());return Math.ceil(n/864e5)}function S(e){if(!Array.isArray(e)||0===e.length)return new Date;var t=new Date,r=!1;if(e.forEach(function(e){e&&Array.isArray(e.tasks)&&e.tasks.forEach(function(e){e&&e.startDate instanceof Date&&(r?e.startDate<t&&(t=new Date(e.startDate)):(t=new Date(e.startDate),r=!0))})}),!r){var n=new Date;return new Date(n.getFullYear(),n.getMonth()-1,1)}return new Date(t.getFullYear(),t.getMonth(),1)}function L(e){if(!Array.isArray(e)||0===e.length)return new Date;var t=new Date,r=!1;if(e.forEach(function(e){e&&Array.isArray(e.tasks)&&e.tasks.forEach(function(e){e&&e.endDate instanceof Date&&(r?e.endDate>t&&(t=new Date(e.endDate)):(t=new Date(e.endDate),r=!0))})}),!r){var n=new Date;return new Date(n.getFullYear(),n.getMonth()+2,0)}return new Date(t.getFullYear(),t.getMonth()+1,0)}function W(e,t,r){if(!(e.startDate instanceof Date)||!(e.endDate instanceof Date)||isNaN(e.startDate.getTime())||isNaN(e.endDate.getTime()))return{left:"0%",width:"10%"};var n=F(new Date(t.getFullYear(),t.getMonth(),1),new Date(r.getFullYear(),r.getMonth()+1,0)),a=n.length,o=e.startDate.getFullYear(),i=e.startDate.getMonth(),s=n.findIndex(function(e){return e.getFullYear()===o&&e.getMonth()===i}),l=s<0?0:s,c=e.endDate.getFullYear(),u=e.endDate.getMonth(),d=n.findIndex(function(e){return e.getFullYear()===c&&e.getMonth()===u}),g=((d<0?n.length-1:d)-l+1)/a*100;return{left:"".concat(l/a*100,"%"),width:"".concat(g,"%")}}function j(e){if(!Array.isArray(e))return[];var t=e.filter(function(e){return e&&e.startDate instanceof Date&&e.endDate instanceof Date&&!isNaN(e.startDate.getTime())&&!isNaN(e.endDate.getTime())});if(0===t.length)return[];var r=[];return t.forEach(function(e){for(var t=!1,n=0;n<r.length;n++){if(!r[n].some(function(t){return!(e.startDate>=t.endDate||e.endDate<=t.startDate)})){r[n].push(e),t=!0;break}}t||r.push([e])}),r}"function"==typeof SuppressedError&&SuppressedError,function(e){e.MINUTE="minute",e.HOUR="hour",e.DAY="day",e.WEEK="week",e.MONTH="month",e.QUARTER="quarter",e.YEAR="year"}(b||(b={})),function(e){e.MONTH_YEAR="month-year",e.FULL_DATE="full-date",e.SHORT_DATE="short-date"}(x||(x={}));var q=e.memo(function(t){var r=t.months,n=t.currentMonthIndex,a=(t.locale,t.className),o=void 0===a?"":a,i=t.viewMode,s=void 0===i?b.MONTH:i,l=t.unitWidth,c=void 0===l?150:l,u=t.showTimelineHeader,d=void 0===u||u,h=[b.MINUTE,b.HOUR,b.DAY,b.WEEK].includes(s),v=function(){if(![b.MINUTE,b.HOUR,b.DAY,b.WEEK].includes(s)||0===r.length)return[];var e=[];if(s===b.MINUTE){var t=new Date(r[0]);t.setMinutes(0,0,0);var n=0;return r.forEach(function(r){r.getHours()===t.getHours()&&r.getDate()===t.getDate()&&r.getMonth()===t.getMonth()&&r.getFullYear()===t.getFullYear()?n+=1:(e.push({date:t,span:n}),(t=new Date(r)).setMinutes(0,0,0),n=1)}),n>0&&e.push({date:t,span:n}),e}if(s===b.HOUR){var a=new Date(r[0]);a.setHours(0,0,0,0);var o=0;return r.forEach(function(t){t.getDate()===a.getDate()&&t.getMonth()===a.getMonth()&&t.getFullYear()===a.getFullYear()?o+=1:(e.push({date:a,span:o}),(a=new Date(t)).setHours(0,0,0,0),o=1)}),o>0&&e.push({date:a,span:o}),e}if(r.length<2)return[];var i=new Date(r[0]),l=0;return r.forEach(function(t){t.getMonth()===i.getMonth()&&t.getFullYear()===i.getFullYear()?l+=1:(e.push({date:i,span:l}),i=new Date(t),l=1)}),l>0&&e.push({date:i,span:l}),e.length>1?e:[]}();return e.createElement("div",{className:"rmg-timeline ".concat(o),style:{"--gantt-unit-width":"".concat(c,"px")},"data-rmg-component":"timeline","data-view-mode":s},d&&h&&v.length>0&&e.createElement("div",{className:"rmg-timeline-header-higher","data-rmg-component":"timeline-header-higher"},v.map(function(t,r){return e.createElement("div",{key:"higher-level-".concat(r),className:"rmg-timeline-unit",style:{width:"".concat(t.span*c,"px")},"data-timeunit-higher":t.date.toISOString(),"data-rmg-component":"timeline-unit-higher"},function(e){if(!(e instanceof Date))return"";switch(s){case b.MINUTE:return g(e,"HH:00",{locale:void 0});case b.HOUR:return g(e,"MMM d",{locale:void 0});case b.DAY:case b.WEEK:return g(e,"MMM yyyy",{locale:void 0});default:return""}}(t.date))})),e.createElement("div",{className:"rmg-timeline-header","data-rmg-component":"timeline-header"},r.map(function(t,r){return e.createElement("div",{key:"timeunit-".concat(r),className:"rmg-timeline-unit ".concat(r===n?"rmg-timeline-unit-current":""),style:{width:"".concat(c,"px")},"data-timeunit":t.toISOString(),"data-rmg-component":"timeline-unit"},function(e){if(!(e instanceof Date&&f(e)))return"";switch(s){case b.MINUTE:return g(e,"HH:mm",{locale:void 0});case b.HOUR:return g(e,"HH:00",{locale:void 0});case b.DAY:return g(e,"d",{locale:void 0});case b.WEEK:var t=m(e);return"W".concat(t);case b.MONTH:return g(e,"MMM yyyy",{locale:void 0});case b.QUARTER:var r=Math.floor(e.getMonth()/3)+1;return"Q".concat(r," ").concat(e.getFullYear());case b.YEAR:return e.getFullYear().toString();default:return g(e,"MMM yyyy",{locale:void 0})}}(t))})))});q.displayName="Timeline";var z=function(t){var r=t.currentMonthIndex,n=t.height,a=t.label,o=void 0===a?"Today":a,i=t.dayOfMonth,s=t.className,l=void 0===s?"":s,c=t.markerClass,u=void 0===c?"":c,d=t.viewMode,g=void 0===d?b.MONTH:d,f=t.unitWidth,m=void 0===f?150:f;if(r<0)return null;var h=function(){var e=new Date,t=i||e.getDate();switch(g){case b.MINUTE:var n=e.getMinutes(),a=e.getSeconds();return r*m+m*((n+a/60)/60);case b.HOUR:var o=e.getMinutes();return r*m+m*(o/60);case b.DAY:return r*m+m/2;case b.WEEK:var s=e.getDay();return r*m+m*((s+7)%7/6);case b.MONTH:var l=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();return r*m+m*((t-1)/l);case b.QUARTER:var c=e.getMonth()%3;return r*m+m*(c/3);case b.YEAR:var u=e.getMonth();return r*m+m*(u/12);default:return r*m+m/2}}(),v=Math.max(100,n);return e.createElement("div",{className:"rmg-today-marker ".concat(l," ").concat(u),style:{left:"".concat(h,"px"),height:"".concat(v,"px")},"data-testid":"today-marker","data-rmg-component":"today-marker"},e.createElement("div",{className:"rmg-today-marker-label","data-rmg-component":"today-marker-label"},o))},B=function(){function e(){}return e.detectOverlaps=function(e,t){var r=this;if(void 0===t&&(t=b.MONTH),!Array.isArray(e)||0===e.length)return[];var n=Y([],e,!0).sort(function(e,t){return e.startDate&&t.startDate?e.startDate.getTime()-t.startDate.getTime():0}),a=[];return n.forEach(function(e){for(var n=!1,o=0;o<a.length;o++){if(!a[o].some(function(n){return r.tasksVisuallyOverlap(e,n,t)})){a[o].push(e),n=!0;break}}n||a.push([e])}),a},e.tasksVisuallyOverlap=function(e,t,r){if(void 0===r&&(r=b.MONTH),!(e.startDate&&e.endDate&&t.startDate&&t.endDate))return!1;var n=e.startDate.getTime(),a=e.endDate.getTime(),o=t.startDate.getTime(),i=t.endDate.getTime(),s=this.getCollisionBufferByViewMode(r);return n+s<i-s&&a-s>o+s||Math.abs(n-o)<2*s||Math.abs(a-i)<2*s},e.getCollisionBufferByViewMode=function(e){var t=36e5,r=24*t;switch(e){case b.MINUTE:return 3e4;case b.HOUR:return 9e5;case b.DAY:return t;case b.WEEK:return 4*t;case b.MONTH:return 12*t;case b.QUARTER:return r;case b.YEAR:return 2*r;default:return 12*t}},e.wouldCollide=function(e,t,r,n){var a=this;return void 0===r&&(r=b.MONTH),t.some(function(t){return t.id!==e.id&&t.id!==n&&a.tasksVisuallyOverlap(e,t,r)})},e.getPreviewArrangement=function(e,t,r){void 0===r&&(r=b.MONTH);var n=t.map(function(t){return t.id===e.id?e:t});return this.detectOverlaps(n,r)},e}(),K=function(){function e(){}return e.calculateDatesFromPosition=function(e,t,r,n,a,o,i){void 0===i&&(i=b.MONTH);try{var s=isNaN(e)?0:e,l=isNaN(t)||t<20?20:t,c=r.getTime(),u=(n.getTime()-c)/(a*o),d=s*u,g=l*u,f=new Date(c+d),m=new Date(c+d+g);switch(i){case b.MINUTE:var p=Math.round(e/o),D=Math.max(1,Math.round(t/o)),w=new Date(r);w.setSeconds(0,0),(f=new Date(w)).setMinutes(w.getMinutes()+p),f.setSeconds(0,0),(m=new Date(f)).setMinutes(f.getMinutes()+D-1),m.setSeconds(59,999);break;case b.HOUR:var M=Math.round(e/o),E=Math.max(1,Math.round(t/o)),y=new Date(r);y.setMinutes(0,0,0),(f=new Date(y)).setHours(y.getHours()+M),f.setMinutes(0,0,0),(m=new Date(f)).setHours(f.getHours()+E-1),m.setMinutes(59,59,999);break;case b.DAY:var k=Math.round(e/o),T=Math.max(1,Math.round(t/o)),x=new Date(r);x.setHours(0,0,0,0),(f=new Date(x)).setDate(x.getDate()+k),f.setHours(0,0,0,0),(m=new Date(f)).setDate(f.getDate()+T-1),m.setHours(23,59,59,999);break;default:f=h(f),m=v(m)}return f<r&&(f=new Date(r)),m>n&&(m=new Date(n)),{newStartDate:f,newEndDate:m}}catch(e){return console.error("Error calculating dates from position:",e),{newStartDate:new Date(r),newEndDate:new Date(n)}}},e.createUpdatedTask=function(e,t,r){return N(N({},e),{startDate:new Date(t),endDate:new Date(r)})},e.calculateTaskPixelPosition=function(e,t,r,n,a,o){var i;void 0===o&&(o=b.MONTH);try{if(!(e.startDate instanceof Date&&e.endDate instanceof Date))throw new Error("Invalid dates in task");var s=t.getTime(),l=r.getTime(),c=Math.max(e.startDate.getTime(),t.getTime()),u=Math.min(e.endDate.getTime(),r.getTime());if(o===b.MINUTE||o===b.HOUR||o===b.DAY){var d=void 0,g=void 0;if(o===b.MINUTE)d=s,g=l;else if(o===b.HOUR){var f=new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),0,0,0).getTime(),m=new Date(r.getFullYear(),r.getMonth(),r.getDate(),r.getHours(),59,59,999).getTime();d=f,g=m}else{var h=new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0,0).getTime(),v=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59,999).getTime();d=h,g=v}if(s=d,l=g,o===b.DAY){var p=new Date(new Date(c).getFullYear(),new Date(c).getMonth(),new Date(c).getDate(),0,0,0,0).getTime(),D=new Date(new Date(u).getFullYear(),new Date(u).getMonth(),new Date(u).getDate(),23,59,59,999).getTime();c=p,u=D}}var w=l-s,M=n*a,E=(c-s)/w*M,y=(u-c)/w*M;o===b.MINUTE?(E=Math.round(E),y=Math.max(10,Math.round(y))):o===b.HOUR?(E=Math.round(E),y=Math.max(15,Math.round(y))):o===b.DAY&&(E=Math.round(E/a)*a,y=Math.max(a,Math.round(y/a)*a));var k=((i={})[b.MINUTE]=10,i[b.HOUR]=15,i[b.DAY]=20,i[b.WEEK]=20,i[b.MONTH]=20,i[b.QUARTER]=30,i[b.YEAR]=40,i)[o]||20;y=Math.max(k,y);var T=M-E;return{leftPx:E,widthPx:y=Math.min(T,y)}}catch(e){return console.error("Error calculating task position:",e),{leftPx:0,widthPx:20}}},e.getLiveDatesFromElement=function(e,t,r,n,a,o){void 0===o&&(o=b.MONTH);try{if(!e)return{startDate:new Date(t),endDate:new Date(r)};var i=parseFloat(e.style.left||"0"),s=parseFloat(e.style.width||"0"),l=this.calculateDatesFromPosition(i,s,t,r,n,a,o);return{startDate:l.newStartDate,endDate:l.newEndDate}}catch(e){return console.error("Error getting live dates:",e),{startDate:new Date(t),endDate:new Date(r)}}},e.datesOverlap=function(e,t,r,n){return p(e,{start:r,end:n})||p(t,{start:r,end:n})||p(r,{start:e,end:t})||p(n,{start:e,end:t})},e}(),Q=function(){function e(){}return e.prepareCloneForExport=function(e,t,r){e.style.padding="".concat(t,"px"),r&&(e.style.backgroundColor="#1f2937");var n=e.querySelector(".rmg-timeline-container");if(n){n.scrollLeft=0,n.scrollTop=0,n.style.overflow="visible",n.style.scrollBehavior="auto";var a=n.querySelector(".rmg-timeline-content");a&&(n.style.width="".concat(a.scrollWidth,"px"),n.style.height="".concat(a.scrollHeight,"px"))}var o=e.querySelector(".rmg-timeline-grid");o&&(o.style.transform="translateX(0)"),e.querySelectorAll(".rmg-task-item").forEach(function(e){e.style.transition="none",e.style.willChange="auto",e.style.overflow="visible"});e.querySelectorAll([".rmg-task-item-name",".rmg-task-group-name",".rmg-task-group-description"].join(", ")).forEach(function(e){e.style.transform="translateY(-7px)",e.style.overflow="visible"});e.querySelectorAll([".rmg-title",".rmg-task-list-header",".rmg-timeline-unit",".rmg-today-marker-label"].join(", ")).forEach(function(e){e.style.overflow="visible"}),e.querySelectorAll(".rmg-resize-handle, .rmg-progress-handle, .rmg-progress-tooltip, .rmg-tooltip").forEach(function(e){e.style.display="none"});var i=e.querySelector(".rmg-header");i&&(i.style.display="none");var s=e.querySelector(".rmg-today-marker");s&&(s.style.display="none"),e.querySelectorAll("*").forEach(function(e){e.style.transition="none",e.style.animation="none"}),e.style.overflow="visible";var l=e.querySelector(".rmg-container");l&&(l.style.overflow="visible")},e.export=function(e){return H(this,arguments,void 0,function(e,t){var r,n,a,o,i,s,l,c,u,d,g,f,m,h,v,p,D,w,M=this;return void 0===t&&(t={}),A(this,function(E){switch(E.label){case 0:r=t.format,n=void 0===r?"png":r,a=t.filename,o=void 0===a?"gantt-chart":a,i=t.quality,s=void 0===i?.95:i,l=t.scale,c=void 0===l?2:l,u=t.backgroundColor,d=void 0===u?"#ffffff":u,g=t.padding,f=void 0===g?20:g,t.includeTitle,m=t.pdfOptions,h=void 0===m?{}:m,E.label=1;case 1:return E.trys.push([1,4,,5]),[4,this.loadHtml2Canvas()];case 2:if(!(v=E.sent()))throw new Error("html2canvas is required for export functionality. Please install it: npm install html2canvas");return p=e.classList.contains("rmg-dark"),[4,v(e,{scale:c,backgroundColor:d,useCORS:!0,allowTaint:!0,logging:!1,windowWidth:e.scrollWidth+2*f,windowHeight:e.scrollHeight+2*f,onclone:function(e,t){M.prepareCloneForExport(t,f,p)}})];case 3:switch(D=E.sent(),n){case"png":return[2,this.exportAsPng(D,o)];case"jpeg":case"jpg":return[2,this.exportAsJpeg(D,o,s)];case"pdf":return[2,this.exportAsPdf(D,o,h)];default:throw new Error("Unsupported export format: ".concat(n))}return[3,5];case 4:return w=E.sent(),console.error("Export failed:",w),[2,{success:!1,error:w instanceof Error?w.message:"Export failed"}];case 5:return[2]}})})},e.exportAsPng=function(e,t){var r=e.toDataURL("image/png");return this.downloadFile(r,"".concat(t,".png")),{success:!0,dataUrl:r,filename:"".concat(t,".png"),format:"png"}},e.exportAsJpeg=function(e,t,r){var n=e.toDataURL("image/jpeg",r);return this.downloadFile(n,"".concat(t,".jpg")),{success:!0,dataUrl:n,filename:"".concat(t,".jpg"),format:"jpeg"}},e.exportAsPdf=function(e,t){return H(this,arguments,void 0,function(e,t,r){var n,a,o,i,s,l,c,u,d,g,f,m,h,v,p,D,w,M,E,y,k,T,b,x,N,H,Y,C,R,F,U,O;return void 0===r&&(r={}),A(this,function(A){switch(A.label){case 0:return[4,this.loadJsPDF()];case 1:if(!(n=A.sent()))throw new Error("jspdf is required for PDF export. Please install it: npm install jspdf");if(a=r.orientation,o=void 0===a?"landscape":a,i=r.pageSize,s=void 0===i?"a4":i,l=r.margins,c=void 0===l?{top:10,right:10,bottom:10,left:10}:l,u=r.title,d=r.author,g=r.subject,f=r.fitToPage,m=void 0===f||f,h=e.width,v=e.height,p=h/v,D=new n({orientation:o,unit:"mm",format:s}),u&&D.setProperties({title:u}),d&&D.setProperties({author:d}),g&&D.setProperties({subject:g}),w=D.internal.pageSize.getWidth(),M=D.internal.pageSize.getHeight(),E=w-c.left-c.right,y=M-c.top-c.bottom,k=E/y,m?p>k?(T=E,b=E/p):(b=y,T=y*p):(x=25.4/96,T=Math.min(h*x,E),b=Math.min(v*x,y)),N=c.left+(E-T)/2,H=c.top+(y-b)/2,Y=e.toDataURL("image/png"),D.addImage(Y,"PNG",N,H,T,b),!m&&h*(25.4/96)>E)for(C=Math.ceil(h*(25.4/96)/E),R=1;R<C;R++)D.addPage(),F=-R*E+c.left,D.addImage(Y,"PNG",F,c.top,h*(25.4/96),b);return U=D.output("blob"),O=URL.createObjectURL(U),D.save("".concat(t,".pdf")),[2,{success:!0,dataUrl:O,filename:"".concat(t,".pdf"),format:"pdf",blob:U}]}})})},e.getDataUrl=function(e){return H(this,arguments,void 0,function(e,t,r){var n,a,o,i,s,l,c=this;return void 0===t&&(t="png"),void 0===r&&(r={}),A(this,function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),[4,this.loadHtml2Canvas()];case 1:if(!(n=u.sent()))throw new Error("html2canvas is required");return a=null!==(l=r.padding)&&void 0!==l?l:20,o=e.classList.contains("rmg-dark"),[4,n(e,{scale:r.scale||2,backgroundColor:r.backgroundColor||"#ffffff",useCORS:!0,allowTaint:!0,logging:!1,windowWidth:e.scrollWidth+2*a,windowHeight:e.scrollHeight+2*a,onclone:function(e,t){c.prepareCloneForExport(t,a,o)}})];case 2:return i=u.sent(),"png"===t?[2,i.toDataURL("image/png")]:"jpeg"===t||"jpg"===t?[2,i.toDataURL("image/jpeg",r.quality||.95)]:[2,i.toDataURL("image/png")];case 3:return s=u.sent(),console.error("Failed to get data URL:",s),[2,null];case 4:return[2]}})})},e.getBlob=function(e){return H(this,arguments,void 0,function(e,t,r){var n,a,o,i,s,l,c=this;return void 0===t&&(t="png"),void 0===r&&(r={}),A(this,function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),[4,this.loadHtml2Canvas()];case 1:if(!(n=u.sent()))throw new Error("html2canvas is required");return a=null!==(l=r.padding)&&void 0!==l?l:20,o=e.classList.contains("rmg-dark"),[4,n(e,{scale:r.scale||2,backgroundColor:r.backgroundColor||"#ffffff",useCORS:!0,allowTaint:!0,logging:!1,windowWidth:e.scrollWidth+2*a,windowHeight:e.scrollHeight+2*a,onclone:function(e,t){c.prepareCloneForExport(t,a,o)}})];case 2:return i=u.sent(),[2,new Promise(function(e){var n="jpeg"===t||"jpg"===t?"image/jpeg":"image/png";i.toBlob(function(t){return e(t)},n,r.quality||.95)})];case 3:return s=u.sent(),console.error("Failed to get blob:",s),[2,null];case 4:return[2]}})})},e.copyToClipboard=function(e){return H(this,arguments,void 0,function(e,t){var r,n;return void 0===t&&(t={}),A(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.getBlob(e,"png",t)];case 1:if(!(r=a.sent()))throw new Error("Failed to create image blob");if(!navigator.clipboard||!navigator.clipboard.write)throw new Error("Clipboard API not available");return[4,navigator.clipboard.write([new ClipboardItem({"image/png":r})])];case 2:return a.sent(),[2,!0];case 3:return n=a.sent(),console.error("Failed to copy to clipboard:",n),[2,!1];case 4:return[2]}})})},e.downloadFile=function(e,t){var r=document.createElement("a");r.href=e,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r)},e.loadHtml2Canvas=function(){return H(this,void 0,void 0,function(){return A(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,import("html2canvas")];case 1:return[2,e.sent().default];case 2:return e.sent(),console.warn("html2canvas is not installed. Export functionality requires html2canvas. Install it with: npm install html2canvas"),[2,null];case 3:return[2]}})})},e.loadJsPDF=function(){return H(this,void 0,void 0,function(){return A(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,import("jspdf")];case 1:return[2,e.sent().jsPDF];case 2:return e.sent(),console.warn("jspdf is not installed. PDF export functionality requires jspdf. Install it with: npm install jspdf"),[2,null];case 3:return[2]}})})},e.checkDependencies=function(){return H(this,void 0,void 0,function(){var e,t;return A(this,function(r){switch(r.label){case 0:return[4,this.loadHtml2Canvas()];case 1:return e=r.sent(),[4,this.loadJsPDF()];case 2:return t=r.sent(),[2,{html2canvas:null!==e,jspdf:null!==t}]}})})},e}(),G=function(t){var r=t.task,n=t.position,a=t.dragType,o=t.taskId,i=t.startDate,s=t.endDate,l=t.totalMonths,c=t.monthWidth,u=t.showProgress,d=void 0!==u&&u,f=t.instanceId,m=t.className,h=void 0===m?"":m,v=t.viewMode,p=void 0===v?b.MONTH:v,D=t.renderTooltip,w=r.startDate,M=r.endDate;try{var E=o||r.id,y=document.querySelector('[data-task-id="'.concat(E,'"][data-instance-id="').concat(f,'"]'));if(y&&(a||y.style.left||y.style.width)){var k=K.getLiveDatesFromElement(y,i,s,l,c,p);w=k.startDate,M=k.endDate}}catch(e){console.error("Error calculating live dates for tooltip:",e)}var T=O(w,M,p),x=function(e){if(!(e instanceof Date)||isNaN(e.getTime()))return"Invalid date";switch(p){case b.MINUTE:return g(e,"MMM d, yyyy HH:mm");case b.HOUR:return g(e,"MMM d, yyyy HH:00");case b.DAY:return g(e,"EEE, MMM d, yyyy");default:return g(e,"MMM d, yyyy")}},N=function(){if(!a)return null;switch(a){case"move":return"Moving task...";case"resize-left":return"Adjusting start date...";case"resize-right":return"Adjusting end date...";default:return null}}();return D?e.createElement("div",{className:"rmg-tooltip ".concat(h," rmg-tooltip-visible"),style:{left:"".concat(n.x,"px"),top:"".concat(n.y-40,"px")},"data-rmg-component":"tooltip"},D({task:r,position:n,dragType:a,startDate:w,endDate:M,viewMode:p})):e.createElement("div",{className:"rmg-tooltip ".concat(h," rmg-tooltip-visible"),style:{left:"".concat(n.x,"px"),top:"".concat(n.y-40,"px")},"data-rmg-component":"tooltip"},e.createElement("div",{className:"rmg-tooltip-title","data-rmg-component":"tooltip-title"},r.name||"Unnamed Task"),N&&e.createElement("div",{className:"rmg-tooltip-action","data-rmg-component":"tooltip-action"},N),e.createElement("div",{className:"rmg-tooltip-content","data-rmg-component":"tooltip-content"},e.createElement("div",{className:"rmg-tooltip-row","data-rmg-component":"tooltip-row"},e.createElement("div",{className:"rmg-tooltip-label"},"Start:"),e.createElement("div",{className:"rmg-tooltip-value"},x(w))),e.createElement("div",{className:"rmg-tooltip-row","data-rmg-component":"tooltip-row"},e.createElement("div",{className:"rmg-tooltip-label"},"End:"),e.createElement("div",{className:"rmg-tooltip-value"},x(M))),e.createElement("div",{className:"rmg-tooltip-row","data-rmg-component":"tooltip-row"},e.createElement("div",{className:"rmg-tooltip-label"},"Duration:"),e.createElement("div",{className:"rmg-tooltip-value"},T.value," ",T.unit)),d&&"number"==typeof r.percent&&e.createElement("div",{className:"rmg-tooltip-row","data-rmg-component":"tooltip-row"},e.createElement("div",{className:"rmg-tooltip-label"},"Progress:"),e.createElement("div",{className:"rmg-tooltip-value"},r.percent,"%")),r.dependencies&&r.dependencies.length>0&&e.createElement("div",{className:"rmg-tooltip-row","data-rmg-component":"tooltip-row"},e.createElement("div",{className:"rmg-tooltip-label"},"Dependencies:"),e.createElement("div",{className:"rmg-tooltip-value"},r.dependencies.join(", ")))))},_=function(t){var r=t.activeMode,n=t.onChange,a=t.darkMode,o=t.availableModes,i=[{id:b.MINUTE,label:"Minute"},{id:b.HOUR,label:"Hour"},{id:b.DAY,label:"Day"},{id:b.WEEK,label:"Week"},{id:b.MONTH,label:"Month"},{id:b.QUARTER,label:"Quarter"},{id:b.YEAR,label:"Year"}],s=[b.DAY,b.WEEK,b.MONTH,b.QUARTER,b.YEAR],l=o?i.filter(function(e){return o.includes(e.id)}):i.filter(function(e){return s.includes(e.id)});return e.createElement("div",{className:"rmg-view-mode-selector ".concat(a?"rmg-dark":""),"data-rmg-component":"view-mode-selector"},l.map(function(t){return e.createElement("button",{key:t.id,type:"button",className:"rmg-view-mode-button ".concat(r===t.id?"rmg-view-mode-button-active":""),onClick:function(){return n(t.id)},"data-rmg-component":"view-mode-button","data-view-mode":t.id,"data-active":r===t.id?"true":"false"},t.label)}))},X=function(a){var o=a.task,i=a.leftPx,s=a.widthPx,l=a.topPx,c=a.isHovered,u=a.isDragging,d=a.editMode,g=a.allowProgressEdit,f=void 0===g||g,m=a.allowTaskResize,h=void 0===m||m,v=a.allowTaskMove,p=void 0===v||v,D=a.showProgress,w=void 0!==D&&D,M=a.instanceId,E=a.renderTask,y=a.getTaskColor,k=a.onMouseDown,T=a.onMouseEnter,b=a.onMouseLeave,x=a.onClick,N=a.onProgressUpdate,H=(c||u)&&d&&h,A=d&&w&&f,Y=d&&p,C=t(null),R=t(null),F=r(!1),U=F[0],O=F[1],I=r(o.percent||0),P=I[0],S=I[1],L=r(!1),W=L[0],j=L[1];if(!o||!o.id)return null;o.color;var q="",z="var(--rmg-task-text-color)";if(y){var B=y({task:o,isHovered:c,isDragging:u});B.backgroundColor,q=B.borderColor||"",z=B.textColor||z}var K=function(e){Y&&k(e,o,"move")};if(n(function(){S(o.percent||0)},[o.percent]),E){var Q=E({task:o,leftPx:i,widthPx:s,topPx:l,isHovered:c,isDragging:u,editMode:d,showProgress:w});return e.createElement("div",{ref:C,className:"rmg-task-item-custom",style:{position:"absolute",left:"".concat(Math.max(0,i),"px"),width:"".concat(Math.max(20,s),"px"),top:"".concat(l,"px")},onClick:function(e){return x(e,o)},onMouseDown:Y?K:void 0,onMouseEnter:function(e){return T(e,o)},onMouseLeave:b,"data-testid":"task-".concat(o.id),"data-task-id":o.id,"data-instance-id":M,"data-dragging":u?"true":"false","data-rmg-component":"task"},Q)}var G={left:"".concat(i,"px"),top:"".concat(l,"px"),width:"".concat(s,"px"),backgroundColor:o.color||"var(--rmg-task-bg)",cursor:u?"grabbing":Y?"grab":"default"};return q&&(G.borderColor=q,G.borderWidth="1px",G.borderStyle="solid"),e.createElement("div",{ref:C,className:"rmg-task-item ".concat(u?"rmg-task-item-dragging":""),style:G,onClick:function(e){return x(e,o)},onMouseDown:Y?K:void 0,onMouseEnter:function(e){return T(e,o)},onMouseLeave:b,"data-testid":"task-".concat(o.id),"data-task-id":o.id,"data-instance-id":M,"data-dragging":u?"true":"false","data-rmg-component":"task"},H&&e.createElement("div",{className:"rmg-resize-handle rmg-resize-handle-left",onMouseDown:function(e){h&&(e.stopPropagation(),k(e,o,"resize-left"))},"data-rmg-component":"resize-handle","data-rmg-handle":"left",style:{cursor:"ew-resize"}}),e.createElement("div",{className:"rmg-task-item-name"},o.name||"Unnamed Task"),w&&"number"==typeof P&&e.createElement("div",{ref:R,className:"rmg-progress-bar",onClick:function(e){if(A&&N){e.stopPropagation();var t=e.currentTarget.clientWidth,r=e.nativeEvent.offsetX,n=Math.round(r/t*100);S(n),N(o,n)}},"data-rmg-component":"progress-bar"},e.createElement("div",{className:"rmg-progress-fill",style:{width:"".concat(P,"%"),transition:U?"none":"width 0.3s ease-out"},"data-rmg-component":"progress-fill"},A&&(c||U)&&e.createElement(e.Fragment,null,e.createElement("div",{className:"rmg-progress-handle ".concat(U?"rmg-progress-handle-dragging":""),onMouseDown:function(e){if(A){e.stopPropagation(),e.preventDefault(),e.nativeEvent.stopImmediatePropagation(),O(!0),j(!0),R.current&&(R.current.style.transition="width 0.05s ease-out");var t=C.current;if(t){var r=P,n=function(e){if(e.stopPropagation(),e.preventDefault(),t){var n=t.getBoundingClientRect(),a=n.width-2,o=Math.max(0,Math.min(a,e.clientX-n.left)),i=Math.round(o/a*100);r=Math.max(0,Math.min(100,i)),S(r)}},a=function(e){e.stopPropagation(),e.preventDefault(),O(!1),j(!1),document.removeEventListener("mousemove",n,!0),document.removeEventListener("mouseup",a,!0),R.current&&(R.current.style.transition=""),N&&r!==o.percent&&N(o,r)};document.addEventListener("mousemove",n,!0),document.addEventListener("mouseup",a,!0)}}},style:{cursor:"ew-resize",pointerEvents:"auto",zIndex:1e3},title:"Drag to adjust progress","data-rmg-component":"progress-handle"}),(W||U)&&e.createElement("div",{className:"rmg-progress-tooltip","data-rmg-component":"progress-tooltip"},P,"%")))),H&&e.createElement("div",{className:"rmg-resize-handle rmg-resize-handle-right",onMouseDown:function(e){h&&(e.stopPropagation(),k(e,o,"resize-right"))},"data-rmg-component":"resize-handle","data-rmg-handle":"right",style:{cursor:"ew-resize"}}))},V=function(t){var r=t.tasks,n=void 0===r?[]:r,a=t.headerLabel,o=void 0===a?"Resources":a,i=t.showIcon,s=void 0!==i&&i,l=t.showTaskCount,c=void 0!==l&&l,u=t.showDescription,d=void 0===u||u,g=t.rowHeight,f=void 0===g?40:g,m=t.className,h=void 0===m?"":m,v=t.onGroupClick,p=t.viewMode,D=t.showTimelineHeader,w=void 0===D||D,M=Array.isArray(n)?n:[];return e.createElement("div",{className:"rmg-task-list ".concat(h),"data-rmg-component":"task-list"},e.createElement("div",{className:"rmg-task-list-header","data-show-timeline-header":w},o),M.map(function(t){if(!t)return null;var r=function(e){if(!e.tasks||!Array.isArray(e.tasks))return 60;var t=B.detectOverlaps(e.tasks,p);return Math.max(60,t.length*f+20)}(t);return e.createElement("div",{key:"task-group-".concat(t.id||"unknown"),className:"rmg-task-group",style:{height:"".concat(r,"px")},onClick:function(){return e=t,void(v&&v(e));var e},"data-testid":"task-group-".concat(t.id||"unknown"),"data-rmg-component":"task-group","data-group-id":t.id},e.createElement("div",{className:"rmg-task-group-content"},s&&t.icon&&e.createElement("span",{className:"rmg-task-group-icon",dangerouslySetInnerHTML:{__html:t.icon},"data-rmg-component":"task-group-icon"}),e.createElement("div",{className:"rmg-task-group-name","data-rmg-component":"task-group-name"},t.name||"Unnamed")),d&&t.description&&e.createElement("div",{className:"rmg-task-group-description","data-rmg-component":"task-group-description"},t.description),c&&t.tasks&&t.tasks.length>0&&e.createElement("div",{className:"rmg-task-group-count","data-rmg-component":"task-group-count"},t.tasks.length," ",1===t.tasks.length?"task":"tasks"))}))},J=function(a){var o=a.taskGroup,i=a.startDate,s=a.endDate,l=a.totalMonths,c=a.monthWidth,u=a.editMode,d=void 0===u||u,g=a.allowProgressEdit,f=void 0===g||g,m=a.allowTaskResize,h=void 0===m||m,v=a.allowTaskMove,p=void 0===v||v,D=a.showProgress,w=void 0!==D&&D,M=a.className,E=void 0===M?"":M,y=a.tooltipClassName,k=void 0===y?"":y,T=a.onTaskUpdate,x=a.onTaskClick,H=a.onTaskSelect,A=a.onAutoScrollChange,Y=a.viewMode,C=void 0===Y?b.MONTH:Y,R=a.scrollContainerRef,F=a.smoothDragging,U=void 0===F||F;a.movementThreshold;var O=a.animationSpeed,I=void 0===O?.25:O,P=a.infiniteScroll,S=void 0!==P&&P,L=a.onTimelineExtend,W=a.renderTask,j=a.renderTooltip,q=a.getTaskColor;if(!o||!o.id||!Array.isArray(o.tasks))return e.createElement("div",{className:"rmg-task-row rmg-task-row-invalid"},"Invalid task group data");var z=i instanceof Date?i:new Date,Q=s instanceof Date?s:new Date,_=r(null),V=_[0],J=_[1],Z=r(null),$=Z[0],ee=Z[1],te=r(null),re=te[0],ne=te[1],ae=r(0),oe=ae[0],ie=ae[1],se=r({x:0,y:0}),le=se[0],ce=se[1],ue=r(null),de=ue[0],ge=ue[1],fe=r(null),me=fe[0],he=fe[1],ve=t(null),pe=t({x:0,y:0}),De=t(null),we=t(null),Me=t({left:0,width:0}),Ee=t(0),ye=t(!1),ke=t(null),Te=t(0),be=t(null),xe=t({minLeft:0,maxLeft:l*c}),Ne=t(null),He=t(null),Ae=t(null),Ye=t(null),Ce=t("task-row-".concat(Math.random().toString(36).substring(2,11))),Re=U&&C!==b.DAY,Fe=function(e){var t=N(N({},e),{startDate:new Date(e.startDate),endDate:new Date(e.endDate)});ge(t),Ae.current=t},Ue=de?B.getPreviewArrangement(de,o.tasks,C):B.detectOverlaps(o.tasks,C),Oe=Math.max(60,40*Ue.length+20);n(function(){xe.current={minLeft:0,maxLeft:l*c}},[l,c]);var Ie=function(){if(Ye.current&&De.current&&we.current){var e=Date.now(),t=e-Ee.current;Ee.current=e;var r=I||.25,n=we.current.left+(De.current.left-we.current.left)*r,a=we.current.width+(De.current.width-we.current.width)*r;Me.current.left=(n-we.current.left)/(t||16),Me.current.width=(a-we.current.width)/(t||16),we.current={left:n,width:a},Ye.current.style.left="".concat(n,"px"),Ye.current.style.width="".concat(a,"px"),He.current&&Pe(n,a),ve.current=requestAnimationFrame(Ie)}else ve.current=null},Pe=function(e,t){if(He.current)try{if(C===b.DAY){var r=Math.round(e/c),n=Math.max(1,Math.round(t/c)),a=new Date(z);a.setHours(0,0,0,0),(f=new Date(a)).setDate(a.getDate()+r),f.setHours(0,0,0,0),(m=new Date(f)).setDate(f.getDate()+n-1),m.setHours(23,59,59,999);var o=z.getTime(),i=Q.getTime(),s=new Date(Math.max(o,f.getTime())),u=new Date(Math.min(i,m.getTime())),d=N(N({},He.current),{startDate:s,endDate:u});Fe(d)}else{var g=K.calculateDatesFromPosition(e,t,z,Q,l,c,C),f=g.newStartDate,m=g.newEndDate;d=N(N({},He.current),{startDate:f,endDate:m});Fe(d)}}catch(e){console.error("Error updating dates:",e)}},Se=function(){if(!ye.current){ye.current=!0,(null==R?void 0:R.current)&&(R.current.style.scrollBehavior="auto");var e=performance.now(),t=function(){if(ye.current&&(null==R?void 0:R.current)&&De.current){var r=performance.now(),n=Math.min(r-e,16);e=r;var a=R.current,o=be.current,i=Te.current,s=a.scrollLeft,l=a.scrollWidth-a.clientWidth,c=i*(n/16);if("left"===o){if(s<=0)return S&&L?(L("left"),void Le()):void Le();var u=s-(f=Math.min(3*c,s));if(a.scrollLeft=u,De.current&&Ye.current){var d=parseFloat(Ye.current.style.left||"0"),g=Math.max(xe.current.minLeft,d-f);De.current.left=g,we.current&&(we.current.left=g),Ye.current.style.left="".concat(g,"px"),He.current&&Pe(g,De.current.width)}}else if("right"===o){if(s>=l)return S&&L?(L("right"),void Le()):void Le();var f;u=s+(f=Math.min(3*c,l-s));if(a.scrollLeft=u,De.current&&Ye.current&&me){d=parseFloat(Ye.current.style.left||"0");var m=xe.current.maxLeft-De.current.width;g=Math.min(m,d+f);De.current.left=g,we.current&&(we.current.left=g),Ye.current.style.left="".concat(g,"px"),He.current&&Pe(g,De.current.width)}}ye.current&&(ke.current=requestAnimationFrame(t))}};ke.current=requestAnimationFrame(t)}},Le=function(){ye.current=!1,null!==ke.current&&(cancelAnimationFrame(ke.current),ke.current=null),(null==R?void 0:R.current)&&(R.current.style.scrollBehavior="")},We=function(e,t){x&&!$&&x(t,o),H&&H(t,!0)},je=function(e,t){$||(J(t),ze(e))},qe=function(){$||J(null)},ze=function(e){if(Ne.current){var t=Ne.current.getBoundingClientRect();ce({x:e.clientX-t.left+20,y:e.clientY-t.top})}},Be=function(e,t,r){if(d){e.preventDefault(),e.stopPropagation();var n=document.querySelector('[data-task-id="'.concat(t.id,'"][data-instance-id="').concat(Ce.current,'"]'));if(n){Ye.current=n;var a=parseFloat(n.style.left||"0"),o=parseFloat(n.style.width||"0");he({left:a,width:o,startDate:new Date(t.startDate),endDate:new Date(t.endDate)}),De.current={left:a,width:o},we.current={left:a,width:o},pe.current={x:e.clientX,y:e.clientY},Ee.current=Date.now(),Me.current={left:0,width:0},n.setAttribute("data-dragging","true"),n.style.transition="none",ee(t),ne(r),ie(e.clientX),ge(t),function(e){var t=N(N({},e),{startDate:new Date(e.startDate),endDate:new Date(e.endDate)});ee(t),He.current=t}(t),Fe(t),null===ve.current&&Re&&(ve.current=requestAnimationFrame(Ie)),document.addEventListener("mouseup",Qe),document.addEventListener("mousemove",Ke)}}},Ke=function(e){if(pe.current={x:e.clientX,y:e.clientY},e instanceof MouseEvent&&V&&Ne.current){var t=Ne.current.getBoundingClientRect();ce({x:e.clientX-t.left+20,y:e.clientY-t.top})}else e instanceof MouseEvent||ze(e);if($&&(null==R?void 0:R.current)&&function(e){if((null==R?void 0:R.current)&&$){var t=R.current.getBoundingClientRect(),r=null,n=0;e<t.left+40?(r="left",n=Math.max(1,Math.round((40-(e-t.left))/10))):e>t.right-40&&(r="right",n=Math.max(1,Math.round((e-(t.right-40))/10))),be.current=r,Te.current=n,r&&!ye.current?(Se(),A&&A(!0)):!r&&ye.current&&(Le(),A&&A(!1))}}(e.clientX),$&&re&&me&&Ne.current&&De.current)try{var r=e.clientX-oe,n=l*c,a=De.current.left,o=De.current.width;switch(re){case"move":a=Math.max(0,Math.min(n-me.width,me.left+r)),C===b.DAY&&(a=Math.round(a/c)*c);break;case"resize-left":var i=me.width-20,s=Math.min(i,r);a=Math.max(0,me.left+s),C===b.DAY&&(a=Math.round(a/c)*c);var u=me.left+me.width;o=Math.max(20,u-a),C===b.DAY&&(o=Math.round(o/c)*c,o=Math.max(c,o));break;case"resize-right":o=Math.max(20,Math.min(n-me.left,me.width+r)),C===b.DAY&&(o=Math.round(o/c)*c,o=Math.max(c,o))}De.current={left:a,width:o},C===b.DAY&&Ye.current?(Ye.current.style.left="".concat(a,"px"),Ye.current.style.width="".concat(o,"px"),Pe(a,o)):Re?null===ve.current&&(Ee.current=Date.now(),ve.current=requestAnimationFrame(Ie)):Ye.current&&(Ye.current.style.left="".concat(a,"px"),Ye.current.style.width="".concat(o,"px"),Pe(a,o))}catch(e){console.error("Error in handleMouseMove:",e)}},Qe=function(){try{null!==ve.current&&(cancelAnimationFrame(ve.current),ve.current=null),function(){if(Ye.current&&De.current&&He.current){var e=De.current.left,t=De.current.width;C===b.DAY?(e=Math.round(e/c)*c,t=Math.round(t/c)*c,t=Math.max(c,t),Ye.current.style.transition="transform 0.15s ease-out, left 0.15s ease-out, width 0.15s ease-out",Ye.current.style.left="".concat(e,"px"),Ye.current.style.width="".concat(t,"px"),Pe(e,t)):Re||(Ye.current.style.transition="transform 0.15s ease-out, left 0.15s ease-out, width 0.15s ease-out",Ye.current.style.left="".concat(e,"px"),Ye.current.style.width="".concat(t,"px"));var r=Ae.current;if(r){var n=z.getTime(),a=Q.getTime();if(r.startDate.getTime()<n&&(r=N(N({},r),{startDate:new Date(n)})),r.endDate.getTime()>a&&(r=N(N({},r),{endDate:new Date(a)})),T&&r)try{T(o.id,r)}catch(e){console.error("Error in onTaskUpdate:",e)}}}}(),Ye.current&&(Ye.current.setAttribute("data-dragging","false"),setTimeout(function(){Ye.current&&(Ye.current.style.transition="")},200))}catch(e){console.error("Error in handleMouseUp:",e)}finally{Le(),A&&A(!1),ee(null),ne(null),ge(null),he(null),He.current=null,Ae.current=null,Ye.current=null,De.current=null,we.current=null,document.removeEventListener("mouseup",Qe),document.removeEventListener("mousemove",Ke)}},Ge=function(e,t){if(T&&o.id)try{var r=N(N({},e),{percent:t});T(o.id,r)}catch(e){console.error("Error updating task progress:",e)}};return n(function(){return function(){document.removeEventListener("mouseup",Qe),document.removeEventListener("mousemove",Ke),Le(),null!==ve.current&&(cancelAnimationFrame(ve.current),ve.current=null)}},[]),o.tasks&&0!==o.tasks.length?e.createElement("div",{className:"rmg-task-row ".concat(E),style:{height:"".concat(Oe,"px"),minWidth:"".concat(l*c,"px")},onMouseMove:function(e){return Ke(e)},onMouseLeave:function(){return J(null)},ref:Ne,"data-testid":"task-row-".concat(o.id),"data-instance-id":Ce.current,"data-rmg-component":"task-row","data-group-id":o.id},Ue.map(function(t,r){return e.createElement(e.Fragment,{key:"task-row-".concat(r)},t.map(function(t){try{if(!(t&&t.id&&t.startDate instanceof Date&&t.endDate instanceof Date))return console.warn("Invalid task data:",t),null;var n=K.calculateTaskPixelPosition(t,z,Q,l,c,C),a=n.leftPx,o=n.widthPx,i=(null==V?void 0:V.id)===t.id,s=(null==$?void 0:$.id)===t.id,u=40*r+10;return e.createElement(X,{key:"task-".concat(t.id),task:t,leftPx:a,widthPx:o,topPx:u,isHovered:i,isDragging:s,editMode:d,allowProgressEdit:f,allowTaskResize:h,allowTaskMove:p,showProgress:w,instanceId:Ce.current,onMouseDown:Be,onMouseEnter:je,onMouseLeave:qe,onClick:We,renderTask:W,getTaskColor:q,onProgressUpdate:Ge})}catch(e){return console.error("Error rendering task:",e),null}}))}),(V||$)&&e.createElement(G,{task:de||$||V,position:le,dragType:re,taskId:null==$?void 0:$.id,startDate:z,endDate:Q,totalMonths:l,monthWidth:c,showProgress:w,instanceId:Ce.current,className:k,viewMode:C,renderTooltip:j})):e.createElement("div",{className:"rmg-task-row rmg-task-row-empty"},"No tasks available")},Z=a(function(a,i){var s=a.tasks,l=void 0===s?[]:s,c=a.startDate,u=a.endDate,d=a.title,g=void 0===d?"Project Timeline":d,f=a.currentDate,m=void 0===f?new Date:f,h=a.showCurrentDateMarker,v=void 0===h||h,p=a.todayLabel,x=void 0===p?"Today":p,C=a.editMode,R=void 0===C||C,U=a.allowProgressEdit,O=void 0===U||U,I=a.allowTaskResize,P=void 0===I||I,W=a.allowTaskMove,j=void 0===W||W,K=a.headerLabel,G=void 0===K?"Resources":K,X=a.showProgress,Z=void 0!==X&&X,$=a.darkMode,ee=void 0!==$&&$,te=a.locale,re=void 0===te?"default":te,ne=a.styles,ae=void 0===ne?{}:ne,oe=a.viewMode,ie=void 0===oe?b.MONTH:oe,se=a.viewModes,le=a.showTimelineHeader,ce=void 0===le||le,ue=a.smoothDragging,de=void 0===ue||ue,ge=a.movementThreshold,fe=void 0===ge?3:ge,me=a.animationSpeed,he=void 0===me?.25:me,ve=a.minuteStep,pe=void 0===ve?5:ve,De=a.infiniteScroll,we=void 0!==De&&De,Me=a.onTimelineExtend,Ee=a.focusMode,ye=void 0===Ee||Ee,ke=a.renderTaskList,Te=a.renderTask,be=a.renderTooltip,xe=a.renderViewModeSelector,Ne=a.renderHeader,He=a.renderTimelineHeader,Ae=a.getTaskColor,Ye=a.onTaskUpdate,Ce=a.onTaskClick,Re=a.onTaskSelect;a.onTaskDoubleClick;var Fe=a.onGroupClick,Ue=a.onViewModeChange,Oe=a.fontSize;a.rowHeight,a.timeStep;var Ie=a.maxHeight,Pe=t(null),Se=t(null),Le=r(ie),We=Le[0],je=Le[1],qe=r([]);qe[0];var ze=qe[1],Be=r(150),Ke=Be[0],Qe=Be[1],Ge=r(!1),_e=Ge[0],Xe=Ge[1],Ve=r(0),Je=Ve[0],Ze=Ve[1],$e=c||S(l),et=u||L(l);o(i,function(){return{exportChart:function(e){return H(void 0,void 0,void 0,function(){return A(this,function(t){return Pe.current?[2,Q.export(Pe.current,N(N({},e),{backgroundColor:ee?"#1f2937":(null==e?void 0:e.backgroundColor)||"#ffffff"}))]:[2,{success:!1,error:"Container element not available"}]})})},getDataUrl:function(e,t){return H(void 0,void 0,void 0,function(){return A(this,function(r){return Pe.current?[2,Q.getDataUrl(Pe.current,e,N(N({},t),{backgroundColor:ee?"#1f2937":(null==t?void 0:t.backgroundColor)||"#ffffff"}))]:[2,null]})})},getBlob:function(e,t){return H(void 0,void 0,void 0,function(){return A(this,function(r){return Pe.current?[2,Q.getBlob(Pe.current,e,N(N({},t),{backgroundColor:ee?"#1f2937":(null==t?void 0:t.backgroundColor)||"#ffffff"}))]:[2,null]})})},copyToClipboard:function(e){return H(void 0,void 0,void 0,function(){return A(this,function(t){return Pe.current?[2,Q.copyToClipboard(Pe.current,N(N({},e),{backgroundColor:ee?"#1f2937":(null==e?void 0:e.backgroundColor)||"#ffffff"}))]:[2,!1]})})},getContainerElement:function(){return Pe.current},scrollToDate:function(e){if(Se.current){var t=Mt(We),r=tt(e,t,We);if(r>=0){var n=r*Ke;Se.current.scrollLeft=n-Se.current.clientWidth/2}}},scrollToToday:function(){Et(We,Ke)}}},[ee,We,Ke]);var tt=function(e,t,r){switch(r){case b.MINUTE:return t.findIndex(function(t){return t.getHours()===e.getHours()&&Math.floor(t.getMinutes()/(pe||5))===Math.floor(e.getMinutes()/(pe||5))&&t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()});case b.HOUR:return t.findIndex(function(t){return t.getHours()===e.getHours()&&t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()});case b.DAY:return t.findIndex(function(t){return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()});case b.WEEK:return t.findIndex(function(t){var r=new Date(t);return r.setDate(t.getDate()+6),e>=t&&e<=r});case b.MONTH:return t.findIndex(function(t){return t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()});case b.QUARTER:var n=Math.floor(e.getMonth()/3);return t.findIndex(function(t){return Math.floor(t.getMonth()/3)===n&&t.getFullYear()===e.getFullYear()});case b.YEAR:return t.findIndex(function(t){return t.getFullYear()===e.getFullYear()});default:return-1}},rt=function(e){if(we&&Me){var t=nt(We),r=$e,n=et;"left"===e?r=ot($e,t,We):n=at(et,t,We),Me(e,r,n)}},nt=function(e){switch(e){case b.MINUTE:return 60;case b.HOUR:return 24;case b.DAY:return 7;case b.WEEK:return 4;case b.MONTH:return 3;case b.QUARTER:return 4;case b.YEAR:return 5;default:return 3}},at=function(e,t,r){switch(r){case b.MINUTE:return T(e,t);case b.HOUR:return k(e,t);case b.DAY:return y(e,t);case b.WEEK:return y(e,7*t);case b.MONTH:return new Date(e.getFullYear(),e.getMonth()+t,e.getDate());case b.QUARTER:return E(e,t);case b.YEAR:return w(e,t);default:return e}},ot=function(e,t,r){switch(r){case b.MINUTE:return T(e,-t);case b.HOUR:return k(e,-t);case b.DAY:return y(e,-t);case b.WEEK:return y(e,7*-t);case b.MONTH:return new Date(e.getFullYear(),e.getMonth()-t,e.getDate());case b.QUARTER:return E(e,-t);case b.YEAR:return w(e,-t);default:return e}},it=function(e,t,r){void 0===r&&(r=5);var n=[],a=new Date(e);a.setSeconds(0,0);var o=a.getMinutes(),i=Math.floor(o/r)*r;a.setMinutes(i);var s=new Date(t);s.setMinutes(s.getMinutes(),59,999);for(var l=0;a<=s&&l<500;)n.push(new Date(a)),a=T(a,r),l++;return l>=500&&console.warn("Minute view limited to ".concat(500," intervals for performance. ")+"Consider using a larger time range or switching to Hour view."),n},st=function(e,t){var r=[],n=new Date(e);n.setMinutes(0,0,0);var a=new Date(t);for(a.setHours(a.getHours(),59,59,999);n<=a;)r.push(new Date(n)),n=k(n,1);return r},lt=function(e,t){var r=[],n=new Date(e);n.setHours(0,0,0,0);var a=new Date(t);for(a.setHours(23,59,59,999);n<=a;)r.push(new Date(n)),n=y(n,1);return r},ct=function(e,t){for(var r=[],n=new Date(e);n<=t;)r.push(new Date(n)),n=y(n,7);return r},ut=function(e,t){for(var r=[],n=M(new Date(e));n<=t;)r.push(new Date(n)),n=E(n,1);return r},dt=function(e,t){for(var r=[],n=D(new Date(e));n<=t;)r.push(new Date(n)),n=w(n,1);return r},gt=function(){return!1!==se&&(Array.isArray(se)?se:[b.DAY,b.WEEK,b.MONTH,b.QUARTER,b.YEAR])},ft=function(){switch(We){case b.MINUTE:return it($e,et,pe);case b.HOUR:return st($e,et);case b.DAY:return lt($e,et);case b.WEEK:return ct($e,et);case b.MONTH:return F($e,et);case b.QUARTER:return ut($e,et);case b.YEAR:return dt($e,et);default:return F($e,et)}}(),mt=ft.length,ht=function(){var e=new Date;switch(We){case b.MINUTE:return ft.findIndex(function(t){return t.getHours()===e.getHours()&&Math.floor(t.getMinutes()/(pe||5))===Math.floor(e.getMinutes()/(pe||5))&&t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()});case b.HOUR:return ft.findIndex(function(t){return t.getHours()===e.getHours()&&t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()});case b.DAY:return ft.findIndex(function(t){return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()});case b.WEEK:return ft.findIndex(function(t){var r=new Date(t);return r.setDate(t.getDate()+6),e>=t&&e<=r});case b.MONTH:return ft.findIndex(function(t){return t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()});case b.QUARTER:var t=Math.floor(e.getMonth()/3);return ft.findIndex(function(r){return Math.floor(r.getMonth()/3)===t&&r.getFullYear()===e.getFullYear()});case b.YEAR:return ft.findIndex(function(t){return t.getFullYear()===e.getFullYear()});default:return-1}}(),vt=function(e){Xe(e),Se.current&&(e?Se.current.classList.add("rmg-auto-scrolling"):Se.current.classList.remove("rmg-auto-scrolling"))},pt=function(e,t){if(Ye)try{var r=N(N({},t),{startDate:t.startDate instanceof Date?t.startDate:new Date(t.startDate),endDate:t.endDate instanceof Date?t.endDate:new Date(t.endDate)});Ze(function(e){return e+1}),Ye(e,r)}catch(e){console.error("Error in handleTaskUpdate:",e)}},Dt=function(e,t){if(Ce)try{Ce(e,t)}catch(e){console.error("Error in handleTaskClick:",e)}},wt=function(e,t){if(ze(function(r){return t?Y(Y([],r,!0),[e.id],!1):r.filter(function(t){return t!==e.id})}),Re)try{Re(e,t)}catch(e){console.error("Error in onTaskSelect handler: