PageSourceSearch

https://vizops360.ai/assets/proposalStudioProfile-BTj_5BfR.js

js vizops360.ai collected 2026-10-05 13:51:29 UTC 45,880 bytes, 21 lines download raw bytes

1import{y as Ot,r as o,iS as Ut,iT as _t,cn as et,j as e,cm as tt,av as me,v as st,as as M,mN as Et,gx as Lt,bv as ze,bw as Be,bx as qe,by as Qe,bz as He,bT as Mt,cf as Ce,cg as Ae,ch as Re,ci as Te,cj as ae,bS as Ft,bA as ge,gy as rt,ap as S,S as oe,ar as nt,X as at,ao as ot,b_ as it,N as Pt,c6 as lt,cr as $t,be as Dt,L as zt,kE as Bt}from"./index-CpeGhXo5.js";import{a as We,t as Ge,s as ue,b as qt,c as Qt,U as ct,g as Ht}from"./SourceIdentityBadge-CY5cRB3J.js";import{C as fe}from"./collapsible-section-z6TCB4P0.js";import{N as dt}from"./NoDataState-CqaLSrFV.js";import{U as ut,R as mt}from"./CompactSelect-BQEB9Gqd.js";import{u as Wt}from"./AiProviderModelSelect-36MMEVgB.js";import{P as Ke}from"./panel-right-close-Ccz6vzCd.js";const os=Ot("FileUser",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 18a3 3 0 1 0-6 0",key:"16awa0"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);function Ve(){if(typeof window>"u")return null;const t=window;return t.SpeechRecognition??t.webkitSpeechRecognition??null}function is(t,n){const[s,c]=o.useState(!1),f=o.useRef(null),m=o.useRef(t),_=o.useRef(n);m.current=t,_.current=n;const A=Ve()!=null,R=o.useCallback(()=>{f.current?.stop()},[]),x=o.useCallback(()=>{const N=Ve();if(!N||f.current)return;const T=new N;T.lang=navigator.language,T.continuous=!0,T.interimResults=!1,T.onresult=y=>{for(let I=y.resultIndex;I<y.results.length;I++){const D=y.results[I],E=D[0]?.transcript?.trim();D.isFinal&&E&&m.current(E)}},T.onerror=y=>{y.error!=="aborted"&&y.error!=="no-speech"&&_.current?.(y.error)},T.onend=()=>{f.current=null,c(!1)},f.current=T,c(!0),T.start()},[]);return o.useEffect(()=>()=>f.current?.abort(),[]),{supported:A,listening:s,start:x,stop:R,toggle:s?R:x}}function Gt(t){const n=t,s=n?.data?.message;return Array.isArray(s)?s.join(", "):s||n?.message||"Request failed"}const Me=o.createContext(null);function ls({children:t}){const{toast:n}=tt(),{data:s,isLoading:c,isFetching:f,isError:m,error:_,refetch:A}=Ut({key:We}),[R]=_t(),[x,N]=o.useState(null),[T,y]=o.useState("idle"),I=o.useRef(""),D=o.useRef(0),E=o.useRef(null),Y=o.useRef(null);Y.current=x,o.useEffect(()=>{if(!s)return;const w=Ge(s),p=ue(w),h=Y.current;h!=null&&ue(h)!==I.current||h&&p===I.current||(N(w),I.current=p,y($=>$==="error"?$:"saved"))},[s]);const b=o.useCallback(async w=>{const p=ue(w);if(p===I.current)return y("saved"),!0;const h=++D.current,O=(async()=>{try{y("saving");const U=await R({key:We,...qt(w)}).unwrap();if(h!==D.current)return!1;const P=Ge(U);return I.current=ue(P),N(g=>!g||ue(g)===p?P:g),y("saved"),!0}catch(U){return h!==D.current||(y("error"),n({title:"Could not save settings",description:Gt(U),variant:"destructive"})),!1}})();E.current=O;const $=await O;return E.current===O&&(E.current=null),$},[n,R]),z=et(x,Qt);o.useEffect(()=>{z&&ue(z)!==I.current&&b(z)},[z,b]);const H=o.useCallback(w=>{N(p=>p&&{...p,...w}),y(p=>p==="saving"?p:"idle")},[]),B=o.useCallback(w=>{N(w),y(p=>p==="saving"?p:"idle")},[]),F=o.useCallback(async()=>E.current&&!await E.current?!1:x?b(x):!0,[x,b]),C=o.useMemo(()=>{const w=_?.data?.message;if(Array.isArray(w))return w.join(", ");if(typeof w=="string")return w;const p=_;return p?.error||p?.message||"Failed to load settings."},[_]),K=o.useMemo(()=>({form:x,patchForm:H,setForm:B,status:T,isLoading:c,isFetching:f,isError:m,errorMessage:C,refetch:()=>{A()},flushSave:F}),[x,H,B,T,c,f,m,C,A,F]);return e.jsx(Me.Provider,{value:K,children:t})}function cs(){const t=o.useContext(Me);if(!t)throw new Error("useUpworkChannelSettings must be used within UpworkChannelSettingsProvider");return t}function ds(){return o.useContext(Me)}function us({status:t,className:n}){return e.jsx("span",{className:M("inline-flex items-center gap-1 text-[10px] font-medium",t==="error"?"text-destructive":"text-muted-foreground",n),children:t==="saving"?e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"h-3 w-3 animate-spin"}),"Saving…"]}):t==="error"?"Couldn’t save — will retry on the next change":t==="saved"?e.jsxs(e.Fragment,{children:[e.jsx(st,{className:"h-3 w-3 text-emerald-600"}),e.jsx("span",{className:"text-emerald-700",children:"Saved"})]}):"Changes save automatically"})}const Kt={playbook_updated:{label:"Playbook change",tone:"bg-amber-500/10 text-amber-700 dark:text-amber-400"},ai_generate:{label:"AI generate",tone:"bg-violet-500/10 text-violet-700 dark:text-violet-400"},ai_revise:{label:"AI feedback",tone:"bg-indigo-500/10 text-indigo-700 dark:text-indigo-400"},ai_refine:{label:"AI refine rules",tone:"bg-sky-500/10 text-sky-700 dark:text-sky-400"},ai_validate:{label:"AI validate",tone:"bg-slate-500/10 text-slate-700 dark:text-slate-300"},ai_answers:{label:"AI answers",tone:"bg-teal-500/10 text-teal-700 dark:text-teal-400"},ai_compare:{label:"AI A/B test",tone:"bg-fuchsia-500/10 text-fuchsia-700 dark:text-fuchsia-400"},letter_saved:{label:"Letter saved",tone:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-400"},letter_edited:{label:"Letter edited",tone:"bg-sky-500/10 text-sky-700 dark:text-sky-400"},letter_submitted:{label:"Submitted",tone:"bg-emerald-600/15 text-emerald-800 dark:text-emerald-300"},letter_unsubmitted:{label:"Unsubmitted",tone:"bg-muted text-muted-foreground"},letter_deleted:{label:"Letter deleted",tone:"bg-red-500/10 text-red-700 dark:text-red-400"}},Je=[{id:"all",label:"All activity"},{id:"playbook",label:"Playbook / rule changes",actions:["playbook_updated","ai_refine"]},{id:"ai",label:"AI runs",actions:["ai_generate","ai_revise","ai_refine","ai_validate","ai_answers","ai_compare"]},{id:"feedback",label:"Feedback applied",actions:["ai_revise"]},{id:"generate",label:"Generated letters",actions:["ai_generate","ai_compare"]}
1,{id:"letters",label:"Saved / edited / submitted / deleted",actions:["letter_saved","letter_edited","letter_submitted","letter_unsubmitted","letter_deleted"]}];function pt(t){const n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function ht(t){return t==null?"—":t<1e3?`${t} ms`:`${(t/1e3).toFixed(1)} s`}function xt({action:t}){const n=Kt[t]??{label:t,tone:"bg-muted text-muted-foreground"};return e.jsx("span",{className:M("inline-flex items-center rounded px-1.5 py-0.5 text-[11px] font-medium whitespace-nowrap",n.tone),children:n.label})}function xe({label:t,text:n}){return n?.trim()?e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:t}),e.jsx("pre",{className:"whitespace-pre-wrap break-words rounded-md border border-border bg-muted/40 p-3 text-xs font-sans leading-relaxed max-h-80 overflow-y-auto custom-scrollbar",children:n})]}):null}function Vt({item:t}){const n=[["When",pt(t.createdAt)],["By",t.actor.fullName],["Status",t.status==="failed"?"Failed":"Success"],...t.sourceAccountName?[["Source",t.sourceAccountName]]:[],...t.source?[["Channel",t.source]]:[],...t.aiProvider||t.aiModel?[["AI model",[t.aiProvider,t.aiModel].filter(Boolean).join(" · ")]]:[],...t.durationMs!=null?[["Duration",ht(t.durationMs)]]:[],...t.wordCount!=null?[["Words",String(t.wordCount)]]:[]];return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xt,{action:t.action}),e.jsx("span",{className:"text-sm font-medium",children:t.summary})]}),e.jsx("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-1.5 text-xs",children:n.map(([s,c])=>e.jsxs("div",{className:"flex gap-2 min-w-0",children:[e.jsx("dt",{className:"text-muted-foreground shrink-0 w-20",children:s}),e.jsx("dd",{className:"truncate",children:c})]},s))}),t.errorMessage?e.jsx("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-3 text-xs text-red-700 dark:text-red-400",children:t.errorMessage}):null,e.jsx(xe,{label:t.action==="ai_revise"?"Feedback given":"Instruction",text:t.feedback}),t.changes?.length?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:["Changes (",t.changes.length,")"]}),t.changes.map((s,c)=>e.jsxs("div",{className:"rounded-md border border-border p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:M("rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase",s.change==="added"&&"bg-emerald-500/10 text-emerald-700 dark:text-emerald-400",s.change==="removed"&&"bg-red-500/10 text-red-700 dark:text-red-400",s.change==="updated"&&"bg-amber-500/10 text-amber-700 dark:text-amber-400"),children:s.change}),e.jsx("span",{className:"text-muted-foreground",children:s.area}),e.jsx("span",{className:"font-medium truncate",children:s.name})]}),e.jsxs("div",{className:M("grid gap-2",s.before&&s.after?"md:grid-cols-2":"grid-cols-1"),children:[e.jsx(xe,{label:"Before",text:s.before}),e.jsx(xe,{label:"After",text:s.after})]})]},`${s.area}-${s.name}-${c}`))]}):null,e.jsxs("div",{className:M("grid gap-3",t.inputText&&t.outputText?"lg:grid-cols-2":"grid-cols-1"),children:[e.jsx(xe,{label:t.action==="letter_deleted"?"Deleted letter":"Before",text:t.inputText}),e.jsx(xe,{label:t.action.startsWith("ai_")?"AI output":"Letter",text:t.outputText})]})]})}function ms({open:t,onOpenChange:n,sourceAccountId:s,sourceLabel:c,defaultScope:f="all"}
1){const[m,_]=o.useState(""),A=et(m,400),[R,x]=o.useState("all"),[N,T]=o.useState("all"),[y,I]=o.useState(f),[D,E]=o.useState(1),[Y,b]=o.useState(25),[z,H]=o.useState("createdAt"),[B,F]=o.useState("desc"),[C,K]=o.useState(null),w=Je.find(i=>i.id===R)?.actions,{data:p,isLoading:h,isFetching:O,refetch:$}=Et({actions:w,status:N==="all"?void 0:N,sourceAccountId:y==="source"?s:void 0,search:A.trim()||void 0,sortBy:z,sortOrder:B,page:D,limit:Y},{skip:!t}),U=p?.items??[],P=o.useMemo(()=>[{key:"createdAt",label:"When",sortable:!0,width:"11rem",render:i=>e.jsx("span",{className:"text-xs whitespace-nowrap",children:pt(i.createdAt)})},{key:"action",label:"Action",sortable:!0,width:"9.5rem",render:i=>e.jsx(xt,{action:i.action})},{key:"summary",label:"Details",render:i=>e.jsx("span",{className:M("text-xs",i.status==="failed"&&"text-red-600 dark:text-red-400"),children:i.summary})},{key:"actorName",label:"By",sortable:!0,width:"10rem",render:i=>e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx(Lt,{userId:i.actor.id,avatar:i.actor.avatar,initials:i.actor.initials||"?",sizeClass:"w-5 h-5 text-[9px]",className:"border-border"}),e.jsx("span",{className:"text-xs truncate",children:i.actor.fullName})]})},{key:"source",label:"Source",width:"8rem",render:i=>e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:i.sourceAccountName||i.source||"—"})},{key:"status",label:"Status",width:"6rem",render:i=>e.jsx("span",{className:M("text-[11px] font-medium",i.status==="failed"?"text-red-600 dark:text-red-400":"text-emerald-600 dark:text-emerald-400"),children:i.status==="failed"?"Failed":"Success"})},{key:"durationMs",label:"Time taken",width:"6.5rem",defaultVisible:!1,render:i=>e.jsx("span",{className:"text-xs text-muted-foreground",children:ht(i.durationMs)})}],[]),g=()=>E(1);return e.jsxs(e.Fragment,{children:[e.jsx(ze,{open:t,onOpenChange:n,children:e.jsxs(Be,{className:"max-w-6xl h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(qe,{children:[e.jsx(Qe,{children:"Cover letter activity log"}),e.jsx(He,{children:"Every playbook and rule change, AI run, feedback applied, and letter saved, submitted, or deleted. Click a row to see the full before and after."})]}),e.jsx("div",{className:"min-h-0 flex-1 flex flex-col",children:e.jsx(Mt,{fillHeight:!0,mode:"server",storageKey:"cover-letter-activity-log-v1",rows:U,columns:P,rowKey:i=>i.id,onRowClick:K,onRefresh:()=>{$()},total:p?.total??0,page:D,pageSize:Y,pageSizeOptions:[10,25,50,100],onPageChange:E,onPageSizeChange:i=>{b(i),g()},sortKey:z,sortDir:B,onSortChange:({sortKey:i,sortDir:Z})=>{i&&H(i),F(Z),g()},loading:h&&U.length===0,fetching:O,hidePrint:!0,emptyTitle:"No activity yet",emptyMessage:"Changes to the playbook, AI runs, and saved letters will show up here.",searchSlot:e.jsx(Ft,{value:m,onChange:i=>{_(i),g()},placeholder:"Search details, feedback, author…",className:"w-[240px] shrink-0"}),actionsSlot:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ce,{value:R,onValueChange:i=>{x(i),g()},children:[e.jsx(Ae,{className:"h-8 w-[200px] text-xs",children:e.jsx(Re,{})}),e.jsx(Te,{children:Je.map(i=>e.jsx(ae,{value:i.id,className:"text-xs",children:i.label},i.id))})]}),e.jsxs(Ce,{value:N,onValueChange:i=>{T(i),g()},children:[e.jsx(Ae,{className:"h-8 w-[120px] text-xs",children:e.jsx(Re,{})}),e.jsxs(Te,{children:[e.jsx(ae,{value:"all",className:"text-xs",children:"Any status"}),e.jsx(ae,{value:"success",className:"text-xs",children:"Success"}),e.jsx(ae,{value:"failed",className:"text-xs",children:"Failed"})]})]}),s?e.jsxs(Ce,{value:y,onValueChange:i=>{I(i),g()},children:[e.jsx(Ae,{className:"h-8 w-[160px] text-xs",children:e.jsx(Re,{})}),e.jsxs(Te,{children:[e.jsx(ae,{value:"all",className:"text-xs",children:"All sources"}),e.jsx(ae,{value:"source",className:"text-xs",children:c?`Only ${c}`:"This source only"})]})]}):null]})})})]})}),e.jsx(ze,{open:!!C,onOpenChange:i=>!i&&K(null),children:e.jsxs(Be,{className:"max-w-4xl max-h-[85vh] overflow-y-auto custom-scrollbar",children:[e.jsxs(qe,{children:[e.jsx(Qe,{children:"Activity details"}),e.jsx(He,{children:"Full record of what changed and who did it."})]}),C?e.jsx(Vt,{item:C}):null]})})]})}const Xe=new Map;function gt(t){let n=Xe.get(t);return n||(n={undo:{current:[]},redo:{current:[]}},Xe.set(t,n)),n}const Ye="w-full min-h-[88px] sm:min-h-[120px] resize-y rounded-md border border-input bg-background px-3 py-2 text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Jt=["Make it shorter","More technical","Add a case study","Drop the plan bullets"],Oe=40;function X(t){return JSON.stringify(t.map(n=>({title:(n.title??"").replace(/\r\n/g,`
2`),content:(n.content??"").replace(/\r\n/g,`
3`),sortOrder:n.sortOrder??0})))}function ps(t){return X(t)}function Ue(t){try{return JSON.parse(t).map((s,c)=>({title:s.title??"",content:s.content??"",sortOrder:s.sortOrder??c}))}catch{return[]}}function _e(t){return/guardrail/i.test(t)}function hs({blocks:t,onBlocksChange:n,restorePointSnap:s,historyKey:c,saveStatus:f,refining:m,onRefineWithAi:_,usingInheritedDefault:A=!1,isLead:R=!1,readOnly:x=!1,excludeGuardrails:N=!1,showNext:T=!1,nextLabel:y="Continue to Additional questions",onNext:I}
3){const[D,E]=o.useState(!0),[Y,b]=o.useState(!1),[z,H]=o.useState(""),[B,F]=o.useState([]),[C,K]=o.useState(null),[w,p]=o.useState(0),{undo:h,redo:O}=o.useMemo(()=>gt(`${c}:blocks`),[c]),$=o.useRef(!1),U=o.useRef(X(t)),P=o.useRef(null),g=o.useRef(null),i=o.useRef(""),Z=o.useMemo(()=>t.map((a,l)=>({block:a,idx:l})).filter(({block:a})=>!N||!_e(a.title)),[t,N]),k=o.useMemo(()=>Z.map(({block:a})=>a),[Z]),ie=o.useMemo(()=>k.map(a=>a.title).join("�"),[k]);o.useEffect(()=>{i.current!==ie&&(i.current=ie,F(k.map(a=>a.title).filter(Boolean)))},[ie,k]),o.useEffect(()=>{const a=X(t);if($.current){$.current=!1,U.current=a,P.current=null,g.current&&(window.clearTimeout(g.current),g.current=null);return}a!==U.current&&(P.current===null&&(P.current=U.current),g.current&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{const l=P.current,u=X(t);l&&l!==u&&(h.current.push(l),h.current.length>Oe&&h.current.shift(),O.current=[],p(v=>v+1)),U.current=u,P.current=null,g.current=null},450))},[t]);const be=o.useRef("");be.current=X(t),o.useEffect(()=>()=>{g.current&&window.clearTimeout(g.current);const a=P.current;a&&a!==be.current&&(h.current.push(a),h.current.length>Oe&&h.current.shift(),O.current=[])},[h,O]);const pe=h.current.length>0,ye=O.current.length>0,we=!!s&&s!==X(t),le=k.filter(a=>a.content.trim()).length,ce=k.reduce((a,l)=>a+l.content.length,0),de=B.filter(a=>k.some(l=>l.title===a)).length,V=o.useCallback(a=>{n(a.map((l,u)=>({...l,sortOrder:u})))},[n]),W=()=>{g.current&&(window.clearTimeout(g.current),g.current=null);const a=P.current,l=X(t);a&&a!==l&&(h.current.push(a),h.current.length>Oe&&h.current.shift(),O.current=[]),U.current=l,P.current=null},he=()=>{W();const a=h.current.pop();a&&(O.current.push(X(t)),$.current=!0,U.current=a,n(Ue(a)),p(l=>l+1))},ve=()=>{W();const a=O.current.pop();a&&(h.current.push(X(t)),$.current=!0,U.current=a,n(Ue(a)),p(l=>l+1))},je=()=>{s&&(W(),h.current.push(X(t)),O.current=[],$.current=!0,U.current=s,n(Ue(s)),p(a=>a+1))},Fe=(a,l)=>{F(u=>l?u.includes(a)?u:[...u,a]:u.filter(v=>v!==a))},se=(a,l)=>{V(t.map((u,v)=>v===a?{...u,...l}:u))},L=()=>{const a=k.length+1,l=N?t.filter(v=>_e(v.title)):[],u=N?t.filter(v=>!_e(v.title)):t;V([...u,{id:`tmp-${Date.now()}`,title:`Custom section ${a}`,content:"",sortOrder:u.length},...l])},q=()=>{if(C==null)return;const a=t[C];V(t.filter((l,u)=>u!==C)),a?.title&&F(l=>l.filter(u=>u!==a.title)),K(null)},re=async()=>{const a=z.trim();if(!a||m)return;const l=B.length>0?B:k.map(v=>v.title).filter(Boolean);await _(a,l)&&H("")};return e.jsxs("div",{className:"space-y-3",children:[x?null:e.jsxs(fe,{title:"Update with AI",open:Y,onOpenChange:b,headerActions:e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold px-2 py-0.5 rounded-full border bg-primary/10 text-primary border-primary/20",children:[e.jsx(oe,{className:"h-3 w-3"}),"AI"]}),children:[e.jsx("p",{className:"text-[10px] text-muted-foreground -mt-1",children:"Describe a change, choose which rule sections it applies to, then update. Changes autosave and apply on the next generate."}),e.jsx(ge,{className:M(Ye,"min-h-[72px]"),value:z,onChange:a=>H(a.target.value),placeholder:'e.g. "Make it shorter" or "Tighten the Output Format closing"',disabled:m}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Jt.map(a=>e.jsx("button",{type:"button",disabled:m,className:"h-7 px-2.5 rounded-full text-[10px] font-semibold border border-border bg-background hover:bg-muted/60 text-foreground disabled:opacity-50",onClick:()=>H(a),children:a},a))}),k.length>0?e.jsxs("div",{className:"rounded-md border border-border bg-muted/20 p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-semibold text-foreground",children:"Apply this update to"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Only checked sections are rewritten by AI."})]}),e.jsxs("span",{className:"text-[10px] font-semibold text-muted-foreground shrink-0",children:[de,"/",k.length," selected"]})]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-1.5",children:Z.map(({block:a,idx:l},u)=>{const v=a.title||`Section ${u+1}`,ee=B.includes(a.title);return e.jsxs("label",{className:M("flex items-center gap-2 rounded-md border px-2 py-1.5 text-[11px] cursor-pointer transition-colors",ee?"border-primary/30 bg-primary/5 text-foreground":"border-border/80 bg-background text-muted-foreground hover:bg-muted/40"),children:[e.jsx(rt,{checked:ee,onCheckedChange:ne=>Fe(a.title,ne===!0),disabled:m||!a.title.trim()}),e.jsx("span",{className:"w-5 h-5 rounded bg-primary/15 text-primary text-[10px] font-bold flex items-center justify-center shrink-0",children:u+1}),e.jsx("span",{className:"min-w-0 truncate font-medium",children:v})]},a.id??`${l}-${v}`)})}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-[10px]",children:[e.jsx("button",{type:"button",className:"text-primary hover:underline font-medium",disabled:m,onClick:()=>F(k.map(a=>
3a.title).filter(Boolean)),children:"Select all"}),e.jsx("button",{type:"button",className:"text-muted-foreground hover:underline",disabled:m,onClick:()=>F([]),children:"Clear"})]})]}):null,e.jsxs(S,{type:"button",size:"sm",className:"h-8 text-xs gap-1 w-full sm:w-auto bg-primary hover:bg-primary/90 text-primary-foreground",disabled:m||!z.trim()||k.length===0,onClick:()=>{re()},children:[m?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(oe,{className:"h-3.5 w-3.5"}),"Update with AI"]})]}),e.jsxs(fe,{title:x?"Playbook rules":"Open and edit the prompt manually",open:D,onOpenChange:E,headerActions:e.jsxs("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full border bg-primary/10 text-primary border-primary/20",children:[k.length," block",k.length===1?"":"s"]}),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 -mt-1 mb-1",children:[e.jsx(ct,{text:"These blocks are the playbook sent on every generate — including any custom sections you add. Editing a source without a saved playbook starts empty and saves for that source — other sources stay unchanged."}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:x?"View only — a CRM Admin manages these rules. Use Generate and the feedback box to adjust your letter.":A?"Empty until you add this source’s playbook. Changes save for this source after you stop typing.":R?`${le}/${k.length} filled · ${ce.toLocaleString()} characters`:`${le}/${k.length} filled · ${ce.toLocaleString()} characters · custom sections are followed on generate`})]}),Z.length===0?e.jsx(dt,{size:"compact",minHeight:100,title:"No instruction blocks yet",subtitle:x?"A CRM Admin has not added rules for this source yet.":"Add a section to build this playbook."}):e.jsx("div",{className:"space-y-3",children:Z.map(({block:a,idx:l},u)=>e.jsxs("div",{className:"rounded-lg border border-border bg-background p-3 space-y-2 relative",children:[e.jsxs("div",{className:"flex items-center gap-2 pr-8",children:[e.jsx("span",{className:"w-6 h-6 rounded-md bg-primary text-[10px] font-bold flex items-center justify-center text-primary-foreground shrink-0",children:u+1}),e.jsx(nt,{className:"h-8 text-xs font-medium",value:a.title,readOnly:x,onChange:v=>{const ee=a.title,ne=v.target.value;se(l,{title:ne}),F(G=>G.includes(ee)?G.map(Ne=>Ne===ee?ne:Ne).filter(Boolean):G)},placeholder:"Section title"})]}),x?null:e.jsx("button",{type:"button",className:"absolute top-2.5 right-2.5 p-1 rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":`Remove ${a.title||`section ${u+1}`}`,onClick:()=>K(l),children:e.jsx(at,{className:"h-3.5 w-3.5"})}),e.jsx(ge,{className:M(Ye,x&&"bg-muted/30 text-muted-foreground"),value:a.content,readOnly:x,onChange:v=>se(l,{content:v.target.value}),placeholder:"Rules for this section…"}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[a.content.length," characters · used on every generate"]})]},a.id??`block-${l}`))}),x?null:e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1 border-t border-border",children:[e.jsxs(S,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:L,children:[e.jsx(ot,{className:"h-3 w-3"}),"Add block"]}),e.jsxs(S,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",disabled:!pe,onClick:he,children:[e.jsx(ut,{className:"h-3 w-3"}),"Undo"]}),e.jsxs(S,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",disabled:!ye,onClick:ve,children:[e.jsx(mt,{className:"h-3 w-3"}),"Redo"]}),e.jsxs(S,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",disabled:!we,onClick:je,children:[e.jsx(it,{className:"h-3 w-3"}),"Restore previous version"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground ml-auto",children:f==="saving"?"Saving…":f==="saved"?"Saved":f==="error"?"Save failed":"Unsaved changes"})]})]}),T&&I?e.jsx("div",{className:"flex justify-end pt-1",children:e.jsxs(S,{type:"button",size:"sm",className:"h-8 text-xs gap-1 bg-primary hover:bg-primary/90 text-primary-foreground",onClick:I,children:[y,e.jsx(Pt,{className:"h-3.5 w-3.5"})]})}):null,e.jsx(lt,{isOpen:C!=null,onClose:()=>K(null),title:"Remove this section?",description:C!=null?`“${t[C]?.title||`Section ${C+1}`}” will be removed from this playbook. Changes autosave and cannot be undone after save unless you use Undo or Restore.`:"",confirmText:"Remove section",variant:"destructive",onConfirm:q})]})}const Ee="w-full min-h-[88px] sm:min-h-[120px] resize-y rounded-md border border-input bg-background px-3 py-2 text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Ze=`Answer client screening / additional questions directly and concisely. These are short box answers — NEVER a cover letter.
4
5HARD RULES:
61. Plain answer text only. No greeting (Hi/Hello), no "Relevant case study" / "WHY WE'RE THE RIGHT FIT" / Approach sections, no emoji letter template, no closing ("Looking forward…"), no sign-off ("Warm regards," / "Best regards," / name line).
72. 2–5 sentences (or a short numbered list only when the question asks for steps). O
7ne question = one focused answer.
83. Use only FAQ facts and case-study evidence from the playbook. Never invent clients, metrics, certifications, frameworks, or URLs.
94. Links/refs: include a stored Loom/demo/URL ONLY when THIS question asks for experience, proof, demo, portfolio, or a similar project — and only that question-matched study's own link. Never paste the same URL into every answer. Stack/cert/process/rate questions get NO link.
105. If asked whether you freelanced, worked as a freelancer, on Upwork, independently, or as a contractor: answer in a professional tone about relevant production experience and remote collaboration. Do NOT mention Upwork, freelance, freelancing, independent contractor, marketplace platforms, or gigs. Sound like a genuine professional / agency teammate.
116. Never write meta-instructions ("Answer from FAQ…", "Do not invent…") as the client-facing answer — write the actual reply the client should read.`,Xt=["Answer more briefly","Name my rate","Be more specific about timelines"],Yt=[{category:"Experience",question:"Describe your recent experience with similar projects",answer:"Lead with one closest case study from the Case Studies Library: what was built, stack, the hard part, and the outcome. Include a stored demo/Loom URL only if that study has one. Keep it to 3–5 sentences."},{category:"Style",question:"Answer style when a fact is genuinely missing",answer:'Never write phrases like "I do not have verified information" or "I cannot confirm." Instead offer a short next step: what you would verify on a quick call, or the closest related experience you do have from the FAQ / case studies. Stay confident and specific.'},{category:"Stack",question:"What frameworks have you worked with?",answer:"Answer from FAQ and case-study stacks only. Group Frontend / Backend / Other briefly. Name versions only when stored. Do not invent frameworks."},{category:"Credentials",question:"Please list any certifications related to this project",answer:"Prefer practical verifiable proof (shipped work, demos, case-study outcomes) over generic cert lists. Only name certifications that appear in the FAQ. If none are listed, say you lead with production proof and offer to share relevant work."},{category:"Process",question:"HOW I USE AI IN MY WORKFLOW",answer:"Explain AI-assisted development honestly: draft → human review → tests → ship. Emphasize judgment, architecture decisions, and code ownership stay with the team. Never claim unsupervised AI delivery."},{category:"Process",question:"When you join a new codebase, what's your process in the first week?",answer:"1) Understand business goals and success metrics. 2) Review architecture, critical paths, and deploy flow. 3) Run the app locally and map ownership. 4) Ship a small safe improvement. 5) Align on priorities with the client. Keep it concrete and short."}];function ft(t=!0){return Yt.map(n=>({...n,answer:t?"":n.answer}))}function te(t){return JSON.stringify(t.map(n=>({category:(n.category??"").replace(/\r\n/g,`
12`),question:(n.question??"").replace(/\r\n/g,`
13`),answer:(n.answer??"").replace(/\r\n/g,`
14`)})))}function xs(t){return te(t)}function Le(t){try{return JSON.parse(t).map(s=>({category:s.category??"Operational",question:s.question??"",answer:s.answer??""}))}catch{return[]}}function gs(t,n){let s=t.trim();if(!s)return"";if(s=s.replace(/^```(?:json|text|markdown)?\s*/i,"").replace(/\s*```$/i,"").trim(),s.startsWith("{"))try{const m=JSON.parse(s),_=n.trim().toLowerCase(),A=Array.isArray(m.items)?m.items:Array.isArray(m.answers)?m.answers:[],R=A.find(x=>(x.question||"").trim().toLowerCase()===_)?.answer?.trim();if(R)return Se(R);if(A.length===1&&A[0]?.answer?.trim())return Se(A[0].answer.trim());if(typeof m.answer=="string"&&m.answer.trim())return Se(m.answer.trim())}catch{}const c=n.trim(),f=s.split(/\r?\n/);return c&&f[0]&&f[0].toLowerCase().includes(c.toLowerCase().slice(0,Math.min(40,c.length)))&&(s=f.slice(1).join(`
15`).trim()),s=s.replace(/^A(?:nswer)?\s*[:).\-–—]\s*/i,"").trim(),Se(s||t.trim())}function Se(t){let n=t.replace(/\r\n/g,`
16`).trim();if(!n)return"";n=n.replace(/^\s*(?:relevant\s+case\s+study|✅?\s*why\s+we['’]?re\s+the\s+right\s+fit|approach)\s*$/gim,"").replace(/\n{3,}/g,`
17
18`).trim();const s=n.split(`
19`);let c=0;for(;c<s.length&&!s[c].trim();)c++;for(;c<s.length&&/^(hi|hello|hey|dear)\b/i.test(s[c].replace(/[*_~`#]/g,"").trim());)c++;if(c>0){for(;c<s.length&&!s[c].trim();)c++;n=s.slice(c).join(`
20`).trim()}return n=n.replace(/\n+(?:looking\s+forward\s+to[^\n]*\n+)?(?:warm\s+|best\s+|kind\s+)?regards?,?\s*(?:\n+[\s\S]*)?$/i,"").replace(/\n+(?:sincerely|cheers|thanks(?:\s+again)?|best|yours\s+truly)[,!]?\s*(?:\n+[\s\S]*)?$/i,"").trim(),n}function fs({faqs:t,onFaqsChange:n,screeningPrompt:s,onScreeningPromptChange:c,restorePointSnap:f,historyKey:m,saveStatus:_,refining:A,answering:R,answeringIndex:x,hasJobBrief:N=!1,studioProvi
20der:T,onStudioProviderChange:y,onRefineWithAi:I,onGenerateAnswer:D,onGenerateAllAnswers:E,usingInheritedDefault:Y=!1,panel:b="combined",rightOpen:z,onRightOpenChange:H,onRequestCollapse:B,rulesReadOnly:F=!1}){const{toast:C}=tt(),{pathPrefix:K}=$t(),{data:w,isLoading:p,enabled:h}=Wt(),[O,$]=o.useState(!0),[U,P]=o.useState(!0),[g,i]=o.useState(!1),[Z,k]=o.useState(!0),ie=b==="questions"||b==="combined",be=b==="rules"||b==="combined",pe=b==="combined",ye=pe?z??Z:!0,we=r=>{H?H(r):k(r)},[le,ce]=o.useState(""),[de,V]=o.useState([]),[W,he]=o.useState(null),[ve,je]=o.useState(null),[Fe,se]=o.useState(0),{undo:L,redo:q}=o.useMemo(()=>gt(`${m}:faqs:${b}`),[m,b]),re=o.useRef(!1),a=o.useRef(te(t)),l=o.useRef(null),u=o.useRef(null),v=o.useRef(""),ee=o.useMemo(()=>t.map(r=>r.question).join("�"),[t]);o.useEffect(()=>{v.current!==ee&&(v.current=ee,V(t.map(r=>r.question).filter(Boolean)))},[ee,t]),o.useEffect(()=>{const r=te(t);if(re.current){re.current=!1,a.current=r,l.current=null,u.current&&(window.clearTimeout(u.current),u.current=null);return}if(r!==a.current)return l.current===null&&(l.current=a.current),u.current&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{l.current!=null&&l.current!==r&&(L.current=[...L.current,l.current].slice(-40),q.current=[],se(d=>d+1)),a.current=r,l.current=null,u.current=null},400),()=>{u.current&&(window.clearTimeout(u.current),u.current=null)}},[t]);const ne=o.useRef("");ne.current=te(t),o.useEffect(()=>()=>{const r=l.current;r!=null&&r!==ne.current&&(L.current=[...L.current,r].slice(-40),q.current=[])},[L,q]);const G=o.useCallback(r=>{n(r.map((d,j)=>({...d,category:d.category||"Operational"})))},[n]),Ne=t.filter(r=>r.question.trim()&&r.answer.trim()).length,bt=t.reduce((r,d)=>r+d.answer.length,0),yt=de.length,wt=L.current.length>0,vt=q.current.length>0,jt=!!f&&f!==te(t),Nt=(r,d)=>{r.trim()&&V(j=>d?j.includes(r)?j:[...j,r]:j.filter(Q=>Q!==r))},Pe=(r,d)=>{G(t.map((j,Q)=>Q===r?{...j,...d}:j))},kt=()=>{const r=t.length+1;G([...t,{id:`tmp-${Date.now()}`,category:"Custom",question:`Custom question ${r}`,answer:""}])},St=()=>{if(W==null)return;const r=t[W];G(t.filter((d,j)=>j!==W)),r?.question&&V(d=>d.filter(j=>j!==r.question)),he(null)},Ct=()=>{const r=L.current[L.current.length-1];r&&(L.current=L.current.slice(0,-1),q.current=[...q.current,te(t)].slice(-40),re.current=!0,G(Le(r)),se(d=>d+1))},At=()=>{const r=q.current[q.current.length-1];r&&(q.current=q.current.slice(0,-1),L.current=[...L.current,te(t)].slice(-40),re.current=!0,G(Le(r)),se(d=>d+1))},Rt=()=>{f&&(L.current=[...L.current,te(t)].slice(-40),q.current=[],re.current=!0,G(Le(f)),se(r=>r+1))},Tt=async()=>{const r=le.trim();if(!r||A)return;const d=de.length>0?de:t.map(Q=>Q.question).filter(Boolean);await I(r,d)&&ce("")},J=A||R;async function It(r){const d=t[r]?.answer?.trim()||"";if(!d){C({title:"Nothing to copy",description:"This question has no answer yet.",variant:"destructive"});return}try{await Bt(d),je(r),window.setTimeout(()=>je(j=>j===r?null:j),1600),C({title:"Copied",description:"Copied with bold text ready to paste as-is."})}catch{C({title:"Copy failed",description:"Could not copy to clipboard.",variant:"destructive"})}}return e.jsxs("div",{className:M(b==="combined"&&"flex flex-col lg:flex-row gap-3 items-stretch min-h-0 relative",b==="questions"&&"w-full min-w-0 space-y-3",b==="rules"&&"w-full min-w-0 h-full min-h-0 space-y-3"),children:[ie?e.jsx("div",{className:M("min-w-0 w-full space-y-3",b==="combined"&&"flex-1"),children:e.jsxs(fe,{title:"Open and edit the prompt manually",open:O,onOpenChange:$,headerActions:e.jsxs("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full border bg-primary/10 text-primary border-primary/20",children:[t.length," block",t.length===1?"":"s"]}),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 -mt-1 mb-1",children:[e.jsx(ct,{text:"These Q&A blocks are listed by default. Customize any question, add or remove blocks, then generate answers from the current playbook, Rules and Guardrails, and source. Job selected on Proposal generation is reused when present."}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Y?"Starter questions for this source. Edit or generate answers to save them here.":`${Ne}/${t.length}
20 filled · ${bt.toLocaleString()} characters`}),N?null:e.jsx("span",{className:"text-[10px] text-amber-700 dark:text-amber-400",children:"No job selected — answers use playbook, rules, and source only. Select a job on Proposal generation to personalize."})]}),t.length===0?e.jsx(dt,{size:"compact",minHeight:100,title:"No additional questions yet",subtitle:"Add a question block or load the default question list."}):e.jsx("div",{className:"space-y-3",children:t.map((r,d)=>{const j=R&&x===d;return e.jsxs("div",{className:"rounded-lg border border-border bg-background p-3 space-y-2 relative",children:[e.jsxs("div",{className:"flex items-center gap-2 pr-8",children:[e.jsx("span",{className:"w-6 h-6 rounded-md bg-primary text-[10px] font-bold flex items-center justify-center text-primary-foreground shrink-0",children:d+1}),e.jsx(nt,{className:"h-8 text-xs font-medium",value:r.question,onChange:Q=>{const ke=r.question,$e=Q.target.value;Pe(d,{question:$e}),V(Ie=>Ie.includes(ke)?Ie.map(De=>De===ke?$e:De).filter(Boolean):Ie)},placeholder:"Question / topic"})]}),e.jsx("button",{type:"button",className:"absolute top-2.5 right-2.5 p-1 rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":`Remove ${r.question||`question ${d+1}`}`,onClick:()=>he(d),children:e.jsx(at,{className:"h-3.5 w-3.5"})}),e.jsx(ge,{className:Ee,value:r.answer,onChange:Q=>Pe(d,{answer:Q.target.value}),placeholder:"Answer for this question — generate from playbook, job, and source, or write your own…"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[r.answer.length," characters · generated from playbook, job, and source"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs(S,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",disabled:!r.answer.trim(),title:"Copy answer with bold formatting for paste",onClick:()=>{It(d)},children:[ve===d?e.jsx(st,{className:"h-3 w-3 text-teal-600"}):e.jsx(Dt,{className:"h-3 w-3"}),ve===d?"Copied":"Copy"]}),e.jsxs(S,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",disabled:J||!r.question.trim(),title:N?"Generate from playbook, rules, job, and source":"Generate from playbook, rules, and source (select a job on Proposal generation to personalize)",onClick:()=>{D(d)},children:[j?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(oe,{className:"h-3 w-3"}),"Generate answer"]})]})]})]},r.id??`faq-${d}`)})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1 border-t border-border",children:[e.jsxs(S,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:kt,children:[e.jsx(ot,{className:"h-3 w-3"}),"Add block"]}),E&&t.some(r=>r.question.trim())?e.jsxs(S,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",disabled:J,title:N?"Generate all answers from playbook, rules, job, and source":"Generate all answers from playbook, rules, and source (select a job on Proposal generation to personalize)",onClick:()=>{E()},children:[R&&x===-1?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(oe,{className:"h-3 w-3"}),"Generate all answers"]}):null,t.length===0?e.jsx(S,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:()=>G(ft(!0)),children:"Load starter questions"}):null,e.jsxs(S,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",disabled:!wt,onClick:Ct,children:[e.jsx(ut,{className:"h-3 w-3"}),"Undo"]}),e.jsxs(S,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",disabled:!vt,onClick:At,children:[e.jsx(mt,{className:"h-3 w-3"}),"Redo"]}),e.jsxs(S,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",disabled:!jt,onClick:Rt,children:[e.jsx(it,{className:"h-3 w-3"}),"Restore previous version"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground ml-auto",children:_==="saving"?"Saving…":_==="saved"?"Saved":_==="error"?"Save failed":"Unsaved changes"})]})]})}):null,be&&ye?e.jsxs("aside",{className:M("w-full shrink-0 space-y-3",b==="combined"&&"lg:w-[min(100%,22rem)] xl:w-[24rem] lg:sticky lg:top-0",b==="rules"&&"h-full min-h-0 overflow-y-auto custom-scrollbar"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[11px] font-semibold text-foreground",children:"Rules & AI"}),b==="rules"&&B?e.jsx(S,{type:"button",size:"sm",variant:"outline",className:"h-7 w-7 p-0 shrink-0",title:"Collapse right panel","aria-label":"Collapse right panel",onClick:B,children:e.jsx(Ke,{className:"h-3.5 w-3.5"})}):pe?e.jsx(S,{type:"button",size:"sm",variant:"outline",className:"h-7 w-7 p-0 shrink-0",title:"Collapse right panel","aria-label":"Collapse right panel",onClick:()=>we(!1),children:e.jsx(Ke,{className:"h-3.5 w-3.5"})}):null]}),e.jsxs(fe,{title:"Rules and Guardrails",open:U,onOpenChange:P,headerActions:e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold px-2 py-0.5 rounded-full border bg-primary/10 text-primary border-primary/20",children:"Rules"}),children:[e.jsx("p",{className:"text-[10px] text-muted-foreground -mt-1",children:"Instructions the AI follows when generating screening answers. Separate from the cover-letter playbook — answers stay short and never use letter sign-offs."}),e.jsx(ge,{className:M(Ee,"min-h-[120px]",F&&"bg-muted/30 text-muted-foreground"),value:s,onChange:r=>c(r.target.value),placeholder:"e.g. Answer directly in 2–5 sentences. No greetings or Warm regards. Only paste a demo link 
20when the question asks for proof…",disabled:J,readOnly:F}),F?null:e.jsx(S,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs w-full",disabled:J||s.trim()===Ze.trim(),onClick:()=>c(Ze),children:"Use recommended rules"}),e.jsx("p",{className:"text-[10px] text-muted-foreground leading-relaxed",children:"Recommended rules ban letter sign-offs, repeated demo links, and marketplace wording on freelance probes."}),e.jsxs("div",{className:"rounded-lg border border-border bg-card overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-2 border-b border-border",children:[e.jsx("div",{className:"text-xs font-semibold",children:"Model"}),e.jsx("p",{className:"text-[10px] text-muted-foreground leading-relaxed mt-0.5",children:"Which model writes additional-question answers. Same enabled models as Proposal generation."})]}),e.jsx("div",{className:"px-3 py-2.5",children:p?e.jsxs("div",{className:"h-9 rounded-md border border-input bg-background flex items-center px-3 text-[11px] text-muted-foreground",children:[e.jsx(me,{className:"h-3 w-3 animate-spin mr-2"}),"Loading…"]}):h.length===0?e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["No enabled models."," ",e.jsx(zt,{to:`${K}/sales/ai-settings`,className:"text-primary hover:underline",children:"AI Settings"})]}):e.jsxs(Ce,{value:T||(h.some(r=>r.key===w?.activeProvider)?w?.activeProvider:h[0]?.key),onValueChange:r=>y(r),children:[e.jsx(Ae,{className:"h-9 text-xs",children:e.jsx(Re,{placeholder:"Select a model"})}),e.jsx(Te,{children:h.map(r=>e.jsx(ae,{value:r.key,children:r.display},r.key))})]})})]})]}),e.jsxs(fe,{title:"Update with AI",open:g,onOpenChange:i,headerActions:e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold px-2 py-0.5 rounded-full border bg-primary/10 text-primary border-primary/20",children:[e.jsx(oe,{className:"h-3 w-3"}),"AI"]}),children:[e.jsx("p",{className:"text-[10px] text-muted-foreground -mt-1",children:"Describe a change, choose which question blocks it applies to, then update. Changes autosave."}),e.jsx(ge,{className:M(Ee,"min-h-[72px]"),value:le,onChange:r=>ce(r.target.value),placeholder:"e.g. answer in one sentence, always name my rate…",disabled:J}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Xt.map(r=>e.jsx("button",{type:"button",disabled:J,className:"h-7 px-2.5 rounded-full text-[10px] font-semibold border border-border bg-background hover:bg-muted/60 text-foreground disabled:opacity-50",onClick:()=>ce(r),children:r},r))}),t.length>0?e.jsxs("div",{className:"rounded-md border border-border bg-muted/20 p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-semibold text-foreground",children:"Apply to"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Only checked questions are rewritten."})]}),e.jsxs("span",{className:"text-[10px] font-semibold text-muted-foreground shrink-0",children:[yt,"/",t.length]})]}),e.jsx("div",{className:"grid grid-cols-1 gap-1.5 max-h-40 overflow-y-auto custom-scrollbar",children:t.map((r,d)=>{const j=r.question||`Question ${d+1}`,Q=de.includes(r.question);return e.jsxs("label",{className:M("flex items-center gap-2 rounded-md border px-2 py-1.5 text-[11px] cursor-pointer transition-colors",Q?"border-primary/30 bg-primary/5 text-foreground":"border-border/80 bg-background text-muted-foreground hover:bg-muted/40"),children:[e.jsx(rt,{checked:Q,onCheckedChange:ke=>Nt(r.question,ke===!0),disabled:J||!r.question.trim()}),e.jsx("span",{className:"w-5 h-5 rounded bg-primary/15 text-primary text-[10px] font-bold flex items-center justify-center shrink-0",children:d+1}),e.jsx("span",{className:"min-w-0 truncate font-medium",children:j})]},r.id??`${d}-${j}`)})}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-[10px]",children:[e.jsx("button",{type:"button",className:"text-primary hover:underline font-medium",disabled:J,onClick:()=>V(t.map(r=>r.question).filter(Boolean)),children:"Select all"}),e.jsx("button",{type:"button",className:"text-muted-foreground hover:underline",disabled:J,onClick:()=>V([]),children:"Clear"})]})]}):null,e.jsxs(S,{type:"button",size:"sm",className:"h-8 text-xs gap-1 w-full bg-primary hover:bg-primary/90 text-primary-foreground",disabled:J||!le.trim()||t.length===0,onClick:()=>{Tt()},children:[A?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(oe,{className:"h-3.5 w-3.5"}),"Update with AI"]})]})]}):null,pe&&!ye?e.jsx("div",{className:"lg:hidden w-full",children:e.jsxs(S,{type:"button",size:"sm",variant:"outline",className:"h-8 text-xs w-full gap-1",onClick:()=>we(!0),children:[e.jsx(oe,{className:"h-3.5 w-3.5"}),"Show Rules & AI"]})}):null,ie?e.jsx(lt,{isOpen:W!=null,onClose:()=>he(null),title:"Remove this question?",description:W!=null?`“${t[W]?.question||`Question ${W+1}`}” will be removed from Additional questions. Changes autosave and cannot be undone after save unless you use Undo or Restore.`:"",confirmText:"Remove question",variant:"destructive",onConfirm:St}):null]})}function bs(t){const n=s=>(s??"").replace(/\r\n/g,`
21`);return JSON.stringify({name:n(t.name),role:n(t.role),niche:n(t.niche),isActive:!!t.isActive,screeningPrompt:n(t.screeningPrompt),abModifierA:n(t.abModifierA),abModifierB:n(t.abModifierB),blocks:t.blocks.map(s=>({title:n(s.title),content:n(s.content)})),caseStudies:t.caseStudies.map(s=>({name:n(s.name),what:n(s.what),stackApproach:n(s.stackApproach),result:n(s.result),link:n(s.link)})),faqs:t.faqs.map(s=>({category:n(s.category),question:n(s.question),answer:n(s.answer)}))})}function ys(t){if(t.id&&String(t.id).startsWith("tmp-")){const{id:n,...s}=t;return s}return t}function ws(t,n,s){return{...t,sourceAccountId:n,name:s||t.name,role:"",niche:"",screeningPrompt:"",abModifierA:"",abModifierB:"",blocks:t.blocks.map(c=>({...c,content:""})),caseStudies:[],faqs:ft(!0)}}function vs(t){return["upwork","linkedin"].find(s=>Ht(s).matchesSource(t))??null}export{us as A,ms as C,os as F,hs as P,ls as U,ds as a,ws as b,xs as c,ys as d,bs as e,fs as f,gs as g,vs as h,cs as i,ps as p,ft as s,is as u};

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.