import{r as e}from"./CjrvnLDf.js";var t={project:{start:`start_date`,end:`date`},task:{start:`start_date`,end:`date`},deliverable:{start:`start_date`,end:`date`},deal:{start:`start_date`,end:`date`},event:{start:`start_date`,end:`date`}},n={weeks:24,months:5,quarters:1.6},r=[`project`,`deliverable`,`task`,`deal`,`event`],i={project:`Projects`,deliverable:`Deliverables`,task:`Tasks`,deal:`Deals`,event:`Events`},a={project:`project`,deliverable:`deliverable`,task:`task`,deal:`deal`,event:`event`},o=t,s={project:new Set([`complete`,`archived`]),task:new Set([`done`,`cancelled`]),deliverable:new Set([`delivered`,`accepted`,`rejected`]),deal:new Set([`won`,`lost`])},c=new Set([`archived`]),l={deal:`stage`};function u(e){return l[e]??`status`}function d(e){return e in o}function f(e){let t=o[e];return t?{startField:t.start,endField:t.end}:{}}function p(e){return a[e]??null}function m(e,t){let n=e.fields[t];if(typeof n!=`string`)return null;let r=/^(\d{4})-(\d{2})-(\d{2})/.exec(n);return r?new Date(Date.UTC(+r[1],r[2]-1,+r[3])):null}function h(e){let t=o[e.entityType];if(!t)return null;let n=m(e,t.start),r=m(e,t.end);if(!n&&!r)return null;if(n&&r)return n.getTime()>r.getTime()?{start:r,end:n}:{start:n,end:r};let i=n??r;return{start:i,end:i,singleEndpoint:n?`start`:`end`}}function g(e){let t=s[e.entityType]??c,n=e.fields[u(e.entityType)];return typeof n==`string`&&t.has(n)}function _(t,n){n.today;let r=[];for(let i of t){let t=p(i.entityType);if(!t)continue;let a=h(i);if(!a)continue;let o=g(i);n.hideCompleted&&o||r.push({entity:i,start:a.start,end:a.end,isCompleted:o,sectionKey:t,color:e(i.entityType),singleEndpoint:a.singleEndpoint})}return r}function v(e,t){let n=x(b(t),-30),r=x(b(t),90);for(let t of e)t.start.getTime()<n.getTime()&&(n=b(t.start)),t.end.getTime()>r.getTime()&&(r=b(x(t.end,1)));return{start:n,end:r,days:y(n,r)}}function y(e,t){return Math.round((t.getTime()-e.getTime())/864e5)}function b(e){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))}function x(e,t){let n=new Date(e.getTime());return n.setUTCDate(n.getUTCDate()+t),n}function S(e,t,n,r,i,a){let o=y(t.start,r)*n,s=y(r,i)*n;s>0&&e.push({x:o,width:s,label:a})}function C(e,t){let n=new Date(Date.UTC(e.start.getUTCFullYear(),0,1));for(;n<e.end;){let e=new Date(Date.UTC(n.getUTCFullYear()+1,0,1));t(n,e),n.setTime(e.getTime())}}function w(e,t){let n=Math.floor(e.start.getUTCMonth()/3)*3,r=new Date(Date.UTC(e.start.getUTCFullYear(),n,1));for(;r<e.end;){let e=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()+3,1));t(r,e),r.setTime(e.getTime())}}function T(e,t){let n=new Date(Date.UTC(e.start.getUTCFullYear(),e.start.getUTCMonth(),1));for(;n<e.end;){let e=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,1));t(n,e),n.setTime(e.getTime())}}function E(e,t){let n=new Date(e.start.getTime()),r=(n.getUTCDay()+6)%7;for(n.setUTCDate(n.getUTCDate()-r);n<e.end;){let e=x(n,7);t(n,e),n.setTime(e.getTime())}}function D(e,t,r){let i=r??n[t],a=[],o=[];return t===`weeks`?(T(e,(t,n)=>{S(a,e,i,t,n,t.toLocaleDateString(`en-US`,{month:`long`,year:`numeric`,timeZone:`UTC`}))}),E(e,(t,n)=>{S(o,e,i,t,n,t.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,timeZone:`UTC`}))})):t===`months`?(C(e,(t,n)=>{S(a,e,i,t,n,String(t.getUTCFullYear()))}),T(e,(t,n)=>{S(o,e,i,t,n,t.toLocaleDateString(`en-US`,{month:`short`,timeZone:`UTC`}))})):(w(e,(t,n)=>{S(a,e,i,t,n,`Q${Math.floor(t.getUTCMonth()/3)+1} ${t.getUTCFullYear()}`)}),T(e,(t,n)=>{S(o,e,i,t,n,t.toLocaleDateString(`en-US`,{month:`short`,timeZone:`UTC`}))})),{primary:a,secondary:o}}export{D as a,y as c,g as d,b as f,x as i,f as l,r as n,_ as o,t as p,n as r,v as s,i as t,d as u};