1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,522826,918310,e=>{"use strict";var t=e.i(843476),a=e.i(271645),s=e.i(476819),n=e.i(73526),l=e.i(209912),i=e.i(620278),r=e.i(394908),o=e.i(63727),c=e.i(607486),d=e.i(149685),u=e.i(191741),m=e.i(32095),p=e.i(341240),h=e.i(39312),x=e.i(25652),f=e.i(595468),g=e.i(87316),j=e.i(664030),y=e.i(805899),v=e.i(187996);e.s(["Mountain",()=>v.default],918310);var v=v,b=e.i(195116),k=e.i(852008),w=e.i(772747),N=e.i(416788),C=e.i(978200),_=e.i(59377),M=e.i(213788),P=e.i(647163);let T={map:n.Map,rocket:l.Rocket,target:i.Target,compass:r.Compass,sparkles:C.SparkleIcon,briefcase:o.Briefcase,building:c.Building2,users:N.PeopleGroupIcon,handshake:d.Handshake,clipboard:u.ClipboardList,graduation:m.GraduationCap,lightbulb:p.Lightbulb,zap:h.Zap,trending:x.TrendingUp,check:f.CheckCircle2,calendar:g.Calendar,trophy:j.Trophy,flag:y.Flag,mountain:v.default,wrench:b.Wrench,layers:k.Layers,heart:w.HeartHandshake},D=["#64748B","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#0EA5E9","#6366F1","#8B5CF6","#EC4899"],L="#F0EEE6";function I(e){return function(e){let t=e.replace("#","");if(6!==t.length)return 1;let a=parseInt(t.slice(0,2),16)/255,s=parseInt(t.slice(2,4),16)/255,n=parseInt(t.slice(4,6),16)/255,l=e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4);return .2126*l(a)+.7152*l(s)+.0722*l(n)}(e)>.55?"#403F3D":"#FFFFFF"}function S({icon:e,icon_color:a,company:l,size:i,className:r}){if(l){let e=i<=20?"xs":i<=32?"sm":i<=40?"md":"lg";return(0,t.jsx)(M.CompanyLogo,{domain:l.domain,companyName:l.name,logoUrl:l.logo_url,size:e,className:r})}let o=a||L;if(e?.startsWith("emoji:")){let a=e.slice(6);return(0,t.jsx)("div",{className:(0,P.cn)("shrink-0 squircle flex items-center justify-center",r),style:{backgroundColor:o,width:(0,s.designPx)(i),height:(0,s.designPx)(i)},children:(0,t.jsx)("span",{style:{fontSize:(0,s.designPx)(.55*i),lineHeight:1},children:a})})}let c=e&&T[e]||n.Map;return(0,t.jsx)("div",{className:(0,P.cn)("shrink-0 squircle flex items-center justify-center",r),style:{backgroundColor:o,width:(0,s.designPx)(i),height:(0,s.designPx)(i)},children:(0,t.jsx)(c,{style:{width:(0,s.designPx)(.5*i),height:(0,s.designPx)(.5*i),color:I(o)},strokeWidth:2})})}function z({icon:e,icon_color:a,company:n,size:l=40,className:i,progressPercent:r}){if(null==r)return(0,t.jsx)(S,{icon:e,icon_color:a,company:n,size:l,className:i});let o=Math.max(0,Math.min(100,r)),c=Math.max(2,Math.round(.08*l)),d=l-2*c-4,u=(l-c)/2,m=2*Math.PI*u,p=o/100*m,h=l/2;return(0,t.jsxs)("div",{className:"relative shrink-0",style:{width:(0,s.designPx)(l),height:(0,s.designPx)(l)},children:[(0,t.jsxs)("svg",{width:l,height:l,viewBox:`0 0 ${l} ${l}`,className:"absolute inset-0 -rotate-90",children:[(0,t.jsx)("circle",{cx:h,cy:h,r:u,fill:"none",stroke:"#9DBE9F",strokeOpacity:.25,strokeWidth:c}),o>0&&(0,t.jsx)("circle",{cx:h,cy:h,r:u,fill:"none",stroke:"#A6BFD0",strokeWidth:c,strokeLinecap:"round",strokeDasharray:`${p} ${m-p}`,style:{transition:"stroke-dasharray 400ms ease-out"}})]}),(0,t.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,t.jsx)(S,{icon:e,icon_color:a,company:n,size:d,className:i})})]})}let F=["ðºï¸","ð","ð¯","ð§","â¨","ð¼","ð¤","ð","ð","ð¡","â¡","ð","â
","ðï¸","ð","ð©","â°ï¸","ð ï¸","ð§±","ð","ð","ð","ð¦","ð§©"];e.s(["PLAN_ICONS",0,T,"PLAN_ICON_COLORS",0,D,"PlanIcon",0,z,"PlanIconPicker",0,function({icon:e,icon_color:n,company:l,onChange:i,size:r=56}){let[o,c]=(0,a.useState)(!1),[d,u]=(0,a.useState)(!1),m=d?null:l,p=n||L,h=e&&!e.startsWith("emoji:")&&T[e]?e:null,x=e?.startsWith("emoji:")?e.slice(6):null;return(0,t.jsxs)(_.Popover,{open:o,onOpenChange:e=>{c(e),e||u(!1)},children:[(0,t.jsx)(_.PopoverTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button","aria-label":"Pick icon",className:"cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>u(!0),children:(0,t.jsx)(z,{icon:e,icon_color:n,company:m,size:r})})}),(0,t.jsx)(_.PopoverContent,{className:"w-72 p-3",align:"start",sideOffset:6,children:(0,t.jsxs)("div",{className:"space-y-3",children:[l&&(0,t.jsx)("div",{className:"rounded-md bg-muted/50 px-2 py-1.5 text-[11px] text-muted-foreground",children:"Plans linked to a company show the company's logo by default. Pick an icon below to override."}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:"Color"}),(0,t.jsxs)("div",{className:"flex items-center flex-wrap gap-1.5",children:[D.map(a=>(0,t.jsx)("button",{type:"button",onClick:()=>i({icon:e??"map",icon_color:a}),className:(0,P.cn)("size-5 rounded-full transition-transform hover:scale-110 cursor-pointer",p.toLowerCase()===a.toLowerCase()&&"ring-2 ring-offset-2 ring-offset-popover ring-foreground
1/30"),style:{backgroundColor:a},"aria-label":`Color ${a}`},a)),(0,t.jsx)("label",{className:"relative size-5 rounded-full cursor-pointer overflow-hidden border border-border",style:{background:"conic-gradient(from 0deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)"},title:"Custom color","aria-label":"Pick custom color",children:(0,t.jsx)("input",{type:"color",value:p,onChange:t=>i({icon:e??"map",icon_color:t.target.value}),className:"absolute inset-0 opacity-0 cursor-pointer"})})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-7 gap-1.5",children:Object.entries(T).map(([e,a])=>{let n=h===e;return(0,t.jsx)("button",{type:"button",onClick:()=>i({icon:e,icon_color:p}),className:(0,P.cn)("flex size-7 items-center justify-center squircle transition-opacity cursor-pointer hover:opacity-80",n&&"ring-2 ring-foreground/30"),style:{backgroundColor:n?p:"var(--muted)"},"aria-label":e,children:(0,t.jsx)(a,{className:n?void 0:"text-muted-foreground",style:{width:(0,s.designPx)(14),height:(0,s.designPx)(14),color:n?I(p):void 0},strokeWidth:2})},e)})}),(0,t.jsx)("div",{className:"grid grid-cols-8 gap-1.5",children:F.map(e=>{let a=x===e;return(0,t.jsx)("button",{type:"button",onClick:()=>i({icon:`emoji:${e}`,icon_color:p}),className:(0,P.cn)("flex size-7 items-center justify-center squircle transition-opacity cursor-pointer hover:opacity-80 text-base",a&&"ring-2 ring-foreground/30"),style:{backgroundColor:a?p:"var(--muted)"},children:e},e)})}),(e||n)&&(0,t.jsx)("button",{type:"button",onClick:()=>i({icon:null,icon_color:null}),className:"w-full text-[11px] text-muted-foreground hover:text-foreground py-1",children:"Reset to default"})]})})]})}],522826)},252591,e=>{"use strict";var t=e.i(843476),a=e.i(271645),s=e.i(522016),n=e.i(618566),l=e.i(542356),i=e.i(494913),r=e.i(941388),o=e.i(73526),c=e.i(158524),d=e.i(778917),u=e.i(541071),m=e.i(595468),p=e.i(270756),h=e.i(248256),x=e.i(167881),f=e.i(195898),g=e.i(295712),j=e.i(672987),y=e.i(463415),v=e.i(947627),b=e.i(132193),k=e.i(29383),w=e.i(826902),N=e.i(527070),C=e.i(821875),_=e.i(846696),M=e.i(647163),P=e.i(522826),T=e.i(852008);let D="shrink-0 rounded-full gap-0 max-sm:size-9 max-sm:p-0 px-5";function L({templates:e}){let l=(0,n.useRouter)(),[i,o]=(0,a.useState)(!1);async function c(e){o(!0);try{let t=await fetch("/api/plans",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({template_id:e??null,with_default_stages:!e})}),a=await t.json();if(!t.ok)throw Error(a.error||"Failed");l.push(`/plans/${a.plan.id}`)}catch(e){_.toast.error(e instanceof Error?e.message:"Failed to create plan")}finally{o(!1)}}return 0===e.length?(0,t.jsxs)(x.Button,{onClick:()=>c(),disabled:i,className:D,children:[(0,t.jsx)(r.Plus,{className:"sm:hidden size-4",strokeWidth:2}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"+ Plan"})]}):(0,t.jsxs)(y.DropdownMenu,{children:[(0,t.jsx)(y.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)(x.Button,{disabled:i,className:D,children:[(0,t.jsx)(r.Plus,{className:"sm:hidden size-4",strokeWidth:2}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"+ Plan"})]})}),(0,t.jsxs)(y.DropdownMenuContent,{align:"end",className:"w-64",children:[(0,t.jsxs)(y.DropdownMenuItem,{onClick:()=>c(),children:[(0,t.jsx)(r.Plus,{className:"mr-2 h-3.5 w-3.5"}),"Blank plan"]}),(0,t.jsx)(y.DropdownMenuSeparator,{}),(0,t.jsx)(y.DropdownMenuLabel,{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"From template"}),e.map(e=>(0,t.jsxs)(y.DropdownMenuItem,{onClick:()=>c(e.id),children:[(0,t.jsx)(P.PlanIcon,{icon:e.icon,icon_color:e.icon_color,size:20,className:"mr-2"}),(0,t.jsx)("span",{className:"truncate",children:e.name})]},e.id)),(0,t.jsx)(y.DropdownMenuSeparator,{}),(0,t.jsx)(y.DropdownMenuItem,{asChild:!0,children:(0,t.jsxs)(s.default,{href:"/plans/templates",children:[(0,t.jsx)(T.Layers,{className:"mr-2 h-3.5 w-3.5"}),"Manage templates"]})})]})]})}var I=e.i(646535),S=e.i(119910),z=e.i(63270),F=e.i(439468),B=e.i(425324);function $({children:e,title:a,surface:s}){return(0,t.jsx)("span",{title:a,className:(0,M.cn)("relative inline-flex squircle p-px shrink-0",s),children:e})}function A({count:e,surface:a}){return(0,t.jsx)($,{surface:a,children:(0,t.jsxs)("span",{className:"flex size-6 items-center justify-center squircle bg-muted text-[10px] font-medium text-muted-foreground",children:["+",e]})})}function E({company:e,surface:a}){let s=(0,F.useDomainLogo)(e.domain),n=e.logo_url??s;return(0,t.jsx)($,{title:e.name,surface:a,children:(0,t.jsxs)(z.Avatar,{size:"sm",children:[n?(0,t.jsx)(z.AvatarImage,{src:n,alt:e.name,className:"object-contain bg-white"}):null,(0,t.jsx)(z.AvatarFallback,{className:"text-[9px] font-medium text-foreground
1/70",children:(0,B.initialsOf)(e.name)})]})})}function H({person:e,surface:a}){return(0,t.jsx)($,{title:e.name,surface:a,children:(0,t.jsxs)(z.Avatar,{size:"sm",children:[e.image_url?(0,t.jsx)(z.AvatarImage,{src:e.image_url,alt:e.name,className:"object-cover"}):null,(0,t.jsx)(z.AvatarFallback,{className:"text-[9px] font-medium text-foreground/70",children:(0,B.initialsOf)(e.name)})]})})}function O({companies:e,people:a,max:s=4,surface:n="bg-background",className:l}){let i=e.length>0,r=a.length>0;return i||r?(0,t.jsxs)("div",{className:(0,M.cn)("flex items-center gap-2",l),children:[i&&(0,t.jsxs)("div",{className:"flex -space-x-2",children:[e.slice(0,s).map(e=>(0,t.jsx)(E,{company:e,surface:n},e.id)),e.length>s&&(0,t.jsx)(A,{count:e.length-s,surface:n})]}),r&&(0,t.jsxs)("div",{className:"flex -space-x-2",children:[a.slice(0,s).map(e=>(0,t.jsx)(H,{person:e,surface:n},e.id)),a.length>s&&(0,t.jsx)(A,{count:a.length-s,surface:n})]})]}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground/40",children:"-"})}var q=e.i(416363),W=e.i(341256),R=e.i(5832);let U={draft:"Draft",active:"Active",won:"Won",lost:"Lost",archived:"Archived"},V=[{value:"draft",label:"Draft"},{value:"active",label:"Active"},{value:"won",label:"Won"},{value:"lost",label:"Lost"},{value:"archived",label:"Archived"}],G=[{value:"external",label:"External (customer-facing)"},{value:"internal",label:"Internal (workspace-only)"}],J={draft:"gray",active:"green",won:"blue",lost:"red",archived:"gray"},K=V.map(e=>({value:e.value,label:e.label,color:J[e.value]})),Z=["title","linked_to","associations","visibility","status","progress","updated_at"],Q={title:"Plan",linked_to:"Linked to",associations:"Companies & people",visibility:"Visibility",status:"Status",progress:"Progress",updated_at:"Updated"};function X({plans:e,dealById:s,companyById:n,tokenByPlan:l,taskStats:i,assocByPlan:r,onDelete:o,onCopyLink:c,onPatchPlan:d}){let u=(0,a.useCallback)(async(e,t)=>{d(e,{status:t})},[d]);return(0,t.jsx)(g.KanbanBoard,{items:e,columns:K,getItemId:e=>e.id,getItemStatus:e=>e.status,onStatusChange:u,showNewButton:!1,emptyText:"No plans",renderCard:e=>(0,t.jsx)(Y,{plan:e,deal:e.deal_id?s.get(e.deal_id)??null:null,company:e.company_id?n.get(e.company_id)??null:null,token:l.get(e.id)??null,stats:i.get(e.id)??{total:0,done:0},assoc:r.get(e.id)??{companies:[],people:[]},onDelete:o,onCopyLink:c,onPatchPlan:d})})}function Y({plan:e,deal:a,company:n,token:r,stats:o,assoc:p,onDelete:h,onCopyLink:x,onPatchPlan:f}){let g=a?.name??n?.name??e.customer_company_name??null,j=e.description?.trim()||null,v=o.total?Math.round(o.done/o.total*100):0,b=(0,l.useIntentPrefetch)({href:`/plans/${e.id}`});return(0,t.jsxs)("div",{className:"relative",...b,children:[(0,t.jsx)(s.default,{href:`/plans/${e.id}`,className:"absolute inset-0 rounded-md","aria-label":e.title}),(0,t.jsxs)("div",{className:"relative flex items-start gap-2.5 pointer-events-none",children:[(0,t.jsx)("div",{className:"pointer-events-auto shrink-0",onClick:e=>e.stopPropagation(),children:(0,t.jsx)(P.PlanIconPicker,{icon:e.icon,icon_color:e.icon_color,company:n??null,onChange:({icon:t,icon_color:a})=>f(e.id,{icon:t,icon_color:a}),size:28})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 pr-12",children:[(0,t.jsx)("h3",{className:"truncate text-sm font-semibold leading-tight",children:e.title}),(0,t.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:g??"No linked deal"})]}),(0,t.jsxs)("div",{className:"absolute right-0 top-0 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 pointer-events-auto",children:[r&&(0,t.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),x(r.token)},className:"squircle p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Copy share link",children:(0,t.jsx)(c.Link2,{className:"h-3.5 w-3.5"})}),(0,t.jsxs)(y.DropdownMenu,{children:[(0,t.jsx)(y.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",onClick:e=>e.preventDefault(),className:"squircle p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"More",children:(0,t.jsx)(u.MoreHorizontal,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(y.DropdownMenuContent,{align:"end",children:[r&&(0,t.jsxs)(y.DropdownMenuItem,{onClick:e=>{e.preventDefault(),window.open(`/p/${r.token}`,"_blank")}
1,children:[(0,t.jsx)(d.ExternalLink,{className:"mr-2 h-3.5 w-3.5"}),"Preview portal"]}),(0,t.jsxs)(y.DropdownMenuItem,{onClick:t=>{t.preventDefault(),h(e.id)},className:"text-destructive focus:text-destructive",children:[(0,t.jsx)(W.TrashIcon,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})]})]}),j&&(0,t.jsx)("p",{className:"relative mt-2 line-clamp-2 text-xs leading-relaxed text-muted-foreground pointer-events-none",children:j}),(0,t.jsxs)("div",{className:"relative mt-2.5 pointer-events-none",children:[(0,t.jsx)("div",{className:"mb-1 flex items-center justify-end text-[11px]",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 tabular-nums text-muted-foreground",children:[(0,t.jsx)(m.CheckCircle2,{className:"h-3 w-3"}),o.done,"/",o.total]})}),(0,t.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,t.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${v}%`,backgroundColor:"var(--ring)"}})})]}),(0,t.jsxs)("div",{className:"relative mt-2.5 flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 overflow-x-auto scrollbar-none pointer-events-auto",onPointerDown:e=>e.stopPropagation(),children:[p.companies.map(e=>(0,t.jsx)(q.CompanyChip,{id:e.id,name:e.name,domain:e.domain,logoUrl:e.logo_url,href:`/companies/${e.id}`},e.id)),p.people.map(e=>(0,t.jsx)(q.ContactChip,{id:e.id,name:e.name,imageUrl:e.image_url,href:`/people/${e.id}`},e.id))]}),(0,t.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground pointer-events-none",children:(0,i.formatDistanceToNow)(new Date(e.updated_at),{addSuffix:!0})})]})]})}function ee({plans:e,dealById:s,companyById:r,tokenByPlan:o,taskStats:m,assocByPlan:x,onDelete:f,onCopyLink:g,onPatchPlan:j}){let _=(0,n.useRouter)(),T=(0,a.useMemo)(()=>(0,l.createIntentPrefetcher)(_),[_]),D=(0,a.useMemo)(()=>[...Z],[]),{orderedIds:L,getDragProps:I}=(0,N.useColumnOrder)("plans",D),{getColumnStyle:z,getResizeProps:F}=(0,C.useColumnResize)("plans"),{sortColumn:B,sortDir:$,handleSort:A}=(0,w.useTableSort)("updated_at","desc"),E=(0,a.useMemo)(()=>{if(!B)return e;let t=[...e];return t.sort((e,t)=>{let a=0;switch(B){case"title":a=e.title.localeCompare(t.title);break;case"linked_to":{let n=(e.deal_id?s.get(e.deal_id)?.name:e.company_id?r.get(e.company_id)?.name:"")??"",l=(t.deal_id?s.get(t.deal_id)?.name:t.company_id?r.get(t.company_id)?.name:"")??"";a=n.localeCompare(l);break}case"visibility":a=(e.visibility??"external").localeCompare(t.visibility??"external");break;case"status":a=e.status.localeCompare(t.status);break;case"progress":a=(m.get(e.id)?.total?m.get(e.id).done/m.get(e.id).total:0)-(m.get(t.id)?.total?m.get(t.id).done/m.get(t.id).total:0);break;case"updated_at":a=new Date(e.updated_at).getTime()-new Date(t.updated_at).getTime();break;default:return 0}return"asc"===$?a:-a}),t},[e,B,$,s,r,m]);return(0,t.jsx)("div",{className:"rounded-lg border border-border/50 overflow-hidden",children:(0,t.jsxs)(v.Table,{children:[(0,t.jsx)(v.TableHeader,{children:(0,t.jsxs)(v.TableRow,{className:"hover:bg-transparent",children:[L.map(e=>(0,t.jsx)(k.SortableTableHead,{columnId:e,label:Q[e],sortColumn:B,sortDir:$,onSort:A,sortable:"associations"!==e,className:(0,M.cn)("text-xs text-muted-foreground font-medium","progress"===e&&"text-right"),style:z(e),extra:(0,t.jsx)(v.TableResizeHandle,{...F(e)}),...I(e)},e)),(0,t.jsx)(v.TableHead,{className:"text-xs text-muted-foreground font-medium w-20"})]})}),(0,t.jsx)(v.TableBody,{children:E.map(e=>{let a=m.get(e.id)??{total:0,done:0},n=o.get(e.id),l=e.deal_id?s.get(e.deal_id):null,k=e.company_id?r.get(e.company_id):null,w=x.get(e.id)??{companies:[],people:[]},N=a.total?Math.round(a.done/a.total*100):0;return(0,t.jsxs)(v.TableRow,{className:"cursor-pointer transition-colors",onClick:()=>{let t;return t=e.id,_.push(`/plans/${t}`)},onMouseEnter:()=>T.enter(`/plans/${e.id}`),onMouseLeave:T.leave,children:[L.map(s=>{switch(s){case"title":return(0,t.jsx)(v.TableCell,{style:z("title"),children:(0,t.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,t.jsx)(v.CellControl,{children:(0,t.jsx)(P.PlanIconPicker,{icon:e.icon,icon_color:e.icon_color,company:k??null,onChange:({icon:t,icon_color:a})=>j(e.id,{icon:t,icon_color:a}),size:28})}),(0,t.jsx)("div",{className:"min-w-0",children:(0,t.jsx)(b.InlineEdit,{value:e.title,onSave:t=>j(e.id,{title:t}),required:!0,className:"font-medium",title:`${e.title} (click to edit)`})})]})},"title");case"linked_to":return(0,t.jsx)(v.TableCell,{className:"text-sm text-muted-foreground",style:z("linked_to"),children:l?(0,t.jsx)("span",{className:"inline-flex items-center gap-1 truncate max-w-[200px]",children:l.name}):k?(0,t.jsx)("span",{className:"truncate max-w-[200px]",children:k.name}
1):(0,t.jsx)("span",{className:"text-muted-foreground/60",children:"-"})},"linked_to");case"associations":return(0,t.jsx)(v.TableCell,{style:z("associations"),children:(0,t.jsx)(O,{companies:w.companies,people:w.people,max:3,surface:"bg-background"})},"associations");case"visibility":return(0,t.jsx)(v.TableCell,{style:z("visibility"),children:(0,t.jsx)("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:(e.visibility??"external")==="internal"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(p.Lock,{className:"h-3 w-3"}),"Internal"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(h.Globe,{className:"h-3 w-3"}),"External"]})})},"visibility");case"status":return(0,t.jsx)(v.TableCell,{style:z("status"),children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs",children:[(0,t.jsx)(S.StateDot,{kind:"plan",value:e.status}),U[e.status]]})},"status");case"progress":return(0,t.jsx)(v.TableCell,{className:"text-right",style:z("progress"),children:(0,t.jsxs)("div",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)("div",{className:"h-1 w-20 overflow-hidden rounded-full bg-muted",children:(0,t.jsx)("div",{className:"h-full rounded-full",style:{width:`${N}%`,backgroundColor:"var(--ring)"}})}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:[a.done,"/",a.total]})]})},"progress");case"updated_at":return(0,t.jsx)(v.TableCell,{className:"text-sm text-muted-foreground",style:z("updated_at"),children:(0,i.formatDistanceToNow)(new Date(e.updated_at),{addSuffix:!0})},"updated_at");default:return null}}),(0,t.jsx)(v.TableCell,{children:(0,t.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[n&&(0,t.jsx)("button",{type:"button",onClick:()=>g(n.token),className:"squircle p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Copy link",children:(0,t.jsx)(c.Link2,{className:"h-3.5 w-3.5"})}),(0,t.jsxs)(y.DropdownMenu,{children:[(0,t.jsx)(y.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",className:"squircle p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"More",children:(0,t.jsx)(u.MoreHorizontal,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(y.DropdownMenuContent,{align:"end",children:[n&&(0,t.jsxs)(y.DropdownMenuItem,{onClick:()=>window.open(`/p/${n.token}`,"_blank"),children:[(0,t.jsx)(d.ExternalLink,{className:"mr-2 h-3.5 w-3.5"}),"Preview portal"]}),(0,t.jsxs)(y.DropdownMenuItem,{onClick:()=>f(e.id),className:"text-destructive focus:text-destructive",children:[(0,t.jsx)(W.TrashIcon,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})]})})]},e.id)})})]})})}function et({onCreate:e}){return(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4 roun
1ded-[20px] border border-dashed border-border bg-card/30 px-6 py-16 text-center",children:[(0,t.jsx)("div",{className:"flex h-12 w-12 items-center justify-center squircle bg-muted avatar-border",children:(0,t.jsx)(o.Map,{className:"h-5 w-5 text-foreground/70"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-semibold",children:"No plans yet"}),(0,t.jsx)("p",{className:"mt-1 max-w-sm text-sm text-muted-foreground",children:"Create a mutual action plan and share a single link with your customer - assets, timeline, and chat in one place."})]}),(0,t.jsxs)(x.Button,{onClick:e,children:[(0,t.jsx)(r.Plus,{className:"h-4 w-4"}),"Create your first plan"]})]})}e.s(["PlansList",0,function({plans:e,tokens:s,deals:l,companies:i,tasks:r,dealContacts:o,templates:c}){let d=(0,n.useRouter)(),[u,m]=(0,a.useState)(e),[p,h]=(0,a.useState)(!1),[x,g]=(0,R.usePersistedView)("plans","kanban"),[y,v]=(0,a.useState)(""),[b,k]=(0,a.useState)([]),w=(0,a.useMemo)(()=>[{key:"status",label:"Status",type:"select",options:V},{key:"visibility",label:"Visibility",type:"select",options:G}],[]),N=(0,a.useMemo)(()=>new Map(l.map(e=>[e.id,e])),[l]),C=(0,a.useMemo)(()=>new Map(i.map(e=>[e.id,e])),[i]),M=(0,a.useMemo)(()=>{let e=new Map;for(let t of s)e.has(t.plan_id)||e.set(t.plan_id,t);return e},[s]),P=(0,a.useMemo)(()=>{let e=new Map;for(let t of r){let a=e.get(t.plan_id)??{total:0,done:0};a.total+=1,t.completed_at&&(a.done+=1),e.set(t.plan_id,a)}return e},[r]),T=(0,a.useMemo)(()=>{let e=new Map;for(let t of o){let a=e.get(t.deal_id)??[];a.some(e=>e.id===t.id)||a.push({id:t.id,name:t.name,image_url:t.image_url}),e.set(t.deal_id,a)}return e},[o]),D=(0,a.useMemo)(()=>{let e=new Map;for(let t of u){let a=new Set,s=[],n=e=>{if(!e||a.has(e))return;let t=C.get(e);t&&(a.add(e),s.push(t))};n(t.company_id),t.deal_id&&n(N.get(t.deal_id)?.company_id),0===s.length&&t.customer_company_name?.trim()&&s.push({id:`cust:${t.id}`,name:t.customer_company_name.trim(),domain:null,logo_url:null}),e.set(t.id,{companies:s,people:t.deal_id?T.get(t.deal_id)??[]:[]})}return e},[u,C,N,T]),S=(0,a.useMemo)(()=>{let e=u;for(let t of b)if("status"===t.field){let a="not_equals"===t.operator;e=e.filter(e=>a?e.status!==t.value:e.status===t.value)}else if("visibility"===t.field){let a="not_equals"===t.operator;e=e.filter(e=>{let s=e.visibility??"external";return a?s!==t.value:s===t.value})}if(y.trim()){let t=y.trim().toLowerCase();e=e.filter(e=>{if(e.title.toLowerCase().includes(t)||e.customer_company_name?.toLowerCase().includes(t))return!0;let a=e.company_id?C.get(e.company_id):null;if(a?.name.toLowerCase().includes(t))return!0;let s=e.deal_id?N.get(e.deal_id):null;return!!s?.name.toLowerCase().includes(t)})}return e},[u,b,y,C,N]);async function z(e){h(!0);try{let t=await fetch("/api/plans",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({template_id:e??null,with_default_stages:!e})}),a=await t.json();if(!t.ok)throw Error(a.error||"Failed");d.push(`/plans/${a.plan.id}`)}catch(e){_.toast.error(e instanceof Error?e.message:"Failed to create plan")}finally{h(!1)}}async function F(e){confirm("Delete this plan?")&&((await fetch(`/api/plans/${e}`,{method:"DELETE"})).ok?m(t=>t.filter(t=>t.id!==e)):_.toast.error("Failed to delete"))}async function B(e,t){m(a=>a.map(a=>a.id===e?{...a,...t}:a)),await fetch(`/api/plans/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}function $(e){let t=`${window.location.origin}/p/${e}`;navigator.clipboard.writeText(t),_.toast.success("Link copied")}return(0,t.jsxs)("div",{className:"space-y-3 sm:space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"page-title text-[26px] sm:text-3xl font-bold tracking-tight",children:"Plans"}),(0,t.jsx)("p",{className:"mt-1 sm:mt-2 text-sm text-muted-foreground",children:"Mutual action plans you share with customers - assets, timeline, and chat in one link."})]}),(0,t.jsx)(L,{templates:c})]}),(0,t.jsx)(I.PlansTabs,{active:"plans"}),0===u.length?(0,t.jsx)(et,{onCreate:()=>z()}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[(0,t.jsx)("div",{className:"flex-1 min-w-0",children:(0,t.jsx)(j.DynamicFilterBar,{fields:w,search:y,onSearchChange:v,searchPlaceholder:"Search plansâ¦",filters:b,onFiltersChange:k})}),(0,t.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,t.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums hidden sm:inline",children:[S.length," of ",u.length]}),(0,t.jsx)(f.ViewToggle,{view:x,onChange:g,className:"shrink-0"})]})]}),0===S.length?(0,t.jsx)("div",{className:"rounded-lg border border-dashed py-12 text-center text-sm text-muted-foreground",children:"No plans match your filters."}):"kanban"===x?(0,t.jsx)(X,{plans:S,dealById:N,companyById:C,tokenByPlan:M,taskStats:P,assocByPlan:D,onDelete:F,onCopyLink:$,onPatchPlan:B}):(0,t.jsx)(ee,{plans:S,dealById:N,companyById:C,tokenByPlan:M,taskStats:P,assocByPlan:D,onDelete:F,onCopyLink:$,onPatchPlan:B})]})]})}],252591)},646535,e=>{"use strict";var t=e.i(843476),a=e.i(522016),s=e.i(647163);let n=[{value:"plans",label:"Plans",href:"/plans"},{value:"templates",label:"Templates",href:"/plans/templates"}];e.s(["PlansTabs",0,function({active:e,className:l}){return(0,t.jsx)("div",{role:"tablist",className:(0,s.cn)("flex items-center gap-1 w-full",l),children:n.map(n=>{let l=n.value===e;return(0,t.jsx)(a.default,{role:"tab","aria-selected":l,href:n.href,className:(0,s.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-full h-8 px-3 text-xs sm:text-sm font-medium transition-colors",l?"bg-accent text-foreground":"text-foreground
1/60 hover:text-foreground hover:bg-accent"),children:n.label},n.value)})})}])},191741,e=>{"use strict";var t=e.i(636284);e.s(["ClipboardList",()=>t.default])},777514,e=>{"use strict";let t=(0,e.i(475254).default)("compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);e.s(["default",0,t])},394908,e=>{"use strict";var t=e.i(777514);e.s(["Compass",()=>t.default])},851758,e=>{"use strict";let t=(0,e.i(475254).default)("graduation-cap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);e.s(["default",0,t])},32095,e=>{"use strict";var t=e.i(851758);e.s(["GraduationCap",()=>t.default])},738111,e=>{"use strict";let t=(0,e.i(475254).default)("heart-handshake",[["path",{d:"M19.414 14.414C21 12.828 22 11.5 22 9.5a5.5 5.5 0 0 0-9.591-3.676.6.6 0 0 1-.818.001A5.5 5.5 0 0 0 2 9.5c0 2.3 1.5 4 3 5.5l5.535 5.362a2 2 0 0 0 2.879.052 2.12 2.12 0 0 0-.004-3 2.124 2.124 0 1 0 3-3 2.124 2.124 0 0 0 3.004 0 2 2 0 0 0 0-2.828l-1.881-1.882a2.41 2.41 0 0 0-3.409 0l-1.71 1.71a2 2 0 0 1-2.828 0 2 2 0 0 1 0-2.828l2.823-2.762",key:"17lmqv"}]]);e.s(["default",0,t])},772747,e=>{"use strict";var t=e.i(738111);e.s(["HeartHandshake",()=>t.default])},744757,e=>{"use strict";let t=(0,e.i(475254).default)("map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);e.s(["default",0,t])},73526,e=>{"use strict";var t=e.i(744757);e.s(["Map",()=>t.default])},187996,e=>{"use strict";let t=(0,e.i(475254).default)("mountain",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]]);e.s(["default",0,t])},782515,e=>{"use strict";let t=(0,e.i(475254).default)("trophy",[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]]);e.s(["default",0,t])},664030,e=>{"use strict";var t=e.i(782515);e.s(["Trophy",()=>t.default])},237092,e=>{"use strict";let t=(0,e.i(475254).default)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]);e.s(["default",0,t])},195116,e=>{"use strict";var t=e.i(237092);e.s(["Wrench",()=>t.default])}]);
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.