1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9845],{19845:(e,t,n)=>{n.r(t),n.d(t,{default:()=>M});var a=n(95155),l=n(12115),s=n(39390),i=n(14585),r=n(37401),o=n(82146),d=n(13038),c=n(12711),u=n(8683),m=n(12180),p=n(27896),h=n(90103);let x={planned:"Planned",on_track:"On Track",at_risk:"At Risk",slipped:"Slipped",complete:"Complete",cancelled:"Cancelled"},g={outreach:"Outreach",engagement:"Engagement",reminder:"Reminder",confirmation:"Confirmation",lead_meeting:"Lead Meeting",team_meeting:"Team Meeting",checkpoint:"Checkpoint",placement:"Placement",vendor:"Vendor",infrastructure:"Infrastructure",ticketing:"Ticketing",finance:"Finance",design:"Design",comms:"Comms",power:"Power"},v={comms:"Comms",checkpoint:"Checkpoint",lead_meeting:"Lead Meeting",engagement:"Engagement",power:"Power",team_meeting:"Team Meeting"},b={invitations:"Invitations",members:"Members",team_leads:"Team Leads",power_team:"Power Team",finance_team:"Finance Team",admin_team:"Admin Team",board:"Board"},j={all:"All",upcoming:"Upcoming",past_due:"Past Due",completed:"Completed"},w=new Set(["planned","on_track","at_risk","slipped"]);function y(e){switch(e){case"all":return{filter:{}};case"upcoming":return{filter:{},dateRange:"next30",customPredicate:e=>w.has(e.status)};case"past_due":return{filter:{},customPredicate:e=>w.has(e.status)&&e.targetDate.toMillis()<Date.now()};case"completed":return{filter:{status:["complete"]}}}}function f(e){return"complete"!==e.status&&"cancelled"!==e.status&&e.targetDate.toMillis()<Date.now()}function N(e){let{options:t,value:n,onChange:l,labels:s}=e,i=new Set(n);return(0,a.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap",children:t.map(e=>{let t=i.has(e);return(0,a.jsx)("button",{type:"button",onClick:()=>{t?l(n.filter(t=>t!==e)):l([...n,e])},className:"inline-flex items-center justify-center gap-1 h-7 px-3 rounded-full border text-[11px] leading-none whitespace-nowrap transition ".concat(t?"bg-weavePink/15 text-weavePink border-weavePink/30":"bg-white/[0.04] text-t2 border-white/[0.06] hover:bg-white/[0.08]"),children:s[e]},e)})})}let k={planned:"bg-white/[0.04] text-t2 border-white/[0.08]",on_track:"bg-emerald-500/15 text-positive-ink border-emerald-500/30",at_risk:"bg-yellow-500/15 text-attention-ink border-yellow-500/30",slipped:"bg-red-500/15 text-negative-ink border-red-500/30",complete:"bg-white/[0.06] text-t3 border-white/[0.10]",cancelled:"bg-white/[0.04] text-t4 border-white/[0.06] line-through"};function D(e,t){var n,a,l,i,r,o,d,c,u,m,p,h,x,g,v,b,j,w,y,f,N;return{id:e,eventId:null!=(n=t.eventId)?n:"",producerId:null!=(a=t.producerId)?a:"",title:null!=(l=t.title)?l:"(untitled milestone)",description:null!=(i=t.description)?i:void 0,category:null!=(r=t.category)?r:"other",phase:null!=(o=t.phase)?o:"pre_production",channels:Array.isArray(t.channels)?t.channels:[],visibility:Array.isArray(t.visibility)?t.visibility:[],beginDate:null!=(d=t.beginDate)?d:void 0,targetDate:null!=(c=t.targetDate)?c:s.Timestamp.now(),completedAt:null!=(u=t.completedAt)?u:void 0,status:null!=(m=t.status)?m:"planned",owner:null!=(p=t.owner)?p:void 0,teamResponsibleId:null!=(h=t.teamResponsibleId)?h:void 0,teamResponsibleName:null!=(x=t.teamResponsibleName)?x:void 0,watchers:Array.isArray(t.watchers)?t.watchers:[],projectIds:Array.isArray(t.projectIds)?t.projectIds:[],taskIds:Array.isArray(t.taskIds)?t.taskIds:[],vendor:null!=(g=t.vendor)?g:void 0,dependsOnMilestoneIds:Array.isArray(t.dependsOnMilestoneIds)?t.dependsOnMilestoneIds:[],link:null!=(v=t.link)?v:void 0,attachmentRefs:Array.isArray(t.attachmentRefs)?t.attachmentRefs:[],isPinned:null!=(b=t.isPinned)&&b,isActive:!1!==t.isActive,tags:Array.isArray(t.tags)?t.tags:[],notes:null!=(j=t.notes)?j:void 0,createdAt:null!=(w=t.createdAt)?w:s.Timestamp.now(),updatedAt:null!=(y=t.updatedAt)?y:s.Timestamp.now(),createdBy:null!=(f=t.createdBy)?f:"",lastModifiedBy:null!=(N=t.lastModifiedBy)?N:void 0}}function C(e){if(!e)return"";let t=e.toDate(),n=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0");return"".concat(n,"-").concat(a,"-").concat(l)}function I(e){if(!e)return;let t=new Date("".concat(e,"T12:00:00"));if(!Number.isNaN(t.getTime()))return s.Timestamp.fromDate(t)}
1let A={title:"",description:"",category:"comms",phase:"pre_production",channels:[],visibility:[],beginDate:"",targetDate:"",completedAt:"",ownerId:"",ownerName:"",teamResponsibleId:"",teamResponsibleName:"",vendorId:"",vendorName:"",watcherIds:[],link:"",notes:"",tagsInput:"",isActive:!0,isPinned:!1,projectIds:[],taskIds:[],dependsOnMilestoneIds:[],attachmentRefs:[]};function M(){let{user:e,notify:t}=(0,r.Y)(),{eventId:n}=(0,o._)(),p=n?"events/".concat(n,"/milestones"):null,{data:w,loading:N}=(0,d.$)(p,[],D),[k,C]=(0,l.useState)("all"),[A,M]=(0,l.useState)("all"),[R,P]=(0,l.useState)("all"),[_,F]=(0,l.useState)(""),[B,Y]=(0,l.useState)("none"),[$,E]=(0,l.useState)("all"),U=(0,l.useCallback)(e=>{var t,n;let a=y(e);P(e),Y(null!=(t=a.groupBy)?t:"none"),E(null!=(n=a.dateRange)?n:"all")},[]),[G,V]=(0,l.useState)("list"),[X,H]=(0,l.useState)(null),[W,z]=(0,l.useState)(!1),[K,Z]=(0,l.useState)(null),q=(0,l.useMemo)(()=>[...w].sort((e,t)=>e.targetDate.toMillis()-t.targetDate.toMillis()),[w]),J=(0,l.useMemo)(()=>{let e=_.trim().toLowerCase(),t=y(R),n=t.filter,a=n.category?new Set(n.category):null,l=n.visibility?new Set(n.visibility):null,s=n.status?new Set(n.status):null,i=t.customPredicate,r=Date.now(),o=new Date(new Date().getFullYear(),0,1).getTime(),d=new Date(new Date().getFullYear(),11,31,23,59).getTime(),c=new Date(new Date().getFullYear(),new Date().getMonth(),1).getTime(),u=new Date(new Date().getFullYear(),new Date().getMonth()+1,0,23,59).getTime(),m=r+2592e6;return q.filter(t=>{var n,p;if("all"!==k&&t.status!==k||"all"!==A&&t.phase!==A||a&&!a.has(t.category)||l&&!(null!=(n=t.visibility)?n:[]).some(e=>l.has(e))||s&&!s.has(t.status)||i&&!i(t))return!1;if("all"!==$){let e=t.targetDate.toMillis();if("thisYear"===$&&(e<o||e>d)||"thisMonth"===$&&(e<c||e>u)||"next30"===$&&(e<r||e>m)||"past"===$&&e>=r)return!1}return!e||!!"".concat(t.title," ").concat(null!=(p=t.description)?p:"").toLowerCase().includes(e)})},[q,k,A,R,_,$]),Q=(0,l.useMemo)(()=>{if("none"===B)return null;let e=new Map;for(let i of J){var t,n,a,l,s;let r,o;if("date"===B){let e=i.targetDate.toDate();r="".concat(e.getFullYear(),"-").concat(String(e.getMonth()+1).padStart(2,"0")),o=e.toLocaleString("en-US",{month:"long",year:"numeric"})}else if("category"===B)r=i.category,o=g[i.category];else if("channel"===B){let a=null!=(t=i.channels)?t:[];if(0===a.length)r="_none",o="(no channel)";else{for(let t of a){let a="ch:".concat(t),l=null!=(n=e.get(a))?n:{label:v[t],items:[]};l.items.push(i),e.set(a,l)}continue}}else"phase"===B?(r=i.phase,o=h.XA[i.phase]):"status"===B?(r=i.status,o=x[i.status]):"team"===B?(r=null!=(a=i.teamResponsibleId)?a:"_none",o=null!=(l=i.teamResponsibleName)?l:"(no team)"):(r="",o="");let d=null!=(s=e.get(r))?s:{label:o,items:[]};d.items.push(i),e.set(r,d)}return Array.from(e.entries()).map(e=>{let[t,n]=e;return{key:t,...n}}).sort((e,t)=>"date"===B?e.key.localeCompare(t.key):e.label.localeCompare(t.label))},[J,B]),ee=(0,l.useMemo)(()=>{let e={all:q.length,upcoming:0,past_due:0,completed:0},t=Date.now(),n=t+2592e6,a=new Set(["planned","on_track","at_risk","slipped"]);for(let l of q){let s=l.targetDate.toMillis();a.has(l.status)&&(s>=t&&s<=n&&e.upcoming++,s<t&&e.past_due++),"complete"===l.status&&e.completed++}return e},[q]),et=(0,l.useMemo)(()=>{var e;return X&&null!=(e=w.find(e=>e.id===X))?e:null},[X,w]),en=(0,l.useMemo)(()=>{let e=0,t=0,n=0,a=0,l=0;for(let s of w)e++,"complete"===s.status&&t++,"at_risk"===s.status&&n++,"slipped"===s.status&&a++,f(s)&&l++;return{total:e,complete:t,atRisk:n,slipped:a,overdue:l}},[w]),ea=(0,l.useCallback)(async(a,l)=>{if(!n||!(null==e?void 0:e.uid))return;let r=I(a.targetDate);r&&await (0,m.$F)(async()=>{var t,o;await (0,s.addDoc)((0,s.collection)(i.db,"events/".concat(n,"/milestones")),{eventId:n,producerId:null==e?void 0:e.uid,title:a.title.trim()||"(untitled milestone)",description:a.description||null,category:a.category,phase:a.phase,channels:a.channels,visibility:a.visibility,beginDate:null!=(t=I(a.beginDate))?t:null,targetDate:r,completedAt:null!=(o=I(a.completedAt))?o:null,status:"planned",owner:a.ownerName?{id:a.ownerId||void 0,name:a.ownerName}:null,teamResponsibleId:a.teamResponsibleId||null,teamResponsibleName:a.teamResponsibleName||null,watchers:l.watchers,projectIds:a.projectIds,taskIds:a.taskIds,vendor:a.vendorName?{id:a.vendorId||void 0,name:a.vendorName}:null,dependsOnMilestoneIds:a.dependsOnMilestoneIds,link:a.link||null,
1notes:a.notes||null,isPinned:a.isPinned,isActive:a.isActive,tags:a.tagsInput.split(",").map(e=>e.trim()).filter(Boolean),attachmentRefs:a.attachmentRefs,createdAt:(0,s.serverTimestamp)(),updatedAt:(0,s.serverTimestamp)(),createdBy:null==e?void 0:e.uid}),z(!1)},"create milestone",t,void 0,"Couldn't save that milestone. Please try again.")},[n,null==e?void 0:e.uid]),el=(0,l.useCallback)(async(a,l,r)=>{if(!n)return;let o=I(l.targetDate);o&&await (0,m.$F)(async()=>{var t,d,c;await (0,s.updateDoc)((0,s.doc)(i.db,"events/".concat(n,"/milestones"),a),{title:l.title.trim()||"(untitled milestone)",description:l.description||null,category:l.category,phase:l.phase,channels:l.channels,visibility:l.visibility,beginDate:null!=(t=I(l.beginDate))?t:null,targetDate:o,completedAt:null!=(d=I(l.completedAt))?d:null,owner:l.ownerName?{id:l.ownerId||void 0,name:l.ownerName}:null,teamResponsibleId:l.teamResponsibleId||null,teamResponsibleName:l.teamResponsibleName||null,watchers:r.watchers,projectIds:l.projectIds,taskIds:l.taskIds,vendor:l.vendorName?{id:l.vendorId||void 0,name:l.vendorName}:null,dependsOnMilestoneIds:l.dependsOnMilestoneIds,link:l.link||null,notes:l.notes||null,isPinned:l.isPinned,isActive:l.isActive,tags:l.tagsInput.split(",").map(e=>e.trim()).filter(Boolean),attachmentRefs:l.attachmentRefs,updatedAt:(0,s.serverTimestamp)(),lastModifiedBy:null!=(c=null==e?void 0:e.uid)?c:null}),H(null)},"update milestone",t,void 0,"Couldn't save your changes to that milestone. Please try again.")},[n,null==e?void 0:e.uid]),es=(0,l.useCallback)(async(e,a)=>{if(!n)return;let l={status:a,updatedAt:(0,s.serverTimestamp)()};"complete"!==a||e.completedAt||(l.completedAt=(0,s.serverTimestamp)()),await (0,m.$F)(async()=>{await (0,s.updateDoc)((0,s.doc)(i.db,"events/".concat(n,"/milestones"),e.id),l)},"change milestone status",t,void 0,"Couldn't update that milestone's status. Please try again.")},[n]),ei=(0,l.useCallback)(async()=>{n&&K&&await (0,m.$F)(async()=>{await (0,s.deleteDoc)((0,s.doc)(i.db,"events/".concat(n,"/milestones"),K.id)),Z(null)},"delete milestone",t,void 0,"Couldn't delete that milestone. Please try again.")},[n,K]);return n?(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-2xl font-bold bg-gradient-to-b from-white to-white/50 bg-clip-text text-transparent",children:"Timeline"}),(0,a.jsxs)("p",{className:"studio-body mt-1",children:[en.total," milestones \xb7 ",en.complete," done \xb7 ",en.atRisk," at risk \xb7 ",en.slipped," slipped",en.overdue>0&&(0,a.jsxs)("span",{className:"text-negative-ink",children:[" \xb7 ",en.overdue," overdue"]})]})]}),(0,a.jsx)(c.$n,{variant:"primary",icon:(0,a.jsx)(u.c1,{className:"w-4 h-4"}),onClick:()=>z(!0),children:"New Milestone"})]}),(0,a.jsx)("div",{className:"flex items-center gap-1 flex-wrap border-b border-white/[0.06] -mb-px",children:Object.keys(j).map(e=>{let t=ee[e],n=R===e;return(0,a.jsxs)("button",{type:"button",onClick:()=>U(e),className:"inline-flex items-center gap-1.5 h-9 px-3 text-sm transition border-b-2 ".concat(n?"text-t1 border-weavePink":"text-t3 border-transparent hover:text-t1 hover:border-white/10"),children:[j[e],t>0&&(0,a.jsxs)("span",{className:"text-[10px] text-t3/80",children:["\xb7 ",t]})]},e)})}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsxs)("select",{value:k,onChange:e=>C(e.target.value),className:"bg-card border border-card rounded-md px-3 h-9 text-sm text-t1",children:[(0,a.jsx)("option",{value:"all",children:"All statuses"}),Object.keys(x).map(e=>(0,a.jsx)("option",{value:e,children:x[e]},e))]}),(0,a.jsxs)("select",{value:A,onChange:e=>M(e.target.value),className:"bg-card border border-card rounded-md px-3 h-9 text-sm text-t1",children:[(0,a.jsx)("option",{value:"all",children:"All phases"}),Object.keys(h.XA).map(e=>(0,a.jsx)("option",{value:e,children:h.XA[e]},e))]}),(0,a.jsxs)("select",{value:$,onChange:e=>E(e.target.value),className:"bg-card border border-card rounded-md px-3 h-9 text-sm text-t1",children:[(0,a.jsx)("option",{value:"all",children:"All dates"}),(0,a.jsx)("option",{value:"thisYear",children:"This year"}),(0,a.jsx)("option",{value:"thisMonth",children:"This month"}),(0,a.jsx)("option",{value:"next30",children:"Next 30 days"}),(0,a.jsx)("option",{value:"past",children:"Past only"})]}),(0,a.jsxs)("select",{value:B,onChange:e=>Y(e.target.value),className:"bg-card border border-card rounded-md px-3 h-9 text-sm text-t1",children:[(0,a.jsx)("option",{value:"none",children:"Group: None"}),(0,a.jsx)("option",{value:"date",children:"Group: Date (month)"}),(0,a.jsx)("option",{value:"category",children:"Group: Category"}),(0,a.jsx)("option",{value:"channel",children:"Group: Channel"}),(0,a.jsx)("option",{value:"phase",children:"Group: Phase"}),(0,a.jsx)("option",{value:"status",children:"Group: Status"}),(0,a.jsx)("option",{value:"team",children:"Group: Team"})]}),(0,a.jsxs)("div",{className:"inline-flex bg-card border border-card rounded-md overflow-hidden",children:[(0,a.jsx)("button",{type:"button",onClick:()=>V("list"),className:"h-9 px-3 text-sm transition ".concat("list"===G?"bg-card-hover text-t1":"text-t3 hover:text-t1"),children:"List"}),(0,a.jsx)("button",{type:"button",onClick:()=>V("calendar"),className:"h-9 px-3 text-sm transition ".concat("calendar"===G?"bg-card-hover text-t1":"text-t3 hover:text-t1"),children:"Calendar"})]}
1),(0,a.jsx)(c.pd,{value:_,onChange:e=>F(e.target.value),placeholder:"Search milestones...",className:"flex-1 min-w-[160px] max-w-[280px]"}),(0,a.jsx)(c.$n,{variant:"ghost",onClick:()=>(function(e){let t=new Blob([[["Title","Description","Category","Phase","Status","Channels","Visibility","Begin Date","Target Date","Completed At","Owner","Team Responsible","Vendor","Link","Tags","Notes"],...e.map(e=>{var t,n,a,l,s,i,r,o,d,c,u;return[e.title,null!=(a=e.description)?a:"",g[e.category],h.XA[e.phase],x[e.status],(null!=(l=e.channels)?l:[]).map(e=>v[e]).join("; "),(null!=(s=e.visibility)?s:[]).map(e=>b[e]).join("; "),e.beginDate?e.beginDate.toDate().toLocaleDateString():"",e.targetDate.toDate().toLocaleDateString(),e.completedAt?e.completedAt.toDate().toLocaleDateString():"",null!=(i=null==(t=e.owner)?void 0:t.name)?i:"",null!=(r=e.teamResponsibleName)?r:"",null!=(o=null==(n=e.vendor)?void 0:n.name)?o:"",null!=(d=e.link)?d:"",(null!=(c=e.tags)?c:[]).join("; "),null!=(u=e.notes)?u:""]})].map(e=>e.map(O).join(",")).join("\n")],{type:"text/csv;charset=utf-8;"}),n=URL.createObjectURL(t),a=document.createElement("a");a.href=n,a.download="timeline-".concat(new Date().toISOString().slice(0,10),".csv"),document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(n)})(J),disabled:0===J.length,children:"Export CSV"})]}),N?(0,a.jsx)("div",{className:"flex justify-center py-12",children:(0,a.jsx)(c.y$,{})}):0===J.length?(0,a.jsx)(c.pp,{heading:0===w.length?"No milestones yet":"No matches",description:0===w.length?"Add high-level dates: permits filed, build crew arrives, gates open.":"Try clearing filters.",action:0===w.length?{label:"Add first milestone",onClick:()=>z(!0)}:void 0}):"calendar"===G?(0,a.jsx)(L,{milestones:J,onEdit:e=>H(e.id)}):Q?(0,a.jsx)("div",{className:"space-y-6",children:Q.map(e=>(0,a.jsxs)("div",{children:[(0,a.jsxs)("h3",{className:"studio-eyebrow mb-2 sticky top-0 bg-app py-1",children:[e.label," ",(0,a.jsxs)("span",{className:"text-t4",children:["\xb7 ",e.items.length]})]}),(0,a.jsx)("div",{className:"space-y-2",children:e.items.map(e=>(0,a.jsx)(S,{milestone:e,onEdit:()=>H(e.id),onDelete:()=>Z(e),onStatusChange:t=>es(e,t)},e.id))})]},e.key))}):(0,a.jsx)("div",{className:"space-y-2",children:J.map(e=>(0,a.jsx)(S,{milestone:e,onEdit:()=>H(e.id),onDelete:()=>Z(e),onStatusChange:t=>es(e,t)},e.id))}),W&&(0,a.jsx)(T,{mode:"create",eventId:n,onSubmit:ea,onClose:()=>z(!1)}),et&&(0,a.jsx)(T,{mode:"edit",eventId:n,existing:et,onSubmit:(e,t)=>el(et.id,e,t),onClose:()=>H(null)}),K&&(0,a.jsx)(c.TM,{open:!0,title:"Delete milestone?",message:'"'.concat(K.title,'" will be removed permanently.'),confirmLabel:"Delete",confirmVariant:"danger",onConfirm:ei,onCancel:()=>Z(null)})]}):(0,a.jsx)(c.pp,{heading:"Select an event",description:"Timeline is per-event."})}function S(e){var t,n,l,s,i,r,o;let{milestone:d,onEdit:m,onDelete:p,onStatusChange:j}=e,w=Math.ceil((d.targetDate.toMillis()-Date.now())/864e5),y=f(d),N="complete"===d.status?"text-t4":y?"text-negative-ink":w<=7?"text-attention-ink":"text-t2";return(0,a.jsx)(c.Zp,{className:"p-3 hover:border-white/20 transition-colors [content-visibility:auto] [contain-intrinsic-size:auto_88px] ".concat(d.isPinned?"ring-1 ring-emerald-500/30":""),children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center min-w-[80px]",children:[(0,a.jsx)("div",{className:"studio-subtitle",children:(o=d.targetDate)?o.toDate().toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):"â"}),(0,a.jsx)("div",{className:"text-[11px] tabular-nums ".concat(N),children:"complete"===d.status?"â done":w<0?"".concat(-w,"d overdue"):0===w?"today":"".concat(w,"d")})]}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("h3",{className:"studio-body-strong truncate",children:d.title}),(0,a.jsx)(c.Ex,{className:"".concat(k[d.status]," text-[10px] px-1.5 py-0"),children:x[d.status]}),(0,a.jsxs)("span",{className:"studio-caption",children:["\xb7 ",g[d.category]]}),(0,a.jsxs)("span",{className:"studio-caption",children:["\xb7 ",h.XA[d.phase]]})]}),(0,a.jsxs)("div",{className:"studio-caption mt-0.5 flex items-center gap-x-2 gap-y-0.5 flex-wrap",children:[(null==(t=d.owner)?void 0:t.name)&&(0,a.jsxs)("span",{children:["Owner: ",(0,a.jsx)("span",{className:"text-t2",children:d.owner.name})]}),d.teamResponsibleName&&(0,a.jsxs)("span",{children:["\xb7 Team: ",(0,a.jsx)("span",{className:"text-t2",children:d.teamResponsibleName})]}),(null==(n=d.vendor)?void 0:n.name)&&(0,a.jsxs)("span",{children:["\xb7 Vendor: ",(0,a.jsx)("span",{className:"text-t2",children:d.vendor.name})]})]}),(null==(l=d.channels)?void 0:l.length)||(null==(s=d.visibility)?void 0:s.length)?(0,a.jsxs)("div",{className:"flex items-center gap-1 flex-wrap mt-1",children:[(null!=(i=d.channels)?i:[]).map(e=>(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-wide px-1.5 py-0.5 rounded-full bg-weaveBlue/15 text-weaveBlue border border-weaveBlue/30",children:v[e]},"c-".concat(e))),(null!=(r=d.visibility)?r:[]).map(e=>(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-wide px-1.5 py-0.5 rounded-full bg-white/[0.06] text-t3 border border-white/[0.10]",children:b[e]},"v-".concat(e)))]}):null,d.description&&(0,a.jsx)("p",{className:"studio-caption mt-1 line-clamp-2",children:d.description})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,a.jsx)("select",{value:d.status,onChange:e=>j(e.target.value),className:"bg-card border border-card rounded-md px-2 h-8 text-xs text-t2",children:Object.keys(x).map(e=>(0,a.jsx)("option",{value:e,children:x[e]},e))}),(0,a.jsx)("button",{onClick:m,className:"p-1.5 rounded hover:bg-white/[0.08] text-t3 hover:text-t1","aria-label":"Edit",children:(0,a.jsx)(u.R2,{className:"w-4 h-4"})}),(0,a.jsx)("button",{onClick:p,className:"p-1.5 rounded hover:bg-red-500/15 text-t3 hover:text-negative-ink","aria-label":"Delete",children:(0,a.jsx)(u.uc,{className:"w-4 h-4"})})]})]})})}function T(e){var t;let{mode:n,eventId:s,existing:i,onSubmit:r,onClose:o}=e,[m,x]=(0,l.useState)(!1),[j,w]=(0,l.useState)(()=>{var e,t,n,a,l,s,r,o,d,c,u,m,p,h,x,g,v,b,j,w,y,f;
1return i?{title:i.title,description:null!=(l=i.description)?l:"",category:i.category,phase:i.phase,channels:null!=(s=i.channels)?s:[],visibility:null!=(r=i.visibility)?r:[],beginDate:C(i.beginDate),targetDate:C(i.targetDate),completedAt:C(i.completedAt),ownerId:null!=(o=null==(e=i.owner)?void 0:e.id)?o:"",ownerName:null!=(d=null==(t=i.owner)?void 0:t.name)?d:"",teamResponsibleId:null!=(c=i.teamResponsibleId)?c:"",teamResponsibleName:null!=(u=i.teamResponsibleName)?u:"",vendorId:null!=(m=null==(n=i.vendor)?void 0:n.id)?m:"",vendorName:null!=(p=null==(a=i.vendor)?void 0:a.name)?p:"",watcherIds:(null!=(h=i.watchers)?h:[]).map(e=>e.id).filter(e=>!!e),link:null!=(x=i.link)?x:"",notes:null!=(g=i.notes)?g:"",tagsInput:(null!=(v=i.tags)?v:[]).join(", "),isActive:!1!==i.isActive,isPinned:null!=(b=i.isPinned)&&b,projectIds:null!=(j=i.projectIds)?j:[],taskIds:null!=(w=i.taskIds)?w:[],dependsOnMilestoneIds:null!=(y=i.dependsOnMilestoneIds)?y:[],attachmentRefs:null!=(f=i.attachmentRefs)?f:[]}:A}),{data:y}=(0,d.$)("events/".concat(s,"/modes"),[],(e,t)=>{var n;return{id:e,person:null!=(n=t.person)?n:{name:"(unnamed)"}}}),f=(e,t)=>w(n=>({...n,[e]:t})),k=async()=>{if(!m){x(!0);try{let e=new Map(y.map(e=>[e.id,e])),t=j.watcherIds.map(t=>{var n,a;let l=e.get(t);return l?{id:t,name:l.person.name,photoURL:null!=(n=l.person.photoURL)?n:null,email:null!=(a=l.person.email)?a:void 0}:null}).filter(e=>null!==e);await r(j,{watchers:t})}finally{x(!1)}}};return(0,a.jsx)(c.aF,{open:!0,onClose:o,size:"lg",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsx)("h2",{className:"studio-subtitle",children:"create"===n?"New Milestone":"Edit Milestone"}),(0,a.jsx)("button",{onClick:o,className:"p-1 rounded hover:bg-white/[0.08] text-t3 hover:text-t1","aria-label":"Close",children:(0,a.jsx)(u.fK,{className:"w-5 h-5"})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsx)(R,{children:"Title *"}),(0,a.jsx)(c.pd,{value:j.title,onChange:e=>f("title",e.target.value),placeholder:"e.g. 'Permits filed', 'Build crew arrives', 'Gates open'",autoFocus:!0})]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsx)(R,{children:"Description"}),(0,a.jsx)(c.pd,{value:j.description,onChange:e=>f("description",e.target.value),placeholder:"Why this matters / what's downstream"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(R,{children:"Category *"}),(0,a.jsx)(_,{value:j.category,onChange:e=>f("category",e),children:Object.keys(g).map(e=>(0,a.jsx)("option",{value:e,children:g[e]},e))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(R,{children:"Phase *"}),(0,a.jsx)(_,{value:j.phase,onChange:e=>f("phase",e),children:Object.keys(h.XA).map(e=>(0,a.jsx)("option",{value:e,children:h.XA[e]},e))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(R,{children:"Begin Date"}),(0,a.jsx)("input",{type:"date",value:j.beginDate,onChange:e=>f("beginDate",e.target.value),className:"w-full bg-card border border-card rounded-md px-3 h-9 text-sm text-t1"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(R,{children:"Target / Due Date *"}),(0,a.jsx)("input",{type:"date",value:j.targetDate,onChange:e=>f("targetDate",e.target.value),className:"w-full bg-card border border-card rounded-md px-3 h-9 text-sm text-t1"})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)(R,{children:["Completed Date ",(0,a.jsx)("span",{className:"text-t3/60 normal-case font-normal",children:"â auto-set on Complete"})]}),(0,a.jsx)("input",{type:"date",value:j.completedAt,onChange:e=>f("completedAt",e.target.value),className:"w-full bg-card border border-card rounded-md px-3 h-9 text-sm text-t1"})]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsxs)(R,{children:["Channels ",(0,a.jsx)("span",{className:"text-t3/60 normal-case font-normal",children:"â medium / forum"})]}),(0,a.jsx)(N,{options:Object.keys(v),labels:v,value:j.channels,onChange:e=>f("channels",e)})]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsxs)(R,{children:["Visibility ",(0,a.jsx)("span",{className:"text-t3/60 normal-case font-normal",children:"â who should see this"})]}),(0,a.jsx)(N,{options:Object.keys(b),labels:b,value:j.visibility,onChange:e=>f("visibility",e)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(R,{children:"Owner"}),(0,a.jsx)(p.MemberPicker,{value:{id:j.ownerId||void 0,name:j.ownerName||void 0},onChange:e=>{var t,n;f("ownerId",null!=(t=e.id)?t:""),f("ownerName",null!=(n=e.name)?n:"")}})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(R,{children:"Team Responsible"}),(0,a.jsx)(p.TeamSinglePicker,{eventId:null!=s?s:"",value:j.teamResponsibleId||void 0,onChange:(e,t)=>
1{f("teamResponsibleId",null!=e?e:""),f("teamResponsibleName",null!=t?t:"")}})]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsx)(R,{children:"Watchers (notified on changes)"}),(0,a.jsx)(c.TT,{collectionPath:"events/".concat(s,"/modes"),value:j.watcherIds,onChange:e=>f("watcherIds",e),getLabel:e=>{var t,n;return null!=(n=null==(t=e.person)?void 0:t.name)?n:"(unnamed)"},getSubtitle:e=>{var t;return null!=(t=e.category)?t:null},placeholder:"Add watchers...",emptyHint:"No members yet on this event."})]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsxs)(R,{children:["Vendor ",(0,a.jsx)("span",{className:"text-t3/60 normal-case font-normal",children:"â when this entry is about a specific vendor"})]}),(0,a.jsx)(c.TT,{collectionPath:"events/".concat(s,"/vendors"),value:j.vendorId?[j.vendorId]:[],onChange:e=>{var t;f("vendorId",null!=(t=e[0])?t:""),e[0]||f("vendorName","")},max:1,getLabel:e=>e.name||"(unnamed)",getSubtitle:e=>{var t;return null!=(t=e.service)?t:null},placeholder:"Optional â pick a vendor",emptyHint:"No vendors yet.",parse:(e,t)=>{let n=t.name||"";return j.vendorId===e&&j.vendorName!==n&&setTimeout(()=>f("vendorName",n),0),{id:e,...t}}})]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsx)(R,{children:"Reference link"}),(0,a.jsx)(c.pd,{value:j.link,onChange:e=>f("link",e.target.value),placeholder:"https://..."})]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsx)(R,{children:"Notes"}),(0,a.jsx)("textarea",{value:j.notes,onChange:e=>f("notes",e.target.value),rows:2,className:"w-full bg-card border border-card rounded-md px-3 py-2 text-sm text-t1"})]})]}),(0,a.jsx)(P,{children:"Linked work"}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(R,{children:"Linked Projects"}),(0,a.jsx)(c.TT,{collectionPath:"events/".concat(s,"/projects"),value:j.projectIds,onChange:e=>f("projectIds",e),getLabel:e=>e.name||"(unnamed)",getSubtitle:e=>{var t;return null!=(t=e.category)?t:null},placeholder:"Projects this milestone gates...",emptyHint:"No projects yet."})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(R,{children:"Linked Tasks"}),(0,a.jsx)(c.TT,{collectionPath:"events/".concat(s,"/tasks"),value:j.taskIds,onChange:e=>f("taskIds",e),getLabel:e=>e.title||"(untitled task)",getSubtitle:e=>{var t,n;return null!=(n=null==(t=e.role)?void 0:t.name)?n:null},placeholder:"Tasks this milestone gates...",emptyHint:"No tasks yet."})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(R,{children:"Depends on milestones (must complete before this)"}),(0,a.jsx)(c.TT,{collectionPath:"events/".concat(s,"/milestones"),value:j.dependsOnMilestoneIds,onChange:e=>f("dependsOnMilestoneIds",e),excludeIds:i?[i.id]:[],getLabel:e=>e.title||"(unnamed)",getSubtitle:e=>{var t;return null!=(t=e.category)?t:null},placeholder:"Milestones that must complete first...",emptyHint:"No other milestones yet."})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(R,{children:"Tags (comma-separated)"}),(0,a.jsx)(c.pd,{value:j.tagsInput,onChange:e=>f("tagsInput",e.target.value),placeholder:"hard-deadline, soft-deadline, dependency-gate"})]}),(0,a.jsx)("div",{className:"col-span-2",children:(0,a.jsx)(c.ik,{label:"Attachments",pathPrefix:"events/".concat(s,"/milestones/").concat(null!=(t=null==i?void 0:i.id)?t:"new","/attachments"),value:j.attachmentRefs,onChange:e=>f("attachmentRefs",e)})}),(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm text-t2",children:[(0,a.jsx)("input",{type:"checkbox",checked:j.isActive,onChange:e=>f("isActive",e.target.checked)}),"Active"]}),(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm text-t2",children:[(0,a.jsx)("input",{type:"checkbox",checked:j.isPinned,onChange:e=>f("isPinned",e.target.checked)}),"Pin as critical milestone"]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap justify-end gap-2 pt-2",children:[(0,a.jsx)(c.$n,{variant:"secondary",onClick:o,disabled:m,children:"Cancel"}),(0,a.jsx)(c.$n,{variant:"primary",onClick:k,disabled:m||!j.title.trim()||!j.targetDate,children:m?"Saving...":"create"===n?"Create milestone":"Save changes"})]})]})})}function R(e){let{children:t}=e;return(0,a.jsx)("label",{className:"studio-eyebrow block mb-1",children:t})}function P(e){let{children:t}=e;return(0,a.jsx)("h3",{className:"studio-eyebrow border-t border-white/[0.06] pt-3",children:t})}function _(e){let{value:t,onChange:n,children:l}=e;return(0,a.jsx)("select",{value:t,onChange:e=>n(e.target.value),className:"w-full bg-card border border-card rounded-md px-3 h-9 text-sm text-t1",children:l})}function O(e){if(null==e)return"";let t=String(e).replace(/"/g,'""');return/[",\n]/.test(t)?'"'.concat(t,'"'):t}function L(e){var t;let{milestones:n,onEdit:s}=e,[i,r]=(0,l.useState)(()=>{var e;let t=Date.now(),a=[...n].filter(e=>e.targetDate.toMillis()>=t).sort((e,t)=>
1e.targetDate.toMillis()-t.targetDate.toMillis())[0],l=null!=(e=null==a?void 0:a.targetDate.toDate())?e:new Date;return new Date(l.getFullYear(),l.getMonth(),1)}),o=i.getFullYear(),d=i.getMonth(),u=new Date(o,d,1).getDay(),m=new Date(o,d+1,0).getDate(),p=i.toLocaleString("en-US",{month:"long",year:"numeric"}),h=(0,l.useMemo)(()=>{let e=new Map;for(let a of n){let n=a.targetDate.toDate();if(n.getFullYear()===o&&n.getMonth()===d){var t;let l=n.getDate(),s=null!=(t=e.get(l))?t:[];s.push(a),e.set(l,s)}}return e},[n,o,d]),x=[];for(let e=0;e<u;e++)x.push(null);for(let e=1;e<=m;e++)x.push({day:e,items:null!=(t=h.get(e))?t:[]});for(;x.length%7!=0;)x.push(null);let g=new Date,v=g.getFullYear()===o&&g.getMonth()===d;return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(c.$n,{variant:"ghost",onClick:()=>r(new Date(o,d-1,1)),children:"â¹"}),(0,a.jsx)("h3",{className:"studio-body-strong min-w-[160px] text-center",children:p}),(0,a.jsx)(c.$n,{variant:"ghost",onClick:()=>r(new Date(o,d+1,1)),children:"âº"})]}),(0,a.jsx)(c.$n,{variant:"ghost",onClick:()=>{let e=new Date;r(new Date(e.getFullYear(),e.getMonth(),1))},children:"Today"})]}),(0,a.jsx)("div",{className:"studio-label grid grid-cols-7 gap-1",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(e=>(0,a.jsx)("div",{className:"px-2 py-1",children:e},e))}),(0,a.jsx)("div",{className:"grid grid-cols-7 gap-1",children:x.map((e,t)=>{if(!e)return(0,a.jsx)("div",{className:"min-h-[88px] rounded-md bg-card"},t);let n=v&&g.getDate()===e.day;return(0,a.jsxs)("div",{className:"min-h-[88px] p-1.5 rounded-md bg-card border ".concat(n?"border-weavePink/50":"border-white/[0.04]"," flex flex-col gap-1"),children:[(0,a.jsx)("div",{className:"text-[11px] font-medium ".concat(n?"text-weavePink":"text-t3"),children:e.day}),e.items.slice(0,4).map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>s(e),title:e.title,className:"text-left text-[10px] px-1.5 py-0.5 rounded bg-weavePink/10 text-t1 hover:bg-weavePink/20 truncate border border-weavePink/20",children:e.title},e.id)),e.items.length>4&&(0,a.jsxs)("span",{className:"studio-micro px-1.5",children:["+",e.items.length-4," more"]})]},t)})})]})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.