PageSourceSearch

https://app.getcitable.com/assets/ai-action-engine-BKtlv627.js

js getcitable.com collected 2026-10-04 20:57:53 UTC 70,001 bytes, 1 lines download raw bytes

1var e=Object.defineProperty,t=Object.defineProperties,s=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,l=(t,s,a)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a,i=(e,t)=>{for(var s in t||(t={}))n.call(t,s)&&l(e,s,t[s]);if(a)for(var s of a(t))r.call(t,s)&&l(e,s,t[s]);return e},o=(e,a)=>t(e,s(a)),c=(e,t,s)=>new Promise((a,n)=>{var r=e=>{try{i(s.next(e))}catch(t){n(t)}},l=e=>{try{i(s.throw(e))}catch(t){n(t)}},i=e=>e.done?a(e.value):Promise.resolve(e.value).then(r,l);i((s=s.apply(e,t)).next())});import{r as d,j as x}from"./react-vendor-Cak5aoPl.js";import{u as m,b2 as u,g as p,ab as h,a as b,l as g,c as f,U as j,b3 as y,A as v,w as N,x as w,y as k,z as C,N as S,I as E,ac as A,ae as I}from"./index-CV2ezbu5.js";import{P as O,a as D,b as $}from"./popover-BAzZVQkR.js";import{S as P,a as F,b as T,c as U,d as _}from"./select-Dn0GfBuz.js";import{P as L}from"./portal-menu-u9tcuV3x.js";import{P as R,S as M,U as B}from"./UnifiedTimeline-Dt7_gquG.js";import{g as z}from"./action-routing-DGQ-64PJ.js";import{t as G,o as J,O as K,p as W,r as q,q as V,X as H,aH as Y,cA as Q,bi as X,au as Z,z as ee,bz as te,aw as se,b1 as ae,ak as ne,a6 as re,M as le,bB as ie,_ as oe,L as ce,y as de,n as xe,ba as me,b3 as ue,$ as pe,a1 as he,a2 as be,J as ge,aF as fe,cB as je,cC as ye}from"./ui-vendor-CjS9qaFR.js";import{u as ve,P as Ne,f as we}from"./ProjectDetailPanel-BUTD6pWH.js";import{a as ke,I as Ce}from"./ae-initiatives-CgTiZCz6.js";import"./chart-vendor-C3HjQ_mn.js";import"./utils-vendor-B9hPcH9G.js";import"./animation-vendor-Cz81Kal9.js";import"./index-DjbvBxZL.js";const Se={technical:{label:"Tech",textColor:"#1F4E79",bgColor:"#E4EEF8"},content_creation:{label:"Content",textColor:"#3B6D11",bgColor:"#EAF3DE"},content_optimization:{label:"Optimize",textColor:"#3B6D11",bgColor:"#EAF3DE"},media_placement:{label:"Media",textColor:"#6B3F92",bgColor:"#F0E7F8"},opportunity:{label:"Opportunity",textColor:"#AE431E",bgColor:"#FAECE7"},report:{label:"Recap",textColor:"#4A4A4A",bgColor:"#EEEEEE"},operational:{label:"Ops",textColor:"#7A7A7A",bgColor:"#F0F0F0"}},Ee=new Set(["done","canceled"]),Ae=[{value:"todo",label:"Todo"},{value:"in_progress",label:"In progress"},{value:"in_review",label:"In review"},{value:"done",label:"Done"},{value:"canceled",label:"Canceled"}],Ie=[{value:"urgent",label:"Urgent"},{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"low",label:"Low"}],Oe=[{value:15,label:"15 min"},{value:30,label:"30 min"},{value:60,label:"1 hour"},{value:120,label:"2 hours"},{value:240,label:"4 hours"}];function De(e){return e.replace(/_/g," ")}function $e(e){if(e<60)return`${e} min`;const t=Math.floor(e/60),s=e%60;return s>0?`${t}h ${s}m`:`${t}h`}function Pe(e){if(!e)return"?";const t=e.trim().split(/\s+/);return t.length>=2?(t[0][0]+t[1][0]).toUpperCase():t[0].substring(0,2).toUpperCase()}function Fe({status:e}){return"done"===e?x.jsx(ae,{className:"h-[16px] w-[16px] text-brand-olive"}):"in_review"===e?x.jsxs("div",{className:"relative h-[16px] w-[16px]",children:[x.jsx(ie,{className:"h-full w-full text-gray-300"}),x.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:x.jsx("div",{className:"h-[8px] w-[8px] rounded-full bg-brand-terracota"})})]}):"in_progress"===e?x.jsxs("div",{className:"relative h-[16px] w-[16px]",children:[x.jsx(ie,{className:"h-full w-full text-gray-300"}),x.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:x.jsx("div",{className:"h-[8px] w-[8px] rounded-full bg-brand-olive"})})]}):"canceled"===e?x.jsxs("div",{className:"relative h-[16px] w-[16px]",children:[x.jsx(ie,{className:"h-full w-full text-gray-300"}),x.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-red-500 text-12 leading-none",children:"✕"})]}):x.jsx(ie,{className:"h-[16px] w-[16px] text-gray-300"})}function Te({priority:e}){if("urgent"===e||"critical"===e)return x.jsx("div",{className:"h-[16px] w-[16px] rounded-sm flex items-center justify-center text-white font-bold text-12",style:{backgroundColor:"#D06224"},children:"!"});const t="high"===e?3:"medium"===e?2:1;return x.jsxs("div",{className:"h-[16px] w-[16px] flex items-end justify-between gap-[2px] px-[2px]",children:[x.jsx("div",{className:"w-[3px] rounded-sm "+(t>=1?"bg-brand-black":"bg-obsidian-200"),style:{height:"8px"}}),x.jsx("div",{className:"w-[3px] rounded-sm "+(t>=2?"bg-brand-black":"bg-obsidian-200"),style:{height:"12px"}}),x.jsx("div",{className:"w-[3px] rounded-sm "+(t>=3?"bg-brand-black":"bg-obsidian-200"),style:{height:"16px"}})]})}function Ue({name:e,profileLogoUrl:t}){return e?t?x.jsx("img",{src:t,alt:"",className:"h-[20px] w-[20px] rounded-full object-cover"}):x.jsx("span",{className:"flex items-center justify-center h-[20px] w-[20px] rounded-full text-12 font-semibold text-gray-700",style:{backgroundColor:"#EAC891"},children:Pe(e)}):x.jsx("span",{className:"flex items-center justify-center h-[20px] w-[20px] rounded-full border border-dashed border-gray-300 text-gray-300",children:x.jsx(ie,{className:"h-[10px] w-[10px]"})})}function _e({brandSlug:e,ticketCode:t,onClose:s}){const[,a]=m(),n=d.useRef(null),{fetchActions:r,members:l}=u(),{toast:f}
1=p(),[j,y]=d.useState("loading"),[v,N]=d.useState(null),[w,k]=d.useState(null),[C,S]=d.useState(""),[E,A]=d.useState(!1),[I,O]=d.useState([]),[D,$]=d.useState(0);d.useEffect(()=>{if(!e||!t)return void y("not-found");let s=!1;return(()=>{c(this,null,function*(){var a;try{y("loading");const n=yield h.get(`/api/action-engine/brands/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}`);if(s)return;N(n.data.task),k(n.data.brandId),O(null!=(a=n.data.relatedContent)?a:[]),y("ready")}catch(n){if(s)return;const e=n instanceof Error?n.message:"Failed to load action";/404|not found|invalid ticket/i.test(e)?y("not-found"):/403|access denied/i.test(e)?(S("You don't have access to this action's brand."),y("error")):(S(e),y("error"))}})})(),()=>{s=!0}},[e,t]),d.useEffect(()=>{var e;"ready"===j&&(null==(e=n.current)||e.focus())},[j]);const P=d.useCallback(e=>c(this,null,function*(){if(!v||!w)return;const t=v;N(i(i({},v),e));try{yield b(`/api/action-engine/tasks/${v.id}`,{method:"PUT",body:JSON.stringify(i({brandId:w},e))}),r(),$(e=>e+1)}catch(s){N(t);const e=s instanceof Error?s.message:"Update failed";f({title:"Update failed",description:e,variant:"destructive"})}}),[v,w,r,f]),F=d.useCallback(e=>c(this,null,function*(){if(!v||!w)return;const t=v;N(o(i({},v),{status:e}));try{yield b(`/api/action-engine/tasks/${v.id}/status`,{method:"PUT",body:JSON.stringify({brandId:w,status:e})}),r(),$(e=>e+1)}catch(s){N(t);const e=s instanceof Error?s.message:"Status update failed";f({title:"Update failed",description:e,variant:"destructive"})}}),[v,w,r,f]),T=d.useCallback(e=>c(this,null,function*(){var t,s,a;if(!v)return;const n=e?l.find(t=>t.id===e):null;yield P({assignedTo:e,assigneeName:null!=(t=null==n?void 0:n.name)?t:null,assigneeEmail:null!=(s=null==n?void 0:n.email)?s:null,assigneeProfileLogoUrl:null!=(a=null==n?void 0:n.profileLogoUrl)?a:null})}),[v,l,P]);return x.jsx(G,{open:!0,onOpenChange:e=>{e||s()},children:x.jsxs(J,{children:[x.jsx(K,{className:g("fixed inset-0 z-[10000] bg-brand-black/25 backdrop-blur-[2px]","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-150")}),x.jsxs(W,{className:g("fixed left-[50%] top-[50%] z-[10000] translate-x-[-50%] translate-y-[-50%]","w-[min(1100px,calc(100vw-48px))] h-[min(780px,calc(100vh-48px))]","bg-white rounded-lg shadow-[0_20px_60px_-10px_rgba(22,22,22,0.25)] border border-obsidian-200","overflow-hidden flex flex-col","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 duration-150","focus:outline-none"),style:{fontFamily:'"IBM Plex Sans", sans-serif'},children:[x.jsx(q,{className:"sr-only",children:v?`${v.ticketCode} ${v.title}`:"Action detail"}),"loading"===j&&x.jsx("div",{className:"flex-1 flex items-center justify-center text-obsidian-400 text-14",children:"Loading action…"}),"not-found"===j&&x.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-8 text-center",children:[x.jsx("h1",{className:"text-18 font-medium text-brand-black",children:"Action not found"}),x.jsxs("p",{className:"text-obsidian-400 max-w-md text-14",children:["No ticket at"," ",x.jsxs("code",{className:"rounded bg-brand-pearl px-1.5 py-0.5 text-12",children:["/",e,"/actions/",t]})," ","— it may have been deleted, or the URL has a typo."]}),x.jsx("button",{type:"button",className:"mt-4 rounded-md px-4 py-2 text-14 font-medium text-white hover:opacity-90",style:{backgroundColor:"#AE431E"},onClick:()=>{s(),a("/action-engine")},children:"Back to Action Engine"})]}),"error"===j&&x.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-8 text-center",children:[x.jsx("h1",{className:"text-18 font-medium text-brand-black",children:"Couldn't load action"}),x.jsx("p",{className:"text-obsidian-400 text-14",children:C||"Unknown error"})]}),"ready"===j&&v&&x.jsx(Le,{task:v,members:l,markingDone:E,onMarkDone:()=>c(this,null,function*(){v&&(A(!0),yield F("done"),A(!1))}),onClose:s,primaryCtaRef:n,relatedContent:I,onNavigate:e=>{s();let t=e;if(!/[?&]contentId=/.test(e)&&v){const s=e.includes("?")?"&":"?";t=`${e}${s}sourceTaskId=${v.id}`}a(t)},onStatusChange:F,onPriorityChange:e=>P({priority:e}),onEffortChange:e=>P({effortMinutes:e}),onAssigneeChange:T,activityRefreshKey:D,onDueDateChange:e=>P({dueDate:e})}),x.jsx(V,{className:"absolute right-3 top-3 rounded-md p-1.5 text-obsidian-400 hover:bg-brand-pearl hover:text-brand-black focus:outline-none focus:ring-2 focus:ring-brand-chile/30","aria-label":"Close",children:x.jsx(H,{className:"h-4 w-4"})})]})]})})}function Le({task:e,members:t,markingDone:s,onMarkDone:a,onClose:n,primaryCtaRef:r,onNavigate:l,onStatusChange:i,onPriorityChange:o,onEffortChange:m,onAssigneeChange:u,onDueDateChange:h,activityRefreshKey:b,relatedContent:g}){var f,j;const y=Ee.has(e.status),v=e.description.length>
10,N=0===g.length&&e.nextStepUrl?"nav":v?"copy-prompt":"back",{toast:w}=p(),[k,C]=d.useState(!1),S=()=>c(this,null,function*(){const t=function(e){const t=[];return t.push(`# ${e.title}`),t.push(""),t.push(`Ticket: ${e.ticketCode}`),e.platforms.length>0&&t.push(`Platforms: ${e.platforms.join(", ")}`),t.push(""),e.description.length>0&&(t.push("## Steps"),e.description.forEach((e,s)=>{t.push(`${s+1}. ${e}`)}),t.push("")),e.impactProjection&&"object"==typeof e.impactProjection&&(t.push("## Expected impact"),Object.entries(e.impactProjection).forEach(([e,s])=>{t.push(`- ${e}: ${String(s)}`)}),t.push("")),t.push("Please implement these changes in the codebase. Show me the diff for each step before applying it, and confirm any change that touches production config."),t.join("\n")}(e);try{yield navigator.clipboard.writeText(t),C(!0),w({title:"Prompt copied",description:"Paste into Claude, Cursor, or your coding agent of choice."}),window.setTimeout(()=>C(!1),2e3)}catch(s){w({title:"Copy failed",description:"Clipboard unavailable — copy manually.",variant:"destructive"})}});return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 border-b border-brand-pearl text-14 pr-12",children:[x.jsx("span",{className:"font-mono text-obsidian-400",children:e.ticketCode}),x.jsx("span",{className:"text-obsidian-200",children:"·"}),x.jsx("span",{className:"text-brand-black font-medium truncate",children:e.title})]}),x.jsxs("div",{className:"flex-1 flex min-h-0",children:[x.jsx("div",{className:"flex-1 overflow-y-auto px-6 md:px-8 py-6",children:x.jsxs("div",{className:"max-w-2xl space-y-6",children:[x.jsx("h1",{className:"text-20 font-semibold leading-tight text-brand-black",children:e.title}),g.length>0&&x.jsx(Me,{rows:g,onOpen:e=>l(e)}),e.description.length>0&&x.jsxs("section",{children:[x.jsx("h2",{className:"text-12 font-semibold uppercase tracking-wide text-obsidian-400 mb-2",children:"Steps"}),x.jsx("ol",{className:"list-decimal space-y-2 pl-5 text-brand-black text-14 leading-[1.55]",children:e.description.map((e,t)=>x.jsx("li",{children:e},t))})]}),null!==e.impactProjection&&"object"==typeof e.impactProjection&&x.jsxs("section",{children:[x.jsx("h2",{className:"text-12 font-semibold uppercase tracking-wide text-obsidian-400 mb-2",children:"Impact projection"}),x.jsx("div",{className:"rounded-md border border-obsidian-200 bg-brand-pearl/50 p-3 text-14 text-brand-black",children:Object.entries(e.impactProjection).map(([e,t])=>x.jsxs("div",{className:"flex justify-between gap-4 py-0.5",children:[x.jsx("span",{className:"text-obsidian-400",children:e}),x.jsx("span",{className:"font-medium text-brand-black",children:String(t)})]},e))})]}),e.platforms.length>0&&x.jsxs("section",{children:[x.jsx("h2",{className:"text-12 font-semibold uppercase tracking-wide text-obsidian-400 mb-2",children:"Platforms"}),x.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.platforms.map(e=>x.jsx("span",{className:"rounded-full bg-brand-pearl px-2 py-0.5 text-12 text-brand-black",children:e},e))})]}),x.jsx(Be,{taskId:e.id,refreshKey:b})]})}),x.jsxs("aside",{className:"hidden md:flex w-[280px] flex-shrink-0 flex-col border-l border-brand-pearl bg-brand-pearl/40 overflow-y-auto",children:[x.jsxs("div",{className:"px-4 py-4 flex flex-col gap-0.5",children:[x.jsxs("div",{className:"flex items-center justify-between px-2 pb-2",children:[x.jsx("h3",{className:"text-12 font-semibold uppercase tracking-wide text-obsidian-400",children:"Properties"}),x.jsx(Re,{deepLinkUrl:e.deepLinkUrl,ticketCode:e.ticketCode,title:e.title,description:e.description,onCopyAiPrompt:"copy-prompt"===N?S:void 0})]}),x.jsx(ze,{icon:x.jsx(Fe,{status:e.status}),label:De(e.status),popover:x.jsx(Je,{options:Ae.map(t=>({value:t.value,label:t.label,icon:x.jsx(Fe,{status:t.value}),selected:t.value===e.status})),onPick:e=>i(String(e))})}),x.jsx(ze,{icon:x.jsx(Te,{priority:e.priority}),label:x.jsx("span",{className:"capitalize",children:e.priority}),popover:x.jsx(Je,{options:Ie.map(t=>({value:t.value,label:t.label,icon:x.jsx(Te,{priority:t.value}),selected:t.value===e.priority})),onPick:e=>o(String(e))})}),x.jsx(ze,{icon:x.jsx(Ue,{name:e.assigneeName,profileLogoUrl:e.assigneeProfileLogoUrl}),label:e.assigneeName?x.jsx("span",{className:"truncate",children:e.assigneeName}):x.jsx("span",{className:"text-obsidian-400",children:"Unassigned"}),popover:x.jsx(We,{members:t,assignedTo:null!=(f=e.assignedTo)?f:null,onPick:u})}),x.jsx(ze,{icon:x.jsx(Y,{className:"h-[14px] w-[14px] text-obsidian-400"}),label:$e(e.effortMinutes),popover:x.jsx(Je,{options:Oe.map(t=>({value:t.value,label:t.label,icon:x.jsx(Y,{className:"h-[14px] w-[14px] text-obsidian-400"}),selected:t.value===e.effortMinutes})),onPick:e=>m(Number(e))})}),x.jsx(Ke,{value:e.dueDate,isOverdue:e.isOverdue,onChange:h}),e.taskCategory&&"generic"!==e.taskCategory&&Se[e.taskCategory]&&x.jsx(Ge,{icon:x.jsx(Q,{className:"h-[14px] w-[14px] text-obsidian-400"}),label:x.jsx("span",{className:"inline-flex items-center text-12 font-medium rounded-full px-2 py-0.5",style:{color:Se[e.taskCategory].textColor,backgroundColor:Se[e.taskCategory].bgColor},title:null!=(j=e.taskType)?j:"",children:Se[e.taskCategory].label})})]}),x.jsxs("div",{className:"mt-auto px-4 py-3 border-t border-brand-pearl space-y-2",children:["nav"===N?x.jsxs("button",{ref:r,type:"button",onClick:()=>l(e.nextStepUrl),className:"inline-flex items-center justify-center gap-1.5 w-full rounded-md px-4 py-2 text-14 font-medium text-white hover:opacity-90",style:{backgroundColor:"#AE431E"},children:["content_post"===e.templateKey?x.jsx(X,{className:"h-4 w-4"}):x.jsx(Z,{className:"h-4 w-4"}),"content_post"===e.templateKey?"Open in editor":"Open next step"]}):"copy-prompt"===N?x.jsxs("button",{ref:r,type:"button",onClick:S,className:"inline-flex items-center justify-center gap-1.5 w-full rounded-md px-4 py-2 text-14 font-medium text-white hover:opacity-90",style:{backgroundColor:"#AE431E"},title:"Paste it into your coding agent to fix this check",children:[k?x.jsx(ee,{className:"h-4 w-4"}):x.jsx(te,{className:"h-4 w-4"}),k?"Copied":"Copy prompt"]}):x.jsxs("button",{ref:r,type:"button",onClick:n,className:"inline-flex items-center justify-center gap-1.5 w-full rounded-md px-4 py-2 text-14 font-medium text-white hover:opacity-90",style:{backgroundColor:"#AE431E"},children:[x.jsx(se,{className:"h-4 w-4"}),"Back to Action Engine"]}),y?x.jsxs("span",{className:"inline-flex items-center justify-center gap-1.5 w-full rounded-md px-3 py-2 text-14 font-medium",style:{backgroundColor:"#EAF3DE",color:"#3B6D11"},children:[x.jsx(ae,{className:"h-4 w-4"}),"done"===e.status?"Done":De(e.status)]}):x.jsxs("button",{type:"button",onClick:a,disabled:s,className:"inline-flex items-center justify-center gap-1.5 w-full rounded-md border border-obsidian-200 px-4 py-2 text-14 font-medium text-brand-black bg-white hover:bg-brand-pearl disabled:opacity-60",children:[x.jsx(ae,{className:"h-4 w-4"}),s?"Marking done…":"Mark as done"]})]})]})]})]})}function Re({deepLinkUrl:e,ticketCode:t,title:s,description:a,onCopyAiPrompt:n}){const[r,l]=d.useState(!1),i=d.useRef(null),[o,m]=d.useState(null),u=e=>{m(e),setTimeout(()=>{l(!1),m(null)},1e3)};return x.jsxs("div",{className:"relative",children:[x.jsx("button",{ref:i,onClick:()=>l(e=>!e),className:"inline-flex items-center justify-center h-6 w-6 rounded text-obsidian-400 hover:bg-white hover:text-brand-black","aria-label":"More actions",children:x.jsx(ne,{className:"h-3.5 w-3.5"})}),x.jsxs(L,{open:r,triggerRef:i,width:200,id:"action-rail-menu-portal",onClose:()=>l(!1),children:[x.jsxs("button",{onClick:()=>c(this,null,function*(){try{yield navigator.clipboard.writeText(e)}catch(t){}u("link")}),className:"flex items-center gap-2 w-full px-3 py-1.5 text-12 text-brand-black hover:bg-brand-pearl",children:["link"===o?x.jsx(ee,{className:"h-3.5 w-3.5 text-[#3B6D11]"}):x.jsx(re,{className:"h-3.5 w-3.5 text-obsidian-400"}),"Copy link"]}),x.jsxs("button",{onClick:()=>c(this,null,function*(){const e=`${t} — ${s}\n\n${a.map((e,t)=>`${t+1}. ${e}`).join("\n")}`;try{yield navigator.clipboard.writeText(e)}catch(n){}u("ticket")}),className:"flex items-center gap-2 w-full px-3 py-1.5 text-12 text-brand-black hover:bg-brand-pearl",children:["ticket"===o?x.jsx(ee,{className:"h-3.5 w-3.5 text-[#3B6D11]"}):x.jsx(te,{className:"h-3.5 w-3.5 text-obsidian-400"}),"Copy ticket"]}),n&&x.jsxs("button",{onClick:()=>c(this,null,function*(){n&&(yield n(),u("prompt"))}),className:"flex items-center gap-2 w-full px-3 py-1.5 text-12 text-brand-black hover:bg-brand-pearl",children:["prompt"===o?x.jsx(ee,{className:"h-3.5 w-3.5 text-[#3B6D11]"}):x.jsx(le,{className:"h-3.5 w-3.5 text-obsidian-400"}),"Copy as AI prompt"]})]})]})}function Me({rows:e,onOpen:t}){const s=1===e.length?"Content from this ticket":`Content from this ticket (${e.length})`;return x.jsxs("section",{children:[x.jsx("h2",{className:"text-12 font-semibold uppercase tracking-wide text-obsidian-400 mb-2",children:s}),x.jsx("ul",{className:"space-y-1.5",children:e.map(e=>{var s,a,n,r,l;const i=null!=(s=R[e.platform])?s:null,o=null!=(a=null==i?void 0:i.label)?a:e.platform.replace(/_/g," "),c=null!=(n=null==i?void 0:i.color)?n:"#7a7a7a",d=null!=(r=null==i?void 0:i.icon)?r:null,m=e.lifecycle||e.status||"queued",u=null!=(l=M[m])?l:M.queued,p=z(e.platform,e.contentId);return x.jsx("li",{children:x.jsxs("button",{type:"button",onClick:()=>t(p),className:"group flex items-center gap-3 w-full text-left rounded-md border border-brand-pearl bg-white px-3 py-2 hover:border-obsidian-200 hover:bg-brand-pearl/40 transition-colors",children:[x.jsx("span",{className:"flex-shrink-0 w-5 h-5 inline-flex items-center justify-center",style:{color:c}
1,"aria-hidden":!0,children:d}),x.jsxs("span",{className:"flex-1 min-w-0",children:[x.jsx("span",{className:"block text-14 text-brand-black truncate",children:e.title}),x.jsxs("span",{className:"block text-12 text-obsidian-400 truncate",children:[o,"hub"===e.broadcastRole?" · Hub":null,"spoke"===e.broadcastRole?" · Spoke":null]})]}),x.jsx("span",{className:`flex-shrink-0 inline-flex items-center px-1.5 py-0.5 text-12 font-medium rounded border ${u.badge}`,children:u.label}),x.jsx(Z,{className:"flex-shrink-0 h-3.5 w-3.5 text-obsidian-400 group-hover:text-brand-black"})]})},e.contentId)})})]})}function Be({taskId:e,refreshKey:t=0}){const{currentBrand:s}=f();return(null==s?void 0:s.id)?x.jsxs("section",{className:"pt-6 mt-6 border-t border-brand-pearl",children:[x.jsx("p",{className:"text-12 font-semibold uppercase tracking-wide text-obsidian-400 mb-2",children:"Activity"}),x.jsx(B,{entityType:"action_task",entityId:e,brandId:s.id,refreshKey:t})]}):null}function ze({icon:e,label:t,popover:s}){const[a,n]=d.useState(!1);return x.jsxs(O,{open:a,onOpenChange:n,children:[x.jsx(D,{asChild:!0,children:x.jsxs("button",{type:"button",className:"flex items-center gap-2.5 w-full px-2 py-1.5 rounded-md hover:bg-white transition-colors text-left",children:[x.jsx("span",{className:"flex-shrink-0 flex items-center justify-center w-5 h-5",children:e}),x.jsx("span",{className:"flex-1 min-w-0 text-14 text-brand-black truncate",children:t})]})}),x.jsx($,{align:"start",side:"bottom",sideOffset:4,className:"w-[220px] p-1 z-[10001]",onInteractOutside:()=>n(!1),children:x.jsx("div",{onClick:()=>n(!1),children:s})})]})}function Ge({icon:e,label:t}){return x.jsxs("div",{className:"flex items-center gap-2.5 w-full px-2 py-1.5 text-left",children:[x.jsx("span",{className:"flex-shrink-0 flex items-center justify-center w-5 h-5",children:e}),x.jsx("span",{className:"flex-1 min-w-0 text-14 text-brand-black truncate",children:t})]})}function Je({options:e,onPick:t}){return x.jsx("div",{className:"flex flex-col",children:e.map(e=>x.jsxs("button",{type:"button",onClick:()=>t(e.value),className:"flex items-center gap-2 px-2 py-1.5 rounded text-14 text-brand-black hover:bg-brand-pearl transition-colors text-left",children:[e.icon&&x.jsx("span",{className:"flex-shrink-0 flex items-center justify-center w-5 h-5",children:e.icon}),x.jsx("span",{className:"flex-1 truncate",children:e.label}),e.selected&&x.jsx(ee,{className:"h-3.5 w-3.5 text-brand-chile"})]},String(e.value)))})}function Ke({value:e,isOverdue:t,onChange:s}){const a=e&&e.length>=10?e.substring(0,10):"";return x.jsxs("div",{className:"flex items-center gap-2.5 w-full px-2 py-1.5",children:[x.jsx("span",{className:"flex-shrink-0 flex items-center justify-center w-5 h-5",children:x.jsx(oe,{className:"h-[14px] w-[14px] "+(t?"text-red-500":"text-obsidian-400")})}),x.jsx("input",{type:"date",value:a,onChange:e=>s(e.target.value||null),"aria-label":"Due date",className:"flex-1 min-w-0 text-14 bg-transparent border-0 p-0 focus:outline-none focus:ring-0 cursor-pointer "+(a?t?"text-red-600":"text-brand-black":"text-obsidian-400")})]})}function We({members:e,assignedTo:t,onPick:s}){return x.jsxs("div",{className:"flex flex-col",children:[e.map(e=>x.jsxs("button",{type:"button",onClick:()=>s(e.id),className:"flex items-center gap-2 px-2 py-1.5 rounded text-14 text-brand-black hover:bg-brand-pearl transition-colors text-left",children:[x.jsx(Ue,{name:e.name,profileLogoUrl:e.profileLogoUrl}),x.jsx("span",{className:"flex-1 truncate",children:e.name||e.email}),t===e.id&&x.jsx(ee,{className:"h-3.5 w-3.5 text-brand-chile"})]},e.id)),null!=t&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"border-t border-brand-pearl my-1"}),x.jsx("button",{type:"button",onClick:()=>s(null),className:"flex items-center gap-2 px-2 py-1.5 rounded text-14 text-obsidian-400 hover:bg-brand-pearl transition-colors text-left",children:"Unassign"})]})]})}const qe={technical:{label:"Tech",textColor:"#1F4E79",bgColor:"#E4EEF8"},content_creation:{label:"Content",textColor:"#3B6D11",bgColor:"#EAF3DE"},content_optimization:{label:"Optimize",textColor:"#3B6D11",bgColor:"#EAF3DE"},media_placement:{label:"Media",textColor:"#6B3F92",bgColor:"#F0E7F8"},opportunity:{label:"Opportunity",textColor:"#AE431E",bgColor:"#FAECE7"},report:{label:"Recap",textColor:"#4A4A4A",bgColor:"#EEEEEE"},operational:{label:"Ops",textColor:"#7A7A7A",bgColor:"#F0F0F0"}},Ve=[{key:"technical",label:"Technical"},{key:"content_creation",label:"Content Creation"},{key:"content_optimization",label:"Content Optimization"},{key:"media_placement",label:"Media Placement"},{key:"opportunity",label:"Opportunity"},{key:"report",label:"Report"},{key:"operational",label:"Operational"}],He=[{key:"todo",label:"Todo"},{key:"in_progress",label:"In Progress"},{key:"in_review",label:"In Review"},{key:"backlog",label:"Backlog"},{key:"done",label:"Done"},{key:"canceled",label:"Cancelled"}],Ye={reddit:"/reddit.png",linkedin:"/linkedin.png",linkedin_founder:"/linkedin.png",linkedin_company:"/linkedin.png",linkedin_announcement:"/linkedin.png",x:"/x.png",twitter:"/x.png",instagram:"/insta.png",youtube:"/youtube.png",blog:"/blog.png",medium:"/blog.png",facebook:"/blog.png"},Qe=[{id:"onboard-broadcast",title:"Create your first content in Organic Broadcast",description:"Draft and publish your first LinkedIn post, blog article, or social update to start building AI visibility across platforms.",route:"/broadcast",Icon:pe},{id:"onboard-social-listening",title:"Start engaging with Social Listening",description:"Monitor Reddit, Hacker News, and other platforms for relevant conversations. Find and respond to threads to build credibility and citations.",route:"/social-listening",Icon:he},{id:"onboard-media-placement",title:"Explore Media Press Placement",description:"Discover available media and press placement channels for your brand. Understand which outlets can amplify your visibility in AI responses.",route:"/paid-media",Icon:be}];function Xe(e){if(e<60)return`${e} min`;const t=Math.floor(e/60),s=e%60;return s>0?`${t}h ${s}m`:`${t}h`}function Ze(e){var t;
1return null!=(t=e.ticketCode)?t:`#${String(e.displaySeq).padStart(3,"0")}`}function et(e){if(!e)return"";return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function tt(e){if(!e)return"";const t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"})}function st(e){if(!e)return"?";const t=e.trim().split(/\s+/);return t.length>=2?(t[0][0]+t[1][0]).toUpperCase():t[0].substring(0,2).toUpperCase()}function at({task:e}){const t=e.priority;if("urgent"===t)return x.jsx("div",{className:"relative h-[20px] w-[20px] rounded-sm flex items-center justify-center text-white font-bold text-12",style:{backgroundColor:"#D06224"},title:"urgent",children:"!"});const s="high"===t?3:"medium"===t?2:1;return x.jsxs("div",{className:"relative h-[20px] w-[20px] flex items-end justify-between gap-[2px] px-[2px]",title:t,children:[x.jsx("div",{className:"w-[4px] rounded-sm "+(s>=1?"bg-obsidian-400":"bg-obsidian-200"),style:{height:"11px"}}),x.jsx("div",{className:"w-[4px] rounded-sm "+(s>=2?"bg-obsidian-400":"bg-obsidian-200"),style:{height:"15px"}}),x.jsx("div",{className:"w-[4px] rounded-sm "+(s>=3?"bg-obsidian-400":"bg-obsidian-200"),style:{height:"20px"}})]})}function nt({platforms:e}){const{currentBrand:t}=f(),s=null==t?void 0:t.websiteUrl,a=e.slice(0,3),n=e.length-3;return x.jsxs("span",{className:"inline-flex items-center ml-1.5",style:{marginLeft:"6px"},children:[x.jsx("span",{className:"inline-flex items-center",style:{paddingRight:"8px"},children:a.map((e,t)=>{const n="website"===e||"industry_site"===e||"github"===e?function(e){if(!e)return null;try{return`https://www.google.com/s2/favicons?domain=${new URL(e.startsWith("http")?e:`https://${e}`).hostname}&sz=32`}catch(t){return null}}(s)||"/blog.png":Ye[e]||"/blog.png";return x.jsx("span",{className:"inline-flex items-center justify-center h-[20px] w-[20px] rounded-full bg-brand-pearl border border-white",style:{marginLeft:t>0?"-8px":"0",zIndex:a.length-t},title:e,children:x.jsx("img",{src:n,alt:e,className:"h-[12px] w-[12px] object-contain"})},`${e}-${t}`)})}),n>0&&x.jsxs("span",{className:"text-14 text-obsidian-400 font-normal ml-1",children:["+",n]})]})}function rt({status:e}){return"done"===e?x.jsx("span",{className:"inline-flex items-center",title:"Published",children:x.jsx(ae,{className:"h-[18px] w-[18px] text-brand-olive"})}):"in_review"===e?x.jsx("span",{className:"inline-flex items-center",title:"In Review",children:x.jsx(Y,{className:"h-[18px] w-[18px] text-[#C89A50]"})}):x.jsx("span",{className:"inline-flex items-center",title:e,children:x.jsx(ie,{className:"h-[18px] w-[18px] text-gray-300"})})}function lt({minutes:e}){return x.jsxs("span",{className:"inline-flex items-center gap-1.5 text-14 font-normal text-obsidian-400 whitespace-nowrap",children:[x.jsx("img",{src:"/action-engine-assets/effort-icon.svg",alt:"",className:"h-[12px] w-[12px]"}),Xe(e)]})}const it={sort:"timeGroup",show:{id:!0,category:!0,platforms:!0,effort:!0,assignee:!0,date:!0}},ot="ae-display-v1";function ct(){var e;try{const t=localStorage.getItem(ot);if(!t)return it;const s=JSON.parse(t);return{sort:["timeGroup","priority","dueDate","newest","effort"].includes(s.sort)?s.sort:it.sort,show:i(i({},it.show),null!=(e=s.show)?e:{})}}catch(t){return it}}const dt={urgent:0,high:1,medium:2,low:3};const xt={timeGroup:"Time group",priority:"Priority",dueDate:"Due date",newest:"Newest",effort:"Effort"},mt={id:"ID",category:"Category",platforms:"Platforms",effort:"Effort",assignee:"Assignee",date:"Date"};function ut({prefs:e,onChange:t}){const s=e.sort!==it.sort||Object.values(e.show).some(e=>!e);return x.jsxs(O,{children:[x.jsx(D,{asChild:!0,children:x.jsx("button",{type:"button","aria-label":"Display options",title:"Display options",className:"inline-flex items-center justify-center h-8 w-8 rounded-lg border transition-colors "+(s?"bg-gray-100 border-gray-300 text-gray-800":"bg-white border-gray-200 text-gray-500 hover:bg-gray-50"),children:x.jsx(ue,{className:"h-4 w-4"})})}),x.jsxs($,{align:"end",className:"w-72 p-0",children:[x.jsxs("div",{className:"px-3 py-2.5 border-b border-gray-100",children:[x.jsx("p",{className:"text-12 font-semibold text-gray-700 mb-2",children:"Ordering"}),x.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(xt).map(s=>x.jsx("button",{onClick:()=>t(o(i({},e),{sort:s})),className:"px-2 py-1 text-12 font-medium rounded-md border transition-colors "+(e.sort===s?"bg-brand-pearl border-gray-300 text-brand-black":"bg-white border-gray-200 text-gray-500 hover:text-gray-700"),children:xt[s]},s))})]}),x.jsxs("div",{className:"px-3 py-2.5",children:[x.jsx("p",{className:"text-12 font-semibold text-gray-700 mb-2",children:"Display properties"}),x.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(mt).map(s=>x.jsx("button",{onClick:()=>t(o(i({},e),{show:o(i({},e.show),{[s]:!e.show[s]})})),className:"px-2 py-1 text-12 font-medium rounded-md border transition-colors "+(e.show[s]?"bg-brand-pearl border-gray-300 text-brand-black":"bg-white border-gray-200 text-gray-400 hover:text-gray-600"),children:mt[s]},s))})]}),x.jsx("div",{className:"px-3 py-2 border-t border-gray-100 text-right",children:x.jsx("button",{onClick:()=>t(it),className:"text-12 font-medium text-gray-500 hover:text-gray-700",children:"Reset"})})]})]})}function pt({task:e,members:t,onAssign:s}
1){const[a,n]=d.useState(!1),r=e.assignedTo&&e.assigneeName;return x.jsxs(O,{open:a,onOpenChange:n,children:[x.jsx(D,{asChild:!0,children:x.jsx("button",{className:"flex-shrink-0 focus:outline-none",title:r?e.assigneeName:"Assign",children:r?x.jsxs(x.Fragment,{children:[e.assigneeProfileLogoUrl?x.jsx("img",{src:e.assigneeProfileLogoUrl,alt:e.assigneeName,className:"h-6 w-6 rounded-full object-cover",onError:e=>{var t;e.currentTarget.style.display="none",null==(t=e.currentTarget.nextElementSibling)||t.classList.remove("hidden")}}):null,x.jsx("span",{className:"flex items-center justify-center h-6 w-6 rounded-full text-12 font-semibold text-gray-700 "+(e.assigneeProfileLogoUrl?"hidden":""),style:{backgroundColor:"#EAC891"},children:st(e.assigneeName)})]}):x.jsx("span",{className:"flex items-center justify-center h-6 w-6 rounded-full border-2 border-dashed border-gray-300 text-gray-300 opacity-0 group-hover:opacity-100 transition-opacity",children:x.jsx(ye,{className:"h-3.5 w-3.5"})})})}),x.jsxs($,{align:"end",className:"w-56 p-2",children:[x.jsx("p",{className:"text-xs font-medium text-gray-500 px-2 py-1.5",children:"Assign to"}),t.map(t=>x.jsxs("button",{onClick:()=>{s(e.id,t.id),n(!1)},className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm text-gray-700 rounded hover:bg-gray-100 transition-colors",children:[t.profileLogoUrl?x.jsx("img",{src:t.profileLogoUrl,alt:t.name,className:"h-6 w-6 rounded-full object-cover flex-shrink-0",onError:e=>{var t;e.currentTarget.style.display="none",null==(t=e.currentTarget.nextElementSibling)||t.classList.remove("hidden")}}):null,x.jsx("span",{className:"flex items-center justify-center h-6 w-6 rounded-full text-12 font-semibold text-gray-700 "+(t.profileLogoUrl?"hidden":""),style:{backgroundColor:"#EAC891"},children:st(t.name)}),x.jsx("span",{className:"truncate",children:t.name||t.email}),e.assignedTo===t.id&&x.jsx(ae,{className:"h-3.5 w-3.5 text-brand-chile ml-auto flex-shrink-0"})]},t.id)),e.assignedTo&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"border-t my-1"}),x.jsx("button",{onClick:()=>{s(e.id,null),n(!1)},className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm text-gray-400 rounded hover:bg-gray-100 transition-colors",children:"Unassign"})]})]})]})}function ht({filters:e,counts:t,onChange:s}){var a;const n=e.statuses.length+e.categories.length+(e.showArchived?1:0);return x.jsxs(O,{children:[x.jsx(D,{asChild:!0,children:x.jsxs("button",{type:"button","aria-label":"Filter tasks",title:"Filter",className:"inline-flex items-center gap-1 h-8 px-2 rounded-lg border transition-colors "+(n>0?"bg-gray-100 border-gray-300 text-gray-800":"bg-white border-gray-200 text-gray-500 hover:bg-gray-50"),children:[x.jsx(me,{className:"h-4 w-4"}),n>0&&x.jsx("span",{className:"text-12 font-semibold",children:n})]})}),x.jsxs($,{align:"end",className:"w-64 p-0",children:[x.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-gray-100",children:[x.jsx("span",{className:"text-12 font-semibold text-gray-700",children:"Filter"}),n>0&&x.jsx("button",{type:"button",onClick:()=>s({statuses:[],categories:[],showArchived:!1}),className:"text-12 text-gray-500 hover:text-gray-800",children:"Clear all"})]}),x.jsx(bt,{title:"Status",children:He.map(a=>{return x.jsx(gt,{label:a.label,count:(n=a.key,null!=(l=null==(r=null==t?void 0:t.status)?void 0:r[n])?l:0),checked:e.statuses.includes(a.key),onChange:e=>((e,t)=>{s(s=>o(i({},s),{statuses:t?[...s.statuses,e]:s.statuses.filter(t=>t!==e)}))})(a.key,e)},a.key);var n,r,l})}),x.jsx(bt,{title:"Category",children:Ve.map(a=>{return x.jsx(gt,{label:a.label,count:(n=a.key,null!=(l=null==(r=null==t?void 0:t.category)?void 0:r[n])?l:0),checked:e.categories.includes(a.key),onChange:e=>((e,t)=>{s(s=>o(i({},s),{categories:t?[...s.categories,e]:s.categories.filter(t=>t!==e)}))})(a.key,e)},a.key);var n,r,l})}),x.jsx(bt,{title:"Other",children:x.jsx(gt,{label:"Archived",count:null!=(a=null==t?void 0:t.archived)?a:0,checked:e.showArchived,onChange:e=>s(t=>o(i({},t),{showArchived:e}))})})]})]})}function bt({title:e,children:t}){return x.jsxs("div",{className:"border-b border-gray-100 last:border-b-0 py-1",children:[x.jsx("div",{className:"px-3 pt-1 pb-0.5 text-12 font-semibold uppercase tracking-wide text-gray-400",children:e}),x.jsx("div",{className:"flex flex-col",children:t})]})}function gt({label:e,count:t,checked:s,onChange:a}){return x.jsxs("label",{className:"flex items-center justify-between gap-2 px-3 py-1 rounded hover:bg-gray-50 cursor-pointer text-14 text-gray-700 mx-1",children:[x.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[x.jsx(I,{checked:s,onCheckedChange:e=>a(!!e)}),x.jsx("span",{className:"truncate",children:e})]}),x.jsx("span",{className:"flex-shrink-0 text-12 text-gray-400 tabular-nums",children:t})]})}function ft({task:e,onToggle:t,onCancel:s,members:a,onAssign:n,onClick:r,guideId:l,show:i}){var o,c,d;const m="done"===e.status,u=!0===e.archived;return x.jsxs("div",{"data-guide":l,className:"flex items-center h-11 px-4 overflow-hidden bg-brand-pearl hover:bg-white transition-colors group border-b border-gray-100 last:border-b-0 cursor-pointer "+(u?"opacity-50 grayscale":m?"opacity-40":""),onClick:r,children:[x.jsxs("div",{className:"flex items-center gap-2.5 flex-1 min-w-0",children:[x.jsx("div",{className:"flex-shrink-0 w-5",children:x.jsx(at,{task:e})}),i.id&&x.jsx("span",{className:"flex-shrink-0 text-14 font-normal text-obsidian-400 w-[65px]",children:Ze(e)}),x.jsx("button",{onClick:e=>{e.stopPropagation(),t()},className:"flex-shrink-0 w-5",children:x.jsx(rt,{status:e.status})}),x.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[x.jsx("span",{className:"text-14 font-medium truncate "+(m?"line-through text-gray-400":"text-brand-black"),children:e.title}),e.isOverdue&&x.jsxs("span",{className:"flex-shrink-0 inline-flex items-center gap-0.5 text-12 font-semibold px-1.5 py-0.5 rounded-full bg-orange-100 text-orange-700",children:[x.jsx(fe,{className:"h-2.5 w-2.5"}),"Overdue"]}),(null==(o=e.templateKey)?void 0:o.startsWith("onboarding_"))&&x.jsx("span",{className:"flex-shrink-0 text-12 font-medium rounded-full px-1.5 py-0.5",style:{color:"#AE431E",backgroundColor:"#FAECE7"},children:"Setup"}),i.category&&e.taskCategory&&"generic"!==e.taskCategory&&qe[e.taskCategory]&&x.jsx("span",{className:"flex-shrink-0 text-12 font-medium rounded-full px-1.5 py-0.5",style:{color:qe[e.taskCategory].textColor,backgroundColor:qe[e.taskCategory].bgColor},title:null!=(c=e.taskType)?c:"",children:qe[e.taskCategory].label}),(null==(d=e.sourceData)?void 0:d.frequency)&&x.jsx("span",{className:"flex-shrink-0 text-12 font-medium rounded-full px-1.5 py-0.5",style:{color:"#3B6D11",backgroundColor:"#EAF3DE"},children:e.sourceData.frequency}),i.platforms&&x.jsx(nt,{platforms:e.platforms})]})]}),x.jsxs("div",{className:"flex items-center gap-2.5 flex-shrink-0 ml-3 hidden @sm:flex",children:[i.effort&&x.jsx("div",{className:"w-[76px] flex justify-end",children:x.jsx(lt,{minutes:e.effortMinutes})}),i.assignee&&x.jsx("div",{onClick:e=>e.stopPropagation(),children:x.jsx(pt,{task:e,members:a,onAssign:n})}),i.date&&x.jsxs("span",{className:"text-14 text-obsidian-400 w-[48px] text-right flex items-center gap-0.5 justify-end whitespace-nowrap",children:[x.jsx("span",{children:et(e.createdAt).split(" ")[0]}),x.jsx("span",{children:et(e.createdAt).split(" ")[1]})]}),x.jsx("button",{onClick:e=>{e.stopPropagation(),s()},className:"opacity-0 group-hover:opacity-100 transition-opacity text-gray-300 hover:text-red-400 w-5",title:"Cancel task",children:x.jsx(H,{className:"h-3.5 w-3.5"})})]})]})}function jt({open:e,onOpenChange:t,onSubmit:s}
1){const[a,n]=d.useState(""),[r,l]=d.useState(""),[i,o]=d.useState("medium"),[c,m]=d.useState("this-week"),[u,p]=d.useState("30");return x.jsx(N,{open:e,onOpenChange:t,children:x.jsxs(w,{className:"sm:max-w-[480px]",children:[x.jsxs(k,{children:[x.jsx(C,{children:"Add Task"}),x.jsx(S,{children:"Create a manual action item for your GEO plan."})]}),x.jsxs("div",{className:"space-y-4 py-2",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Title"}),x.jsx(E,{value:a,onChange:e=>n(e.target.value),placeholder:"e.g. Write blog post about AI search trends",autoFocus:!0})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Steps (one per line)"}),x.jsx("textarea",{value:r,onChange:e=>l(e.target.value),placeholder:"Step 1: Research topic\nStep 2: Draft outline\nStep 3: Write and publish",rows:3,className:"flex w-full rounded-lg border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"})]}),x.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Priority"}),x.jsxs(P,{value:i,onValueChange:o,children:[x.jsx(F,{className:"h-9 text-sm",children:x.jsx(T,{})}),x.jsxs(U,{children:[x.jsx(_,{value:"urgent",children:"Urgent"}),x.jsx(_,{value:"high",children:"High"}),x.jsx(_,{value:"medium",children:"Medium"}),x.jsx(_,{value:"low",children:"Low"})]})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"When"}),x.jsxs(P,{value:c,onValueChange:m,children:[x.jsx(F,{className:"h-9 text-sm",children:x.jsx(T,{})}),x.jsxs(U,{children:[x.jsx(_,{value:"today",children:"Today"}),x.jsx(_,{value:"this-week",children:"This Week"}),x.jsx(_,{value:"next-week",children:"Next Week"})]})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Effort"}),x.jsxs(P,{value:u,onValueChange:p,children:[x.jsx(F,{className:"h-9 text-sm",children:x.jsx(T,{})}),x.jsxs(U,{children:[x.jsx(_,{value:"15",children:"15 min"}),x.jsx(_,{value:"30",children:"30 min"}),x.jsx(_,{value:"60",children:"1 hour"}),x.jsx(_,{value:"120",children:"2 hours"}),x.jsx(_,{value:"240",children:"4 hours"})]})]})]})]})]}),x.jsxs(A,{children:[x.jsx("button",{onClick:()=>t(!1),className:"px-4 py-2 text-sm text-gray-500 hover:text-gray-700 transition-colors",children:"Cancel"}),x.jsx("button",{onClick:()=>{if(!a.trim())return;const e=r.trim()?r.trim().split("\n").filter(Boolean):[];s({title:a.trim(),description:e,priority:i,timeGroup:c,effortMinutes:parseInt(u)||30}),n(""),l(""),o("medium"),m("this-week"),p("30"),t(!1)},disabled:!a.trim(),className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors disabled:opacity-50",style:{backgroundColor:"#AE431E"},children:"Add Task"})]})]})})}function yt({brandId:e,onComplete:t}){const[,s]=m(),[a,n]=d.useState(()=>{try{return JSON.parse(localStorage.getItem(`action-engine-onboard-visited-${e}`)||"[]")}catch(t){return[]}});return x.jsxs("div",{children:[x.jsxs("div",{className:"px-6 pt-4 pb-3",children:[x.jsx("h2",{className:"text-16 font-semibold text-brand-black mb-1",children:"Get Started with AI Actions"}),x.jsx("p",{className:"text-12 text-obsidian-400 leading-[1.4]",children:"Explore these key features to start improving your AI visibility. Complete each step to unlock your personalized action plan."})]}),x.jsx("div",{className:"flex items-center justify-between py-1.5 px-6 bg-brand-pearl mb-1",children:x.jsx("span",{className:"text-14 font-medium text-black",children:"Actions for Today"})}),x.jsx("div",{className:"bg-brand-pearl p-3 mb-1",children:x.jsx("div",{className:"flex gap-4 overflow-x-auto pb-1",style:{scrollbarWidth:"none"},children:Qe.map(t=>{const r=a.includes(t.id);return x.jsxs("div",{onClick:()=>(t=>{const r=[...new Set([...a,t.id])];n(r),localStorage.setItem(`action-engine-onboard-visited-${e}`,JSON.stringify(r)),s(t.route)})(t),className:"min-w-[340px] max-w-[380px] flex-shrink-0 p-4 border bg-white group relative cursor-pointer hover:border-brand-chile/40 transition-colors "+(r?"border-green-200":"border-gray-200"),children:[r&&x.jsx("div",{className:"absolute top-3 right-3",children:x.jsx(ae,{className:"h-5 w-5 text-green-500"})}),x.jsxs("div",{className:"flex items-center gap-2.5 mb-2.5",children:[x.jsx("div",{className:"h-8 w-8 rounded-full flex items-center justify-center",style:{backgroundColor:"#F2F1ED"},children:x.jsx(t.Icon,{className:"h-4 w-4",style:{color:"#AE431E"}})}),x.jsx("span",{className:"text-14 font-medium text-brand-black pr-6",children:t.title})]}),x.jsx("p",{className:"text-12 text-obsidian-400 leading-[1.5] mb-3",children:t.description}),x.jsxs("div",{className:"flex items-center gap-1 text-12 font-medium",style:{color:"#AE431E"},children:[x.jsx("span",{children:r?"Visited":"Explore"}),x.jsx(ge,{className:"h-3.5 w-3.5"})]})]},t.id)})})}),x.jsx("div",{className:"flex justify-center pt-4 pb-2",children:x.jsx("button",{onClick:()=>{localStorage.setItem(`action-engine-onboarded-${e}`,"true"),t()},className:"text-12 text-obsidian-400 hover:text-brand-black transition-colors underline",children:"Skip and generate action plan"})})]})}function vt({onGenerate:e,generating:t}){return x.jsxs("div",{className:"flex flex-col items-center justify-center py-20",children:[x.jsx("div",{className:"h-16 w-16 rounded-full flex items-center justify-center mb-5",style:{backgroundColor:"#F2F1ED"},children:x.jsx(le,{className:"h-8 w-8",style:{color:"#AE431E"}})}),x.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"No action items yet"}),x.jsx("p",{className:"text-sm text-gray-500 mb-6 text-center max-w-sm",children:"Generate a personalized GEO action plan based on your brand's performance data and AI visibility metrics."}),x.jsxs("button",{onClick:e,disabled:t,className:"inline-flex items-center gap-2 px-5 py-2.5 text-sm font-medium text-white rounded-lg transition-colors disabled:opacity-50",style:{backgroundColor:"#AE431E"},children:[t?x.jsx(ce,{className:"h-4 w-4 animate-spin"}):x.jsx(le,{className:"h-4 w-4"}),"Generate Action Plan"]})]})}function Nt({onSetUp:e}){return x.jsxs("div",{className:"flex flex-col items-center justify-center py-20",children:[x.jsx("div",{className:"h-16 w-16 rounded-full flex items-center justify-center mb-5 bg-brand-pearl",children:x.jsx(le,{className:"h-8 w-8 text-brand-chile"})}),x.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Set up your account first"}),x.jsx("p",{className:"text-sm text-gray-500 mb-6 text-center max-w-sm",children:"The Action Engine builds your plan from your brand setup and AI-visibility data. Finish setting up your brand and run your first analysis — your plan will appear here automatically."}),x.jsxs("button",{onClick:e,className:"inline-flex items-center gap-2 px-5 py-2.5 text-sm font-medium text-white rounded-lg transition-colors bg-brand-chile hover:bg-brand-chile/90",children:[x.jsx(le,{className:"h-4 w-4"}),"Set up your account"]})]})}function wt({text:e,active:t}){const[s,a]=d.useState(""),n=d.useRef(0);return d.useEffect(()=>{if(!t)return void a(e);a(""),n.current=0;const s=setInterval(()=>{n.current+=1,n.current<=e.length?a(e.slice(0,n.current)):clearInterval(s)},38);return()=>clearInterval(s)},[e,t]),x.jsxs("span",{children:[s,t&&s.length<e.length&&x.jsx("span",{className:"inline-block w-[2px] h-[14px] bg-brand-chile ml-0.5 animate-pulse align-middle"})]})}function kt({steps:e}){var t;const s=e.filter(e=>e.done).length,a=s-1,n=e.length>0?Math.round(s/e.length*100):0,r=a>=0?e[a].text:(null==(t=e[0])?void 0:t.text)||"";return x.jsx("div",{className:"flex items-center justify-center min-h-[420px]",children:x.jsxs("div",{className:"w-full max-w-md rounded-2xl p-8",style:{backgroundColor:"#F2F1ED",border:"1.5px solid #EAC891"},children:[x.jsx("h3",{className:"text-18 font-semibold text-gray-900 mb-3",children:"Building Your Action Plan"}),x.jsxs("div",{className:"flex items-center justify-between mb-2",children:[x.jsx("p",{className:"text-14 text-gray-500 truncate pr-4",children:r}),x.jsxs("span",{className:"text-14 font-medium text-gray-500 flex-shrink-0",children:[n,"%"]})]}),x.jsx("div",{className:"h-[6px] rounded-full overflow-hidden mb-6",style:{backgroundColor:"#E8E7E3"}
1,children:x.jsx("div",{className:"h-full rounded-full transition-all duration-700 ease-out",style:{width:`${n}%`,backgroundColor:"#AE431E"}})}),x.jsx("div",{className:"space-y-4",children:e.map((e,t)=>{const n=t<s-1,r=t===a;return x.jsxs("div",{className:"flex items-center gap-3",children:[n?x.jsx(ae,{className:"h-5 w-5 flex-shrink-0",style:{color:"#8A8635"}}):r?x.jsx(ce,{className:"h-5 w-5 flex-shrink-0 animate-spin",style:{color:"#AE431E"}}):x.jsx(ie,{className:"h-5 w-5 flex-shrink-0 text-gray-300"}),x.jsx("span",{className:"text-14 leading-snug "+(r?"font-medium text-gray-900":n?"text-gray-500":"text-gray-400"),children:r?x.jsx(wt,{text:e.text,active:!0}):e.text})]},t)})})]})})}const Ct={health:!0,owner:!0,target:!0,tickets:!0,progress:!0},St="ae-projects-display-v1";function Et(){try{const e=localStorage.getItem(St);return e?i(i({},Ct),JSON.parse(e)):Ct}catch(e){return Ct}}const At={health:"Health",owner:"Owner",target:"Target",tickets:"Tickets",progress:"Progress"};function It({cols:e,onChange:t}){const s=Object.values(e).some(e=>!e);return x.jsxs(O,{children:[x.jsx(D,{asChild:!0,children:x.jsx("button",{type:"button","aria-label":"Display options",title:"Display options",className:"inline-flex items-center justify-center h-8 w-8 rounded-lg border transition-colors "+(s?"bg-white border-gray-200/60 text-gray-900":"border-transparent text-gray-500 hover:text-gray-700"),children:x.jsx(ue,{className:"h-4 w-4"})})}),x.jsxs($,{align:"end",className:"w-64 p-0",children:[x.jsxs("div",{className:"px-3 py-2.5",children:[x.jsx("p",{className:"text-12 font-semibold text-gray-700 mb-2",children:"Display properties"}),x.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(At).map(s=>x.jsx("button",{onClick:()=>t(o(i({},e),{[s]:!e[s]})),className:"px-2 py-1 text-12 font-medium rounded-md border transition-colors "+(e[s]?"bg-brand-pearl border-gray-300 text-brand-black":"bg-white border-gray-200 text-gray-400 hover:text-gray-600"),children:At[s]},s))})]}),x.jsx("div",{className:"px-3 py-2 border-t border-gray-100 text-right",children:x.jsx("button",{onClick:()=>t(Ct),className:"text-12 font-medium text-gray-500 hover:text-gray-700",children:"Reset"})})]})]})}const Ot="ae-project-views-v1";function Dt(){try{const e=localStorage.getItem(Ot),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>e&&"string"==typeof e.name&&Array.isArray(e.statuses)):[]}catch(e){return[]}}const $t=["proposed","approved","launched","measuring","done","archived"];function Pt({selected:e,counts:t,onChange:s,onSaveView:a}){const n=e.size;return x.jsxs(O,{children:[x.jsx(D,{asChild:!0,children:x.jsxs("button",{type:"button","aria-label":"Filter projects",title:"Filter",className:"inline-flex items-center gap-1 h-8 px-2 rounded-lg border transition-colors "+(n>0?"bg-white border-gray-200/60 text-gray-900":"border-transparent text-gray-500 hover:text-gray-700"),children:[x.jsx(me,{className:"h-4 w-4"}),n>0&&x.jsx("span",{className:"text-12",children:n})]})}),x.jsxs($,{align:"end",className:"w-56 p-0",children:[x.jsxs("div",{className:"px-3 py-2.5",children:[x.jsx("p",{className:"text-12 font-semibold text-gray-700 mb-2",children:"Status"}),$t.map(a=>{var n;return x.jsxs("label",{className:"flex items-center gap-2 py-1 text-14 text-gray-700 cursor-pointer",children:[x.jsx("input",{type:"checkbox",checked:e.has(a),onChange:()=>{const t=new Set(e);t.has(a)?t.delete(a):t.add(a),s(t)},className:"h-3.5 w-3.5 accent-[#AE431E]"}),x.jsx("span",{className:"capitalize",children:a}),x.jsx("span",{className:"ml-auto text-12 text-gray-400",children:null!=(n=t[a])?n:0})]},a)})]}),x.jsxs("div",{className:"px-3 py-2 border-t border-gray-100 flex items-center justify-between gap-2",children:[n>0&&a?x.jsx(Ft,{onSave:a}):x.jsx("span",{}),x.jsx("button",{onClick:()=>s(new Set),className:"text-12 font-medium text-gray-500 hover:text-gray-700",children:"Clear"})]})]})]})}function Ft({onSave:e}){const[t,s]=d.useState("");return x.jsxs("span",{className:"flex items-center gap-1",children:[x.jsx("input",{value:t,onChange:e=>s(e.target.value),onKeyDown:a=>{"Enter"===a.key&&t.trim()&&(e(t.trim()),s(""))},placeholder:"View name…",className:"h-6 w-24 rounded border border-gray-200 px-1.5 text-12 focus:outline-none focus:border-gray-400"}),x.jsx("button",{onClick:()=>{t.trim()&&(e(t.trim()),s(""))},disabled:!t.trim(),className:"text-12 font-medium text-brand-chile disabled:text-gray-300",children:"Save view"})]})}function Tt({project:e,visibleStatuses:t,cols:s=Ct,onClick:a}){var n;const r=null!=(n=e.ticket_rollup)?n:{total:0,done:0,humanOpen:0},l=t.includes(e.status),i=l&&r.total>0,o=i?Math.round(r.done/r.total*100):0,c=l&&!("done"===(d=e.status)||"archived"===d)&&r.humanOpen>0;var d;const m="done"===e.status?{label:"Done",cls:"text-gray-500"}:"archived"===e.status?{label:"Archived",cls:"text-gray-400"}:"at_risk"===e.health?{label:"At risk",cls:"text-amber-700"}:"off_track"===e.health?{label:"Off track",cls:"text-red-700"}:"on_track"===e.health?{label:"On track",cls:"text-emerald-700"}:{label:"—",cls:"text-gray-400"};return x.jsx("div",{className:"group flex items-center h-11 border-b border-gray-100 last:border-b-0 cursor-pointer",onClick:a,children:x.jsxs("div",{className:"flex items-center w-full h-9 mx-1 px-3 rounded-md border border-transparent overflow-hidden transition-colors group-hover:border-gray-200/60 group-hover:bg-white",children:[x.jsxs("div",{className:"flex items-center gap-2.5 flex-1 min-w-0",children:[x.jsx("span",{className:"text-14 text-brand-black truncate",children:e.name}),c&&x.jsxs("span",{className:"flex-shrink-0 text-12 font-medium rounded-full px-1.5 py-0.5 bg-amber-50 text-amber-700 whitespace-nowrap",children:[r.humanOpen," for you"]}),"approved"===e.status&&x.jsx("span",{className:"flex-shrink-0 text-12 font-medium rounded-full px-1.5 py-0.5 bg-emerald-50 text-emerald-700 whitespace-nowrap",children:"Ready to launch"})]}),x.jsxs("div",{className:"flex items-center flex-shrink-0 ml-3",children:[x.jsx("span",{className:"w-24 flex items-center",children:x.jsx(Ne,{status:e.status,variant:"row"})}),s.health&&x.jsx("span",{className:`hidden @md:block w-20 text-14 whitespace-nowrap ${m.cls}`,children:m.label}),s.owner&&x.jsx("span",{className:"hidden @sm:flex w-16 items-center gap-1 text-14 text-obsidian-400 whitespace-nowrap",children:"agent"===e.proposed_by?x.jsx("img",{src:"/logo-black.svg",alt:"Citable",className:"h-3.5 w-3.5 object-contain",title:"Proposed by Citable"}):x.jsx(je,{className:"h-3.5 w-3.5","aria-label":"You"})}),s.target&&x.jsx("span",{className:"w-14 text-14 text-obsidian-400 text-right whitespace-nowrap",children:e.target_date?we(e.target_date):"—"}),s.tickets&&x.jsx("span",{className:"hidden @sm:block w-14 text-14 text-obsidian-400 text-right whitespace-nowrap",children:l&&r.total>0?`${r.done}/${r.total}`:"—"}),s.progress&&x.jsx("span",{className:"hidden @sm:flex w-24 items-center justify-end gap-1.5",children:i?x.jsxs(x.Fragment,{children:[x.jsx("span",{className:"w-14 h-1 rounded bg-gray-200 overflow-hidden",children:x.jsx("span",{className:"block h-1 rounded bg-brand-olive",style:{width:`${o}%`}})}),x.jsxs("span",{className:"text-12 text-obsidian-400 w-7 text-right",children:[o,"%"]})]}):x.jsx("span",{className:"text-12 text-gray-400",children:"—"})}),x.jsx("span",{className:"w-8"})]})]})})}function Ut({open:e,onOpenChange:t,defaultInitiative:s,initiativeDefs:a,onSubmit:n,submitting:r}
1){const[l,i]=d.useState(""),[o,c]=d.useState(s),[m,u]=d.useState(""),[p,h]=d.useState("");d.useEffect(()=>{e&&c(s)},[e,s]);return x.jsx(N,{open:e,onOpenChange:t,children:x.jsxs(w,{className:"sm:max-w-xl",children:[x.jsxs(k,{children:[x.jsx(C,{children:"New project"}),x.jsx(S,{children:"A project is a business goal with a metric that can prove it moved."})]}),x.jsxs("div",{className:"space-y-4 py-2",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Name"}),x.jsx(E,{value:l,onChange:e=>i(e.target.value),placeholder:"e.g. Own the “best CRM for agencies” question cluster",autoFocus:!0})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Initiative"}),x.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-3 gap-2",children:ke.map(e=>{var t;const s=null!=(t=a[e])?t:Ce[e],n=o===e;return x.jsxs("button",{type:"button",onClick:()=>c(e),className:"text-left rounded-lg border p-2.5 transition-colors "+(n?"border-brand-chile bg-brand-pearl":"border-gray-200 bg-white hover:bg-brand-pearl"),children:[x.jsx("span",{className:"block text-14 font-medium text-brand-black",children:s.name}),x.jsx("span",{className:"block text-12 text-gray-500",children:s.tagline}),x.jsx("span",{className:"block text-12 text-obsidian-400 mt-1",children:s.why})]},e)})})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Goal"}),x.jsx("textarea",{value:m,onChange:e=>u(e.target.value),placeholder:"What business outcome does this project buy, in one sentence?",rows:3,className:"flex w-full rounded-lg border border-input bg-background px-3 py-2 text-sm r
1ing-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Target date"}),x.jsx(E,{type:"date",value:p,onChange:e=>h(e.target.value)})]})]}),x.jsxs(A,{children:[x.jsx("button",{onClick:()=>t(!1),className:"px-4 py-2 text-sm text-gray-500 hover:text-gray-700 transition-colors",children:"Cancel"}),x.jsxs("button",{onClick:()=>{l.trim()&&m.trim()&&(n({name:l.trim(),initiativeKey:o,goalStatement:m.trim(),targetDate:p||void 0}),i(""),u(""),h(""))},disabled:!l.trim()||!m.trim()||r,className:"inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-brand-chile rounded-lg transition-opacity hover:opacity-90 disabled:opacity-50",children:[r&&x.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),"Create project"]})]})]})})}function _t({brandId:e}){var t;const{initiatives:s,initiativeDefs:a,ticketsVisibleStatuses:n,loading:r,mutating:l,error:i,createProject:o}=ve(e),[,u]=m(),[p,h]=d.useState(!1),[b,g]=d.useState("foundation"),[f,j]=d.useState(new Set),[y,v]=d.useState(Dt),[N,w]=d.useState(null),k=e=>{v(e);try{localStorage.setItem(Ot,JSON.stringify(e))}catch(t){}},C=e=>{var t;if(w(e),null===e)return void j(new Set);const s=y.find(t=>t.name===e);j(new Set(null!=(t=null==s?void 0:s.statuses)?t:[]))},[S,E]=d.useState(Et);d.useEffect(()=>{try{localStorage.setItem(St,JSON.stringify(S))}catch(e){}},[S]);const A=s.flatMap(e=>e.projects),I={};for(const c of A)I[c.status]=(null!=(t=I[c.status])?t:0)+1;const O=e=>0===f.size||f.has(e.status);return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap py-2 mb-1",children:[x.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[x.jsx("button",{onClick:()=>C(null),className:"inline-flex h-8 items-center px-3 rounded-lg border text-14 transition-colors "+(null===N?"bg-white border-gray-200/60 font-medium text-gray-900":"border-transparent text-gray-500 hover:text-gray-700"),children:"All projects"}),y.map(e=>x.jsxs("span",{className:"group relative inline-flex",children:[x.jsx("button",{onClick:()=>C(e.name),className:"inline-flex h-8 items-center pl-3 pr-6 rounded-lg border text-14 transition-colors "+(N===e.name?"bg-white border-gray-200/60 font-medium text-gray-900":"border-transparent text-gray-500 hover:text-gray-700"),children:e.name}),x.jsx("button",{onClick:()=>{k(y.filter(t=>t.name!==e.name)),N===e.name&&C(null)},"aria-label":`Delete view ${e.name}`,className:"absolute right-1.5 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 text-gray-400 hover:text-gray-600 transition-opacity",children:x.jsx(H,{className:"h-3 w-3"})})]},e.name))]}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(Pt,{selected:f,counts:I,onChange:e=>{j(e),w(null)},onSaveView:e=>{const t=[...y.filter(t=>t.name!==e),{name:e,statuses:[...f]}];k(t),w(e)}}),x.jsx(It,{cols:S,onChange:E})]})]}),x.jsxs("div",{className:"max-w-full",children:[i&&x.jsx("p",{className:"mb-3 text-12 text-brand-chile",children:i}),r&&0===s.length?x.jsx("div",{className:"flex items-center justify-center py-24",children:x.jsxs("div",{className:"text-center",children:[x.jsx(ce,{className:"h-8 w-8 animate-spin text-brand-chile mx-auto mb-3"}),x.jsx("p",{className:"text-14 text-gray-500",children:"Loading your projects…"})]})}):x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center min-h-9 py-2 px-4 border-b border-gray-200/70 text-14 text-gray-500",children:[x.jsx("span",{className:"flex-1",children:"Name"}),x.jsx("span",{className:"w-24",children:"Status"}),S.health&&x.jsx("span",{className:"hidden @md:block w-20",children:"Health"}),S.owner&&x.jsx("span",{className:"hidden @sm:block w-16",children:"Owner"}),S.target&&x.jsx("span",{className:"w-14 text-right",children:"Target"}),S.tickets&&x.jsx("span",{className:"hidden @sm:block w-14 text-right",children:"Tickets"}),S.progress&&x.jsx("span",{className:"hidden @sm:block w-24 text-right",children:"Progress"}),x.jsx("span",{className:"w-8"})]}),ke.map(e=>{var t,r,l;const i=null!=(t=a[e])?t:Ce[e],o=(null!=(l=null==(r=s.find(t=>t.key===e))?void 0:r.projects)?l:[]).filter(O);return x.jsxs("section",{children:[x.jsxs("div",{className:"flex items-center h-9 px-4 bg-gray-100/60 border-b border-gray-200/60",title:`${i.why} ${i.scope}`,children:[x.jsx("span",{className:"text-14 text-gray-900",children:i.name}),x.jsx("span",{className:"ml-2 text-14 text-gray-500 truncate hidden @sm:block",children:i.tagline}),x.jsx("span",{className:"ml-2 text-14 text-gray-400",children:o.length}),x.jsx("span",{className:"ml-auto flex items-center justify-end w-8",children:x.jsx("button",{onClick:()=>(e=>{g(e),h(!0)})(e),"aria-label":`New ${i.name} project`,title:`New ${i.name} project`,className:"inline-flex items-center justify-center h-6 w-6 rounded text-gray-400 hover:text-brand-black hover:bg-gray-200 transition-colors",children:x.jsx(de,{className:"h-3.5 w-3.5"})})})]}),0===o.length?x.jsx("p",{className:"px-4 py-2.5 text-12 text-gray-400 border-b border-gray-100",children:"No projects yet — the agent proposes here as it learns your brand."}):o.map(e=>x.jsx(Tt,{project:e,visibleStatuses:n,cols:S,onClick:()=>u(`/action-engine/projects/${e.id}`)},String(e.id)))]},e)})]})]}),x.jsx(Ut,{open:p,onOpenChange:h,defaultInitiative:b,initiativeDefs:a,submitting:l,onSubmit:e=>c(this,null,function*(){(yield o(e)).ok&&h(!1)})})]})}function Lt(){const{data:e,loading:t,generating:s,generationSteps:a,members:n,filters:r,setFilters:l,handleGenerate:i,handleToggleStatus:o,handleCancelTask:c,handleCreateTask:p,handleAssignTask:h,fetchActions:g}=u(),{currentBrand:N}=f(),[,w]=m(),k=j(),C="tickets"===new URLSearchParams(k).get("view"),[S,E]=d.use
1State(!1),[A,I]=d.useState(!1),[O,D]=d.useState("all"),[$,P]=d.useState(ct);d.useEffect(()=>{try{localStorage.setItem(ot,JSON.stringify($))}catch(e){}},[$]);const F=null==e?void 0:e.ready,[T,U]=y("/:brandSlug/actions/:ticketCode/:titleSlug?"),_=d.useCallback(()=>{w("/action-engine")},[w]);d.useEffect(()=>{if(!(null==N?void 0:N.id)||t)return;const s=localStorage.getItem(`action-engine-onboarded-${N.id}`),a=e&&0===e.stats.total&&!e.stats.lastGeneratedAt;I(!(s||!a))},[null==N?void 0:N.id,t,e]);d.useEffect(()=>{(null==N?void 0:N.id)&&b("/api/action-engine/sync",{method:"POST",body:JSON.stringify({brandId:N.id})}).then(e=>e.json().catch(()=>null)).then(e=>{(function(e){if(!e||"object"!=typeof e)return!0;const t=e.synced;return"number"!=typeof t||!Number.isFinite(t)||0!==t})(e)&&g()}).catch(()=>{})},[null==N?void 0:N.id]);const L=d.useRef(!1);d.useEffect(()=>{if(L.current)return;L.current=!0;const e=new URLSearchParams(window.location.search);let t=(e.get("status")||"").split(",").map(e=>e.trim()).filter(Boolean);0===t.length&&"1"===e.get("completed")&&(t=["todo","in_progress","in_review","backlog","done","canceled"]);const s=(e.get("cat")||"").split(",").map(e=>e.trim()).filter(Boolean),a="1"===e.get("archived");(t.length>0||s.length>0||a)&&l({statuses:t,categories:s,showArchived:a})},[l]),d.useEffect(()=>{if(!L.current)return;const e=new URLSearchParams(window.location.search);e.delete("completed"),r.statuses.length>0?e.set("status",r.statuses.join(",")):e.delete("status"),r.categories.length>0?e.set("cat",r.categories.join(",")):e.delete("cat"),r.showArchived?e.set("archived","1"):e.delete("archived");const t=e.toString(),s=`${window.location.pathname}${t?`?${t}`:""}${window.location.hash}`;s!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(null,"",s)},[r.statuses,r.categories,r.showArchived]);const R=s&&a.length>0,M=T&&(null==U?void 0:U.brandSlug)&&(null==U?void 0:U.ticketCode)?x.jsx(_e,{brandSlug:U.brandSlug,ticketCode:U.ticketCode,onClose:_}):null;if(!C)return x.jsxs(x.Fragment,{children:[x.jsx(v,{title:"AI Action Engine",subtitle:"Your initiatives, and the projects moving them",flush:!0}),x.jsx(_t,{brandId:null==N?void 0:N.id}),M]});if(t&&!e)return x.jsxs(x.Fragment,{children:[x.jsxs(x.Fragment,{children:[x.jsx(v,{title:"AI Action Engine",subtitle:"Your next moves to increase AI visibility"}),x.jsx("div",{className:"max-w-6xl",children:x.jsx("div",{className:"flex items-center justify-center min-h-[350px]",children:x.jsxs("div",{className:"text-center",children:[x.jsx(ce,{className:"h-8 w-8 animate-spin text-brand-chile mx-auto mb-3"}),x.jsx("p",{className:"text-sm text-gray-500",children:"Loading your action plan..."})]})})})]}),M]});if(R)return x.jsxs(x.Fragment,{children:[x.jsxs(x.Fragment,{children:[x.jsx(v,{title:"AI Action Engine",subtitle:"Your next moves to increase AI visibility"}),x.jsx("div",{className:"max-w-6xl",children:x.jsx(kt,{steps:a})})]}),M]});const B=e&&(e.tasks.today.length>0||e.tasks["this-week"].length>0||e.tasks["next-week"].length>0||e.tasks.backlog.length>0),z=function(e,t){if("timeGroup"===t)return e;const s=[...e];return"priority"===t?s.sort((e,t)=>{var s,a;return(null!=(s=dt[e.priority])?s:9)-(null!=(a=dt[t.priority])?a:9)}):"dueDate"===t?s.sort((e,t)=>e.dueDate||t.dueDate?e.dueDate?t.dueDate?e.dueDate.localeCompare(t.dueDate):-1:1:0):"newest"===t?s.sort((e,t)=>{var s,a;return(null!=(s=t.createdAt)?s:"").localeCompare(null!=(a=e.createdAt)?a:"")}):"effort"===t&&s.sort((e,t)=>{var s,a;return(null!=(s=e.effortMinutes)?s:0)-(null!=(a=t.effortMinutes)?a:0)}),s}(e?"today"===O?e.tasks.today:"week"===O?[...e.tasks.today,...e.tasks["this-week"]]:[...e.tasks.today,...e.tasks["this-week"],...e.tasks["next-week"],...e.tasks.backlog]:[],$.sort);return x.jsxs(x.Fragment,{children:[x.jsxs(x.Fragment,{children:[x.jsx(v,{title:"AI Action Engine",subtitle:x.jsxs(x.Fragment,{children:[x.jsx("span",{children:"Your next moves to increase AI visibility, last updated at "}),(null==e?void 0:e.stats.lastGeneratedAt)&&x.jsx("span",{className:"font-bold",children:tt(e.stats.lastGeneratedAt)}),!(null==e?void 0:e.stats.lastGeneratedAt)&&x.jsx("span",{className:"font-bold",children:"Not yet generated"})]})}),x.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap mb-4",children:[x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx("a",{href:"/action-engine",className:"text-12 text-gray-500 hover:text-gray-700 underline-offset-2 hover:underline whitespace-nowrap",children:"← Projects"}),B&&e&&x.jsx("div",{className:"inline-flex items-center border border-gray-200 rounded-lg overflow-hidden bg-white",children:[["today","Today",e.tasks.today.length],["week","This week",e.tasks.today.length+e.tasks["this-week"].length],["all","All",e.tasks.today.length+e.tasks["this-week"].length+e.tasks["next-week"].length+e.tasks.backlog.length]].map(([e,t,s])=>x.jsxs("button",{onClick:()=>D(e),className:"px-2.5 py-1.5 text-14 transition-colors "+(O===e?"bg-brand-pearl font-medium text-brand-black":"bg-white text-gray-500 hover:text-gray-700"),children:[t," · ",s]},e))})]}),x.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:B&&x.jsxs(x.Fragment,{children:[x.jsx(ht,{filters:r,counts:null==e?void 0:e.counts,onChange:l}),x.jsx(ut,{prefs:$,onChange:P}),x.jsxs("button",{onClick:()=>E(!0),className:"inline-flex items-center gap-1.5 h-8 px-2.5 text-14 font-medium text-gray-700 bg-white border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors",children:[x.jsx(de,{className:"h-3.5 w-3.5"}),"Add Task"]}),x.jsx("button",{onClick:()=>i(),disabled:s,className:"inline-flex items-center justify-center h-8 w-8 text-gray-500 bg-white border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors disabled:opacity-50","aria-label":"Refresh AI plan",title:"Refresh AI plan (rate-limited to 1/hr)",children:s?x.jsx(ce,{className:"h-4 w-4 animate-spin"}):x.jsx(xe,{className:"h-4 w-4"})})]})})]}),x.jsxs("div",{className:"max-w-full",children:[!B&&!s&&!1===F&&x.jsx(Nt,{onSetUp:()=>w("/brand-settings")}),!B&&!s&&A&&(null==N?void 0:N.id)&&!1!==F&&x.jsx(yt,{brandId:N.id,onComplete:()=>{I(!1),i()}}),!B&&!s&&!A&&!1!==F&&x.jsx(vt,{onGenerate:()=>i(),generating:s}),!B&&s&&x.jsx("div",{className:"flex items-center justify-center min-h-[350px]",children:x.jsxs("div",{className:"text-center",children:[x.jsx(ce,{className:"h-8 w-8 animate-spin text-brand-chile mx-auto mb-3"}),x.jsx("p",{className:"text-sm text-gray-500",children:"Building your action plan…"})]})}),B&&e&&x.jsx("div",{className:"mb-1",children:0===z.length?x.jsx("p",{className:"px-4 py-8 text-14 text-obsidian-400 text-center",children:"Nothing in this scope — switch to All to see every open action."}):z.map((e,t)=>x.jsx(ft,{task:e,guideId:0===t?"top-action-card":void 0,show:$.show,onToggle:()=>
1o(e),onCancel:()=>c(e.id),members:n,onAssign:h,onClick:()=>(e=>{var t,s,a;const n=null!=(t=e.brandSlug)?t:(null==N?void 0:N.id)?`brand-${N.id}`:"",r=null!=(s=e.ticketCode)?s:`GEO-${String(e.displaySeq).padStart(3,"0")}`,l=null!=(a=e.titleSlug)?a:"";if(!n)return void w(`/actions/${e.id}`);w(l?`/${n}/actions/${r}/${l}`:`/${n}/actions/${r}`)})(e)},e.id))}),x.jsx(jt,{open:S,onOpenChange:E,onSubmit:p})]})]}),M]})}export{Lt as 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.