1import{c as u,r as n,a as g,j as e,L as h}from"./index-tNhE6V5Q.js";function b(t){if(t.selected_rank){const a=t.selected_rank===1?"bg-yellow-100 text-yellow-800":t.selected_rank===2?"bg-gray-100 text-gray-700":"bg-orange-50 text-orange-700";return e.jsxs("span",{className:`text-xs px-2 py-0.5 rounded ${a}`,children:["Rank #",t.selected_rank]})}return t.status==="verified"?e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-green-50 text-green-700",children:"Verified"}):t.status==="landing_mismatch"?e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-50 text-amber-700",children:"Landing mismatch"}):t.status==="iterated"?e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-purple-50 text-purple-700",children:"Iterated"}):t.status==="published"?e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-blue-50 text-blue-700",children:"Published"}):e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-gray-100 text-gray-600",children:t.status||"generated"})}function j(){const{productId:t}=u(),[a,m]=n.useState([]),[d,p]=n.useState(!0);n.useEffect(()=>{t&&(async()=>{try{const s=await g.get(`/v1/creative-engine/candidates/${t}?limit=200`);m(s.candidates||[])}finally{p(!1)}})()},[t]);const i=[...a].sort((s,r)=>{const l=s.selected_rank??99,x=r.selected_rank??99;if(l!==x)return l-x;const o=s.composite_score??-1,c=r.composite_score??-1;return c!==o?c-o:(r.created_at||"").localeCompare(s.created_at||"")});return e.jsxs("div",{className:"p-6 max-w-[1400px] mx-auto",children:[e.jsxs("header",{className:"mb-4",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Ad Candidates"}),e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:d?"Loadingâ¦":`${a.length} candidate${a.length===1?"":"s"} for this product. Click any to refine via chat.`})]}),d?null:i.length===0?e.jsx("div",{className:"text-gray-500 text-sm border border-dashed border-gray-300 rounded p-10 text-center",children:"No candidates yet. Run the creative engine first."}):e.jsx("div",{className:"space-y-2",children:i.map(s=>e.jsx(h,{to:`/campaigns/iterate/${s.id}`,className:"block border border-gray-200 hover:border-blue-400 rounded p-4 bg-white transition",children:e.jsxs("div",{className:"flex items-start gap-4",children:[s.visual_url?e.jsx("img",{src:s.visual_url,alt:"",className:"w-20 h-20 object-cover rounded border border-gray-200 flex-shrink-0",loading:"lazy"}):e.jsx("div",{className:"w-20 h-20 bg-gray-100 border border-gray-200 rounded flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[b(s),e.jsx("span",{className:"text-xs text-gray-500",children:s.hook_angle}),(s.iteration_number||1)>1&&e.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-purple-50 text-purple-700 rounded",children:["iter ",s.iteration_number]}),(s.claim_violations_high??0)>0&&e.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-red-50 text-red-700 rounded",children:["â ",s.claim_violations_high]})]}),e.jsx("div",{className:"font-medium text-sm",children:(s.headlines||[])[0]||s.hook_label||"(no headline)"}),e.jsx("div",{className:"text-xs text-gray-600 mt-0.5 truncate",children:s.target_persona})]}),e.jsxs("div",{className:"text-right text-xs text-gray-600 flex-shrink-0",children:[s.composite_score!=null&&e.jsxs("div",{children:["score ",e.jsx("strong",{className:"text-gray-800",children:s.composite_score.toFixed(1)})]}),s.predicted_roas!=null&&e.jsxs("div",{children:["ROAS ",e.jsxs("strong",{className:"text-gray-800",children:[s.predicted_roas.toFixed(1),"x"]})]}),s.predicted_ctr_pct!=null&&e.jsxs("div",{children:["CTR ",e.jsxs("strong",{className:"text-gray-800",children:[s.predicted_ctr_pct.toFixed(1),"%"]})]})]})]})},s.id))})]})}export{j 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.