decocms
Version:
Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools
7 lines (5 loc) • 33.7 kB
JavaScript
import{c as T,b as L,j as n,n as Q,m as V,r as G,B as F,aJ as te,aK as X,bn as Se,ct as _e,bF as ke,an as Pe,a6 as Ce,E as Y,ex as pe,a as Ie,av as Ae,t as $e}from"./index-ztdGKvBm.js";import{o as De,bp as Ee,a as qe,aq as Te}from"./agent-icon-BYWtutu9.js";import{i as ie,s as Me}from"./UserSquare-CafFh5_d.js";import{B as xe}from"./badge-DcUertOZ.js";import{i as Re}from"./ArrowLeft-B0PZnf1E.js";import{i as le}from"./ArrowRight-mzMrxxYI.js";import{a7 as Oe,a8 as q,a9 as ze,c as ge,aa as Be,ab as Fe,ac as Ge,ad as Le,ae as Ke}from"./chat-context-DFEln8mI.js";import{T as ae}from"./textarea-viSdm6BE.js";import{a as Ue}from"./shell-layout-UF80oiAz.js";import"./index-5erPNBmj.js";import{g as he,h as Xe,i as He}from"./use-organization-settings-C2vcrj4S.js";import{d as oe}from"./delay-CnY5UFtP.js";import{u as Je,f as We}from"./use-date-fns-locale-CloMwBOl.js";import{u as Qe}from"./use-org-fs-D9dHgOYs.js";import{P as Ye}from"./schema-Bb-DbvPZ.js";const Ve={plan:{heading:"home.comingSoon.planHeading",description:"home.comingSoon.planDescription",points:[{Icon:ie,labelKey:"home.comingSoon.planGoals",tone:"bg-chart-2/15 text-chart-2"},{Icon:De,labelKey:"home.comingSoon.planTasks",tone:"bg-chart-1/15 text-chart-1"},{Icon:Ee,labelKey:"home.comingSoon.planProgress",tone:"bg-chart-4/15 text-chart-4"}]}};function Ze(t){const e=T.c(4),{className:l}=t;let a;e[0]!==l?(a=V("block h-2 rounded-full bg-muted",l),e[0]=l,e[1]=a):a=e[1];let s;return e[2]!==a?(s=n.jsx("span",{className:a}),e[2]=a,e[3]=s):s=e[3],s}const et=[{title:"w-32",fill:"w-[72%]",tone:"bg-chart-2",value:"72%"},{title:"w-24",fill:"w-[45%]",tone:"bg-chart-1",value:"45%"},{title:"w-28",fill:"w-[88%]",tone:"bg-chart-4",value:"88%"}];function tt(){const t=T.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex flex-col gap-5",children:et.map(st)}),t[0]=e):e=t[0],e}function st(t){return n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center gap-2.5",children:[n.jsx("span",{className:"flex size-6 items-center justify-center rounded-md bg-muted text-muted-foreground",children:n.jsx(ie,{size:14})}),n.jsx(Ze,{className:t.title}),n.jsx("span",{className:"ml-auto text-xs font-medium tabular-nums text-muted-foreground",children:t.value})]}),n.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted",children:n.jsx("div",{className:V("h-full rounded-full",t.fill,t.tone)})})]},t.value)}function ts(t){const e=T.c(30),{kind:l}=t,a=L(),s=Ve[l];let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"absolute inset-x-10 -top-4 h-40 rounded-full bg-chart-2/20 blur-3xl"}),e[0]=i):i=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsxs("div",{"aria-hidden":!0,className:"relative w-full max-w-md",children:[i,n.jsx("div",{className:"relative surface p-6 [mask-image:linear-gradient(to_bottom,black_65%,transparent)]",children:n.jsx(tt,{})})]}),e[1]=r):r=e[1];let d;e[2]!==a?(d=a("home.comingSoon.badge"),e[2]=a,e[3]=d):d=e[3];let o;e[4]!==d?(o=n.jsx(xe,{variant:"muted",children:d}),e[4]=d,e[5]=o):o=e[5];let u;e[6]!==s.heading||e[7]!==a?(u=a(s.heading),e[6]=s.heading,e[7]=a,e[8]=u):u=e[8];let c;e[9]!==u?(c=n.jsx("h1",{className:"text-2xl font-medium text-balance text-foreground",children:u}),e[9]=u,e[10]=c):c=e[10];let m;e[11]!==s.description||e[12]!==a?(m=a(s.description),e[11]=s.description,e[12]=a,e[13]=m):m=e[13];let p;e[14]!==m?(p=n.jsx("p",{className:"max-w-md text-sm text-pretty text-muted-foreground",children:m}),e[14]=m,e[15]=p):p=e[15];let f;e[16]!==o||e[17]!==c||e[18]!==p?(f=n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[o,c,p]}),e[16]=o,e[17]=c,e[18]=p,e[19]=f):f=e[19];let x;if(e[20]!==s.points||e[21]!==a){let b;e[23]!==a?(b=j=>{const{Icon:w,labelKey:y,tone:E}=j;return n.jsxs("li",{className:"flex items-center gap-3 surface p-4 sm:flex-col sm:items-start",children:[n.jsx("span",{className:V("flex size-9 shrink-0 items-center justify-center rounded-lg",E),children:n.jsx(w,{size:18})}),n.jsx("span",{className:"text-sm text-foreground",children:a(y)})]},y)},e[23]=a,e[24]=b):b=e[24],x=s.points.map(b),e[20]=s.points,e[21]=a,e[22]=x}else x=e[22];let g;e[25]!==x?(g=n.jsx("ul",{className:"grid w-full gap-3 sm:grid-cols-3",children:x}),e[25]=x,e[26]=g):g=e[26];let h;return e[27]!==g||e[28]!==f?(h=n.jsx(Q,{children:n.jsx(Q.Content,{children:n.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col items-center gap-10 px-4 pt-12 pb-16 md:pt-20",children:[r,f,g]})})}),e[27]=g,e[28]=f,e[29]=h):h=e[29],h}const nt=["plan.guide.thinking1","plan.guide.thinking2","plan.guide.thinking3","plan.guide.thinking4","plan.guide.thinking5","plan.guide.thinking6","plan.guide.thinking7","plan.guide.thinking8"],it=["plan.guide.building1","plan.guide.building2","plan.guide.building3","plan.guide.building4","plan.guide.building5","plan.guide.building6","plan.guide.building7","plan.guide.building8","plan.guide.building17","plan.guide.building9","plan.guide.building10","plan.guide.building11","plan.guide.building12","plan.guide.building13","plan.guide.building14","plan.guide.building15","plan.guide.building16"],ne=7e3,lt=5e3,ce=Oe.length;function de(t){const e=T.c(19),{phrases:l,offset:a,building:s,filled:i}=t,r=s===void 0?!1:s,d=L(),o=Ue(ne),u=l[(Math.floor(o/ne)+a)%l.length];let c;e[0]!==r||e[1]!==i?(c=r?n.jsx("div",{className:"plan-guide-tiles","aria-hidden":"true",children:Array.from({length:ce},(b,j)=>n.jsx("span",{"data-tile":i===void 0?void 0:j<i?"filled":"waiting",style:{animationDelay:`${j*90}ms`}},j))}):n.jsxs("div",{className:"plan-guide-dots","aria-hidden":"true",children:[n.jsx("span",{}),n.jsx("span",{}),n.jsx("span",{})]}),e[0]=r,e[1]=i,e[2]=c):c=e[2];let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m={animationDelay:`${ne-lt}ms`},e[3]=m):m=e[3];let p;e[4]!==u||e[5]!==d?(p=d(u),e[4]=u,e[5]=d,e[6]=p):p=e[6];let f;e[7]!==p?(f=n.jsx("span",{className:"plan-guide-shimmer",style:m,children:p}),e[7]=p,e[8]=f):f=e[8];let x;e[9]!==u||e[10]!==f?(x=n.jsx("p",{className:"plan-guide-reveal text-base",children:f},u),e[9]=u,e[10]=f,e[11]=x):x=e[11];let g;e[12]!==i||e[13]!==d?(g=i!==void 0&&i>0&&n.jsx("p",{className:"text-xs text-muted-foreground",children:d("plan.case.buildingProgress",{filled:i,total:ce})}),e[12]=i,e[13]=d,e[14]=g):g=e[14];let h;return e[15]!==c||e[16]!==x||e[17]!==g?(h=n.jsxs("div",{role:"status","aria-live":"polite",className:"flex flex-col items-center gap-5 animate-in fade-in-0 duration-300 motion-reduce:animate-none",children:[c,x,g]}),e[15]=c,e[16]=x,e[17]=g,e[18]=h):h=e[18],h}function at({text:t,delay:e}){return t.split(/\s+/).map((l,a)=>n.jsxs(G.Fragment,{children:[n.jsx("span",{className:"plan-guide-reveal inline-block",style:{animationDelay:`${e+a*be}ms`},children:l})," "]},a))}const be=45,rt=350;function ot(t){const e=T.c(7),{done:l,current:a,total:s}=t,r=Math.max(s===void 0?0:s,l+(a?1:0));if(r===0)return null;let d;if(e[0]!==r||e[1]!==a||e[2]!==l){let o;e[4]!==a||e[5]!==l?(o=(u,c)=>n.jsx("span",{className:V("h-1.5 rounded-full transition-all duration-500 animate-in zoom-in-0 fade-in-0 motion-reduce:animate-none",a&&c===l?"w-5 bg-foreground":c<l?"w-1.5 bg-muted-foreground/40":"w-1.5 bg-muted-foreground/15")},c),e[4]=a,e[5]=l,e[6]=o):o=e[6],d=n.jsx("div",{className:"ml-auto flex items-center gap-1.5","aria-hidden":"true",children:Array.from({length:r},o)}),e[0]=r,e[1]=a,e[2]=l,e[3]=d}else d=e[3];return d}function ct(t){const e=T.c(72),{view:l,onAnswer:a,skipLabel:s}=t,i=L(),[r,d]=G.useState(""),[o,u]=G.useState(null);let c;e[0]!==r?(c=r.trim(),e[0]=r,e[1]=c):c=e[1];const m=c.length>0,p=l.reaction?rt:0;let f;if(e[2]!==l.question.text){let P;e[4]===Symbol.for("react.memo_cache_sentinel")?(P=/\s+/,e[4]=P):P=e[4],f=l.question.text.split(P),e[2]=l.question.text,e[3]=f}else f=e[3];const x=p+f.length*be+150,g=x+l.question.options.length*70+100;let h;e[5]!==o||e[6]!==a?(h=P=>{if(o===null){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){a(P);return}u(P)}},e[5]=o,e[6]=a,e[7]=h):h=e[7];const b=h;let j;e[8]!==r||e[9]!==b||e[10]!==m?(j=P=>{P.preventDefault(),m&&b(r)},e[8]=r,e[9]=b,e[10]=m,e[11]=j):j=e[11];const w=j;let y;e[12]!==o||e[13]!==a?(y=P=>{P.target===P.currentTarget&&o!==null&&a(o)},e[12]=o,e[13]=a,e[14]=y):y=e[14];const E=o!==null&&"animate-out fade-out-0 slide-out-to-top-4 fill-mode-forwards duration-300 delay-150";let C;e[15]!==E?(C=V("flex w-full flex-col gap-6",E),e[15]=E,e[16]=C):C=e[16];let D;e[17]!==l.reaction?(D=l.reaction&&n.jsx("p",{className:"plan-guide-reveal text-base text-muted-foreground",children:l.reaction}),e[17]=l.reaction,e[18]=D):D=e[18];let _;e[19]!==p||e[20]!==l.question.text?(_=n.jsx("h2",{className:"text-2xl font-medium text-balance text-foreground md:text-3xl",children:n.jsx(at,{text:l.question.text,delay:p})}),e[19]=p,e[20]=l.question.text,e[21]=_):_=e[21];let I;e[22]!==D||e[23]!==_?(I=n.jsxs("div",{className:"flex flex-col gap-3",children:[D,_]}),e[22]=D,e[23]=_,e[24]=I):I=e[24];let v;e[25]!==b||e[26]!==o||e[27]!==x||e[28]!==l.question.options?(v=l.question.options.length>0&&n.jsx("div",{className:"flex flex-wrap gap-2",children:l.question.options.map((P,ye)=>n.jsx(F,{type:"button",variant:"outline","aria-pressed":o===P,className:V("h-auto rounded-full px-4 py-2 text-left whitespace-normal transition-[background-color,color,opacity,transform] duration-200 hover:-translate-y-0.5 animate-in fade-in-0 slide-in-from-bottom-2 fill-mode-both duration-500 motion-reduce:animate-none motion-reduce:hover:translate-y-0",o===P&&"border-foreground bg-foreground text-background hover:bg-foreground hover:text-background",o!==null&&o!==P&&"opacity-30"),style:{animationDelay:`${x+ye*70}ms`},onClick:()=>b(P),children:P},P))}),e[25]=b,e[26]=o,e[27]=x,e[28]=l.question.options,e[29]=v):v=e[29];const N=`${g}ms`;let k;e[30]!==N?(k={animationDelay:N},e[30]=N,e[31]=k):k=e[31];let S;e[32]!==i?(S=i("plan.guide.answerLabel"),e[32]=i,e[33]=S):S=e[33];let A;e[34]!==i?(A=i("plan.guide.answerPlaceholder"),e[34]=i,e[35]=A):A=e[35];let $;e[36]===Symbol.for("react.memo_cache_sentinel")?($=P=>d(P.target.value),e[36]=$):$=e[36];let M;e[37]!==w?(M=P=>{P.key==="Enter"&&(P.metaKey||P.ctrlKey)&&w(P)},e[37]=w,e[38]=M):M=e[38];let R;e[39]!==r||e[40]!==S||e[41]!==A||e[42]!==M?(R=n.jsx(ae,{autoFocus:!0,"aria-label":S,placeholder:A,value:r,onChange:$,onKeyDown:M,className:"min-h-24 text-[15px] transition-shadow"}),e[39]=r,e[40]=S,e[41]=A,e[42]=M,e[43]=R):R=e[43];let O;e[44]!==b?(O=()=>b(""),e[44]=b,e[45]=O):O=e[45];let z;e[46]!==s||e[47]!==i?(z=s??i("plan.guide.skip"),e[46]=s,e[47]=i,e[48]=z):z=e[48];let K;e[49]!==O||e[50]!==z?(K=n.jsx(F,{type:"button",variant:"ghost",onClick:O,children:z}),e[49]=O,e[50]=z,e[51]=K):K=e[51];const B=!m;let U;e[52]!==i?(U=i("plan.guide.continue"),e[52]=i,e[53]=U):U=e[53];let Z;e[54]===Symbol.for("react.memo_cache_sentinel")?(Z=n.jsx(le,{className:"transition-transform duration-200 group-hover:translate-x-0.5"}),e[54]=Z):Z=e[54];let H;e[55]!==B||e[56]!==U?(H=n.jsxs(F,{type:"submit",disabled:B,className:"group transition-all duration-200",children:[U,Z]}),e[55]=B,e[56]=U,e[57]=H):H=e[57];let J;e[58]!==K||e[59]!==H?(J=n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[K,H]}),e[58]=K,e[59]=H,e[60]=J):J=e[60];let W;e[61]!==k||e[62]!==R||e[63]!==J?(W=n.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in-0 fill-mode-both duration-500 motion-reduce:animate-none",style:k,children:[R,J]}),e[61]=k,e[62]=R,e[63]=J,e[64]=W):W=e[64];let ee;return e[65]!==w||e[66]!==I||e[67]!==v||e[68]!==W||e[69]!==y||e[70]!==C?(ee=n.jsxs("form",{onSubmit:w,onAnimationEnd:y,className:C,children:[I,v,W]}),e[65]=w,e[66]=I,e[67]=v,e[68]=W,e[69]=y,e[70]=C,e[71]=ee):ee=e[71],ee}function dt(t){const e=T.c(7),{state:l,onAnswer:a}=t,{view:s}=l;switch(s.phase){case"thinking":{const i=l.step*3+l.idea.length;let r;return e[0]!==i?(r=n.jsx(de,{phrases:nt,offset:i}),e[0]=i,e[1]=r):r=e[1],r}case"asking":{let i;return e[2]!==a||e[3]!==l.step||e[4]!==s?(i=n.jsx(ct,{view:s,onAnswer:a},l.step),e[2]=a,e[3]=l.step,e[4]=s,e[5]=i):i=e[5],i}case"building":{let i;return e[6]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(de,{phrases:it,offset:0,building:!0}),e[6]=i):i=e[6],i}}}function ut({guide:t}){const e=L();return n.jsxs("div",{ref:t.screenRef,className:"flex h-full min-h-0 flex-col animate-in fade-in-0 duration-300 motion-reduce:animate-none",children:[n.jsxs("div",{className:"flex items-center gap-3 px-4 pt-4 md:px-8 animate-in fade-in-0 slide-in-from-top-1 duration-500 motion-reduce:animate-none",children:[n.jsxs(F,{variant:"ghost",size:"sm",onClick:t.cancel,children:[n.jsx(Re,{}),e("plan.guide.back")]}),n.jsxs("p",{className:"min-w-0 truncate text-sm text-muted-foreground",children:[n.jsx("span",{className:"text-meta mr-2",children:e("plan.guide.yourIdea")}),t.state.idea]}),n.jsx(ot,{done:t.state.answers.length,current:t.state.view.phase==="asking"})]}),n.jsx("div",{className:"flex min-h-0 flex-1 overflow-auto",children:n.jsx("div",{className:"m-auto flex w-full max-w-2xl justify-center px-4 py-10 md:px-8",children:n.jsx(dt,{state:t.state,onAnswer:t.answer})})})]})}function mt(t){const e=T.c(34),{draft:l,onResume:a,onDiscard:s}=t,i=L();let r;e[0]!==i?(r=i("plan.guide.resume.heading"),e[0]=i,e[1]=r):r=e[1];let d;e[2]!==i?(d=i("plan.guide.resume.heading"),e[2]=i,e[3]=d):d=e[3];let o;e[4]!==d?(o=n.jsx("h2",{className:"text-sm font-medium text-foreground",children:d}),e[4]=d,e[5]=o):o=e[5];let u;e[6]!==i?(u=i("plan.guide.resume.description"),e[6]=i,e[7]=u):u=e[7];let c;e[8]!==u?(c=n.jsx("p",{className:"text-sm text-muted-foreground",children:u}),e[8]=u,e[9]=c):c=e[9];let m;e[10]!==o||e[11]!==c?(m=n.jsxs("div",{className:"flex flex-col gap-1",children:[o,c]}),e[10]=o,e[11]=c,e[12]=m):m=e[12];let p;e[13]!==l.idea?(p=n.jsx("p",{className:"line-clamp-2 text-sm text-foreground",children:l.idea}),e[13]=l.idea,e[14]=p):p=e[14];let f;e[15]!==i?(f=i("plan.guide.resume.discard"),e[15]=i,e[16]=f):f=e[16];let x;e[17]!==s||e[18]!==f?(x=n.jsx(F,{type:"button",variant:"ghost",size:"sm",onClick:s,children:f}),e[17]=s,e[18]=f,e[19]=x):x=e[19];let g;e[20]!==i?(g=i("plan.guide.resume.continue"),e[20]=i,e[21]=g):g=e[21];let h;e[22]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(le,{}),e[22]=h):h=e[22];let b;e[23]!==a||e[24]!==g?(b=n.jsxs(F,{type:"button",size:"sm",onClick:a,children:[g,h]}),e[23]=a,e[24]=g,e[25]=b):b=e[25];let j;e[26]!==b||e[27]!==x?(j=n.jsxs("div",{className:"flex justify-end gap-2",children:[x,b]}),e[26]=b,e[27]=x,e[28]=j):j=e[28];let w;return e[29]!==r||e[30]!==j||e[31]!==m||e[32]!==p?(w=n.jsxs("section",{"aria-label":r,className:"flex flex-col gap-3 rounded-xl border border-border bg-muted/40 p-4",children:[m,p,j]}),e[29]=r,e[30]=j,e[31]=m,e[32]=p,e[33]=w):w=e[33],w}function je(t,e){return t.map(({question:l,answer:a})=>`- ${l.trim()}
${a.trim()||e}`).join(`
`)}function ft(t,e){const l=e.idea.trim(),a=e.objective?.trim(),s=e.casePath,i=a?t("plan.prompt.withObjective",{idea:l,objective:a,casePath:s}):t("plan.prompt.withoutObjective",{idea:l,casePath:s});if(!e.answers)return i;const r=je(e.answers,t("plan.prompt.skipped"));return`${i}
${r?t("plan.prompt.guidedAnswers",{answers:r}):t("plan.prompt.guidedNothing")}`}function ss(t,e){return t("plan.case.openFlow.prompt",{answers:je(e,t("plan.case.openFlow.skipped"))})}const ve="studio:plan-case-seed:",pt=te({title:X().min(1).max(q.title),objective:X().max(q.text).nullable(),request:X().min(1).max(q.text)});function xt(t){const e=t.trim().split(`
`)[0]??"";return e.length>q.title?`${e.slice(0,q.title-1)}…`:e}function gt(t,e,l){const a=l.request.trim().slice(0,q.text),s={title:xt(l.title?.trim()||a),objective:l.objective?.trim().slice(0,q.text)||null,request:a};try{t.setItem(ve+e,JSON.stringify(s))}catch{}}function ns(t,e){let l;try{l=t.getItem(ve+e)}catch{return null}if(!l)return null;let a;try{a=JSON.parse(l)}catch{return null}const s=pt.safeParse(a);return s.success?ze(s.data):null}const ht="studio:plan-guide-draft:",bt=10080*60*1e3,we=4e3,Ne=10,jt=te({idea:X().trim().min(1).max(we),answers:ke(te({question:X().min(1).max(q.item),answer:X().max(q.text)})).max(Ne),title:X().min(1).max(q.title).nullable(),done:te({guided:_e()}).nullable(),savedAt:Se()}),re=t=>ht+t;function vt(t,e,l,a=Date.now()){const s={idea:l.idea.slice(0,we),answers:l.answers.slice(0,Ne).map(({question:i,answer:r})=>({question:i.slice(0,q.item),answer:r.slice(0,q.text)})),title:l.title?.slice(0,q.title)||null,done:l.view.phase==="building"?{guided:l.view.guided}:null,savedAt:a};try{t.setItem(re(e),JSON.stringify(s))}catch{}}function ue(t,e,l=Date.now()){let a;try{a=t.getItem(re(e))}catch{return null}if(!a)return null;let s;try{s=JSON.parse(a)}catch{s=null}const i=jt.safeParse(s);return!i.success||l-i.data.savedAt>bt?(se(t,e),null):i.data}function se(t,e){try{t.removeItem(re(e))}catch{}}function wt(t){return{step:t.answers.length,idea:t.idea,answers:t.answers,title:t.title,view:t.done?{phase:"building",guided:t.done.guided}:{phase:"thinking"}}}function Nt(t){return{step:0,idea:t.trim(),answers:[],title:null,view:{phase:"thinking"}}}function me(t,e){if(e.step!==t.step)return t;switch(e.type){case"answered":return t.view.phase!=="asking"?t:{...t,step:t.step+1,answers:[...t.answers,{question:t.view.question.text,answer:e.answer.trim()}],view:{phase:"thinking"}};case"resolved":{if(t.view.phase!=="thinking")return t;const{question:l,reaction:a,title:s}=e.result;return{...t,title:s??t.title,view:l?{phase:"asking",question:l,reaction:a}:{phase:"building",guided:!0}}}case"failed":return t.view.phase!=="thinking"?t:{...t,view:{phase:"building",guided:!1}}}}function yt(t){return t.view.phase==="building"&&t.view.guided||t.answers.length>0?t.answers:void 0}const St=1600,_t=2200;function kt(){const t=T.c(37),e=L(),l=Pe(),{createTaskWithMessage:a}=ge(),s=he()?.statement??null,{org:i}=Ce(),[r,d]=G.useState(null);let o;t[0]!==i.id?(o=()=>ue(localStorage,i.id),t[0]=i.id,t[1]=o):o=t[1];const[u,c]=G.useState(o),m=G.useRef(null),p=G.useRef(!1);let f;t[2]!==i.id?(f=v=>{d(v),vt(localStorage,i.id,v)},t[2]=i.id,t[3]=f):f=t[3];const x=f;let g;t[4]!==a||t[5]!==s||t[6]!==i.id||t[7]!==e?(g=async v=>{const N=yt(v);Y("plan_guide_done",{has_objective:!!s,questions:v.answers.length,skipped:v.answers.filter(Ct).length,guided:v.view.phase==="building"&&v.view.guided});const k=crypto.randomUUID(),S=Be(k);gt(sessionStorage,S,{objective:s,request:v.idea,title:v.title}),await a({id:k,tabId:pe(S),message:{parts:[{type:"text",text:ft(e,{idea:v.idea,objective:s,casePath:Fe(S),...N?{answers:N}:{}})}]}})&&se(localStorage,i.id)},t[4]=a,t[5]=s,t[6]=i.id,t[7]=e,t[8]=g):g=t[8];const h=g;let b;t[9]!==s||t[10]!==h||t[11]!==x||t[12]!==l?(b=async v=>{m.current?.abort();const N=new AbortController;m.current=N;const{signal:k}=N;x(v);let S;try{const[$]=await Promise.all([l.call("PLAN_CASE_NEXT_QUESTION",{idea:v.idea.slice(0,q.text),objective:s,answers:v.answers.map(Pt)}),oe(St,{signal:k})]);S={type:"resolved",step:v.step,result:$}}catch{S={type:"failed",step:v.step}}if(k.aborted)return;const A=me(v,S);if(x(A),A.view.phase==="building"){try{await oe(_t,{signal:k})}catch{return}m.current=null,p.current&&(d(null),h(A))}},t[9]=s,t[10]=h,t[11]=x,t[12]=l,t[13]=b):b=t[13];const j=b;let w;t[14]!==h||t[15]!==i.id||t[16]!==j?(w=()=>{const v=ue(localStorage,i.id);if(c(null),!v)return;const N=wt(v);if(Y("plan_guide_resumed",{questions:N.answers.length,done:N.view.phase==="building"}),N.view.phase==="building"){h(N);return}j(N)},t[14]=h,t[15]=i.id,t[16]=j,t[17]=w):w=t[17];let y;t[18]!==i.id?(y=()=>{se(localStorage,i.id),c(null)},t[18]=i.id,t[19]=y):y=t[19];let E;t[20]===Symbol.for("react.memo_cache_sentinel")?(E=v=>{p.current=v!==null},t[20]=E):E=t[20];let C;t[21]!==s||t[22]!==j?(C=v=>{v.trim()&&(Y("plan_idea_submitted",{has_objective:!!s}),c(null),j(Nt(v)))},t[21]=s,t[22]=j,t[23]=C):C=t[23];let D;t[24]!==r||t[25]!==j?(D=v=>{if(!r)return;const N=me(r,{type:"answered",step:r.step,answer:v});N!==r&&(Y("plan_guide_question_answered",{step:r.step,skipped:!v.trim()}),j(N))},t[24]=r,t[25]=j,t[26]=D):D=t[26];let _;t[27]!==i.id?(_=()=>{m.current?.abort(),m.current=null,se(localStorage,i.id),d(null)},t[27]=i.id,t[28]=_):_=t[28];let I;return t[29]!==u||t[30]!==r||t[31]!==w||t[32]!==y||t[33]!==C||t[34]!==D||t[35]!==_?(I={state:r,saved:u,resume:w,discard:y,screenRef:E,start:C,answer:D,cancel:_},t[29]=u,t[30]=r,t[31]=w,t[32]=y,t[33]=C,t[34]=D,t[35]=_,t[36]=I):I=t[36],I}function Pt(t){const{question:e,answer:l}=t;return{question:e.slice(0,q.item),answer:l.slice(0,q.text)}}function Ct(t){return!t.answer}const It=20,At={framing:"plan.case.status.framing",building:"plan.case.status.building",ready:"plan.case.status.ready"};function $t(t){const e=T.c(28),{entry:l,threadId:a}=t,s=L(),i=Je(),{openTask:r}=ge(),d=Le(l.path),o=d.data?.value;let u;e[0]!==l.path||e[1]!==r||e[2]!==a?(u=()=>r(a,{tabId:pe(l.path)}),e[0]=l.path,e[1]=r,e[2]=a,e[3]=u):u=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(qe,{className:"size-4 shrink-0 text-muted-foreground"}),e[4]=c):c=e[4];let m;e[5]!==d.isPending||e[6]!==s||e[7]!==o?.title?(m=o?.title??(d.isPending?"…":s("plan.cases.unreadable")),e[5]=d.isPending,e[6]=s,e[7]=o?.title,e[8]=m):m=e[8];let p;e[9]!==m?(p=n.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:m}),e[9]=m,e[10]=p):p=e[10];let f;e[11]!==l.updatedAt||e[12]!==i||e[13]!==s?(f=s("plan.cases.updated",{when:We(new Date(l.updatedAt),{addSuffix:!0,locale:i})}),e[11]=l.updatedAt,e[12]=i,e[13]=s,e[14]=f):f=e[14];let x;e[15]!==f?(x=n.jsx("span",{className:"text-xs text-muted-foreground",children:f}),e[15]=f,e[16]=x):x=e[16];let g;e[17]!==p||e[18]!==x?(g=n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[p,x]}),e[17]=p,e[18]=x,e[19]=g):g=e[19];let h;e[20]!==s||e[21]!==o?(h=o&&n.jsx(xe,{variant:o.status==="ready"?"success":"agent",children:s(At[o.status])}),e[20]=s,e[21]=o,e[22]=h):h=e[22];let b;e[23]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Ae,{className:"size-4 shrink-0 text-muted-foreground"}),e[23]=b):b=e[23];let j;return e[24]!==u||e[25]!==g||e[26]!==h?(j=n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:u,className:"flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left hover:bg-accent focus-ring",children:[c,g,h,b]})}),e[24]=u,e[25]=g,e[26]=h,e[27]=j):j=e[27],j}function Dt(){const t=T.c(28),e=L(),{data:l}=Ie.useSession(),a=l?.user?.id,s=Qe("home",Ge);let i,r,d,o,u;if(t[0]!==s.data||t[1]!==e||t[2]!==a){u=Symbol.for("react.early_return_sentinel");e:{let p;t[8]!==a?(p=j=>{const w=Ke(j.path);return j.kind==="file"&&w&&(!j.createdBy||j.createdBy===a)?[{entry:j,threadId:w}]:[]},t[8]=a,t[9]=p):p=t[9];const f=(s.data??[]).flatMap(p).toSorted(qt).slice(0,It);if(f.length===0){u=null;break e}d="flex flex-col gap-3";let x;t[10]!==e?(x=e("plan.cases.heading"),t[10]=e,t[11]=x):x=t[11];let g;t[12]!==x?(g=n.jsx("h2",{className:"text-xl font-medium text-foreground",children:x}),t[12]=x,t[13]=g):g=t[13];let h;t[14]!==e?(h=e("plan.cases.description"),t[14]=e,t[15]=h):h=t[15];let b;t[16]!==h?(b=n.jsx("p",{className:"text-sm text-muted-foreground",children:h}),t[16]=h,t[17]=b):b=t[17],t[18]!==g||t[19]!==b?(o=n.jsxs("div",{className:"flex flex-col gap-1",children:[g,b]}),t[18]=g,t[19]=b,t[20]=o):o=t[20],i="-mx-3 flex flex-col",r=f.map(Et)}t[0]=s.data,t[1]=e,t[2]=a,t[3]=i,t[4]=r,t[5]=d,t[6]=o,t[7]=u}else i=t[3],r=t[4],d=t[5],o=t[6],u=t[7];if(u!==Symbol.for("react.early_return_sentinel"))return u;let c;t[21]!==i||t[22]!==r?(c=n.jsx("ul",{className:i,children:r}),t[21]=i,t[22]=r,t[23]=c):c=t[23];let m;return t[24]!==d||t[25]!==o||t[26]!==c?(m=n.jsxs("section",{className:d,children:[o,c]}),t[24]=d,t[25]=o,t[26]=c,t[27]=m):m=t[27],m}function Et(t){const{entry:e,threadId:l}=t;return n.jsx($t,{entry:e,threadId:l},e.path)}function qt(t,e){return e.entry.updatedAt.localeCompare(t.entry.updatedAt)}const Tt=[{label:"plan.idea.topic.shipping",prompt:"plan.idea.topic.shippingPrompt"},{label:"plan.idea.topic.pdp",prompt:"plan.idea.topic.pdpPrompt"},{label:"plan.idea.topic.checkout",prompt:"plan.idea.topic.checkoutPrompt"},{label:"plan.idea.topic.search",prompt:"plan.idea.topic.searchPrompt"},{label:"plan.idea.topic.performance",prompt:"plan.idea.topic.performancePrompt"},{label:"plan.idea.topic.paidMedia",prompt:"plan.idea.topic.paidMediaPrompt"}];function Mt(t){const e=T.c(52),{initialIdea:l,onSubmit:a}=t,s=L(),[i,r]=G.useState(l);let d;e[0]!==i?(d=i.trim(),e[0]=i,e[1]=d):d=e[1];const o=d.length>0;let u;e[2]!==i||e[3]!==a||e[4]!==o?(u=$=>{$.preventDefault(),o&&a(i)},e[2]=i,e[3]=a,e[4]=o,e[5]=u):u=e[5];const c=u;let m;e[6]!==s?(m=s("plan.idea.heading"),e[6]=s,e[7]=m):m=e[7];let p;e[8]!==m?(p=n.jsx("h2",{className:"text-xl font-medium text-foreground",children:m}),e[8]=m,e[9]=p):p=e[9];let f;e[10]!==s?(f=s("plan.idea.description"),e[10]=s,e[11]=f):f=e[11];let x;e[12]!==f?(x=n.jsx("p",{className:"text-sm text-pretty text-muted-foreground",children:f}),e[12]=f,e[13]=x):x=e[13];let g;e[14]!==p||e[15]!==x?(g=n.jsxs("div",{className:"flex flex-col gap-1",children:[p,x]}),e[14]=p,e[15]=x,e[16]=g):g=e[16];let h;e[17]!==s?(h=s("plan.idea.label"),e[17]=s,e[18]=h):h=e[18];let b;e[19]!==s?(b=s("plan.idea.placeholder"),e[19]=s,e[20]=b):b=e[20];let j;e[21]===Symbol.for("react.memo_cache_sentinel")?(j=$=>r($.target.value),e[21]=j):j=e[21];let w;e[22]!==c?(w=$=>{$.key==="Enter"&&($.metaKey||$.ctrlKey)&&c($)},e[22]=c,e[23]=w):w=e[23];let y;e[24]!==i||e[25]!==w||e[26]!==h||e[27]!==b?(y=n.jsx(ae,{"aria-label":h,placeholder:b,value:i,onChange:j,onKeyDown:w,className:"min-h-32 text-[15px]"}),e[24]=i,e[25]=w,e[26]=h,e[27]=b,e[28]=y):y=e[28];const E=!o;let C;e[29]!==s?(C=s("plan.idea.submit"),e[29]=s,e[30]=C):C=e[30];let D;e[31]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(le,{}),e[31]=D):D=e[31];let _;e[32]!==E||e[33]!==C?(_=n.jsx("div",{className:"flex justify-end",children:n.jsxs(F,{type:"submit",disabled:E,children:[C,D]})}),e[32]=E,e[33]=C,e[34]=_):_=e[34];let I;e[35]!==c||e[36]!==y||e[37]!==_?(I=n.jsxs("form",{onSubmit:c,className:"flex flex-col gap-3",children:[y,_]}),e[35]=c,e[36]=y,e[37]=_,e[38]=I):I=e[38];let v;e[39]!==s?(v=s("plan.idea.startWith"),e[39]=s,e[40]=v):v=e[40];let N;e[41]!==v?(N=n.jsx("span",{className:"mr-1 text-meta",children:v}),e[41]=v,e[42]=N):N=e[42];let k;e[43]!==s?(k=Tt.map($=>n.jsx(F,{type:"button",variant:"outline",size:"sm",onClick:()=>r(M=>M||s($.prompt)),children:s($.label)},$.label)),e[43]=s,e[44]=k):k=e[44];let S;e[45]!==N||e[46]!==k?(S=n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[N,k]}),e[45]=N,e[46]=k,e[47]=S):S=e[47];let A;return e[48]!==I||e[49]!==S||e[50]!==g?(A=n.jsxs("section",{className:"flex flex-col gap-4",children:[g,I,S]}),e[48]=I,e[49]=S,e[50]=g,e[51]=A):A=e[51],A}function Rt(t){return t.found?{kind:"found",statement:t.found.statement,source:t.found.source.label,quote:t.found.quote}:{kind:"missing",message:t.reason==="unavailable"?"plan.objective.findUnavailable":"plan.objective.notFound",read:t.read,unread:t.unread}}function Ot(t){const e=T.c(28),{notice:l,draft:a}=t,s=L();if(l.kind==="found"){if(!a)return null;let f;e[0]!==l.quote||e[1]!==l.source||e[2]!==s?(f=s("plan.objective.found",{source:l.source,quote:l.quote}),e[0]=l.quote,e[1]=l.source,e[2]=s,e[3]=f):f=e[3];let x;return e[4]!==f?(x=n.jsx("p",{className:"text-meta",children:f}),e[4]=f,e[5]=x):x=e[5],x}let i;e[6]!==l.message||e[7]!==s?(i=s(l.message),e[6]=l.message,e[7]=s,e[8]=i):i=e[8];let r;e[9]!==i?(r=n.jsx("p",{className:"text-foreground",children:i}),e[9]=i,e[10]=r):r=e[10];let d;e[11]!==l.read||e[12]!==s?(d=l.read.length>0?s("plan.objective.read",{sources:l.read.join(", ")}):s("plan.objective.readNothing"),e[11]=l.read,e[12]=s,e[13]=d):d=e[13];let o;e[14]!==d?(o=n.jsx("p",{children:d}),e[14]=d,e[15]=o):o=e[15];let u;e[16]!==l.unread||e[17]!==s?(u=l.unread.length>0&&n.jsx("p",{children:s("plan.objective.unread",{files:l.unread.join(", ")})}),e[16]=l.unread,e[17]=s,e[18]=u):u=e[18];let c;e[19]!==s?(c=s("plan.objective.connectHint"),e[19]=s,e[20]=c):c=e[20];let m;e[21]!==c?(m=n.jsx("p",{children:c}),e[21]=c,e[22]=m):m=e[22];let p;return e[23]!==r||e[24]!==o||e[25]!==u||e[26]!==m?(p=n.jsxs("div",{className:"flex flex-col gap-1 text-sm text-muted-foreground",children:[r,o,u,m]}),e[23]=r,e[24]=o,e[25]=u,e[26]=m,e[27]=p):p=e[27],p}function fe(t){const e=T.c(60),{initial:l,onDone:a}=t,s=L(),[i,r]=G.useState(l),[d,o]=G.useState(null),u=Xe(),c=He();let m;e[0]!==i?(m=i.trim(),e[0]=i,e[1]=m):m=e[1];const p=m,f=u.isPending||c.isPending;let x;e[2]!==a||e[3]!==u||e[4]!==s?(x=B=>u.mutate({statement:B},{onSuccess:()=>a?.(),onError:()=>$e.error(s("plan.objective.saveError"))}),e[2]=a,e[3]=u,e[4]=s,e[5]=x):x=e[5];const g=x;let h;e[6]!==p||e[7]!==g?(h=B=>{B.preventDefault(),p&&g(p)},e[6]=p,e[7]=g,e[8]=h):h=e[8];const b=h;let j;e[9]!==c?(j=()=>{Y("plan_objective_find_clicked"),o(null),c.mutate(void 0,{onSuccess:B=>{const U=Rt(B);Y("plan_objective_find_answered",{outcome:B.found?"found":B.reason??"not_found"}),U.kind==="found"&&r(U.statement),o(U)},onError:()=>o({kind:"missing",message:"plan.objective.findUnavailable",read:[],unread:[]})})},e[9]=c,e[10]=j):j=e[10];const w=j;let y;e[11]!==s?(y=s("plan.objective.label"),e[11]=s,e[12]=y):y=e[12];let E;e[13]!==s?(E=s("plan.objective.placeholder"),e[13]=s,e[14]=E):E=e[14];let C;e[15]===Symbol.for("react.memo_cache_sentinel")?(C=B=>r(B.target.value),e[15]=C):C=e[15];const D=a!==void 0;let _;e[16]!==i||e[17]!==c.isPending||e[18]!==y||e[19]!==E||e[20]!==D?(_=n.jsx(ae,{"aria-label":y,placeholder:E,value:i,maxLength:Ye,onChange:C,disabled:c.isPending,className:"min-h-20 text-base",autoFocus:D}),e[16]=i,e[17]=c.isPending,e[18]=y,e[19]=E,e[20]=D,e[21]=_):_=e[21];let I;e[22]!==c.isPending||e[23]!==d||e[24]!==p||e[25]!==s?(I=c.isPending?n.jsx("p",{className:"animate-pulse text-sm text-muted-foreground",children:s("plan.objective.finding")}):d?n.jsx(Ot,{notice:d,draft:p}):n.jsx("span",{className:"text-meta",children:s("plan.objective.hint")}),e[22]=c.isPending,e[23]=d,e[24]=p,e[25]=s,e[26]=I):I=e[26];let v;e[27]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Me,{}),e[27]=v):v=e[27];let N;e[28]!==s?(N=s("plan.objective.find"),e[28]=s,e[29]=N):N=e[29];let k;e[30]!==f||e[31]!==w||e[32]!==N?(k=n.jsxs(F,{type:"button",variant:"outline",size:"sm",disabled:f,onClick:w,children:[v,N]}),e[30]=f,e[31]=w,e[32]=N,e[33]=k):k=e[33];let S;e[34]!==f||e[35]!==l||e[36]!==s||e[37]!==g?(S=l&&n.jsx(F,{type:"button",variant:"ghost",size:"sm",disabled:f,onClick:()=>g(null),children:s("plan.objective.clear")}),e[34]=f,e[35]=l,e[36]=s,e[37]=g,e[38]=S):S=e[38];let A;e[39]!==a||e[40]!==u.isPending||e[41]!==s?(A=a&&n.jsx(F,{type:"button",variant:"outline",size:"sm",disabled:u.isPending,onClick:a,children:s("plan.objective.cancel")}),e[39]=a,e[40]=u.isPending,e[41]=s,e[42]=A):A=e[42];const $=!p||f;let M;e[43]!==s?(M=s("plan.objective.save"),e[43]=s,e[44]=M):M=e[44];let R;e[45]!==$||e[46]!==M?(R=n.jsx(F,{type:"submit",size:"sm",disabled:$,children:M}),e[45]=$,e[46]=M,e[47]=R):R=e[47];let O;e[48]!==S||e[49]!==A||e[50]!==R?(O=n.jsxs("div",{className:"ml-auto flex gap-2",children:[S,A,R]}),e[48]=S,e[49]=A,e[50]=R,e[51]=O):O=e[51];let z;e[52]!==k||e[53]!==O?(z=n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[k,O]}),e[52]=k,e[53]=O,e[54]=z):z=e[54];let K;return e[55]!==b||e[56]!==I||e[57]!==z||e[58]!==_?(K=n.jsxs("form",{onSubmit:b,className:"flex flex-col gap-2",children:[_,I,z]}),e[55]=b,e[56]=I,e[57]=z,e[58]=_,e[59]=K):K=e[59],K}function zt(){const t=T.c(12),e=L(),l=he(),[a,s]=G.useState(!1),i=l?.statement??"";let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(ie,{size:13}),t[0]=r):r=t[0];let d;t[1]!==e?(d=e("plan.objective.eyebrow"),t[1]=e,t[2]=d):d=t[2];let o;t[3]!==d?(o=n.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium tracking-wide text-muted-foreground uppercase",children:[r,d]}),t[3]=d,t[4]=o):o=t[4];let u;t[5]!==a||t[6]!==i||t[7]!==e?(u=i?a?n.jsx(fe,{initial:i,onDone:()=>s(!1)}):n.jsxs("div",{className:"flex flex-col items-start gap-3",children:[n.jsx("p",{className:"max-w-[720px] text-2xl leading-snug font-medium text-balance text-foreground",children:i}),n.jsxs(F,{variant:"outline",size:"sm",onClick:()=>s(!0),children:[n.jsx(Te,{}),e("plan.objective.edit")]})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"max-w-[560px] text-base text-pretty text-muted-foreground",children:e("plan.objective.empty")}),n.jsx(fe,{initial:""})]}),t[5]=a,t[6]=i,t[7]=e,t[8]=u):u=t[8];let c;return t[9]!==o||t[10]!==u?(c=n.jsxs("section",{className:"flex flex-col gap-3",children:[o,u]}),t[9]=o,t[10]=u,t[11]=c):c=t[11],c}function is(){const t=T.c(19),e=kt(),[l,a]=G.useState(""),{state:s}=e;if(s){let c;t[0]!==e||t[1]!==s?(c=()=>{a(s.idea),e.cancel()},t[0]=e,t[1]=s,t[2]=c):c=t[2];let m;return t[3]!==e||t[4]!==s||t[5]!==c?(m=n.jsx(Q,{children:n.jsx(ut,{guide:{...e,state:s,cancel:c}})}),t[3]=e,t[4]=s,t[5]=c,t[6]=m):m=t[6],m}let i;t[7]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(zt,{}),t[7]=i):i=t[7];let r;t[8]!==e.discard||t[9]!==e.resume||t[10]!==e.saved?(r=e.saved&&n.jsx(mt,{draft:e.saved,onResume:e.resume,onDiscard:e.discard}),t[8]=e.discard,t[9]=e.resume,t[10]=e.saved,t[11]=r):r=t[11];let d;t[12]!==l||t[13]!==e.start?(d=n.jsx(Mt,{initialIdea:l,onSubmit:e.start}),t[12]=l,t[13]=e.start,t[14]=d):d=t[14];let o;t[15]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Dt,{}),t[15]=o):o=t[15];let u;return t[16]!==r||t[17]!==d?(u=n.jsx(Q,{children:n.jsx(Q.Content,{children:n.jsxs(Q.Container,{width:"standard",className:"flex flex-col gap-12",children:[i,r,d,o]})})}),t[16]=r,t[17]=d,t[18]=u):u=t[18],u}export{it as B,ts as C,is as P,ct as Q,de as T,ot as a,ss as o,ns as r};