PageSourceSearch

https://socialbrilliance.ai/assets/Strategy-ifI8w8Cq.js

js socialbrilliance.ai collected 2026-10-05 15:07:41 UTC 262,647 bytes, 873 lines download raw bytes

1import{c as hr,r as g,t as de,j as e,Y as Tn,I as rt,E as se,B as _e,L as Pt,A as or,_ as ka,l as Z,F as Mt,k as is,T as lt,S as Lt,v as os,g as De,s as Je,X as br,b as kt,e as yr,o as lr,i as Ps,Z as Rn,Q as Sa,R as ns,h as ws,$ as $a,a as Ca,C as Ta,a0 as Jr,a1 as Qr,a2 as Ra,P as cr,a3 as Aa,H as za,m as Ea,x as Ia,a4 as Pa,V as La,p as An,d as zn,a5 as Ba,a6 as Ns,a7 as Da,a8 as Ma,a9 as Oa,aa as Ua,u as Fa,ab as qa,ac as ks,ad as Kr,ae as Ga,af as Ha,ag as Wa,ah as Ya}from"./index-BRZCj0Re.js";import{c as _r,n as Vs,g as En,d as Va,E as In,s as Ja,a as Ss,b as dr,r as Qa,e as Ka,f as Js,h as Xr,i as Xa,j as Za,k as ei,l as ti,F as Zr,m as si,H as ri,o as ni,R as Qs}from"./ConfidenceBadge-6vtgW72w.js";import{L as Pn}from"./link-2-dH9oFIxo.js";import{T as Ln}from"./textarea-qYbQ7l9N.js";import{C as Bt}from"./chevron-up-CKR1K-Xb.js";import{C as pr}from"./chevron-down-CxZl0YU8.js";import{r as en}from"./run-meter-ux-BMC9nY3O.js";import{r as It,m as We,f as nt,s as je,p as Bn,i as $s}from"./report-qa-BqLJeMRX.js";import{C as ai}from"./compass-CKhwCCK2.js";import{C as Dn}from"./clock-DzJjljJM.js";import{A as ii}from"./arrow-up-right-Kz86cU9H.js";import{A as oi}from"./arrow-down-right-BPBgiwao.js";import{M as vr}from"./minus-b9Z8p4tW.js";import{G as Mn}from"./globe-zTOOlU6I.js";import{L as li,T as ci,H as di,a as pi,F as ui,R as ur,d as mi,P as xi}from"./diagnosis-findings-CqUy9fmo.js";import{T as jr}from"./trending-down--hx7wGvs.js";import{f as ct}from"./format-QYTbuQ-l.js";import{T as gi,a as fi,b as Xt,c as Zt}from"./tabs-DCPd9NRa.js";import{F as hi}from"./file-down-XQsP816Y.js";import{E as On}from"./eye-oVG2_fbt.js";import{A as tn,g as bi}from"./audience-presets-BzG7fYsQ.js";import{S as Un,a as Fn,b as yi,c as _i,d as vi}from"./sheet-B08SY-Nd.js";import{P as qn}from"./plus-DfQ5ZUn4.js";import{S as mr}from"./send-BzrHhqdO.js";import{L as Gn}from"./lightbulb-CQfwAI4X.js";import{S as Hn}from"./shield-BRc8Z5pf.js";import{D as Cs}from"./download-JWLnTCSD.js";import{A as ji}from"./arrow-left-CZ27GFxq.js";import{S as xr}from"./share-2-BRcE5BzD.js";import{B as sn}from"./briefcase-Dpr0X9FT.js";import{G as rn}from"./grid-3x3-C9ZHYrzH.js";import{B as wi}from"./building-2-DqhMrtAG.js";import{A as nn,c as W,G as an,a as Ni,S as ki,b as Si,U as $i,T as Ci,P as Ti,Q as Ri,D as Ai,C as zi,F as es,d as Ei,N as Ii,e as Pi,f as Li,g as Bi,h as Di,i as Mi,R as Oi,j as Ui,O as Fi,W as qi,k as Gi,l as Hi,E as Wi}from"./AudiencePersonaCard-B3KeKelU.js";import{h as Yi,s as Ks,d as on}from"./work-context-CpdKjtVO.js";import{g as Wn,c as Vi,r as Ji,o as Qi,s as Ki,d as Xi}from"./composer-asset-B2yJNrEH.js";import"./index-B6EJG7xU.js";import"./index-CfA_ZSKz.js";import"./index-D95Dm1ms.js";import"./use-brand-profiles-BhGXxN34.js";import"./circle-check-BQ6NcKx6.js";import"./calendar-clock-Co1liGkt.js";import"./shield-check-CLywzTCg.js";import"./dollar-sign-CmGrrqa9.js";import"./award-D3H9-_JY.js";import"./wand-sparkles-CqyNPuin.js";import"./copy-q8U8Nw7W.js";import"./book-open-D_hGwOqK.js";import"./megaphone-hR1J6cd0.js";import"./quote-WDxh1A5p.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Yn=hr("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Zi=hr("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const ln=hr("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}
16],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);function eo(t){const s=t.trim();return s.length<2?!1:s.startsWith("http")||s.includes(".")?s.replace(/^https?:\/\//,"").length>2:s.length>=2}const to=g.forwardRef(function({onSubmitUrl:s,isSubmitting:n=!1},i){const[a,o]=g.useState(""),[c,d]=g.useState(null),y=g.useRef(!1),v=g.useRef(!1),f=g.useRef(!1),_=g.useRef(!1),N=g.useRef(!1);g.useEffect(()=>{y.current||(y.current=!0,de(se.STRATEGY_ENTRY_VIEW,{surface:"guided_onboarding"}))},[]),g.useEffect(()=>{const x=()=>{N.current=!0},k={capture:!0,passive:!0};return window.addEventListener("pointerdown",x,k),window.addEventListener("touchstart",x,k),window.addEventListener("keydown",x,k),()=>{window.removeEventListener("pointerdown",x,k),window.removeEventListener("touchstart",x,k),window.removeEventListener("keydown",x,k)}},[]);const m=g.useRef(null),h=x=>{x.preventDefault();const k=new FormData(x.currentTarget).get("audit-target"),$=(typeof k=="string"&&k.trim().length>0?k:a).trim(),V=Date.now(),G=m.current;if(!(G&&G.value===$&&V-G.at<800)){if(m.current={value:$,at:V},n){de(se.STRATEGY_AUDIT_VALIDATION_ERROR,{reason:"request_in_progress",surface:"guided_onboarding"});return}if(!eo($)){d("Enter your website (e.g. yourcompany.com), a LinkedIn URL, or a company name."),de(se.STRATEGY_AUDIT_VALIDATION_ERROR,{reason:$?"unusable_target":"empty",surface:"guided_onboarding"});return}d(null),de(se.STRATEGY_AUDIT_SUBMIT_CLICK,{has_value:!0,surface:"guided_onboarding"}),s($)}};return e.jsx(Tn.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},ref:i,"data-testid":"strategy-first-screen",className:"w-full max-w-2xl mx-auto pt-3 md:pt-10",children:e.jsxs("div",{className:"px-1 text-center",children:[e.jsx("h2",{className:"text-2xl md:text-4xl font-bold text-foreground mb-2 md:mb-3",children:"See what’s weakening your message."}),e.jsx("p",{className:"text-sm md:text-base text-muted-foreground leading-relaxed mb-5 md:mb-7 max-w-xl mx-auto",children:"Paste your website. We’ll analyze the positioning, clarity, and conversion friction."}),e.jsxs("form",{onSubmit:h,className:"space-y-3 max-w-xl mx-auto",children:[e.jsxs("div",{className:"relative rounded-lg ring-2 ring-primary/25 focus-within:ring-primary/60 transition-shadow bg-card",children:[e.jsx(Pn,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-primary"}),e.jsx(rt,{value:a,onChange:x=>{o(x.target.value),c&&d(null),!f.current&&x.target.value.trim().length>0&&(f.current=!0,de(se.STRATEGY_URL_INPUT_CHANGED,{surface:"guided_onboarding",entry_method:_.current?"paste":"type"}))},onPaste:()=>{_.current=!0},onFocus:()=>{!N.current||v.current||(v.current=!0,de(se.STRATEGY_URL_INPUT_FOCUS,{surface:"guided_onboarding"}))},placeholder:"yourcompany.com",name:"audit-target","aria-label":"Your website","aria-invalid":!!c,type:"text",inputMode:"url",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,enterKeyHint:"go",className:"pl-12 h-14 md:h-16 text-base md:text-lg border-primary/30 bg-card shadow-sm"})]}),e.jsxs(_e,{type:"submit",size:"lg",disabled:n,className:"w-full h-12 md:h-14 gradient-primary text-primary-foreground gap-2 text-base font-semibold",children:[n?e.jsx(Pt,{className:"w-4 h-4 animate-spin"}):null,"Analyze my website ",e.jsx(or,{className:"w-4 h-4"})]}),c&&e.jsx("p",{role:"alert",className:"text-xs text-destructive text-left",children:c}),e.jsx("p",{className:"text-[11px] md:text-xs text-muted-foreground leading-snug",children:ka})]})]})})}),so=["idea","product concept","messaging","deck","campaign","session proposal","post/article","outreach email","landing page copy","initiative/program","press release","pitch","investor narrative","partnership outreach","other"],ro=["founders","VCs","enterprise buyers","marketers","healthcare leaders","biopharma leaders","clinical ops","patients","developers","media","partners","recruiters","general audience"],Vn=[{id:"clarity",label:"Clarity",desc:"Is the message immediately understandable?"},{id:"differentiation",label:"Differentiation",desc:"Does it stand out from competitors?"},{id:"trust",label:"Trust",desc:"Does it build credibility?"},{id:"conversion",label:"Conversion",desc:"Does it drive action?"},{id:"authority",label:"Authority",desc:"Does it establish thought leadership?"},{id:"investor_appeal",label:"Investor Appeal",desc:"Would investors respond positively?"},{id:"enterprise_appeal",label:"Enterprise Appeal",desc:"Does it resonate with enterprise buyers?"},{id:"adoption_readiness",label:"Adoption Readiness",desc:"Is the audience ready to adopt?"},{id:"speaker_acceptance",label:"Speaker Acceptance",desc:"Would a conference accept this?"},{id:"partnership_interest",label:"Partnership Interest",desc:"Does it attract strategic partners?"},{id:"lead_generation",label:"Lead Generation",desc:"Will it generate inbound leads?"}],cn=[{id:"founder_pitch",label:"Founder Pitch",emoji:"🚀",asset:"pitch",audiences:["VCs","enterprise buyers"],outcome:"investor_appeal",tone
16:"confident",industry:"Tech / SaaS"},{id:"investor_narrative",label:"Investor Narrative",emoji:"💰",asset:"investor narrative",audiences:["VCs"],outcome:"investor_appeal",tone:"data-driven",industry:""},{id:"product_launch",label:"Product Launch",emoji:"🎯",asset:"product concept",audiences:["enterprise buyers","developers"],outcome:"differentiation",tone:"bold",industry:""},{id:"enterprise_landing",label:"Enterprise Landing Page",emoji:"🏢",asset:"landing page copy",audiences:["enterprise buyers"],outcome:"conversion",tone:"professional",industry:""},{id:"thought_leadership",label:"Thought Leadership Post",emoji:"💡",asset:"post/article",audiences:["founders","marketers"],outcome:"authority",tone:"authoritative",industry:""},{id:"speaker_session",label:"Speaker / Session Application",emoji:"🎤",asset:"session proposal",audiences:["media","enterprise buyers"],outcome:"speaker_acceptance",tone:"compelling",industry:""},{id:"outreach_email",label:"Outreach Email",emoji:"📧",asset:"outreach email",audiences:["enterprise buyers"],outcome:"conversion",tone:"personalized",industry:""},{id:"partnership",label:"Partnership Proposal",emoji:"🤝",asset:"partnership outreach",audiences:["partners"],outcome:"partnership_interest",tone:"collaborative",industry:""},{id:"healthcare",label:"Healthcare / Biopharma Initiative",emoji:"🏥",asset:"initiative/program",audiences:["healthcare leaders","biopharma leaders","clinical ops"],outcome:"trust",tone:"precise",industry:"Healthcare / Biopharma"},{id:"recruitment",label:"Recruitment / Hiring Brand",emoji:"👥",asset:"messaging",audiences:["recruiters","developers"],outcome:"differentiation",tone:"authentic",industry:""},{id:"patient_comms",label:"Patient-Facing Communication",emoji:"❤️",asset:"messaging",audiences:["patients"],outcome:"clarity",tone:"empathetic",industry:"Healthcare"}],Jn=g.forwardRef(function({onSubmit:s,isLoading:n},i){const[a,o]=g.useState(""),[c,d]=g.useState(""),[y,v]=g.useState([]),[f,_]=g.useState(""),[N,m]=g.useState(!1),[h,x]=g.useState(!1),[k,w]=g.useState(null),[$,V]=g.useState(""),[G,E]=g.useState(""),[L,R]=g.useState(""),[l,T]=g.useState(""),[S,z]=g.useState(""),[C,K]=g.useState(""),[U,re]=g.useState(!1),[xe,u]=g.useState(""),[pe,q]=g.useState(""),[ye,ue]=g.useState(""),[Ee,Qe]=g.useState(""),[Ke,le]=g.useState(""),Se=I=>{v(Ce=>Ce.includes(I)?Ce.filter(at=>at!==I):[...Ce,I])},Ue=I=>{const Ce=cn.find(at=>at.id===I);Ce&&(w(I),d(Ce.asset),v([...Ce.audiences]),_(Ce.outcome),Ce.tone&&K(Ce.tone),Ce.industry&&V(Ce.industry))},we=a.trim().length>10&&c&&y.length>0&&f,ne=()=>{we&&s({content:a.trim(),assetType:c,audiences:y,outcome:f,industry:$||void 0,companyStage:G||void 0,geography:L||void 0,competitors:l||void 0,brandLink:S||void 0,toneOfVoice:C||void 0,regulated:U||void 0,platform:xe||void 0,audienceSophistication:pe||void 0,riskTolerance:ye||void 0,desiredCTA:Ee||void 0,hardConstraints:Ke||void 0,presetId:k||void 0})};return e.jsxs("div",{ref:i,className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground mb-2",children:"Quick Start — Presets"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:cn.map(I=>e.jsxs("button",{onClick:()=>Ue(I.id),className:Z("text-[11px] px-2.5 py-1.5 rounded-lg border transition-all",k===I.id?"bg-primary/10 border-primary/30 text-primary font-medium":"bg-card border-border text-muted-foreground hover:text-foreground hover:border-primary/20"),children:[I.emoji," ",I.label]},I.id))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-foreground mb-1.5 block",children:"Paste your content"}),e.jsx("p",{className:"text-[10px] text-muted-foreground mb-2",children:"Paste text, describe what you're working on, or share rough notes."}),e.jsx(Ln,{value:a,onChange:I=>o(I.target.value),placeholder:'e.g. "New AI product pitch for hospital executives" or paste your full deck copy, landing page draft, session proposal…',className:"min-h-[120px] text-sm",disabled:n}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 text-right",children:a.length>
160?`${a.length.toLocaleString()} chars`:""})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-semibold text-foreground mb-1.5 flex items-center gap-1.5",children:[e.jsx(Mt,{className:"w-3.5 h-3.5 text-primary"}),"What are you analyzing?",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:so.map(I=>e.jsx("button",{onClick:()=>d(I),className:Z("text-xs px-3 py-1.5 rounded-lg border transition-all capitalize",c===I?"bg-primary/10 border-primary/30 text-primary font-medium":"bg-card border-border text-muted-foreground hover:text-foreground hover:border-primary/20"),children:I},I))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-semibold text-foreground mb-1.5 flex items-center gap-1.5",children:[e.jsx(is,{className:"w-3.5 h-3.5 text-primary"}),"Who is this for?",e.jsx("span",{className:"text-destructive",children:"*"}),e.jsx("span",{className:"text-[10px] text-muted-foreground font-normal",children:"(select all that apply)"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:ro.map(I=>e.jsx("button",{onClick:()=>Se(I),className:Z("text-xs px-3 py-1.5 rounded-lg border transition-all capitalize",y.includes(I)?"bg-primary/10 border-primary/30 text-primary font-medium":"bg-card border-border text-muted-foreground hover:text-foreground hover:border-primary/20"),children:I},I))}),y.length>0&&e.jsxs("p",{className:"text-[10px] text-primary mt-1",children:[y.length," audience",y.length>1?"s":""," selected"]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-semibold text-foreground mb-1.5 flex items-center gap-1.5",children:[e.jsx(lt,{className:"w-3.5 h-3.5 text-primary"}),"What outcome matters most?",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Vn.map(I=>e.jsx("button",{onClick:()=>_(I.id),className:Z("text-xs px-3 py-1.5 rounded-lg border transition-all",f===I.id?"bg-primary/10 border-primary/30 text-primary font-medium":"bg-card border-border text-muted-foreground hover:text-foreground hover:border-primary/20"),title:I.desc,children:I.label},I.id))})]}),e.jsxs("div",{className:"border border-border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>m(!N),className:"w-full flex items-center justify-between px-4 py-2.5 bg-secondary/20 hover:bg-secondary/30 transition-colors",children:[e.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Context (optional)"}),N?e.jsx(Bt,{className:"w-3.5 h-3.5 text-muted-foreground"}):e.jsx(pr,{className:"w-3.5 h-3.5 text-muted-foreground"})]}),N&&e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1 block",children:"Industry"}),e.jsx(rt,{value:$,onChange:I=>V(I.target.value),placeholder:"e.g. HealthTech, SaaS",className:"text-xs h-8"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1 block",children:"Company / Stage"}),e.jsx(rt,{value:G,onChange:I=>E(I.target.value),placeholder:"e.g. Series A startup",className:"text-xs h-8"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1 block",children:"Geography"}),e.jsx(rt,{value:L,onChange:I=>R(I.target.value),placeholder:"e.g. US, Global",className:"text-xs h-8"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1 block",children:"Platform"}),e.jsx(rt,{value:xe,onChange:I=>u(I.target.value),placeholder:"e.g. LinkedIn, website, email",className:"text-xs h-8"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1 block",children:"Competitors (names or links)"}),e.jsx(rt,{value:l,onChange:I=>T(I.target.value),placeholder:"e.g. Gong, Drift, HubSpot",className:"text-xs h-8"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1 block",children:"Brand / Website link"}),e.jsx(rt,{value:S,onChange:I=>z(I.target.value),placeholder:"e.g. https://yourcompany.com",className:"text-xs h-8"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1 block",children:"Tone of voice"}),e.jsx(rt,{value:C,onChange:I=>K(I.target.value),placeholder:"e.g. bold, data-driven, empathetic",className:"text-xs h-8"})]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:I=>re(I.target.checked),className:"rounded border-border"}),"Regulated / sensitive space (healthcare, finance, legal)"]})]})]}),e.jsxs("div",{className:"border border-border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>x(!h),className:"w-full flex items-center justify-between px-4 py-2.5 bg-secondary/20 hover:bg-secondary/30 transition-colors",children:[e.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Advanced (optional)"}),h?e.jsx(Bt,{className:"w-3.5 h-3.5 text-muted-foreground"}):e.jsx(pr,{className:"w-3.5 h-3.5 text-muted-foreground"})]}),h&&e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1 block",children:"Audience sophistication"}),e.jsx("div",{className:"flex gap-1.5",children:["Low","Medium","High","Expert"].map(I=>e.jsx("button",{onClick:()=>q(I),className:Z("text-xs px-3 py-1.5 rounded-lg border transition-all",pe===I?"bg-primary/10 border-primary/30 text-primary font-medium":"bg-card border-border text-muted-foreground hover:text-foreground"),children:I},I))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1 block",children:"Risk tolerance"}),e.jsx("div",{className:"flex gap-1.5",children:["Conservative","Balanced","Bold"].map(I=>e.jsx("button",{onClick:()=>ue(I),className:Z("text-xs px-3 py-1.5 rounded-lg border transition-all",ye===I?"bg-primary/10 border-primary/30 text-primary font-medium":"bg-card border-border text-muted-foreground hover:text-foreground"),children:I},I))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1 block",children:"Desired CTA"}),e.jsx(rt,{value:Ee,onChange:I=>Qe(I.target.value),placeholder:"e.g. Book a demo, Download report",className:"text-xs h-8"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1 block",children:"Hard constraints"}),e.jsx(rt,{value:Ke,onChange:I=>le(I.target.value),placeholder:"e.g. max 500 words, no hype, compliance-safe",className:"text-xs h-8"})]})]})]}),e.jsx(_e,{onClick:ne,disabled:!we||n,className:"w-full gap-2",size:"lg",children:n?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"w-4 h-4 animate-spin"})," Analyzing…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Lt,{className:"w-4 h-4"})," Analyze Strategic Brief"]})}),!we&&a.length>0&&e.jsx("p",{className:"text-[10px] text-muted-foreground text-center",children:"Fill all 3 required fields (asset type, audience, outcome) to proceed."})]})});function Qn(){const[t,s]=g.useState([]),[n,i]=g.useState(!0),{user:a}=os(),o=De(),c=g.useCallback(async()=>{let v=null;a?v=(await Je.from("strategy_diagnoses").select("*").or(`user_id.eq.${a.id},and(device_id.eq.${o},user_id.is.null)`).order("created_at",{ascending:!1}).limit(20)).data:v=(await Je.rpc("get_diagnoses_by_device",{p_device_id:o})).data,v&&s(v.map(f=>({id:f.id,input_text:f.input_text,input_mode:f.input_mode,is_website:f.is_website,content:f.content,scorecard:f.scorecard,message_gap:f.message_gap,strategic_content:f.strategic_content,audit_result:f.audit_result,forecast_data:f.forecast_data,friction_data:f.friction_data,positioning_data:f.positioning_data,narrative_data:f.narrative_data,persona_data:f.persona_data,created_at:f.created_at}))),i(!1)},[a,o]);g.useEffect(()=>{a?Je.from("strategy_diagnoses").update({user_id:a.id}).eq("device_id",o).is("user_id",null).then(()=>c()):c()},[a,o,c]);const d=g.useCallback(async v=>{var N;if(a){const{data:m,error:h}=await Je.from("strategy_diagnoses").insert({device_id:o,user_id:a.id,input_text:v.input_text,input_mode:v.input_mode,is_website:v.is_website,content:v.content,scorecard:v.scorecard,message_gap:v.message_gap,strategic_content:v.strategic_content,audit_result:v.audit_result}).select("id").single();return!h&&m?(c(),m.id):null}const{data:f,error:_}=await Je.functions.invoke("secure-mutate",{body:{table:"strategy_diagnoses",operation:"insert",device_id:o,data:{user_id:null,input_text:v.input_text,input_mode:v.input_mode,is_website:v.is_website,content:v.content,scorecard:v.scorecard,message_gap:v.message_gap,strategic_content:v.strategic_content,audit_result:v.audit_result}}});return!_&&((N=f==null?void 0:f.data)!=null&&N.id)?(c(),f.data.id):null},[a,o,c]),y=g.useCallback(async(v,f)=>{a?await Je.from("strategy_diagnoses").update(f).eq("id",v):await Je.functions.invoke("secure-mutate",{body:{table:"strategy_diagnoses",operation:"update",device_id:o,record_id:v,data:f}}),c()},[c,a,o]);return{history:t,loading:n,saveDiagnosis:d,updateDiagnosis:y,fetchHistory:c}}const no=10,Kn="Not comparable — legacy score scale unknown";function dn(t){return t?It(t.scorecard)??(typeof t.scorecard_score_schema=="str
16ing"&&t.scorecard_score_schema.trim()?t.scorecard_score_schema.trim():null):null}function gr(t,s){if(s)return!1;const n=typeof t=="number"?t:Number(String(t??"").replace(/[^\d.\-]/g,""));return Number.isFinite(n)?n<=no:!0}function ao(t){const s=t.metric??"dimension_score",n=t.currentSchema??null,i=t.previousSchema??null,a=We(t.current,s,{schema:n??void 0}),o=gr(t.current,n);if(t.previous===void 0||t.previous===null)return{currentValue:a,previousValue:null,delta:null,comparable:!1,currentAmbiguous:o};const c=gr(t.previous,i);if(o||c)return{currentValue:a,previousValue:null,delta:null,comparable:!1,note:Kn,currentAmbiguous:o};const d=We(t.previous,s,{schema:i??void 0});return{currentValue:a,previousValue:d,delta:a-d,comparable:!0,currentAmbiguous:o}}const io="scale unknown";function oo(t,s,n="dimension_score"){const i=s??null;if(gr(t,i)){const a=typeof t=="number"?t:Number(String(t??"").replace(/[^\d.\-]/g,""));return Number.isFinite(a)?`${Math.round(a*10)/10} · ${io}`:"—"}return nt(t,n,{schema:i??void 0})??"—"}function lo(t){var v;if(!t.length)return null;const s=t[0],n=t.length>1?t[1]:null,i=s.scorecard;if(!i)return null;const a=dn(s),o=n?dn(n):null,c=[];if(i!=null&&i.scores){const f=n==null?void 0:n.scorecard;for(const _ of i.scores){const N=(v=f==null?void 0:f.scores)==null?void 0:v.find(k=>k.dimension===_.dimension),m=ao({current:_.score,currentSchema:a,previous:n?(N==null?void 0:N.score)??null:null,previousSchema:o}),h=oo(_.score,a);let x;m.comparable&&m.previousValue!==null&&m.delta!==null?x=`${m.previousValue}/100 → ${h} (${m.delta>0?"+":""}${m.delta})`:n&&N&&m.note?x=`${h} · ${Kn}`:x=`Score: ${h}`,c.push({label:_.dimension,trend:m.comparable&&m.delta!==null?m.delta>0?"up":m.delta<0?"down":"stable":"stable",detail:x})}}const d=[];if(i!=null&&i.scores){const f=m=>We(m==null?void 0:m.score,"dimension_score",{schema:a??void 0}),N=[...i.scores].sort((m,h)=>f(m)-f(h)).slice(0,2);for(const m of N){const h=f(m);d.push({priority:m.dimension,reason:m.diagnosis||"Below benchmark",urgency:h<=40?"high":h<=60?"medium":"low"})}}i!=null&&i.biggest_blind_spot&&d.push({priority:"Blind Spot",reason:i.biggest_blind_spot,urgency:"high"});const y={action:(i==null?void 0:i.one_line_repositioning)||"Run a new diagnosis to get personalized recommendations",rationale:(i==null?void 0:i.headline_verdict)||"",impact:i!=null&&i.overall_grade?`Moving from ${i.overall_grade} grade to the next level`:"Improved market positioning"};return{whatChanged:c,whatMattersNow:d,bestNextMove:y}}function co({trend:t}){return t==="up"?e.jsx(ii,{className:"w-3.5 h-3.5 text-emerald-500"}):t==="down"?e.jsx(oi,{className:"w-3.5 h-3.5 text-destructive"}):e.jsx(vr,{className:"w-3.5 h-3.5 text-muted-foreground"})}function po({urgency:t}){return e.jsx("span",{className:Z("w-2 h-2 rounded-full shrink-0",t==="high"&&"bg-destructive",t==="medium"&&"bg-amber-500",t==="low"&&"bg-emerald-500")})}const Xn=g.forwardRef(({onDismiss:t},s)=>{var _;const{user:n}=os(),{history:i,loading:a}=Qn(),[o,c]=g.useState(!1);if(!n||a||o)return null;const d=lo(i);if(!d)return null;const y=(_=i[0])==null?void 0:_.created_at,v=y?uo(new Date(y)):"",f=()=>{c(!0),t()};return e.jsx("div",{ref:s,className:"animate-slide-up",children:e.jsxs("div",{className:"bg-card border border-border rounded-2xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(ai,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-foreground",children:"Your Strategic Briefing"}),v&&e.jsxs("p",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[e.jsx(Dn,{className:"w-2.5 h-2.5"})," Last diagnosis ",v]})]})]}),e.jsx(_e,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:f,children:e.jsx(br,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 divide-y md:divide-y-0 md:divide-x divide-border",children:[e.jsxs("div",{className:"p-4 space-y-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(kt,{className:"w-3.5 h-3.5 text-primary"}),e.jsx("h4",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"What Changed"})]}),e.jsx("div",{className:"space-y-1.5",children:d.whatChanged.slice(0,4).map((N,m)=>e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:N.label}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(co,{trend:N.trend}),e.jsx("span",{className:"text-[11px] font-medium text-foreground",children:N.detail})]})]},m))})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(yr,{className:"w-3.5 h-3.5 text-amber-500"}),e.jsx("h4",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"What Matters Now"})]}),e.jsx("div",{className:"space-y-2",children:d.whatMattersNow.slice(0,3).map((N,m)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(po,{urgency:N.urgency}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-foreground",children:N.priority}),e.jsx("p",{className:"text-[11px] text-muted-foreground line-clamp-2",children:N.reason})]})]},m))})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(lr,{className:"w-3.5 h-3.5 text-emerald-500"}),e.jsx("h4",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Best Next Move"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-foreground leading-relaxed",children:d.bestNextMove.action}),d.bestNextMove.rationale&&e.jsx("p",{className:"text-[11px] text-muted-foreground line-clamp-2",children:d.bestNextMove.rationale}),e.jsx("div",{className:"bg-primary/5 border border-primary/10 rounded-md px-2.5 py-1.5",children:e.jsxs("p",{className:"text-[11px] text-primary font-medium",children:["🎯 ",d.bestNextMove.impact]})})]})]})]})]})})});Xn.displayName="StrategicBriefing";function uo(t){const n=new Date().getTime()-t.getTime(),i=Math.floor(n/6e4);if(i<60)return`${i}m ago`;const a=Math.floor(i/60);if(a<24)return`${a}h ago`;const o=Math.floor(a/24);return o===1?"yesterday":o<7?`${o}d ago`:t.toLocaleDateString()}function pn(t){var s,n;return(n=(s=t.scorecard)==null?void 0:s.scores)!=null&&n.length?Math.round(t.scorecard.scores.reduce((i,a)=>i+a.score,0)/t.scorecard.scores.length*10)/10:null}function un({history:t,onLoad:s,onCompareToCurrent:n,onCompare:i}){return t.length?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dn,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Previous Diagnoses"})]}),e.jsx("div",{className:"space-y-2",children:t.map((a,o)=>{var v;const c=pn(a),d=o<t.length-1?pn(t[o+1]):null,y=c!==null&&d!==null?Math.round((c-d)*10)/10:null;return e.jsxs("div",{className:"bg-card border border-border/50 rounded-xl px-4 py-3 flex items-center gap-3",children:[e.jsx("div",{className:"shrink-0",children:a.is_website?e.jsx(Mn,{className:"w-4 h-4 text-primary"}):a.input_mode==="paste"?e.jsx(Mt,{className:"w-4 h-4 text-accent"}):e.jsx(li,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:a.input_text||"Pasted content"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[ct(new Date(a.created_at),"MMM d, yyyy 'at' h:mm a"),
16c!==null&&e.jsxs("span",{className:"ml-2",children:["Grade: ",(v=a.scorecard)==null?void 0:v.overall_grade," (",nt(c,"average_score","DiagnosisHistory")??"—",")"]})]})]}),y!==null&&e.jsxs("div",{className:`flex items-center gap-0.5 text-xs font-bold ${y>0?"text-success":y<0?"text-destructive":"text-muted-foreground"}`,children:[y>0?e.jsx(kt,{className:"w-3 h-3"}):y<0?e.jsx(jr,{className:"w-3 h-3"}):e.jsx(vr,{className:"w-3 h-3"}),y>0?"+":"",y]}),e.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[e.jsx(_e,{variant:"outline",size:"sm",className:"text-[10px] h-7 px-2",onClick:()=>s(a),children:"View"}),n&&e.jsxs(_e,{variant:"ghost",size:"sm",className:"text-[10px] h-7 px-2 gap-1",onClick:()=>n(a),title:"Compare this run to your current session",children:[e.jsx(Yn,{className:"w-3 h-3"}),"vs current"]}),i&&o<t.length-1&&!n&&e.jsx(_e,{variant:"ghost",size:"sm",className:"text-[10px] h-7 px-2",onClick:()=>i(a,t[o+1]),children:"Compare"})]})]},a.id)})})]}):null}function Ae(t){return t==null?"":String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ts(t){const s=(t==null?void 0:t.scores)||[];return s.length?Math.round(s.reduce((n,i)=>n+i.score,0)/s.length*10)/10:null}function Zn(t=[],s=[]){const n=new Set(t.map(a=>a.toLowerCase().trim())),i=new Set(s.map(a=>a.toLowerCase().trim()));return{added:s.filter(a=>!n.has(a.toLowerCase().trim())),removed:t.filter(a=>!i.has(a.toLowerCase().trim())),same:s.filter(a=>n.has(a.toLowerCase().trim()))}}function Rs(t=[],s=["title","label","issue","action","name"]){return t.map(n=>{if(typeof n=="string")return n;for(const i of s)if(n!=null&&n[i])return String(n[i]);try{return JSON.stringify(n)}catch{return String(n)}})}function As(t){return t>0?`+${t}`:t<0?`${t}`:"0"}const wr=[{key:"audience",label:"Target audience"},{key:"postGoal",label:"Post goal"},{key:"language",label:"Language"},{key:"tone",label:"Tone / style"},{key:"industry",label:"Industry"},{key:"assetType",label:"Asset type"},{key:"audiences",label:"Brief audiences",isList:!0},{key:"inputMode",label:"Input mode"}];function as(t){return t==null||t===""?"":Array.isArray(t)?t.filter(Boolean).join(", "):String(t)}function zs(t){return t?wr.some(({key:s})=>as(t[s])):!1}function mo(t,s){var _,N,m,h;const n=[],i=ct(new Date(s.created_at),"MMM d, yyyy 'at' h:mma"),a=t.created_at?ct(new Date(t.created_at),"MMM d, yyyy 'at' h:mma"):"Current session";n.push("# Run Comparison Report"),n.push(""),n.push(`**Previous:** ${s.input_text||"—"}  `),n.push(`*${i}*`),n.push(""),n.push(`**Current:** ${t.input_text||"—"}  `),n.push(`*${a}*`),n.push(""),n.push("---"),n.push(""),(zs(t.settings)||zs(s.settings))&&(n.push("## ⚙️ Run Settings"),n.push(""),n.push("| Setting | Previous | Current |"),n.push("|---|---|---|"),wr.forEach(({key:x,label:k})=>{var G,E;const w=as((G=s.settings)==null?void 0:G[x]),$=as((E=t.settings)==null?void 0:E[x]);if(!w&&!$)return;const V=w&&$&&w!==$?" 🔄":"";n.push(`| **${k}**${V} | ${w||"_—_"} | ${$||"_—_"} |`)}),n.push(""));const o=Ts(t.scorecard),c=Ts(s.scorecard);if(n.push("## 📊 Scores"),n.push(""),o!==null&&c!==null){const x=Math.round((o-c)*10)/10;n.push(`**Overall average:** ${c} → ${o} (**${As(x)}**)`),n.push(""),n.push(`**Grade:** ${((_=s.scorecard)==null?void 0:_.overall_grade)||"–"} → ${((N=t.scorecard)==null?void 0:N.overall_grade)||"–"}`),n.push("")}const d=((m=t.scorecard)==null?void 0:m.scores)||[],y=((h=s.scorecard)==null?void 0:h.scores)||[],v=Array.from(new Set([...d.map(x=>x.dimension),...y.map(x=>x.dimension)]));v.length&&(n.push("| Dimension | Previous | Current | Δ |"),n.push("|---|---|---|---|"),v.forEach(x=>{const k=d.find(G=>G.dimension===x),w=y.find(G=>G.dimension===x),$=((k==null?void 0:k.score)??0)-((w==null?void 0:w.score)??0),V=k&&w?As($):w?"**REMOVED**":"**NEW**";n.push(`| ${x} | ${(w==null?void 0:w.score)??"–"} | ${(k==null?void 0:k.score)??"–"} | ${V} |`)}),n.push(""));const f=(x,k,w,$,V,G)=>{if(n.push(`## ${k} ${x}`),n.push(""),!w&&!$){n.push("*No data in either run.*"),n.push("");return}V.forEach(({key:E,label:L,aliases:R=[]})=>{const l=[E,...R],T=l.map(z=>w==null?void 0:w[z]).find(Boolean),S=l.map(z=>$==null?void 0:$[z]).find(Boolean);!T&&!S||(n.push(`### ${L}`),n.push(`**Previous:** ${T||"_(not present)_"}`),n.push(""),n.push(`**Current:** ${S||"_(not present)_"}`),n.push(""))}),G.forEach(({keys:E,label:L})=>{const R=Rs(E.map(C=>w==null?void 0:w[C]).find(C=>Array.isArray(C))||[]),l=Rs(E.map(C=>$==null?void 0:$[C]).find(C=>Array.isArray(C))||[]);if(!R.length&&!l.length)return;const{added:T,removed:S,same:z}=Zn(R,l);n.push(`### ${L}
16`),S.forEach(C=>n.push(`- ❌ ~~${C}~~ _(removed)_`)),T.forEach(C=>n.push(`- ✅ **${C}** _(new)_`)),z.forEach(C=>n.push(`- ⚪ ${C} _(unchanged)_`)),n.push("")})};return f("Forecast","🔮",s.forecast_data,t.forecast_data,[{key:"appears_as",label:"Appears as"},{key:"wants_to_be",label:"Wants to be"},{key:"commercial_consequence",label:"Commercial consequence"},{key:"fastest_unlock",label:"Fastest unlock"}],[]),f("Friction","🚧",s.friction_data,t.friction_data,[{key:"headline_friction",label:"Headline friction",aliases:["summary"]}],[{keys:["friction_points"],label:"Friction points"},{keys:["quick_wins"],label:"Quick wins"}]),f("Positioning","🎯",s.positioning_data,t.positioning_data,[{key:"current_position",label:"Current position",aliases:["summary"]},{key:"recommended_angle",label:"Recommended angle",aliases:["recommended_position"]}],[{keys:["differentiators"],label:"Differentiators"},{keys:["competitors"],label:"Competitors mentioned"}]),f("Narrative","📖",s.narrative_data,t.narrative_data,[{key:"core_narrative",label:"Core narrative",aliases:["headline","summary"]},{key:"hero_statement",label:"Hero statement",aliases:["tagline"]}],[{keys:["pillars","themes"],label:"Pillars / themes"},{keys:["proof_points"],label:"Proof points"}]),n.push("---"),n.push(""),n.push(`_Generated by Social Brilliance · ${ct(new Date,"MMM d, yyyy")}_`),n.join(`
17`)}function xo(t,s){const n=mo(t,s),i=new Blob([n],{type:"text/markdown;charset=utf-8"}),a=URL.createObjectURL(i),o=document.createElement("a");o.href=a,o.download=`run-comparison-${ct(new Date,"yyyy-MM-dd")}.md`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)}function go(t,s){var $,V,G,E;const n=ct(new Date(s.created_at),"MMM d, yyyy 'at' h:mma"),i=t.created_at?ct(new Date(t.created_at),"MMM d, yyyy 'at' h:mma"):"Current session",a=Ts(t.scorecard),o=Ts(s.scorecard),c=a!==null&&o!==null?Math.round((a-o)*10)/10:0,d=(($=t.scorecard)==null?void 0:$.scores)||[],y=((V=s.scorecard)==null?void 0:V.scores)||[],v=Array.from(new Set([...d.map(L=>L.dimension),...y.map(L=>L.dimension)])),f=L=>L>0?"#16a34a":L<0?"#dc2626":"#6b7280",_=!zs(t.settings)&&!zs(s.settings)?"":`<section style="margin:24px 0;page-break-inside:avoid;">
18      <h2 style="font-size:16px;color:#111827;margin:0 0 12px;border-bottom:2px solid #e5e7eb;padding-bottom:6px;">⚙️ Run Settings</h2>
19      <table>
20        <thead>
21          <tr style="background:#f9fafb;">
22            <th style="text-align:left;padding:8px 12px;font-size:10px;text-transform:uppercase;color:#6b7280;border-bottom:2px solid #e5e7eb;">Setting</th>
23            <th style="text-align:left;padding:8px 12px;font-size:10px;text-transform:uppercase;color:#6b7280;border-bottom:2px solid #e5e7eb;">Previous</th>
24            <th style="text-align:left;padding:8px 12px;font-size:10px;text-transform:uppercase;color:#2563eb;border-bottom:2px solid #e5e7eb;">Current</th>
25          </tr>
26        </thead>
27        <tbody>${wr.map(({key:R,label:l})=>{var K,U;const T=as((K=s.settings)==null?void 0:K[R]),S=as((U=t.settings)==null?void 0:U[R]);if(!T&&!S)return"";const C=T&&S&&T!==S?'<span style="display:inline-block;font-size:9px;background:#fef3c7;color:#92400e;padding:2px 6px;border-radius:4px;margin-left:6px;font-weight:700;">CHANGED</span>':"";return`<tr>
28        <td style="padding:8px 12px;border-bottom:1px solid #e5e7eb;font-size:11px;font-weight:600;text-transform:uppercase;color:#374151;letter-spacing:0.04em;">${Ae(l)}${C}</td>
29        <td style="padding:8px 12px;border-bottom:1px solid #e5e7eb;font-size:12px;color:#6b7280;">${T?Ae(T):'<em style="color:#9ca3af;">—</em>'}</td>
30        <td style="padding:8px 12px;border-bottom:1px solid #e5e7eb;font-size:12px;color:#111827;font-weight:600;">${S?Ae(S):'<em style="color:#9ca3af;">—</em>'}</td>
31      </tr>`}).join("")}</tbody>
32      </table>
33    </section>`,N=v.map(L=>{const R=d.find(C=>C.dimension===L),l=y.find(C=>C.dimension===L),T=((R==null?void 0:R.score)??0)-((l==null?void 0:l.score)??0),S=R&&l?As(T):l?"REMOVED":"NEW",z=R&&l?f(T):l?"#dc2626":"#16a34a";return`<tr>
34        <td style="padding:8px 12px;border-bottom:1px solid #e5e7eb;font-size:12px;font-weight:600;text-transform:uppercase;color:#374151;">${Ae(L)}</td>
35        <td style="padding:8px 12px;border-bottom:1px solid #e5e7eb;font-size:13px;color:#6b7280;text-align:center;font-family:monospace;">${(l==null?void 0:l.score)??"–"}</td>
36        <td style="padding:8px 12px;border-bottom:1px solid #e5e7eb;font-size:13px;color:#111827;text-align:center;font-family:monospace;font-weight:700;">${(R==null?void 0:R.score)??"–"}</td>
37        <td style="padding:8px 12px;border-bottom:1px solid #e5e7eb;font-size:12px;text-align:right;font-weight:700;color:${z};">${S}</td>
38      </tr>`}).join(""),m=(L,R,l)=>!R&&!l?"":`<div style="margin:8px 0;">
39      <p style="font-size:10px;text-transform:uppercase;color:#6b7280;margin:0 0 4px;font-weight:700;letter-spacing:0.04em;">${Ae(L)}</p>
40      <div style="display:grid;grid-template-columns:1fr 1fr;gap:8px;">
41        <div style="background:#f9fafb;border:1px solid #e5e7eb;border-radius:8px;padding:10px;">
42          <p style="font-size:9px;text-transform:uppercase;color:#9ca3af;margin:0 0 4px;font-weight:700;">Previous</p>
43          <p style="font-size:12px;color:#374151;margin:0;line-height:1.5;">${R?Ae(R):'<em style="color:#9ca3af;">— not present —</em>'}</p>
44        </div>
45        <div style="background:#eff6ff;border:1px solid #bfdbfe;border-radius:8px;padding:10px;">
46          <p style="font-size:9px;text-transform:uppercase;color:#2563eb;margin:0 0 4px;font-weight:700;">Current</p>
47          <p style="font-size:12px;color:#111827;margin:0;line-height:1.5;">${l?Ae(l):'<em style="color:#9ca3af;">— not present —</em>'}</p>
48        </div>
49      </div>
50    </div>`,h=(L,R,l)=>{if(!R.length&&!l.length)return"";const{added:T,removed:S,same:z}=Zn(R,l),C=(K,U,re,xe,u="")=>`<span style="display:inline-block;font-size:11px;padding:3px 8px;border-radius:4px;background:${re};color:${U};margin:2px 3px 2px 0;${u}">${Ae(xe)} ${Ae(K)}</span>`;return`<div style="margin:10px 0;">
51      <p style="font-size:10px;text-transform:uppercase;color:#6b7280;margin:0 0 6px;font-weight:700;letter-spacing:0.04em;">${Ae(L)}</p>
52      <div>
53        ${S.map(K=>C(K,"#dc2626","#fee2e2","−","text-decoration:line-through;")).join("")}
54        ${T.map(K=>C(K,"#16a34a","#dcfce7","+","font-weight:600;")).join("")}
55        ${z.map(K=>C(K,"#6b7280","#f3f4f6","=")).join("")}
56      </div>
57    </div>`},x=(L,R,l,T,S,z)=>{if(!l&&!T)return`<section style="margin:24px 0;page-break-inside:avoid;">
58        <h2 style="font-size:16px;color:#111827;margin:0 0 12px;border-bottom:2px solid #e5e7eb;padding-bottom:6px;">${R} ${Ae(L)}</h2>
59        <p style="font-size:12px;color:#9ca3af;font-style:italic;">No data in either run.</p>
60      </section>`;
60const C=S.map(({key:U,label:re,aliases:xe=[]})=>{const u=[U,...xe],pe=u.map(ye=>l==null?void 0:l[ye]).find(Boolean),q=u.map(ye=>T==null?void 0:T[ye]).find(Boolean);return m(re,pe,q)}).join(""),K=z.map(({keys:U,label:re})=>{const xe=Rs(U.map(pe=>l==null?void 0:l[pe]).find(pe=>Array.isArray(pe))||[]),u=Rs(U.map(pe=>T==null?void 0:T[pe]).find(pe=>Array.isArray(pe))||[]);return h(re,xe,u)}).join("");return`<section style="margin:24px 0;page-break-inside:avoid;">
61      <h2 style="font-size:16px;color:#111827;margin:0 0 12px;border-bottom:2px solid #e5e7eb;padding-bottom:6px;">${R} ${Ae(L)}</h2>
62      ${C}
63      ${K}
64    </section>`},k=`<!DOCTYPE html>
65<html>
66<head>
67  <meta charset="utf-8" />
68  <title>Run Comparison Report</title>
69  <style>
70    @page { size: A4; margin: 16mm; }
71    body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: #111827; max-width: 800px; margin: 0 auto; padding: 20px; }
72    h1 { font-size: 22px; margin: 0 0 4px; }
73    table { width: 100%; border-collapse: collapse; margin: 8px 0; }
74    .header { background: linear-gradient(135deg, #eff6ff, #f0fdf4); border: 1px solid #bfdbfe; border-radius: 12px; padding: 16px; margin-bottom: 20px; }
75    .summary { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; padding: 16px; border-radius: 12px; background: ${c>0?"#dcfce7":c<0?"#fee2e2":"#f3f4f6"}; margin: 12px 0; }
76    .summary .num { font-size: 28px; font-weight: 900; font-family: monospace; text-align: center; }
77    .summary .label { font-size: 9px; text-transform: uppercase; font-weight: 700; color: #6b7280; text-align: center; }
78    @media print { .no-print { display: none; } }
79  </style>
80</head>
81<body>
82  <div class="no-print" style="text-align:center;margin-bottom:20px;padding:12px;background:#fef3c7;border-radius:8px;">
83    <p style="margin:0;font-size:14px;">Use your browser's <strong>Print → Save as PDF</strong> to download this report.</p>
84  </div>
85
86  <div class="header">
87    <h1>🔍 Run Comparison Report</h1>
88    <p style="margin:4px 0 12px;font-size:11px;color:#6b7280;">Differences across scores, forecast, friction, positioning, and narrative.</p>
89    <div style="display:grid;grid-template-columns:1fr 1fr;gap:12px;">
90      <div>
91        <p style="font-size:9px;text-transform:uppercase;color:#6b7280;margin:0;font-weight:700;">Previous Run</p>
92        <p style="font-size:13px;color:#374151;margin:2px 0 0;font-weight:600;">${Ae(s.input_text||"—")}</p>
93        <p style="font-size:10px;color:#9ca3af;margin:2px 0 0;">${Ae(n)}</p>
94      </div>
95      <div>
96        <p style="font-size:9px;text-transform:uppercase;color:#2563eb;margin:0;font-weight:700;">Current Run</p>
97        <p style="font-size:13px;color:#111827;margin:2px 0 0;font-weight:600;">${Ae(t.input_text||"—")}</p>
98        <p style="font-size:10px;color:#9ca3af;margin:2px 0 0;">${Ae(i)}</p>
99      </div>
100    </div>
101  </div>
102
103  ${a!==null&&o!==null?`<div class="summary">
104    <div>
105      <p class="label">Previous Avg</p>
106      <p class="num" style="color:#6b7280;">${o}</p>
107    </div>
108    <div style="font-size:24px;color:#6b7280;">→</div>
109    <div>
110      <p class="label" style="color:#111827;">Current Avg</p>
111      <p class="num" style="color:#111827;">${a}</p>
112      <p style="text-align:center;font-size:13px;font-weight:700;margin:4px 0 0;color:${f(c)};">${As(c)}</p>
113    </div>
114  </div>`:""}
115
116  ${_}
117
118  <section style="margin:24px 0;page-break-inside:avoid;">
119    <h2 style="font-size:16px;color:#111827;margin:0 0 12px;border-bottom:2px solid #e5e7eb;padding-bottom:6px;">📊 Dimension Scores</h2>
120    ${N?`<table>
121      <thead>
122        <tr style="background:#f9fafb;">
123          <th style="text-align:left;padding:8px 12px;font-size:10px;text-transform:uppercase;color:#6b7280;border-bottom:2px solid #e5e7eb;">Dimension</th>
124          <th style="text-align:center;padding:8px 12px;font-size:10px;text-transform:uppercase;color:#6b7280;border-bottom:2px solid #e5e7eb;">Previous</th>
125          <th style="text-align:center;padding:8px 12px;font-size:10px;text-transform:uppercase;color:#6b7280;border-bottom:2px solid #e5e7eb;">Current</th>
126          <th style="text-align:right;padding:8px 12px;font-size:10px;text-transform:uppercase;color:#6b7280;border-bottom:2px solid #e5e7eb;">Δ</th>
127        </tr>
128      </thead>
129      <tbody>${N}</tbody>
130    </table>
131    <p style="font-size:11px;color:#6b7280;margin:8px 0 0;"><strong>Grade:</strong> ${Ae(((G=s.scorecard)==null?void 0:G.overall_grade)||"–")} → <strong>${Ae(((E=t.scorecard)==null?void 0:E.overall_grade)||"–")}</strong></p>`:'<p style="font-size:12px;color:#9ca3af;font-style:italic;">No score data available.</p>'}
132  </section>
133
134  ${x("Forecast","🔮",s.forecast_data,t.forecast_data,[{key:"appears_as",label:"Appears as"},{key:"wants_to_be",label:"Wants to be"},{key:"commercial_consequence",label:"Commercial consequence"},{key:"fastest_unlock",label:"Fastest unlock"}],[])}
135
136  ${x("Friction","🚧",s.friction_data,t.friction_data,[{key:"headline_friction",label:"Headline friction",aliases:["summary"]}],[{keys:["friction_points"],label:"Friction points"},{keys:["quick_wins"],label:"Quick wins"}])}
137
138  ${x("Positioning","🎯",s.positioning_data,t.positioning_data,[{key:"current_position",label:"Current position",aliases:["summary"]},{key:"recommended_angle",label:"Recommended angle",aliases:["recommended_position"]}],[{keys:["differentiators"],label:"Differentiators"},{keys:["competitors"],label:"Competitors mentioned"}])}
139
140  ${x("Narrative","📖",s.narrative_data,t.narrative_data,[{key:"c
140ore_narrative",label:"Core narrative",aliases:["headline","summary"]},{key:"hero_statement",label:"Hero statement",aliases:["tagline"]}],[{keys:["pillars","themes"],label:"Pillars / themes"},{keys:["proof_points"],label:"Proof points"}])}
141
142  <footer style="margin-top:32px;padding-top:12px;border-top:1px solid #e5e7eb;text-align:center;font-size:10px;color:#9ca3af;">
143    Generated by Social Brilliance · ${ct(new Date,"MMM d, yyyy")}
144  </footer>
145
146  <script>setTimeout(() => window.print(), 400);<\/script>
147</body>
148</html>`,w=window.open("","_blank","width=900,height=1000");if(!w){alert("Please allow popups to export the comparison report.");return}w.document.open(),w.document.write(k),w.document.close()}function fo(t){return t>0?"text-success":t<0?"text-destructive":"text-muted-foreground"}function ho({d:t,className:s}){return t>0?e.jsx(kt,{className:s}):t<0?e.jsx(jr,{className:s}):e.jsx(vr,{className:s})}function mn({delta:t,suffix:s=""}){return e.jsxs("div",{className:`inline-flex items-center gap-0.5 text-[11px] font-bold ${fo(t)}`,children:[e.jsx(ho,{d:t,className:"w-3 h-3"}),t>0?"+":"",t,s]})}function ts({icon:t,title:s,status:n}){const i={added:{text:"NEW",cls:"bg-success/10 text-success"},removed:{text:"REMOVED",cls:"bg-destructive/10 text-destructive"},changed:{text:"CHANGED",cls:"bg-amber-500/10 text-amber-500"},same:{text:"UNCHANGED",cls:"bg-muted text-muted-foreground"}};return e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(t,{className:"w-4 h-4 text-primary"}),e.jsx("h4",{className:"text-sm font-bold uppercase tracking-wider text-foreground",children:s}),n&&e.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full ${i[n].cls}`,children:i[n].text})]})}function pt({leftLabel:t,rightLabel:s,left:n,right:i}){if(!n&&!i)return null;const a=n&&i&&n.trim()===i.trim();return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsxs("div",{className:"bg-muted/30 border border-border/50 rounded-lg p-2.5",children:[e.jsx("p",{className:"text-[9px] uppercase font-bold text-muted-foreground mb-1",children:t}),e.jsx("p",{className:"text-xs text-foreground/80 whitespace-pre-wrap",children:n||e.jsx("span",{className:"italic text-muted-foreground",children:"— not present —"})})]}),e.jsxs("div",{className:`border rounded-lg p-2.5 ${a?"bg-muted/30 border-border/50":"bg-primary/5 border-primary/20"}`,children:[e.jsx("p",{className:"text-[9px] uppercase font-bold text-primary mb-1",children:s}),e.jsx("p",{className:"text-xs text-foreground whitespace-pre-wrap",children:i||e.jsx("span",{className:"italic text-muted-foreground",children:"— not present —"})})]})]})}function bo(t=[],s=[]){const n=new Set(t.map(a=>a.toLowerCase().trim())),i=new Set(s.map(a=>a.toLowerCase().trim()));return{added:s.filter(a=>!n.has(a.toLowerCase().trim())),removed:t.filter(a=>!i.has(a.toLowerCase().trim())),same:s.filter(a=>n.has(a.toLowerCase().trim()))}}function zt({label:t,prev:s,cur:n}){const{added:i,removed:a,same:o}=bo(s,n);return!i.length&&!a.length&&!o.length?null:e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase font-bold text-muted-foreground mb-1.5",children:t}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.map((c,d)=>e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-destructive/10 text-destructive line-through",children:["− ",c]},`r-${d}`)),i.map((c,d)=>e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-success/10 text-success font-medium",children:["+ ",c]},`a-${d}`)),o.map((c,d)=>e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-muted/40 text-muted-foreground",children:["= ",c]},`s-${d}`))]})]})}function bs(t,s){const n=t!=null&&(Array.isArray(t)?t.length>0:Object.keys(t||{}).length>0),i=s!=null&&(Array.isArray(s)?s.length>0:Object.keys(s||{}).length>0);if(!n&&!i)return null;if(!n&&i)return"added";if(n&&!i)return"removed";try{return JSON.stringify(t)===JSON.stringify(s)?"same":"changed"}catch{return"changed"}}function yo({current:t,previous:s,onClose:n}){var G,E,L,R;const{toast:i}=Ps(),a=((G=t.scorecard)==null?void 0:G.scores)||[],o=((E=s.scorecard)==null?void 0:E.scores)||[],c=a.length?Math.round(a.reduce((l,T)=>l+T.score,0)/a.length*10)/10:0,d=o.length?Math.round(o.reduce((l,T)=>l+T.score,0)/o.length*10)/10:0,y=Math.round((c-d)*10)/10,v=Array.from(new Set([...a.map(l=>l.dimension),...o.map(l=>
148l.dimension)])),f=t.forecast_data,_=s.forecast_data,N=t.friction_data,m=s.friction_data,h=t.positioning_data,x=s.positioning_data,k=t.narrative_data,w=s.narrative_data,$=()=>{xo(t,s),i({title:"📝 Markdown exported",description:"Comparison report downloaded."})},V=()=>{go(t,s),i({title:"📄 Opening print dialog",description:"Choose 'Save as PDF' to download."})};return e.jsxs("div",{className:"bg-card border border-border rounded-2xl overflow-hidden",children:[e.jsxs("div",{className:"bg-primary/5 border-b border-border px-4 py-3 flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Yn,{className:"w-4 h-4 text-primary shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-sm font-bold text-foreground",children:"Compare Runs"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[ct(new Date(s.created_at),"MMM d, h:mma")," → ",t.created_at?ct(new Date(t.created_at),"MMM d, h:mma"):"Current session"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs(_e,{variant:"outline",size:"sm",className:"h-7 px-2 text-[11px] gap-1",onClick:$,title:"Download Markdown summary",children:[e.jsx(Mt,{className:"w-3 h-3"}),e.jsx("span",{className:"hidden sm:inline",children:"Markdown"})]}),e.jsxs(_e,{variant:"outline",size:"sm",className:"h-7 px-2 text-[11px] gap-1",onClick:V,title:"Export as PDF (print dialog)",children:[e.jsx(hi,{className:"w-3 h-3"}),e.jsx("span",{className:"hidden sm:inline",children:"PDF"})]}),e.jsx(_e,{variant:"ghost",size:"icon",className:"w-7 h-7",onClick:n,children:e.jsx(br,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:`flex items-center justify-center gap-3 py-3 rounded-xl ${y>0?"bg-success/10":y<0?"bg-destructive/10":"bg-muted/30"}`,children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[9px] uppercase text-muted-foreground font-bold",children:"Previous"}),e.jsx("span",{className:"text-2xl font-black font-mono text-muted-foreground",children:d})]}),e.jsx("span",{className:"text-lg text-muted-foreground",children:"→"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[9px] uppercase text-foreground font-bold",children:"Current"}),e.jsx("span",{className:"text-2xl font-black font-mono text-foreground",children:c})]}),e.jsx(mn,{delta:y})]}),e.jsxs(gi,{defaultValue:"scores",className:"w-full",children:[e.jsxs(fi,{className:"grid grid-cols-5 w-full h-auto",children:[e.jsx(Xt,{value:"scores",className:"text-[10px] py-1.5",children:"Scores"}),e.jsx(Xt,{value:"forecast",className:"text-[10px] py-1.5",children:"Forecast"}),e.jsx(Xt,{value:"friction",className:"text-[10px] py-1.5",children:"Friction"}),e.jsx(Xt,{value:"positioning",className:"text-[10px] py-1.5",children:"Positioning"}),e.jsx(Xt,{value:"narrative",className:"text-[10px] py-1.5",children:"Narrative"})]}),e.jsxs(Zt,{value:"scores",className:"space-y-2 mt-3",children:[e.jsx(ts,{icon:lt,title:"Dimension Scores"}),e.jsx("div",{className:"space-y-1.5",children:v.map(l=>{const T=a.find(C=>C.dimension===l),S=o.find(C=>C.dimension===l),z=((T==null?void 0:T.score)??0)-((S==null?void 0:S.score)??0);return e.jsxs("div",{className:"flex items-center gap-3 text-xs bg-muted/20 rounded-lg px-3 py-2",children:[e.jsx("span",{className:"flex-1 font-bold uppercase text-foreground/80 truncate",children:l}),e.jsx("span",{className:"text-muted-foreground font-mono w-7 text-right",children:(S==null?void 0:S.score)??"–"}),e.jsx("span",{className:"text-muted-foreground",children:"→"}),e.jsx("span",{className:"text-foreground font-mono font-bold w-7",children:(T==null?void 0:T.score)??"–"}),e.jsxs("div",{className:"w-12 text-right",children:[S&&T&&e.jsx(mn,{delta:z}),!S&&T&&e.jsx("span",{className:"text-[9px] font-bold text-success",children:"NEW"}),S&&!T&&e.jsx("span",{className:"text-[9px] font-bold text-destructive",children:"GONE"})]})]},l)})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 pt-2",children:[e.jsxs("div",{className:"bg-muted/30 rounded-lg p-2.5 text-center",children:[e.jsx("p",{className:"text-[9px] uppercase font-bold text-muted-foreground",children:"Prev Grade"}),e.jsx("p",{className:"text-lg font-black text-muted-foreground",children:((L=s.scorecard)==null?void 0:L.overall_grade)||"–"})]}),e.jsxs("div",{className:"bg-primary/5 rounded-lg p-2.5 text-center",children:[e.jsx("p",{className:"text-[9px] uppercase font-bold text-primary",children:"Current Grade"}),e.jsx("p",{className:"text-lg font-black text-foreground",children:((R=t.scorecard)==null?void 0:R.overall_grade)||"–"})]})]})]}),e.jsxs(Zt,{value:"forecast",className:"space-y-3 mt-3",children:[e.jsx(ts,{icon:Rn,title:"Market Reaction Forecast",status:bs(_,f)}),!_&&!f?e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No forecast data in either run."}):e.jsxs(e.Fragment,{children:[e.jsx(pt,{leftLabel:"Prev: Appears as",rightLabel:"Current: Appears as",left:(_==null?void 0:_.appears_as)||null,right:(f==null?void 0:f.a
148ppears_as)||null}),e.jsx(pt,{leftLabel:"Prev: Wants to be",rightLabel:"Current: Wants to be",left:(_==null?void 0:_.wants_to_be)||null,right:(f==null?void 0:f.wants_to_be)||null}),e.jsx(pt,{leftLabel:"Prev: Commercial consequence",rightLabel:"Current: Commercial consequence",left:(_==null?void 0:_.commercial_consequence)||null,right:(f==null?void 0:f.commercial_consequence)||null}),e.jsx(pt,{leftLabel:"Prev: Fastest unlock",rightLabel:"Current: Fastest unlock",left:(_==null?void 0:_.fastest_unlock)||null,right:(f==null?void 0:f.fastest_unlock)||null})]})]}),e.jsxs(Zt,{value:"friction",className:"space-y-3 mt-3",children:[e.jsx(ts,{icon:On,title:"Conversion Friction",status:bs(m,N)}),!m&&!N?e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No friction data in either run."}):e.jsxs(e.Fragment,{children:[e.jsx(pt,{leftLabel:"Prev: Headline friction",rightLabel:"Current: Headline friction",left:(m==null?void 0:m.headline_friction)||(m==null?void 0:m.summary)||null,right:(N==null?void 0:N.headline_friction)||(N==null?void 0:N.summary)||null}),e.jsx(zt,{label:"Friction points",prev:((m==null?void 0:m.friction_points)||[]).map(l=>typeof l=="string"?l:l.title||l.label||l.issue||JSON.stringify(l)),cur:((N==null?void 0:N.friction_points)||[]).map(l=>typeof l=="string"?l:l.title||l.label||l.issue||JSON.stringify(l))}),e.jsx(zt,{label:"Quick wins",prev:((m==null?void 0:m.quick_wins)||[]).map(l=>typeof l=="string"?l:l.title||l.action||JSON.stringify(l)),cur:((N==null?void 0:N.quick_wins)||[]).map(l=>typeof l=="string"?l:l.title||l.action||JSON.stringify(l))})]})]}),e.jsxs(Zt,{value:"positioning",className:"space-y-3 mt-3",children:[e.jsx(ts,{icon:lt,title:"Competitive Positioning",status:bs(x,h)}),!x&&!h?e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No positioning data in either run."}):e.jsxs(e.Fragment,{children:[e.jsx(pt,{leftLabel:"Prev: Current position",rightLabel:"Current: Current position",left:(x==null?void 0:x.current_position)||(x==null?void 0:x.summary)||null,right:(h==null?void 0:h.current_position)||(h==null?void 0:h.summary)||null}),e.jsx(pt,{leftLabel:"Prev: Recommended angle",rightLabel:"Current: Recommended angle",left:(x==null?void 0:x.recommended_angle)||(x==null?void 0:x.recommended_position)||null,right:(h==null?void 0:h.recommended_angle)||(h==null?void 0:h.recommended_position)||null}),e.jsx(zt,{label:"Differentiators",prev:((x==null?void 0:x.differentiators)||[]).map(l=>typeof l=="string"?l:l.title||JSON.stringify(l)),cur:((h==null?void 0:h.differentiators)||[]).map(l=>typeof l=="string"?l:l.title||JSON.stringify(l))}),e.jsx(zt,{label:"Competitors mentioned",prev:((x==null?void 0:x.competitors)||[]).map(l=>typeof l=="string"?l:l.name||JSON.stringify(l)),cur:((h==null?void 0:h.competitors)||[]).map(l=>typeof l=="string"?l:l.name||JSON.stringify(l))})]})]}),e.jsxs(Zt,{value:"narrative",className:"space-y-3 mt-3",children:[e.jsx(ts,{icon:is,title:"Narrative Architecture",status:bs(w,k)}),!w&&!k?e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No narrative data in either run."}):e.jsxs(e.Fragment,{children:[e.jsx(pt,{leftLabel:"Prev: Core narrative",rightLabel:"Current: Core narrative",left:(w==null?void 0:w.core_narrative)||(w==null?void 0:w.headline)||(w==null?void 0:w.summary)||null,right:(k==null?void 0:k.core_narrative)||(k==null?void 0:k.headline)||(k==null?void 0:k.summary)||null}),e.jsx(pt,{leftLabel:"Prev: Hero statement",rightLabel:"Current: Hero statement",left:(w==null?void 0:w.hero_statement)||(w==null?void 0:w.tagline)||null,right:(k==null?void 0:k.hero_statement)||(k==null?void 0:k.tagline)||null}),e.jsx(zt,{label:"Pillars / themes",prev:((w==null?void 0:w.pillars)||(w==null?void 0:w.themes)||[]).map(l=>typeof l=="string"?l:l.title||l.name||JSON.stringify(l)),cur:((k==null?void 0:k.pillars)||(k==null?void 0:k.themes)||[]).map(l=>typeof l=="string"?l:l.title||l.name||JSON.stringify(l))}),e.jsx(zt,{label:"Proof points",prev:((w==null?void 0:w.proof_points)||[]).map(l=>typeof l=="string"?l:l.title||JSON.stringify(l)),cur:((k==null?void 0:k.proof_points)||[]).map(l
148=>typeof l=="string"?l:l.title||JSON.stringify(l))})]})]})]})]})]})}const _o=[{id:"founder-vc",patterns:[/\bfounders?\b/i,/\bco[-\s]?founders?\b/i,/\bvc\b/i,/venture\s?(capital)?/i,/seed|series\s?[a-d]\b|pre[-\s]?seed/i,/startups?/i,/portfolio\s?(co|company)?/i,/\blp\b|limited\s?partner/i,/\barr\b|\bmrr\b|runway|burn\s?rate/i,/angel\s?invest|cap\s?table|term\s?sheet/i,/\byc\b|y\s?combinator|techstars|accelerator/i,/pitch\s?deck|fundrais/i],fuzzyTerms:["founder","cofounder","startup","venture","investor","seed","series","portfolio","runway","traction","fundraise","accelerator","angel","unicorn"]},{id:"healthcare-exec",patterns:[/\bhealth(care|tech)?\b/i,/clinical|patient|trial|provider|payer|hospital|pharma|biotech/i,/\bcmo\b|chief\s?medical/i,/\bfda\b|\bce\s?mark\b|\bhipaa\b|\birb\b/i,/life\s?science|medtech|digital\s?health|telehealth|telemedicine/i,/clinician|physician|nurse|oncolog|cardiolog|neurolog/i,/payor|reimburs|formulary|\bcms\b/i],fuzzyTerms:["healthcare","clinical","patient","hospital","pharma","biotech","provider","payer","clinician","physician","medtech","telehealth","fda","hipaa"]},{id:"developer",patterns:[/\bdevelopers?\b/i,/\bengineers?\b/i,/\bsdk\b|\bapi\b|\bcli\b/i,/devtool|developer\s?platform|backend|frontend|infrastructure|infra\b/i,/\bdevops\b|\bsre\b|kubernetes|docker|serverless/i,/open[-\s]?source|\boss\b|github|monorepo/i,/typescript|javascript|python|rust|golang|\bgo\b/i,/\bcto\b|tech\s?lead|staff\s?engineer/i],fuzzyTerms:["developer","engineer","programmer","backend","frontend","fullstack","devops","kubernetes","docker","github","opensource","typescript","python","infrastructure"]},{id:"recruiter",patterns:[/\brecruit(er|ing|ment)?\b/i,/\bhr\b|human\s?resources/i,/\btalent\b/i,/hiring|sourcing|head\s?hunt/i,/people\s?(ops|operations)|workforce/i,/\bats\b|applicant\s?tracking|candidate\s?experience/i,/\bchro\b|\bvp\s?people\b|head\s?of\s?people/i],fuzzyTerms:["recruiter","recruiting","hiring","talent","sourcing","candidate","workforce","retention","onboarding"]},{id:"educator",patterns:[/\beducat(or|ion)/i,/teachers?|professors?|instructors?/i,/coach(es|ing)?/i,/curriculum|syllabus|pedagog/i,/learning|training|workshop|course/i,/\bl&d\b|learning\s?and\s?development/i,/edtech|online\s?learning|\bmooc\b/i,/student|cohort|bootcamp/i],fuzzyTerms:["educator","teacher","coach","curriculum","training","learning","student","cohort","bootcamp","edtech","instructor","mentor"]},{id:"marketer",patterns:[/\bmarket(er|ers|ing)\b/i,/\bcmo\b|chief\s?marketing/i,/brand(ing)?|campaign|content\s?(marketing|strategy)?|creative\s?director/i,/growth\s?(hack|marketing|loop)?|demand\s?gen|performance\s?marketing/i,/\bseo\b|\bsem\b|\bppc\b|paid\s?(social|media|ads)/i,/copywrit|storytelling|positioning|messaging/i],fuzzyTerms:["marketer","marketing","brand","campaign","content","creative","growth","demand","copywriter","storytelling","positioning"]},{id:"enterprise-b2b",patterns:[/\benterprise\b/i,/\bb2b\b/i,/platform/i,/analyst|gartner|forrester|\bidc\b|magic\s?quadrant/i,/ecosystem|partner\s?(channel|program)/i,/\bsoc\s?2\b|\biso\s?27001\b|compliance|procurement/i,/total\s?addressable|\btam\b|category\s?(creation|leader)/i,/\bsi\b|systems?\s?integrator|\bisv\b/i],fuzzyTerms:["enterprise","platform","ecosystem","analyst","gartner","forrester","compliance","procurement","integrator","governance","scalability"]},{id:"sales-leader",patterns:[/\bsales\b/i,/revenue|\bquota\b|pipeline|forecast/i,/account\s?(exec|executive|manager)|\bae\b\s|\bsdr\b|\bbdr\b/i,/gtm\s?(lead|leader|strategy)?|go[-\s]?to[-\s]?market/i,/\bcro\b|chief\s?revenue|\bvp\s?sales\b/i,/\bcrm\b|salesforce|hubspot|outreach/i,/cold\s?(call|email)|prospect|deal\s?cycle|close\s?rate/i],fuzzyTerms:["sales","revenue","quota","pipeline","prospect","outreach","salesforce","hubspot","closer","gtm","forecast","commission"]}];function vo(t,s,n=2){if(t===s)return 0;if(Math.abs(t.length-s.length)>n)return 1/0;const i=t.length,a=s.length;if(!i)return a;if(!a)return i;let o=new Array(a+1),c=new Array(a+1);for(let d=0;d<=a;d++)o[d]=d;for(let d=1;d<=i;d++){c[0]=d;let y=d;for(let v=1;v<=a;v++){const f=t.charCodeAt(d-1)===s.charCodeAt(v-1)?0:1;c[v]=Math.min(c[v-1]+1,o[v]+1,o[v-1]+f),c[v]<y&&(y=c[v])}if(y>n)return 1/0;[o,c]=[c,o]}return o[a]}function jo(t){return t.toLowerCase().match(/[a-záéíóúñàâçèêëîïôûùüÿœãõ]{4,}/gi)||[]}
148function wo(t,s){const n=t.toLowerCase(),i=n.length>=7?2:1;for(const a of s)if(a===n||a.length>=5&&(a.includes(n)||n.includes(a))||Math.abs(a.length-n.length)<=i&&vo(a,n,i)<=i)return!0;return!1}function xn(t){if(!t)return null;const s=jo(t);let n=null;for(const{id:i,patterns:a,fuzzyTerms:o}of _o){let c=0;for(const d of a)d.test(t)&&(c+=2);for(const d of o)wo(d,s)&&(c+=1);c>0&&(!n||c>n.score)&&(n={id:i,score:c})}return n&&n.score>=2?n.id:null}function No(t){var a,o,c,d,y,v,f;const s=((a=t.persona_data)==null?void 0:a.personas)||((o=t.persona_data)==null?void 0:o.audiences)||[];if(Array.isArray(s)&&s.length){const _=s.map(x=>[x==null?void 0:x.name,x==null?void 0:x.label,x==null?void 0:x.role,x==null?void 0:x.archetype,x==null?void 0:x.description].filter(Boolean).join(" ")).join(" | "),N=xn(_);if(N){const x=tn.find(k=>k.id===N);if(x)return x.label}const m=s[0],h=(m==null?void 0:m.name)||(m==null?void 0:m.label)||(m==null?void 0:m.role)||(m==null?void 0:m.archetype);if(h)return String(h)}const n=[(c=t.positioning_data)==null?void 0:c.current_position,(d=t.positioning_data)==null?void 0:d.recommended_angle,(y=t.positioning_data)==null?void 0:y.summary,(v=t.narrative_data)==null?void 0:v.core_narrative,(f=t.narrative_data)==null?void 0:f.headline,t.input_text].filter(Boolean).join(" "),i=xn(n);if(i){const _=tn.find(N=>N.id===i);if(_)return _.label}}function ko(t){var i,a;const s=((i=t.persona_data)==null?void 0:i.personas)||((a=t.persona_data)==null?void 0:a.audiences);if(!Array.isArray(s)||!s.length)return;const n=s.map(o=>(o==null?void 0:o.name)||(o==null?void 0:o.label)||(o==null?void 0:o.role)||(o==null?void 0:o.archetype)).filter(Boolean).map(String);return n.length?Array.from(new Set(n)):void 0}function So(t){var i,a,o,c,d;const s=((i=t.positioning_data)==null?void 0:i.recommended_angle)||((a=t.positioning_data)==null?void 0:a.recommended_position)||((o=t.forecast_data)==null?void 0:o.fastest_unlock)||((c=t.narrative_data)==null?void 0:c.hero_statement),n=String(s||"").toLowerCase();return n?/reposition|reframe|new angle|pivot/.test(n)?"Reposition / Reframe":/authority|thought\s?leader|category/.test(n)?"Build authority":/awareness|reach|visibility|distribution/.test(n)?"Drive awareness":/convert|conversion|signup|demo|pipeline|lead/.test(n)?"Drive conversion":/trust|credibility|proof|case\s?stud/.test(n)?"Build trust":/launch|announce|reveal/.test(n)?"Launch / announce":/educate|teach|explain/.test(n)?"Educate":String(s).slice(0,100)+(String(s).length>100?"…":""):(d=t.forecast_data)!=null&&d.wants_to_be?`Reach: ${String(t.forecast_data.wants_to_be).slice(0,80)}`:void 0}function $o(t){var v,f,_,N;const s=[t.input_text,(v=t.narrative_data)==null?void 0:v.core_narrative,(f=t.narrative_data)==null?void 0:f.hero_statement,(_=t.positioning_data)==null?void 0:_.current_position,(N=t.positioning_data)==null?void 0:N.recommended_angle].filter(Boolean).join(" ").slice(0,1500);if(!s.trim())return;const n=s.toLowerCase(),i=m=>(n.match(m)||[]).length,a=m=>m.test(s)?3:0,o={Spanish:i(/\b(el|la|los|las|de|del|y|que|para|con|por|una?|en|es|son|más|pero|como|este|esta)\b/g)+a(/[áéíóúñ¿¡]/i),French:i(/\b(le|la|les|des|une?|pour|avec|que|nous|vous|est|sont|dans|sur|par|mais|comme|cette|ce|aux?)\b/g)+a(/[àâçèêëîïôûùüÿœ]/i),German:i(/\b(der|die|das|und|für|mit|nicht|eine?|ist|sind|auf|von|zu|den|dem|aber|auch|wie|diese[rns]?)\b/g)+a(/[äöüß]/i),Portuguese:i(/\b(o|a|os|as|de|que|para|com|não|uma?|em|é|são|mas|como|este|esta|por|do|da|dos|das)\b/g)+a(/[ãõáéíóúçâê]/i),Italian:i(/\b(il|la|gli|le|che|per|con|non|una?|è|sono|nel|della|dei|delle|ma|come|questa?|questo)\b/g)+a(/[àèéìòù]/i),Dutch:i(/\b(de|het|een|en|van|voor|met|niet|is|zijn|dat|die|maar|ook|als|deze|dit)\b/g),English:i(/\b(the|and|of|to|a|in|is|that|for|with|on|as|are|this|but|not|or|by|from|we|you|our)\b/g)},c=Object.entries(o).sort((m,h)=>h[1]-m[1]),[d,y]=c[0];return y<2||d!=="English"&&o.English>=y-1?"English":d}function Co(t){var i,a,o,c,d,y,v;const s=((i=t.narrative_data)==null?void 0:i.tone)||((a=t.narrative_data)==null?void 0:a.voice)||((o=t.narrative_data)==null?void 0:o.tone_of_voice)||((c=t.positioning_data)==null?void 0:c.tone);if(s)return String(s);const n=[(d=t.narrative_data)==null?void 0:d.core_narrative,(y=t.narrative_data)==null?void 0:y.hero_statement,(v=t.positioning_data)==null?void 0:v.recommended_angle].filter(
148Boolean).join(" ").toLowerCase();if(n){if(/empath|warm|human|caring/.test(n))return"Empathetic";if(/bold|provocative|contrarian|sharp/.test(n))return"Bold / contrarian";if(/authorit|expert|measured|boardroom/.test(n))return"Authoritative";if(/playful|fun|cheek|witty/.test(n))return"Playful";if(/clinical|evidence|rigor|data/.test(n))return"Evidence-based";if(/visionary|inspir|aspiration/.test(n))return"Visionary"}}const To=[{label:"Clinical Trials / Healthcare",patterns:[/clinical\s?trial/i,/patient\s?recruit/i,/\bhealth(care|tech)?\b/i,/pharma|biotech|hospital|provider/i]},{label:"Fintech",patterns:[/fintech|banking|payments?|lending|crypto|defi/i]},{label:"DevTools / SaaS",patterns:[/devtool|developer\s?platform|saas|api\s?platform|infrastructure/i]},{label:"AI / ML",patterns:[/\bai\b|\bllm\b|machine\s?learning|generative/i]},{label:"Consumer / Lifestyle",patterns:[/consumer|lifestyle|community|events?|potluck|social/i]},{label:"Enterprise B2B",patterns:[/enterprise|platform|ecosystem/i]},{label:"E-commerce / Retail",patterns:[/ecommerce|e-commerce|retail|shopify|d2c/i]},{label:"Education / EdTech",patterns:[/edtech|education|learning|curriculum/i]}];function Ro(t){var n,i,a;const s=[t.input_text,(n=t.positioning_data)==null?void 0:n.current_position,(i=t.narrative_data)==null?void 0:i.core_narrative,(a=t.scorecard)==null?void 0:a.summary].filter(Boolean).join(" ");for(const{label:o,patterns:c}of To)if(c.some(d=>d.test(s)))return o}function Ao(t){if(t.input_mode==="brief"){const s=String(t.input_text||"").toLowerCase();return/pitch\s?deck/.test(s)?"Pitch deck":/landing\s?page/.test(s)?"Landing page":/email|newsletter/.test(s)?"Email / newsletter":/post|tweet|linkedin/.test(s)?"Social post":/campaign|launch/.test(s)?"Campaign brief":"Strategic brief"}if(t.is_website||t.input_mode==="url")return"Website"}function zo(t){if(t.input_mode==="brief")return"brief";if(t.is_website||t.input_mode==="url")return"url";if(t.input_mode)return t.input_mode}function gn(t,s){const n={audience:No(t),audiences:ko(t),postGoal:So(t),language:$o(t),tone:Co(t),industry:Ro(t),assetType:Ao(t),inputMode:zo(t)};return s?{audience:s.audience||n.audience,audiences:s.audiences&&s.audiences.length?s.audiences:n.audiences,postGoal:s.postGoal||n.postGoal,language:s.language||n.language,tone:s.tone||n.tone,industry:s.industry||n.industry,assetType:s.assetType||n.assetType,inputMode:s.inputMode||n.inputMode}:n}const Eo={Clarity:On,Trust:Hn,Differentiation:lt,"Audience Fit":kt,Actionability:Gn,"Signal Strength":Rn};function Io({label:t,score:s}){const n=Eo[t]||Hn,i=We(s,"dimension_score","StrategicBriefReport.ScoreBar"),a=i>=70?"bg-emerald-500":i>=50?"bg-amber-500":"bg-red-500";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"w-24 text-xs text-muted-foreground truncate",children:t}),e.jsx("div",{className:"flex-1 bg-muted rounded-full h-2",children:e.jsx("div",{className:Z("h-2 rounded-full transition-all",a),style:{width:`${i}%`}})}),e.jsx("span",{className:"w-12 text-right text-xs font-bold",children:nt(s,"dimension_score")??"—"})]})}function Nr({basis:t}){const s=t==="measured"||t==="observed"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":t==="external_research"?"bg-blue-500/10 text-blue-600 dark:text-blue-400":t==="inferred"?"bg-amber-500/10 text-amber-600 dark:text-amber-400":"bg-muted text-muted-foreground";return e.jsx("span",{className:Z("text-[9px] font-bold uppercase px-1.5 py-0.5 rounded-full shrink-0",s),children:In[t]})}function Po(t,s){const n=typeof t=="number"&&Number.isFinite(t)?t:null;return{label:n===null?"Medium":n>=60?"High":n>=30?"Medium":"Low",basis:s&&n!==null?"measured":n!==null?"inferred":"validation_needed"}}function Es(t,s,n){const i=n.filter(o=>!$s(o)),a=t.filter(o=>{const c=s(o);return $s(c)?!0:!i.some(d=>Ja(d,c)>=.62)});return Ss(a,s)}function Lo({grade:t,score:s}){const n=s>=70?"stroke-emerald-500":s>=50?"stroke-amber-500":"stroke-red-500";return e.jsxs("div",{className:"relative w-16 h-16",children:[e.jsxs("svg",{className:"w-16 h-16 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("path",{d:"M18 2.0845a 15.9155 15.9155 0 0 1 0 31.831a 15.9155 15.9155 0 0 1 0 -31.831",fill:"none",className:"stroke-muted",strokeWidth:"3"}),e.jsx("path",{d:"M18 2.0845a 15.9155 15.9155 0 0 1 0 31.831a 15.9155 15.9155 0 0 1 0 -31.831",fill:"none",className:n,strokeWidth:"3",strokeDasharray:`${s}, 100`,strokeLinecap:"round"})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-base font-black text-foreground",children:t}),e.jsxs("span",{className:"text-[9px] text-muted-foreground",children:[s,"/100"]})]})]})}function Nt({label:t}){return e.jsxs("div",{className:"bg-secondary/20 border border-border/50 rounded-xl p-4 animate-pulse",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Pt,{className:"w-3.5 h-3.5 text-primary animate-spin"}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-bold",children:t})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-3 bg-muted/40 rounded-full w-4/5"}),e.jsx("div",{className:"h-3 bg-muted/40 rounded-full w-3/5"})]})]})}const Bo=[{id:"diagnosis",label:"Diagnosis",icon:lt,shortLabel:"Diagnosis"},{id:"audience",label:"Audience Perception Simulation",icon:is,shortLabel:"Audience"},{id:"gaps",label:"Gaps & Risks",icon:yr,shortLabel:"Gaps"}
148,{id:"recommendations",label:"Recommendations",icon:Gn,shortLabel:"Recs"}],Do=Sa.forwardRef(function({data:s,audienceData:n,audienceLoading:i,frictionData:a,frictionLoading:o,positioningData:c,positioningLoading:d,narrativeData:y,narrativeLoading:v,personaData:f,personaLoading:_,forecastData:N,forecastLoading:m,inputText:h,intakeData:x,onRetryAudience:k,personaSuggestions:w,personaSuggestionsLoading:$,onGeneratePersonas:V,onGenerateCustomPersona:G,analyticsConnected:E=!1,userCompetitors:L,evidenceInventory:R},l){var xe;const[T,S]=g.useState("diagnosis"),z=je(s,"strategic-brief-report"),C=z==null?void 0:z.brand_intelligence;if(!C)return null;const K={contentNames:(R==null?void 0:R.contentNames)??(R==null?void 0:R.competitor_names)??[],userProvidedNames:L??[],sourcedNames:(R==null?void 0:R.sourcedNames)??(R==null?void 0:R.sourced_competitor_names)??[],competitorReferences:(R==null?void 0:R.competitorReferences)??(R==null?void 0:R.competitor_references)??0},U=_r(N,E),re=(xe=C.scores)!=null&&xe.length?Math.round(C.scores.reduce((u,pe)=>u+We(pe.score,"dimension_score","StrategicBriefReport.avgScore"),0)/C.scores.length):0;return e.jsxs("div",{ref:l,"data-section":"diagnosis",className:"bg-card border border-border rounded-2xl overflow-hidden",children:[e.jsxs("div",{className:"bg-primary/5 border-b border-border px-4 py-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Lo,{grade:C.overall_grade||"?",score:re}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-0.5",children:e.jsx("span",{className:"text-[9px] uppercase tracking-wider bg-primary/10 text-primary px-1.5 py-0.5 rounded-full font-bold",children:"Strategic Brief"})}),e.jsx("h2",{className:"text-sm font-bold text-foreground truncate",children:h||"Brief Analysis"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:new Date().toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})})]})]}),(()=>{const u=C.biggest_friction||C.biggest_blind_spot,pe=Es([C.biggest_strength].filter(Boolean),ye=>
148ye,[])[0],q=Es([C.highest_leverage_move].filter(Boolean),ye=>ye,[u,pe])[0];return e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 mt-3",children:[pe&&e.jsxs("div",{className:"bg-emerald-500/10 rounded-lg px-2 py-1.5",children:[e.jsx("p",{className:"text-[9px] uppercase text-emerald-600 dark:text-emerald-400 font-bold",children:"💪 Strength"}),e.jsx("p",{className:"text-[11px] text-foreground leading-tight mt-0.5 line-clamp-2",children:pe})]}),u&&e.jsxs("div",{className:"bg-red-500/10 rounded-lg px-2 py-1.5",children:[e.jsx("p",{className:"text-[9px] uppercase text-red-600 dark:text-red-400 font-bold",children:"🔴 Weakness"}),e.jsx("p",{className:"text-[11px] text-foreground leading-tight mt-0.5 line-clamp-2",children:u})]}),q&&e.jsxs("div",{className:"bg-blue-500/10 rounded-lg px-2 py-1.5 col-span-2 sm:col-span-2",children:[e.jsx("p",{className:"text-[9px] uppercase text-blue-600 dark:text-blue-400 font-bold",children:"🎯 Next Move"}),e.jsx("p",{className:"text-[11px] text-foreground leading-tight mt-0.5 line-clamp-2",children:q})]})]})})()]}),e.jsx("div",{className:"flex border-b border-border bg-secondary/10 overflow-x-auto scrollbar-hide",children:Bo.map(u=>e.jsxs("button",{onClick:()=>S(u.id),className:Z("flex items-center gap-1.5 px-3 py-2.5 text-xs font-medium whitespace-nowrap transition-all border-b-2 -mb-[1px]",T===u.id?"border-primary text-primary bg-primary/5":"border-transparent text-muted-foreground hover:text-foreground"),children:[e.jsx(u.icon,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:u.label}),e.jsx("span",{className:"sm:hidden",children:u.shortLabel})]},u.id))}),e.jsxs("div",{className:"p-4",children:[T==="diagnosis"&&e.jsx(Mo,{bi:C,intakeData:x,forecastData:U,forecastLoading:m,analyticsConnected:E}),T==="audience"&&e.jsx(Oo,{audienceData:n,audienceLoading:i,onRetry:k,personaSuggestions:w,personaSuggestionsLoading:$,onGeneratePersonas:V,onGenerateCustomPersona:G,analyticsConnected:E}),T==="gaps"&&e.jsx(Uo,{bi:C,frictionData:a,frictionLoading:o,positioningData:c,positioningLoading:d,competitorGuardInput:K}),T==="recommendations"&&e.jsx(Fo,{bi:C,audienceData:n,narrativeData:y,narrativeLoading:v,personaData:f,personaLoading:_,analyticsConnected:E})]})]})});function Mo({bi:t,intakeData:s,forecastData:n,forecastLoading:i,analyticsConnected:a=!1}){var c;const o=(s==null?void 0:s.initial_findings)||s;return e.jsxs("div",{className:"space-y-4",children:[o&&e.jsx("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[["Industry",o.industry],["Model",o.b2b_b2c],["Stage",o.stage]].map(([d,y])=>y&&e.jsxs("div",{className:"bg-secondary/30 rounded-lg px-2.5 py-1.5 text-center",children:[e.jsx("span",{className:"text-muted-foreground block text-[10px]",children:d}),e.jsx("span",{className:"text-foreground font-medium capitalize",children:y})]},d))}),t.headline_verdict&&e.jsxs("div",{className:"bg-primary/5 border border-primary/10 rounded-xl p-3",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:t.headline_verdict}),t.one_line_repositioning&&e.jsxs("p",{className:"text-xs text-primary mt-1",children:["→ ",t.one_line_repositioning]})]}),((c=t.scores)==null?void 0:c.length)>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-bold text-foreground mb-2 uppercase tracking-wider",children:"Signal Dimensions"}),e.jsx("div",{className:"space-y-1.5",children:t.scores.map(d=>e.jsx(Io,{label:d.dimension,score:d.score},d.dimension))})]}),t.what_you_appear_to_be&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"bg-red-500/5 border border-red-500/10 rounded-lg p-2.5",children:[e.jsx("p",{className:"text-[10px] uppercase text-red-500 font-bold mb-0.5",children:"Reads As"}),e.jsx("p",{className:"text-xs text-foreground",children:t.what_you_appear_to_be})]}),e.jsxs("div",{className:"bg-emerald-500/5 border border-emerald-500/10 rounded-lg p-2.5",children:[e.jsx("p",{className:"text-[10px] uppercase text-emerald-500 font-bold mb-0.5",children:"Wants To Be"}),e.jsx("p",{className:"text-xs text-foreground",children:t.what_you_want_to_be})]})]}),t.market_read_summary&&e.jsxs("div",{className:"bg-primary/5 border border-primary/10 rounded-lg p-2.5",children:[e.jsx("p",{className:"text-[10px] uppercase text-primary font-bold mb-0.5",children:"📊 Market-Read"}),e.jsx("p",{className:"text-xs text-foreground",children:t.market_read_summary})]}),i&&e.jsx(Nt,{label:"Modeling growth trajectory…"}),(n==null?void 0:n.fastest_unlock)&&e.jsxs("div",{className:"bg-emerald-500/5 border border-emerald-500/10 rounded-lg p-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-0.5",children:[e.jsx("p",{className:"text-[10px] uppercase text-emerald-600 dark:text-emerald-400 font-bold",children:"🚀 Fastest Unlock"}),(()=>{const d=Vs(n.fastest_unlock,{hasAnalytics:a});return e.jsx(Nr,{basis:d.evidence_basis})})()]}),(()=>{const d=n.fastest_unlock,y=Vs(n.fastest_unlock,{hasAnalytics:a}),v=N=>typeof N=="string"&&N.trim()?N:"",f=d&&typeof d=="object"?d:{}
148,_=typeof d=="string"?d:v(f.action)||v(f.scenario)||v(y.action)||v(y.scenario)||"";return _?e.jsx("p",{className:"text-xs font-semibold text-foreground",children:_}):null})(),(()=>{const d=Vs(n.fastest_unlock,{hasAnalytics:a});return!d.affected_dimensions.length&&!d.expected_impact?null:e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:["Expected impact: ",d.expected_impact,d.affected_dimensions.length?` · Affects: ${d.affected_dimensions.join(", ")}`:""]})})()]})]})}function Oo({audienceData:t,audienceLoading:s,onRetry:n,personaSuggestions:i,personaSuggestionsLoading:a,onGeneratePersonas:o,onGenerateCustomPersona:c,analyticsConnected:d=!1}){var $,V,G,E,L,R;const[y,v]=g.useState(0),[f,_]=g.useState(-1),[N,m]=g.useState("");if(s)return e.jsx(Nt,{label:"Simulating audience reactions…"});if(!(($=t==null?void 0:t.audience_reactions)!=null&&$.length))return e.jsxs("div",{className:"text-center py-6 space-y-3",children:[e.jsx(is,{className:"w-8 h-8 text-muted-foreground mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Audience simulation not available yet."}),n&&e.jsxs("button",{onClick:n,className:"text-xs text-primary hover:underline flex items-center gap-1 mx-auto",children:[e.jsx(ns,{className:"w-3 h-3"})," Retry"]})]});const h=t.audience_reactions,x=t.cross_audience_insights,k=i==null?void 0:i.suggested_personas,w=i==null?void 0:i.persona_strategy;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-secondary/20 px-3 py-2",children:[e.jsx("p",{className:"text-xs font-bold text-foreground",children:"Audience Perception Simulation"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Inferred assessment modeled from your content — not observed audience behavior or measured results."})]}),h.map((l,T)=>{const S=y===T,z=We(l.reception_score,"reception_score"),C=z>=70?"text-emerald-500 bg-emerald-500/10":z>=50?"text-amber-500 bg-amber-500/10":"text-red-500 bg-red-500/10";return e.jsxs("div",{className:"border border-border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>v(S?-1:T),className:"w-full flex items-center gap-3 px-3 py-2.5 bg-secondary/20 hover:bg-secondary/30 transition-colors",children:[e.jsx("span",{className:Z("text-xs font-bold px-2 py-0.5 rounded-full",C),children:nt(l.reception_score,"reception_score","StrategicBriefReport.segment")??"—"}),e.jsx("span",{className:"text-sm font-semibold text-foreground flex-1 text-left capitalize",children:l.segment}),e.jsx(lr,{className:Z("w-4 h-4 text-muted-foreground transition-transform",S&&"rotate-90")})]}),S&&e.jsxs("div",{className:"px-3 py-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground italic",children:l.mindset}),e.jsx(ss,{icon:"✅",label:"Clear to them",items:l.clear,color:"text-emerald-600 dark:text-emerald-400"}),e.jsx(ss,{icon:"❓",label:"Feels vague",items:l.vague,color:"text-amber-600 dark:text-amber-400"}),e.jsx(ss,{icon:"🔒",label:"Builds trust",items:l.trust_builders,color:"text-blue-600 dark:text-blue-400"}),e.jsx(ss,{icon:"⚡",label:"Creates friction",items:l.friction_points,color:"text-red-600 dark:text-red-400"}),e.jsx(ss,{icon:"👻",label:"Gets ignored",items:l.ignored,color:"text-muted-foreground"}),e.jsxs("div",{className:"bg-primary/5 border border-primary/10 rounded-lg p-2.5",children:[e.jsxs("p",{className:"text-[10px] uppercase text-primary font-bold mb-0.5",children:["💡 Key Insight for ",l.segment]}),e.jsx("p",{className:"text-xs text-foreground",children:l.killer_insight})]}),l.rewrite&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:["✏️ Rewrite for ",l.segment]}),e.jsx("div",{className:"bg-red-500/5 rounded-lg p-2 text-xs text-muted-foreground line-through",children:l.rewrite.original_section}),e.jsx("div",{className:"bg-emerald-500/5 border border-emerald-500/10 rounded-lg p-2 text-xs text-foreground",children:l.rewrite.improved_version}),e.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:l.rewrite.rationale})]})]})]},T)}),x&&e.jsxs("div",{className:"border border-primary/20 rounded-xl p-3 space-y-2.5 bg-primary/5",children:[e.jsx("p",{className:"text-xs font-bold text-foreground uppercase tracking-wider",children:"🔗 Cross-Audience Insights"}),((V=x.universal_strengths)==null?void 0:V.length)>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-emerald-600 dark:text-emerald-400 font-bold mb-0.5",children:"Works for everyone"}),x.universal_strengths.map((l,T)=>e.jsx("p",{className:"text-xs text-foreground pl-3 relative before:content-['•'] before:absolute before:left-0 before:text-emerald-500",children:l},T))]}),((G=x.universal_gaps)==null?void 0:G.length)>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-red-600 dark:text-red-400 font-bold mb-0.5",children:"Fails for everyone"}),x.universal_gaps.map((l,T)=>e.jsx("p",{className:"text-xs text-foreground pl-3 relative before:content-['•'] before:absolute before:left-0 before:text-red-500",children:l},T))]}),((E=x.audience_conflicts)==null?void 0:E.length)>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-amber-600 dar
148k:text-amber-400 font-bold mb-0.5",children:"Audience conflicts"}),x.audience_conflicts.map((l,T)=>e.jsx("p",{className:"text-xs text-foreground pl-3 relative before:content-['•'] before:absolute before:left-0 before:text-amber-500",children:l},T))]}),x.priority_audience&&e.jsxs("div",{className:"bg-background/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-[10px] text-primary font-bold mb-0.5",children:"🎯 Priority audience"}),e.jsx("p",{className:"text-xs text-foreground",children:x.priority_audience})]}),x.unified_recommendation&&e.jsxs("div",{className:"bg-background/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-[10px] text-primary font-bold mb-0.5",children:"🔑 Unified recommendation"}),e.jsx("p",{className:"text-xs text-foreground",children:x.unified_recommendation})]})]}),e.jsxs("div",{className:"border border-border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"bg-secondary/20 px-3 py-2.5 flex items-center gap-2",children:[e.jsx(ws,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-xs font-bold text-foreground uppercase tracking-wider flex-1",children:"AI Persona Role-Play"}),!k&&!a&&o&&e.jsxs(_e,{size:"sm",variant:"outline",onClick:o,className:"text-[10px] h-7 gap-1.5",children:[e.jsx(Lt,{className:"w-3 h-3"})," Generate Personas"]})]}),e.jsxs("div",{className:"p-3",children:[a&&e.jsx(Nt,{label:"Generating realistic personas for your use case…"}),!k&&!a&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx(ln,{className:"w-6 h-6 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generate AI personas to role-play how specific people would react to your messaging."}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Each persona includes inner monologue, objections, and targeted rewrites."})]}),(k==null?void 0:k.length)>0&&e.jsxs("div",{className:"space-y-3",children:[w&&e.jsxs("div",{className:"bg-primary/5 border border-primary/10 rounded-lg p-2.5 space-y-1.5",children:[e.jsx("p",{className:"text-[10px] uppercase text-primary font-bold",children:"🎯 Persona Strategy"}),e.jsxs("p",{className:"text-xs text-foreground",children:[e.jsx("span",{className:"font-semibold",children:"Optimize for:"})," ",w.primary_persona]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:w.reasoning}),w.recommended_variants&&e.jsxs("p",{className:"text-[10px] text-primary font-medium",children:["→ ",w.recommended_variants," message variant",w.recommended_variants>1?"s":""," recommended"]}),((L=w.universal_hooks)==null?void 0:L.length)>0&&e.jsxs("div",{className:"mt-1",children:[e.jsx("p",{className:"text-[10px] text-emerald-600 dark:text-emerald-400 font-bold mb-0.5",children:"Universal hooks"}),w.universal_hooks.map((l,T)=>e.jsx("p",{className:"text-[10px] text-foreground pl-2 relative before:content-['•'] before:absolute before:left-0 before:text-emerald-500",children:l},T))]}),((R=w.messaging_tensions)==null?void 0:R.length)>0&&e.jsxs("div",{className:"mt-1",children:[e.jsx("p",{className:"text-[10px] text-amber-600 dark:text-amber-400 font-bold mb-0.5",children:"Messaging tensions"}),w.messaging_tensions.map((l,T)=>e.jsx("p",{className:"text-[10px] text-foreground pl-2 relative before:content-['•'] before:absolute before:left-0 before:text-amber-500",children:l},T))]})]}),k.map((l,T)=>{var U,re;const S=f===T,z=l.trust_level==="high"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":l.trust_level==="medium"?"bg-amber-500/10 text-amber-600 dark:text-amber-400":"bg-red-500/10 text-red-600 dark:text-red-400",C=Po(l.conversion_probability,d),K=C.label==="High"?"text-emerald-500":C.label==="Medium"?"text-amber-500":"text-red-500";return e.jsxs("div",{className:"border border-border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>_(S?-1:T),className:"w-full flex items-center gap-2 px-3 py-2 bg-secondary/10 hover:bg-secondary/20 transition-colors",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ln,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{className:"flex-1 text-left min-w-0",children:[e.jsxs("p",{className:"text-xs font-semibold text-foreground truncate",children:[l.name,", ",l.age," — ",l.role]}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:l.headline})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{className:Z("text-[10px] font-bold px-1.5 py-0.5 rounded-full",z),children:l.trust_level}),e.jsx("span",{className:Z("text-xs font-bold",K),children:C.label})]}),e.jsx(lr,{className:Z("w-3.5 h-3.5 text-muted-foreground transition-transform shrink-0",S&&"rotate-90")})]}),S&&e.jsxs("div",{className:"px-3 py-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:l.backstory}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:Z("text-[10px] font-medium px-2 py-0.5 rounded-full",z),children:["Trust: ",l.trust_level]}),e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-secondary/40 text-muted-foreground",children:l.decision_style}),e.jsxs("span",{className:Z("text-[10px] font-bold",K),children:[C.label," likelihood to convert"]}),e.jsx(Nr,{basis:C.basis})]}),((U=l.inner_monologue)==null?void 0:U.length)>0&&e.jsxs("div",{className:"bg-secondary/20 border border-border/50 rounded-lg p-2.5",children:[e.jsxs("p",{className:"text-[10px] uppercase font-bold text-muted-foreground mb-1.5 flex items-center gap-1",children:[e.jsx($a,{className:"w-3 h-3"})," Inner Monologue"]}),e.jsx("div",{className:"space-y-1.5",children:l.inner_monologue.map((xe,u)=>e.jsxs("p",{className:"text-xs text-foreground italic pl-3 border-l-2 border-primary/20",children:['"',xe,'"']},u))})]}),((re=l.objections)==null?void 0:re.length)>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] text-red-600 dark:text-red-400 font-bold mb-0.5 flex items-center gap-1",children:[e.jsx(Zi,{className:"w-3 h-3"})," Objections"]}),l.objections.map((xe,u)=>e.jsx("p",{className:"text-xs text-foreground pl-3 relative before:content-['–'] before:absolute before:left-0 before:text-red-500 mb-0.5",children:xe},u))]}),l.what_would_convert_them&&e.jsxs("div",{className:"bg-emerald-500/5 border border-emerald-500/10 rounded-lg p-2.5",children:[e.jsxs("p",{className:"text-[10px] uppercase text-emerald-600 dark:text-emerald-400 font-bold mb-0.5 flex items-center gap-1",children:[e.jsx(ci,{className:"w-3 h-3"})," What Would Convert Them"]}),e.jsx("p",{className:"text-xs text-foreground",children:l.what_would_convert_them})]}),l.rewrite_for_persona&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:["✏️ Rewrite for ",l.name]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:l.rewrite_for_persona.key_change}),e.jsx("div",{className:"bg-emerald-500/5 border border-emerald-500/10 rounded-lg p-2 text-xs text-foreground",children:l.rewrite_for_persona.sample_line})]})]})]},T)})]}),c&&e.jsxs("div",{className:"border-t border-border/50 pt-3 mt-2",children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground mb-2 flex items-center gap-1",children:[e.jsx(qn,{
148className:"w-3 h-3"})," Add Your Own Persona"]}),e.jsx("p",{className:"text-[10px] text-muted-foreground mb-2",children:'Describe a specific person to role-play (e.g. "skeptical smoker, 47, tried quitting 3 times")'}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(rt,{value:N,onChange:l=>m(l.target.value),placeholder:"e.g. busy working mom, 34, health-conscious but time-poor",className:"text-xs h-8 flex-1",onKeyDown:l=>{l.key==="Enter"&&N.trim()&&(c(N.trim()),m(""))},disabled:a}),e.jsxs(_e,{size:"sm",variant:"outline",className:"h-8 px-2.5 gap-1 text-[10px]",disabled:!N.trim()||a,onClick:()=>{c(N.trim()),m("")},children:[e.jsx(mr,{className:"w-3 h-3"})," Role-Play"]})]})]})]})]})]})}function ss({icon:t,label:s,items:n,color:i}){return n!=null&&n.length?e.jsxs("div",{children:[e.jsxs("p",{className:Z("text-[10px] font-bold mb-0.5",i),children:[t," ",s]}),n.map((a,o)=>e.jsx("p",{className:"text-xs text-foreground pl-3 relative before:content-['–'] before:absolute before:left-0 before:text-muted-foreground mb-0.5",children:a},o))]}):null}function Uo({bi:t,frictionData:s,frictionLoading:n,positioningData:i,positioningLoading:a,competitorGuardInput:o}){t.message_gap_analysis||t.obvious_gaps;const y=(t.scores||[]).map(_=>({..._,normalized:We(_.score,"dimension_score","StrategicBriefReport.gaps")})).filter(_=>_.normalized<=50),v=o??{},f=Bn(En(i==null?void 0:i.stolen_narratives,v),["narrative","owned_by"],"StrategicBriefReport.stolenNarratives");return e.jsxs("div",{className:"space-y-4",children:[y.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-bold text-foreground mb-2 uppercase tracking-wider",children:"⚠️ Weak Signals"}),e.jsx("div",{className:"space-y-2",children:y.map(_=>e.jsxs("div",{className:"bg-red-500/5 border border-red-500/10 rounded-lg p-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-semibold text-foreground",children:_.dimension}),e.jsx("span",{className:Z("text-xs font-bold",_.normalized<=30?"text-red-500":"text-amber-500"),children:nt(_.score,"dimension_score")??"—"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:_.diagnosis})]},_.dimension))})]}),t.what_you_appear_to_be&&t.what_you_want_to_be&&e.jsxs("div",{className:"bg-amber-500/5 border border-amber-500/10 rounded-lg p-2.5",children:[e.jsx("p",{className:"text-[10px] uppercase text-amber-500 font-bold mb-1",children:"🔀 Perception Gap Risk"}),e.jsxs("p",{className:"text-xs text-foreground",children:[e.jsx("strong",{children:"Reads as:"})," ",t.what_you_appear_to_be]}),e.jsxs("p",{className:"text-xs text-foreground",children:[e.jsx("strong",{children:"Should read as:"})," ",t.what_you_want_to_be]})]}),n&&e.jsx(Nt,{label:"Analyzing friction points…"}),(s==null?void 0:s.dimensions)&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-bold text-foreground mb-2 uppercase tracking-wider",children:"⚡ Friction Points"}),e.jsx("div",{className:"space-y-2",children:s.dimensions.filter(_=>{var N;return(N=_.friction_points)==null?void 0:N.some(m=>m.severity==="critical"||m.severity==="high")}).flatMap(_=>_.friction_points.filter(N=>N.severity==="critical"||N.severity==="high")).slice(0,5).map((_,N)=>e.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[e.jsx("span",{className:Z("text-[9px] font-bold uppercase px-1.5 py-0.5 rounded shrink-0",_.severity==="critical"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-500"),children:_.severity}),e.jsxs("div",{children:[e.jsx("p",{className:"text-foreground font-medium",children:_.issue}),e.jsx("p",{className:"text-muted-foreground mt-0.5",children:_.fix})]})]},N))})]}),t.biggest_friction&&e.jsxs("div",{className:"bg-red-500/5 border border-red-500/10 rounded-lg p-2.5",children:[e.jsx("p",{className:"text-[10px] uppercase text-red-500 font-bold mb-0.5",children:"🔴 Biggest Risk"}),e.jsx("p",{className:"text-xs text-foreground",children:t.biggest_friction})]}),a&&e.jsx(Nt,{label:"Mapping competitive positioning…"}),(i==null?void 0:i.biggest_positioning_risk)&&e.jsxs("div",{className:"bg-amber-500/5 border border-amber-500/10 rounded-lg p-2.5",children:[e.jsx("p",{className:"text-[10px] uppercase text-amber-600 dar
148k:text-amber-400 font-bold mb-0.5",children:"🎯 Positioning Risk"}),e.jsx("p",{className:"text-xs text-foreground",children:i.biggest_positioning_risk})]}),f.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-bold text-foreground mb-2 uppercase tracking-wider",children:"🏴 Stolen Narratives"}),e.jsx("div",{className:"space-y-1.5",children:f.slice(0,3).map((_,N)=>e.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[e.jsx("span",{className:Z("text-[9px] font-bold uppercase px-1.5 py-0.5 rounded shrink-0",_.strength==="strong"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-500"),children:_.recommendation}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-foreground font-medium",children:['"',_.narrative,'"']}),!$s(_.owned_by)&&e.jsxs("p",{className:"text-muted-foreground",children:["Owned by ",_.owned_by]})]})]},N))})]})]})}function Fo({bi:t,audienceData:s,narrativeData:n,narrativeLoading:i,personaData:a,personaLoading:o,analyticsConnected:c=!1}){var _,N,m;const d=[t.headline_verdict,t.one_line_repositioning,t.highest_leverage_move],y=Es(t.top_3_fast_improvements||[],h=>h,d);y.forEach(h=>d.push(h));const v=Va({confidence:t.highest_leverage_move_confidence,hasAnalytics:c}),f=Es(t.website_recommendations||[],h=>(h==null?void 0:h.fix)||(h==null?void 0:h.issue)||"",d);return e.jsxs("div",{className:"space-y-4",children:[t.one_line_repositioning&&e.jsxs("div",{className:"bg-primary/5 border border-primary/10 rounded-xl p-3",children:[e.jsx("p",{className:"text-[10px] uppercase text-primary font-bold mb-0.5",children:"🎯 Repositioning"}),e.jsx("p",{className:"text-sm font-semibold text-foreground",children:t.one_line_repositioning})]}),y.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-bold text-foreground mb-2 uppercase tracking-wider",children:"⚡ Quick Wins"}),e.jsx("div",{className:"space-y-1.5",children:y.map((h,x)=>e.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[e.jsx("span",{className:"w-5 h-5 rounded-full bg-emerald-500/10 text-emerald-500 flex items-center justify-center shrink-0 text-[10px] font-bold",children:x+1}),e.jsx("p",{className:"text-foreground",children:h})]},x))})]}),t.highest_leverage_move&&e.jsxs("div",{className:"bg-blue-500/5 border border-blue-500/10 rounded-lg p-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-0.5",children:[e.jsx("p",{className:"text-[10px] uppercase text-blue-500 font-bold",children:"🎯 Highest-Leverage Move"}),e.jsx(Nr,{basis:v})]}),e.jsx("p",{className:"text-xs text-foreground",children:t.highest_leverage_move})]}),((_=s==null?void 0:s.audience_reactions)==null?void 0:_.some(h=>h.rewrite))&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-bold text-foreground mb-2 uppercase tracking-wider",children:"✏️ Audience-Tailored Rewrites"}),e.jsx("div",{className:"space-y-3",children:s.audience_reactions.filter(h=>h.rewrite).map((h,x)=>e.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"bg-secondary/20 px-3 py-1.5 flex items-center gap-2",children:[e.jsx(is,{className:"w-3 h-3 text-primary"}),e.jsxs("span",{className:"text-xs font-semibold text-foreground capitalize",children:["For ",h.segment]}),e.jsx("span",{className:Z("text-[9px] font-bold px-1.5 py-0.5 rounded-full ml-auto",We(h.reception_score,"reception_score")>=70?"bg-emerald-500/10 text-emerald-500":We(h.reception_score,"reception_score")>=50?"bg-amber-500/10 text-amber-500":"bg-red-500/10 text-red-500"),children:nt(h.reception_score,"reception_score","StrategicBriefReport.persona")??"—"})]}),e.jsxs("div",{className:"px-3 py-2 space-y-1.5",children:[e.jsx("div",{className:"bg-red-500/5 rounded p-2 text-xs text-muted-foreground line-through",children:h.rewrite.original_section}),e.jsx("div",{className:"bg-emerald-500/5 border border-emerald-500/10 rounded p-2 text-xs text-foreground",children:h.rewrite.improved_version}),e.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:h.rewrite.rationale})]})]},x))})]}
148),((N=s==null?void 0:s.cross_audience_insights)==null?void 0:N.unified_recommendation)&&e.jsxs("div",{className:"bg-primary/5 border border-primary/10 rounded-lg p-2.5",children:[e.jsx("p",{className:"text-[10px] uppercase text-primary font-bold mb-0.5",children:"🔑 Universal Improvement"}),e.jsx("p",{className:"text-xs text-foreground",children:s.cross_audience_insights.unified_recommendation})]}),i&&e.jsx(Nt,{label:"Building narrative architecture…"}),(n==null?void 0:n.messaging_hierarchy)&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-bold text-foreground mb-2 uppercase tracking-wider",children:"📝 Messaging Hierarchy"}),e.jsxs("div",{className:"bg-secondary/20 rounded-lg p-2.5 space-y-1.5",children:[e.jsxs("p",{className:"text-xs",children:[e.jsx("span",{className:"font-semibold text-foreground",children:"Promise:"})," ",e.jsx("span",{className:"text-muted-foreground",children:n.messaging_hierarchy.tier_1_promise})]}),(m=n.messaging_hierarchy.tier_2_proof)==null?void 0:m.map((h,x)=>e.jsx("p",{className:"text-xs text-muted-foreground pl-3 relative before:content-['•'] before:absolute before:left-0 before:text-primary",children:h},x))]})]}),(n==null?void 0:n.fastest_narrative_win)&&e.jsxs("div",{className:"bg-emerald-500/5 border border-emerald-500/10 rounded-lg p-2.5",children:[e.jsx("p",{className:"text-[10px] uppercase text-emerald-600 dark:text-emerald-400 font-bold mb-0.5",children:"✨ Fastest Narrative Win"}),e.jsx("p",{className:"text-xs text-foreground",children:n.fastest_narrative_win})]}),o&&e.jsx(Nt,{label:"Synthesizing audience personas…"}),(a==null?void 0:a.fastest_persona_win)&&e.jsxs("div",{className:"bg-blue-500/5 border border-blue-500/10 rounded-lg p-2.5",children:[e.jsx("p",{className:"text-[10px] uppercase text-blue-600 dark:text-blue-400 font-bold mb-0.5",children:"👤 Persona Insight"}),e.jsx("p",{className:"text-xs text-foreground",children:a.fastest_persona_win})]}),f.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-bold text-foreground mb-2 uppercase tracking-wider",children:"🌐 Copy Recommendations"}),e.jsx("div",{className:"space-y-2",children:f.map((h,x)=>e.jsxs("div",{className:"bg-secondary/20 rounded-lg p-2.5",children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:h.area}),e.jsxs("p",{className:"text-[10px] text-red-500 mt-0.5",children:["Issue: ",h.issue]}),e.jsxs("p",{className:"text-[10px] text-emerald-500 mt-0.5",children:["Fix: ",h.fix]})]},x))})]})]})}function b(t){return t?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""}function ys(t,s="dimension_score",n){const i=We(t,s,{schema:n,location:"export-diagnosis.scoreColor"});return i>=70?"#22c55e":i>=50?"#f59e0b":"#ef4444"}function Xs(t,s,n){if(ti(s))return`
149    <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:8px 0 2px;">${b(Zr[t]||t)}</p>
150    <p style="font-size:12px;font-weight:700;color:#6b7280;margin:0;">Needs validation — material signals conflict</p>
151  `;const i=si(n,s),a=i==="bad"?"#ef4444":i==="warn"?"#f59e0b":"#22c55e";return`
152    <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:8px 0 2px;">${b(Zr[t]||t)}</p>
153    <p style="font-size:13px;font-weight:700;color:${a};margin:0;">${b(String(s).replace(/_/g," "))}</p>
154  `}function fn(t){return t!=null&&t.startsWith("A")?"#22c55e":t!=null&&t.startsWith("B")?"#3b82f6":t!=null&&t.startsWith("C")?"#f59e0b":"#ef4444"}function _s(t){return t==="critical"||t==="high"?"#ef4444":t==="medium"?"#f59e0b":"#22c55e"}function qo(t){return t==="critical"||t==="high"?"#fef2f2":t==="medium"?"#fffbeb":"#f0fdf4"}function hn(t,s,n){if(!t)return;const i=Go(t,s,n),a=window.open("","_blank");a&&(a.document.write(i),a.document.close(),setTimeout(()=>a.print(),500))}function Go(t,s,n){var Ce,at,Pe,ut,Ot,St,Fe,mt,Ut,$t,ls,Ct,cs,xt,ds,_t,ps;const i=je(t,"diagnosis-pdf"),a=je(n||{},"diagnosis-pdf-options"),o=i.brand_intelligence,c=It(o)??It(i),d=i.white_space,y=i.market_opportunity,v=i.competitive_strategy,f=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),_=((Ce=a==null?void 0:a.intakeData)==null?void 0:Ce.initial_findings)||(a==null?void 0:a.intakeData),N=(()=>{var Q,P,ge;return!_||!_.industry&&!((Q=_.key_strengths)!=null&&Q.length)?"":`
155      <div style="display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px;">
156        ${[_.industry&&["Industry",_.industry],_.b2b_b2c&&["Model",_.b2b_b2c],_.stage&&["Stage",_.stage],_.geography&&["Geography",_.geography]].filter(
156Boolean).map(([J,O])=>`
157          <div style="background:#f3f4f6;border-radius:8px;padding:6px 14px;text-align:center;">
158            <span style="font-size:10px;color:#6b7280;display:block;text-transform:uppercase;letter-spacing:0.05em;">${b(J)}</span>
159            <span style="font-size:13px;font-weight:600;color:#111827;text-transform:capitalize;">${b(O)}</span>
160          </div>
161        `).join("")}
162      </div>
163      ${(P=_.key_strengths)!=null&&P.length?`
164        <div style="margin-bottom:12px;">
165          <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 4px;letter-spacing:0.05em;">Key Strengths Detected</p>
166          <div style="display:flex;gap:6px;flex-wrap:wrap;">
167            ${_.key_strengths.map(J=>`<span style="font-size:12px;background:#ecfdf5;color:#059669;border-radius:9999px;padding:3px 10px;">${b(J)}</span>`).join("")}
168          </div>
169        </div>
170      `:""}
171      ${(ge=_.obvious_gaps)!=null&&ge.length?`
172        <div style="margin-bottom:12px;">
173          <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 4px;letter-spacing:0.05em;">Gaps Identified</p>
174          <div style="display:flex;gap:6px;flex-wrap:wrap;">
175            ${_.obvious_gaps.map(J=>`<span style="font-size:12px;background:#fef2f2;color:#dc2626;border-radius:9999px;padding:3px 10px;">${b(J)}</span>`).join("")}
176          </div>
177        </div>
178      `:""}
179    `})(),m=dr((a==null?void 0:a.objective)??((at=a==null?void 0:a.intakeData)==null?void 0:at.objective)??((Pe=a==null?void 0:a.intakeData)==null?void 0:Pe.outcome)??((ut=a==null?void 0:a.intakeData)==null?void 0:ut.desired_outcome)),k=((o==null?void 0:o.entity_type)||(i==null?void 0:i.entity_type)||"company")==="company"?ri:ni,w=a==null?void 0:a.frictionData,$=Qa({scores:o==null?void 0:o.scores,overallGrade:o==null?void 0:o.overall_grade,friction:w,forecast:a==null?void 0:a.forecastData,narrativeGapSeverity:(Ot=a==null?void 0:a.narrativeData)==null?void 0:Ot.gap_severity,partnerBlockers:(St=a==null?void 0:a.forecastData)==null?void 0:St.partner_blockers,scoreSchema:c}),V={competitorReferences:((Fe=o==null?void 0:o.evidence_inventory)==null?void 0:Fe.competitor_references)||0,contentNames:((mt=a==null?void 0:a.positioningData)==null?void 0:mt.competitor_names_in_content)||[],userProvidedNames:(a==null?void 0:a.userCompetitors)||((Ut=a==null?void 0:a.intakeData)==null?void 0:Ut.competitors)||[],hasExternalSource:!!((ls=($t=a==null?void 0:a.positioningData)==null?void 0:$t.external_sources)!=null&&ls.length)},G=Ka({...(o==null?void 0:o.evidence_inventory)||{},hasAnalytics:!!(a!=null&&a.analyticsConnected),pagesAnalyzed:(a==null?void 0:a.pagesAnalyzed)??((Ct=a==null?void 0:a.intakeData)==null?void 0:Ct.pages_analyzed)??null}),E=!!(a!=null&&a.analyticsConnected),L=(()=>{if(!(o!=null&&o.evidence_inventory))return"";const p=G.counts;return`
180      <div class="card" style="background:#f9fafb;border:1px solid #e5e7eb;border-radius:8px;padding:12px;margin-bottom:16px;">
181        <p style="font-size:12px;margin:0 0 6px;"><strong>Analysis Coverage: ${G.level}</strong></p>
182        <table style="width:100%;border-collapse:collapse;font-size:11px;margin:0 0 6px;">
183          ${G.inputs.map(Q=>`
184            <tr>
185              <td style="padding:3px 6px;border-bottom:1px solid #f3f4f6;color:#374151;">${b(Q.label)}</td>
186              <td style="padding:3px 6px;border-bottom:1px solid #f3f4f6;font-weight:700;color:${Q.included?"#16a34a":"#9ca3af"};">${Q.included?"Included":"Not included"}</td>
187              <td style="padding:3px 6px;border-bottom:1px solid #f3f4f6;color:#6b7280;">${Q.sources!=null?`${Q.sources} source${Q.sources===1?"":"s"}`:"—"}</td>
188            </tr>`).join("")}
189        </table>
190        <p style="font-size:12px;color:#6b7280;margin:0;">Interpretation: ${b(G.interpretation)}</p>
191        <p style="font-size:10px;color:#9ca3af;margin:6px 0 0;">Signal counts (detail): quotes ${p.direct_quotes} · features ${p.observable_features} · third-party ${p.third_party_signals} · data ${p.data_points} · competitor refs ${p.competitor_references}. Counts describe coverage, not proof.</p>
192      </div>
193    `})(),R=((cs=o==null?void 0:o.scores)==null?void 0:cs.map(p=>`
194    <tr>
195      <td style="padding:8px 12px;border-bottom:1px solid #e5e7eb;font-size:13px;font-weight:600;">${b(p.dimension)}</td>
196      <td style="padding:8px 12px;border-bottom:1px solid #e5e7eb;text-align:center;">
197        <div style="display:inline-flex;align-items:center;gap:8px;">
198          <div style="width:120px;height:8px;background:#f3f4f6;border-radius:4px;overflow:hidden;">
199            <div style="width:${We(p.score,"dimension_score",{schema:c})}%;height:100%;background:${ys(p.score,"dimension_score",c)};border-radius:4px;"></div>
200          </div>
201          <strong style="color:${ys(p.score,"dimension_score",c)}">${nt(p.score,"dimension_score",{schema:c})??"—"}</strong>
202        </div>
203      </td>
204    </tr>
205    ${p.diagnosis?`<tr><td colspan="2" style="padding:2px 12px 10px;font-size:12px;color:#6b7280;border-bottom:1px solid #f3f4f6;">${b(p.diagnosis)}</td></tr>`:""}
206  `).join(""))||"",l=Ss((o==null?void 0:o.top_3_fast_improvements)||[],p=>p),T=((d==null?void 0:d.positioning_gaps)||(d==null?void 0:d.opportunities)||[]).map(Q=>`
207      <div style="background:#fffbeb;border:1px solid #fde68a;border-radius:8px;padding:12px;margin-bottom:8px;">
208        <strong style="font-size:13px;">${b(Q.crowded_lane||Q.opportunity||Q.title||"")}</strong>
209        ${Q.white_space?`<p style="font-size:12px;color:#22c55e;margin:4px 0 0;">→ ${b(Q.white_space)}</p>`:""}
210        <p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(Q.why_winnable||Q.why||Q.description||"")}</p>
211      </div>
212    `).join(""),S=[...((y==null?void 0:y.local_opportunities)||[]).map(p=>`
213      <div style="background:#ecfdf5;border:1px solid #a7f3d0;border-radius:8px;padding:12px;margin-bottom:8px;">
214        <strong style="font-size:13px;">🏠 ${b(p.opportunity)}</strong>
215        <p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(p.why)}</p>
216      </div>
217    `),...((y==null?void 0:y.global_opportunities)||[]).map(p=>`
218      <div style="background:#eff6ff;border:1px solid #bfdbfe;border-radius:8px;padding:12px;margin-bottom:8px;">
219        <strong style="font-size:13px;">🌍 ${b(p.opportunity)}</strong>
220        <p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(p.why)}</p>
221      </div>
222    `)].join("")||"",z=(()=>{var ge;const p=Js(((ge=v==null?void 0:v.competitors)==null?void 0:ge.direct)||[],V),Q=(v==null?void 0:v.positioning_moves)||[];return(p.length>0?p:Q).map(J=>`
223      <div style="background:#f5f3ff;border:1px solid #ddd6fe;border-radius:8px;padding:12px;margin-bottom:8px;">
224        <strong style="font-size:13px;">${b(J.name||J.move||J.title||"")}</strong>
225        <p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(J.strength||J.rationale||J.description||"")}</p>
226        ${J.vulnerability?`<p style="font-size:12px;color:#ef4444;margin:4px 0 0;">Vulnerability: ${b(J.vulnerability)}</p>`:""}
227        ${J.differentiation_angle?`<p style="font-size:12px;color:#22c55e;margin:4px 0 0;">Your angle: ${b(J.differentiation_angle)}</p>`:""}
228      </div>
229    `).join("")})(),C=((xt=v==null?void 0:v.quick_wins_30_days)==null?void 0:xt.map(p=>`<li style="margin-bottom:6px;font-size:13px;">${b(p)}</li>`).join(""))||"",K=(()=>{const p=_r(a==null?void 0:a.forecastData,E);if(!p)return"";const Q=(p.audience_reads||[]).map(O=>`
230      <div style="background:#fff;border:1px solid #e5e7eb;border-radius:8px;padding:12px;margin-bottom:8px;">
231        <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px;">
232          <strong style="font-size:13px;">${b(O.audience||"")}</strong>
233          <span style="font-size:11px;padding:2px 8px;border-radius:9999px;background:#eff6ff;color:#3b82f6;">${b(O.action_probability||"")}</span>
234        </div>
235        <p style="font-size:12px;color:#374151;margin:4px 0 0;">Reaction: ${b(O.reaction||"")}</p>
236        <p style="font-size:12px;color:#ef4444;margin:4px 0 0;">Hesitation: ${b(O.hesitation||"")}</p>
237        ${O.lean_in?`<p style="font-size:12px;color:#22c55e;margin:4px 0 0;">Lean-in: ${b(O.lean_in)}</p>`:""}
238      </div>
239    `).join(""),P=(p.score_consequences||[]).map(O=>`
240      <div style="background:#fef2f2;border:1px solid #fecaca;border-radius:8px;padding:10px;margin-bottom:6px;">
241        <strong style="font-size:12px;color:#ef4444;">${b(O.pattern||"")}</strong>
242        <p style="font-size:12px;color:#374151;margin:4px 0 0;">${b(O.consequence||"")}</p>
243      </div>
244    `).join(""),J=Xr(p.scenarios,{hasAnalytics:E}).map((O,Te)=>{var D;return`
245      <div class="card" style="background:${Te===0?"#ecfdf5":"#f9fafb"};border:1px solid ${Te===0?"#a7f3d0":"#e5e7eb"};border-radius:8px;padding:12px;margin-bottom:8px;">
246        <div style="display:flex;justify-content:space-between;align-items:center;gap:8px;">
247          <strong style="font-size:13px;">${Te===0?"★ ":""}${b(O.name)}</strong>
248          <span style="font-size:11px;color:#6b7280;text-transform:uppercase;">Impact: ${O.expected_impact} · Effort: ${O.effort}</span>
249        </div>
250        <p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(O.why)}</p>
251        ${O.affected_dimensions.length?`<p style="font-size:11px;color:#3b82f6;margin:4px 0 0;">Affected dimensions: ${b(O.affected_dimensions.join(", "))}</p>`:""}
252        <p style="font-size:11px;color:#6b7280;margin:4px 0 0;">${O.revenue_proximity!=="unknown"?`Goal proximity: ${b(O.revenue_proximity.replace(/_/g," "))} · `:""}Basis: ${b(O.evidence_basis_label)}</p>
253        ${O.evidence.length?`<p style="font-size:11px;color:#9ca3af;margin:2px 0 0;">Evidence: ${b(O.evidence.slice(0,2).join(" · "))}</p>`:""}
254        ${(D=O.audience_effects)!=null&&D.length?`<p style="font-size:11px;color:#6b7280;margin:4px 0 0;">${O.audience_effects.map(X=>`${b(X.audience)}: ${b(X.effect)}`).join(" · ")}</p>`:""}
255      </div>
256    `}).join("");return`
257      <h2 class="page-break">📈 Signal Forecast</h2>
258      ${p.headline_forecast?`
259        <div style="background:#eff6ff;border:1px solid #bfdbfe;border-radius:8px;padding:16px;margin-bottom:16px;">
260          <p style="font-size:14px;font-weight:600;color:#1e40af;margin:0;">${b(p.headline_forecast)}</p>
261        </div>
262      `:""}
263
264      ${Q?`
265        <h3 style="font-size:14px;margin:16px 0 4px;page-break-after:avoid;break-after:avoid;">👥 Audience Perception Simulation</h3>
266        <p style="font-size:11px;color:#6b7280;margin:0 0 8px;font-style:italic;">Modeled from analyzed signals; not observed audience behavior unless analytics or research were supplied.</p>
267
268        ${Q}
269      `:""}
270
271      ${P?`
272        <h3 style="font-size:14px;margin:16px 0 8px;">⚠️ What Your Scores Are Likely Causing</h3>
273        ${P}
274      `:""}
275
276      ${p.trajectory_risk?`
277        <div style="background:#fffbeb;border:1px solid #fde68a;border-radius:8px;padding:12px;margin-bottom:12px;">
278          <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 4px;">Trajectory Risk</p>
279          <p style="font-size:13px;color:#374151;margin:0;">${b(p.trajectory_risk)}</p>
280        </div>
281      `:""}
282
283      <div class="card" style="margin-bottom:8px;">
284        ${Xs("revenue_friction_risk",String($.revenue_friction_risk),"risk")}
285        ${Xs("partner_readiness",String($.partner_readiness),"positive")}
286        ${Xs("narrative_alignment",String($.narrative_alignment),"positive")}
287        ${$.notes.length?`<p style="font-size:10px;color:#b45309;margin:8px 0 0;">Reconciled by report QA: ${$.notes.map(O=>b(O.reason)).join(" ")}</p>`:""}
288      </div>
289
290      ${p.fastest_revenue_unlock?`
291        <div style="background:#ecfdf5;border:1px solid #a7f3d0;border-radius:8px;padding:14px;margin:16px 0 8px;">
292          <p style="font-size:11px;text-transform:uppercase;color:#059669;margin:0 0 4px;">⚡ Fastest Revenue Unlock</p>
293          <p style="font-size:13px;font-weight:600;color:#374151;margin:0;">${b(p.fastest_revenue_unlock)}</p>
294        </div>
295      `:""}
296      ${p.most_undervalued_asset?`
297        <div style="margin-bottom:8px;">
298          <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 2px;">Most Undervalued Asset</p>
299          <p style="font-size:13px;color:#374151;margin:0;">${b(p.most_undervalued_asset)}</p>
300        </div>
301      `:""}
302      ${p.biggest_commercial_confusion?`
303        <div style="margin-bottom:8px;">
304          <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 2px;">Biggest Commercial Confusion</p>
305          <p style="font-size:13px;color:#ef4444;margin:0;">${b(p.biggest_commercial_confusion)}</p>
306        </div>
307      `:""}
308      ${p.if_unchanged?`
309        <div style="background:#fef2f2;border:1px solid #fecaca;border-radius:8px;padding:14px;margin:16px 0 8px;">
310          <p style="font-size:11px;text-transform:uppercase;color:#ef4444;margin:0 0 4px;">🚨 If Nothing Changes</p>
311          <p style="font-size:13px;color:#374151;margin:0;">${b(p.if_unchanged)}</p>
312        </div>
313      `:""}
314
315      ${p.top_intervention?`
316        <div style="background:#f0f9ff;border:1px solid #bae6fd;border-radius:8px;padding:14px;margin:16px 0 8px;">
317          <p style="font-size:11px;text-transform:uppercase;color:#0284c7;margin:0 0 4px;">🎯 Top Intervention</p>
318          <strong style="font-size:14px;color:#1e40af;">${b(p.top_intervention.title||"")}</strong>
319          <p style="font-size:12px;color:#374151;margin:6px 0 0;">${b(p.top_intervention.why||"")}</p>
320        </div>
321      `:""}
322
323      ${J?`
324        <h3 style="font-size:14px;margin:16px 0 8px;">
324🔮 Scenario Simulator</h3>
325        ${J}
326      `:""}
327    `})(),U=(()=>{const p=n==null?void 0:n.frictionData;if(!p)return"";const Q=p.dimensions||[],P=p.revenue_blockers||[],ge=p.quick_fixes||[];return`
328      <h2 class="page-break">🔥 Conversion Friction Report</h2>
329      ${p.headline?`<p style="font-size:14px;font-weight:600;color:#374151;margin-bottom:12px;">${b(p.headline)}</p>`:""}
330      ${p.overall_friction_grade||p.friction_score!=null?`
331        <div style="background:#fef2f2;border:1px solid #fecaca;border-radius:8px;padding:16px;margin-bottom:16px;display:flex;align-items:center;gap:16px;">
332          ${p.overall_friction_grade?`<div style="font-size:28px;font-weight:800;color:#ef4444;">${b(p.overall_friction_grade)}</div>`:""}
333          ${p.friction_score!=null?`<div><p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0;">Friction Score</p><strong style="font-size:20px;color:#ef4444;">${nt(p.friction_score,"friction_score",{schema:c})??"—"}</strong></div>`:""}
334        </div>
335      `:""}
336
337      ${Q.map(J=>`
338        <div style="margin-bottom:16px;">
339          <div style="display:flex;align-items:center;gap:8px;margin-bottom:8px;">
340            <strong style="font-size:13px;">${b(J.name||"")}</strong>
341            ${J.score!=null?`<span style="font-size:12px;color:${ys(J.score,"dimension_score",c)};font-weight:700;">${nt(J.score,"dimension_score",{schema:c})??"—"}</span>`:""}
342          </div>
343          ${(J.friction_points||[]).map(O=>`
344            <div style="background:${qo(O.severity)};border:1px solid ${_s(O.severity)}30;border-radius:8px;padding:10px;margin-bottom:6px;">
345              <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px;">
346                <strong style="font-size:12px;">${b(O.issue||O.finding||O.element||"")}</strong>
347                <span style="font-size:10px;padding:2px 6px;border-radius:9999px;background:${_s(O.severity)}15;color:${_s(O.severity)};font-weight:600;text-transform:uppercase;">${b(O.severity||"")}</span>
348              </div>
349              ${O.evidence?`<p style="font-size:12px;color:#6b7280;margin:2px 0;">${b(O.evidence)}</p>`:""}
350              ${O.fix||O.recommendation?`<p style="font-size:12px;color:#22c55e;margin:4px 0 0;">Fix: ${b(O.fix||O.recommendation)}</p>`:""}
351              ${O.revenue_impact?`<p style="font-size:11px;color:#3b82f6;margin:2px 0 0;">💰 ${b(O.revenue_impact)}</p>`:""}
352            </div>
353          `).join("")}
354        </div>
355      `).join("")}
356
357      ${P.length>0?`
358        <h3 style="font-size:14px;margin:16px 0 8px;">💰 Revenue Blockers</h3>
359        ${P.map(J=>`
360          <div style="background:#fef2f2;border:1px solid #fecaca;border-radius:8px;padding:10px;margin-bottom:6px;">
361            <strong style="font-size:12px;">${b(J.blocker||"")}</strong>
362            <p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(J.impact||"")}</p>
363            ${J.fix?`<p style="font-size:12px;color:#22c55e;margin:4px 0 0;">Fix: ${b(J.fix)}</p>`:""}
364          </div>
365        `).join("")}
366      `:""}
367
368      ${ge.length>0?`
369        <h3 style="font-size:14px;margin:16px 0 8px;">⚡ Quick Fixes</h3>
370        <ol style="padding-left:20px;">
371          ${ge.map(J=>`<li style="margin-bottom:6px;font-size:13px;">${b(typeof J=="string"?J:J.fix||J.action||"")}</li>`).join("")}
372        </ol>
373      `:""}
374    `})(),re=(()=>{var X,Ie;const p=n==null?void 0:n.positioningData;if(!p)return"";const Q=((X=p.positioning_map)==null?void 0:X.entities)||p.positioning_map||p.competitors||[],P=Js(Array.isArray(Q)?Q:[],V),ge=Bn(En(p.stolen_narratives||[],V),["narrative"],"pdf.stolen_narratives"),J=p.ownable_positions||[],O=p.white_space_opportunities||[],Te=p.messaging_comparison,D=Js(p.battlecards||[],V,"competitor");return`
375      <h2 class="page-break">🎯 Competitive Positioning</h2>
376      ${p.positioning_verdict?`<p style="font-size:14px;background:#f5f3ff;border-left:4px solid #8b5cf6;padding:12px;border-radius:0 8px 8px 0;margin-bottom:16px;">${b(p.positioning_verdict)}</p>`:""}
377
378      ${P.length>0?`
379        <h3 style="font-size:14px;margin:16px 0 8px;">Positioning Map</h3>
380        ${P.map(M=>`
381          <div style="background:${M.is_subject?"#eff6ff":"#f9fafb"};border:1px solid ${M.is_subject?"#bfdbfe":"#e5e7eb"};border-radius:8px;padding:12px;margin-bottom:8px;">
382            <strong style="font-size:13px;">${b(M.name||"")}${M.is_subject&&!/^you$/i.test((M.name||"").trim())?" (You)":""}</strong>${M.source_label?`<span style="font-size:10px;color:#6b7280;"> · ${b(M.source_label)}</span>`:""}
383            <p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(M.reasoning||M.positioning||M.claim||"")}</p>
384          </div>
385        `).join("")}
386      `:""}
387
388      ${(Ie=Te==null?void 0:Te.dimensions)!=null&&Ie.length?`
389        <h3 style="font-size:14px;margin:16px 0 8px;">📊 Messaging Comparison</h3>
390        <table style="width:100%;border-collapse:collapse;margin-bottom:16px;">
391          <thead>
392            <tr>
393              <th style="text-align:left;padding:6px 10px;background:#f9fafb;border-bottom:2px solid #e5e7eb;font-size:11px;text-transform:uppercase;color:#6b7280;">Brand</th>
394              ${Te.dimensions.map(M=>`<th style="text-align:center;padding:6px 10px;background:#f9fafb;border-bottom:2px solid #e5e7eb;font-size:11px;text-transform:uppercase;color:#6b7280;">${b(M)}</th>`).join("")}
395            </tr>
396          </thead>
397          <tbody>
398            ${(Te.brands||[]).map(M=>`
399              <tr style="${M.is_subject?"background:#eff6ff;":""}">
400                <td style="padding:6px 10px;border-bottom:1px solid #e5e7eb;font-size:12px;font-weight:${M.is_subject?"700":"400"};">${b(M.name)}${M.is_subject?" ★":""}</td>
401                ${(M.scores||[]).map(ae=>`<td style="padding:6px 10px;border-bottom:1px solid #e5e7eb;text-align:center;font-size:12px;font-weight:600;color:${ys(ae,"dimension_score",c)};">${nt(ae,"dimension_score",{schema:c})??"—"}</td>`).join("")}
402              </tr>
403            `).join("")}
404          </tbody>
405        </table>
406      `:""}
407
408      ${ge.length>0?`
409        <h3 style="font-size:14px;margin:16px 0 8px;">⚠️ Stolen Narratives</h3>
410        ${ge.map(M=>`
411          <div style="background:#fef2f2;border:1px solid #fecaca;border-radius:8px;padding:12px;margin-bottom:8px;">
412            <strong style="font-size:13px;">${b(M.narrative||M.claim||"")}</strong>
413            ${$s(M.stolen_by||M.owned_by||M.competitor)?"":`<p style="font-size:12px;color:#6b7280;margin:4px 0 0;">Stolen by: ${b(M.stolen_by||M.owned_by||M.competitor)}</p>`}
414            ${M.reclaim_strategy?`<p style="font-size:12px;color:#3b82f6;margin:4px 0 0;">Reclaim: ${b(M.reclaim_strategy)}</p>`:""}
415          </div>
416        `).join("")}
417      `:""}
418
419      ${J.length>0?`
420        <h3 style="font-size:14px;margin:16px 0 8px;">✅ Ownable Positions</h3>
421        ${J.map(M=>`
422          <div style="background:#ecfdf5;border:1px solid #a7f3d0;border-radius:8px;padding:12px;margin-bottom:8px;">
423            <strong style="font-size:13px;">${b(M.position||M.territory||"")}</strong>
424            <p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(M.rationale||M.why||"")}</p>
425            ${M.fit_score!=null?`<p style="font-size:11px;color:#3b82f6;margin:4px 0 0;">Fit: ${nt(M.fit_score,"fit_score",{schema:c})??"—"}</p>`:""}
426          </div>
427        `).join("")}
428      `:""}
429
430      ${O.length>0?`
431        <h3 style="font-size:14px;margin:16px 0 8px;">💡 White-Space Opportunities</h3>
432        ${O.map(M=>`
433          <div style="background:#fffbeb;border:1px solid #fde68a;border-radius:8px;padding:12px;margin-bottom:8px;">
434            <strong style="font-size:13px;">${b(M.territory||M.opportunity||M.space||"")}</strong>
435            <p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(M.description||M.rationale||M.why||"")}</p>
436            ${M.why_open?`<p style="font-size:12px;color:#22c55e;margin:4px 0 0;">Why open: ${b(M.why_open)}</p>`:""}
437          </div>
438        `).join("")}
439      `:""}
440
441      ${D.length>0?`
442        <h3 style="font-size:14px;margin:16px 0 8px;">⚔️ Battlecards</h3>
443        ${D.map(M=>`
444          <div style="background:#f9fafb;border:1px solid #e5e7eb;border-radius:8px;padding:12px;margin-bottom:8px;">
445            <strong style="font-size:13px;">vs. ${b(M.competitor||M.name||"")}</strong>
446            ${M.their_claim?`<p style="font-size:12px;color:#6b7280;margin:4px 0 0;">Their claim: ${b(M.their_claim)}</p>`:""}
447            ${M.your_counter?`<p style="font-size:12px;color:#22c55e;margin:4px 0 0;">Your counter: ${b(M.your_counter)}</p>`:""}
448            ${M.proof_point?`<p style="font-size:11px;color:#3b82f6;margin:4px 0 0;">Proof: ${b(M.proof_point)}</p>`:""}
449          </div>
450        `).join("")}
451      `:""}
452    `})(),xe=(()=>{var Te,D;const p=n==null?void 0:n.narrativeData;if(!p)return"";const Q=p.messaging_hierarchy||[],P=p.objection_handling||[],ge=p.tone_guidelines||p.tone_voice,J=p.proof_points||[],O=p.content_pillars||[];return`
453      <h2 class="page-break">🏗️ Narrative Architecture</h2>
454      ${p.headline?`
455        <div style="background:#f0f9ff;border:1px solid #bae6fd;border-radius:8px;padding:16px;margin-bottom:12px;">
456          <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 4px;">Recommended Headline</p>
457          <strong style="font-size:18px;color:#1e40af;">${b(p.headline.text||p.headline)}</strong>
458          ${p.headline.rationale?`<p style="font-size:12px;color:#6b7280;margin:6px 0 0;">${b(p.headline.rationale)}</p>`:""}
459        </div>
460      `:""}
461      ${p.tagline?`
462        <div style="margin-bottom:12px;">
463          <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 4px;">Tagline</p>
464          <p style="font-size:15px;font-style:italic;color:#374151;">"${b(p.tagline.text||p.tagline)}"</p>
465          ${p.tagline.rationale?`<p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(p.tagline.rationale)}</p>`:""}
466        </div>
467      `:""}
468      ${p.elevator_pitch?`
469        <div style="margin-bottom:12px;">
470          <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 4px;">Elevator Pitch${p.elevator_pitch.word_count?` (${p.elevator_pitch.word_count} words)`:""}</p>
471          <p style="font-size:13px;color:#374151;">${b(p.elevator_pitch.text||p.elevator_pitch)}</p>
472          ${p.elevator_pitch.rationale?`<p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(p.elevator_pitch.rationale)}</p>`:""}
473        </div>
474      `:""}
475      ${Q.length>0?`
476        <h3 style="font-size:14px;margin:16px 0 8px;">Messaging Hierarchy</h3>
477        ${Q.map((X,Ie)=>`
478          <div style="background:#f9fafb;border:1px solid #e5e7eb;border-radius:8px;padding:12px;margin-bottom:8px;">
479            <strong style="font-size:13px;">Tier ${Ie+1}: ${b(X.tier||X.level||X.name||"")}</strong>
480            <p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(X.message||X.description||"")}</p>
481            ${X.audience?`<p style="font-size:11px;color:#3b82f6;margin:4px 0 0;">Audience: ${b(X.audience)}</p>`:""}
482          </div>
483        `).join("")}
484      `:""}
485      ${P.length>0?`
486        <h3 style="font-size:14px;margin:16px 0 8px;">Objection Handling</h3>
487        ${P.map(X=>`
488          <div style="background:#fff;border:1px solid #e5e7eb;border-radius:8px;padding:12px;margin-bottom:8px;">
489            <strong style="font-size:13px;color:#ef4444;">"${b(X.objection||X.concern||"")}"</strong>
490            <p style="font-size:12px;color:#22c55e;margin:4px 0 0;">→ ${b(X.reframe||X.response||"")}</p>
491            ${X.proof_point?`<p style="font-size:11px;color:#6b7280;margin:4px 0 0;">Proof: ${b(X.proof_point)}</p>`:""}
492          </div>
493        `).join("")}
494      `:""}
495      ${J.length>0?`
496        <h3 style="font-size:14px;margin:16px 0 8px;">🔒 Proof Points</h3>
497        ${J.map(X=>`
498          <div style="background:#ecfdf5;border:1px solid #a7f3d0;border-radius:8px;padding:10px;margin-bottom:6px;">
499            <strong style="font-size:12px;">${b(X.claim||X.point||"")}</strong>
500            ${X.evidence?`<p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(X.evidence)}</p>`:""}
501          </div>
502        `).join("")}
503      `:""}
504      ${O.length>0?`
505        <h3 style="font-size:14px;margin:16px 0 8px;">📌 Content Pillars</h3>
506        ${O.map(X=>`
507          <div style="background:#f9fafb;border:1px solid #e5e7eb;border-radius:8px;padding:10px;margin-bottom:6px;">
508            <strong style="font-size:12px;">${b(typeof X=="string"?X:X.pillar||X.name||"")}</strong>
509            ${X.description?`<p style="font-size:12px;color:#6b7280;margin:4px 0 0;">${b(X.description)}</p>`:""}
510          </div>
511        `).join("")}
512      `:""}
513      ${ge?`
514        <h3 style="font-size:14px;margin:16px 0 8px;">🎙️ Tone & Voice</h3>
515        <div style="background:#f9fafb;border:1px solid #e5e7eb;border-radius:8px;padding:12px;">
516          ${(ge.attributes||[]).map(X=>`<span style="display:inline-block;font-size:12px;background:#e5e7eb;border-radius:9999px;padding:2px 10px;margin:2px;">${b(typeof X=="string"?X:X.attribute||"")}</span>`).join("")}
517          ${(Te=ge.do_say)!=null&&Te.length?`<p style="font-size:12px;color:#22c55e;margin:8px 0 4px;">✓ Do say: ${ge.do_say.map(X=>b(X)).join(", ")}</p>`:""}
518          ${(D=ge.dont_say)!=null&&D.length?`<p style="font-size:12px;color:#ef4444;margin:4px 0 0;">✗ Don't say: ${ge.dont_say.map(X=>b(X)).join(", ")}</p>`:""}
519        </div>
520      `:""}
521    `})(),u=(()=>{const p=n==null?void 0:n.personaData;if(!p)return"";const Q=p.personas||[];return`
522      <h2 class="page-break">👥 Audience Personas</h2>
523      ${p.persona_verdict?`<p style="font-size:14px;background:#eff6ff;border-left:4px solid #3b82f6;padding:12px;border-radius:0 8px 8px 0;margin-bottom:16px;">${b(p.persona_verdict)}</p>`:""}
524      ${p.biggest_persona_gap?`<p style="font-size:13px;color:#ef4444;margin-bottom:12px;">⚠️ <strong>Biggest Gap:</strong> ${b(p.biggest_persona_gap)}</p>`:""}
525      ${Q.map((P,ge)=>{var J,O,Te,D,X,Ie,M;return`
526        <div style="background:#f9fafb;border:1px solid #e5e7eb;border-radius:8px;padding:16px;margin-bottom:12px;">
527          <div style="display:flex;align-items:center;gap:8px;margin-bottom:8px;">
528            <span style="font-size:24px;">${P.emoji||"👤"}</span>
529            <div>
530              <strong style="font-size:15px;">${b(P.name||`Persona ${ge+1}`)}</strong>
531              ${P.role_title||P.role?`<p style="font-size:12px;color:#6b7280;margin:0;">${b(P.role_title||P.role)}</p>`:""}
532            </div>
533          </div>
534          ${P.archetype?`<p style="font-size:12px;color:#8b5cf6;margin:4px 0;">${b(P.archetype)}</p>`:""}
535          ${P.pain_narrative?`<p style="font-size:13px;color:#374151;margin:8px 0;">${b(P.pain_narrative)}</p>`:""}
536
537          ${P.demographics?`
538            <div style="margin:8px 0;">
539              <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 4px;">Demographics</p>
540              <div style="display:flex;gap:8px;flex-wrap:wrap;font-size:12px;">
541                ${P.demographics.age_range?`<span style="background:#e5e7eb;border-radius:9999px;padding:2px 8px;">Age: ${b(P.demographics.age_range)}</span>`:""}
542                ${P.demographics.seniority?`<span style="background:#e5e7eb;border-radius:9999px;padding:2px 8px;">${b(P.demographics.seniority)}</span>`:""}
543                ${P.demographics.company_size?`<span style="background:#e5e7eb;border-radius:9999px;padding:2px 8px;">${b(P.demographics.company_size)}</span>`:""}
544              </div>
545              ${(J=P.demographics.industry_verticals)!=null&&J.length?`<p style="font-size:12px;margin:4px 0;">Industries: ${P.demographics.industry_verticals.map(ae=>b(ae)).join(", ")}</p>`:""}
546            </div>
547          `:""}
548
549          ${P.psychographics?`
550            <div style="margin:8px 0;">
551              <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 4px;">Psychographics</p>
552              ${(O=P.psychographics.values)!=null&&O.length?`<p style="font-size:12px;margin:2px 0;">Values: ${P.psychographics.values.map(ae=>b(ae)).join(", ")}</p>`:""}
553              ${(Te=P.psychographics.fears)!=null&&Te.length?`<p style="font-size:12px;margin:2px 0;">Fears: ${P.psychographics.fears.map(ae=>b(ae)).join(", ")}</p>`:""}
554              ${(D=P.psychographics.aspirations)!=null&&D.length?`<p style="font-size:12px;margin:2px 0;">Aspirations: ${P.psychographics.aspirations.map(ae=>b(ae)).join(", ")}</p>`:""}
555              ${P.psychographics.decision_style?`<p style="font-size:12px;margin:2px 0;">Decision style: ${b(P.psychographics.decision_style)}</p>`:""}
556            </div>
557          `:""}
558
559          ${(X=P.buying_triggers)!=null&&X.length?`
560            <div style="margin:8px 0;">
561              <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 4px;">Buying Triggers</p>
562              ${P.buying_triggers.map(ae=>{const it=typeof ae=="string"?ae:ae.trigger||ae.name||"",gt=typeof ae=="object"?ae.urgency:null;return`<p style="font-size:12px;margin:2px 0;">• ${b(it)}${gt?` <span style="font-size:10px;color:${_s(gt)};text-transform:uppercase;">(${gt})</span>`:""}</p>`}).join("")}
563            </div>
564          `:""}
565
566          ${(Ie=P.objections)!=null&&Ie.length?`
567            <div style="margin:8px 0;">
568              <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 4px;">Objections</p>
569              ${P.objections.map(ae=>{const it=typeof ae=="string"?ae:ae.objection||ae.concern||"",gt=typeof ae=="object"&&(ae.counter||ae.response)||"";return`<div style="margin-bottom:4px;"><p style="font-size:12px;color:#ef4444;margin:0;">• "${b(it)}"</p>${gt?`<p style="font-size:12px;color:#22c55e;margin:2px 0 0 12px;">→ ${b(gt)}</p>`:""}</div>`}).join("")}
570            </div>
571          `:""}
572
573          ${(M=P.preferred_channels)!=null&&M.length?`
574            <div style="margin:8px 0;">
575              <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 4px;">Preferred Channels</p>
576              <div style="display:flex;gap:6px;flex-wrap:wrap;">
577                ${P.preferred_channels.map(ae=>`<span style="font-size:12px;background:#eff6ff;color:#3b82f6;border-radius:9999px;padding:2px 10px;">${b(typeof ae=="string"?ae:ae.channel||ae.name||"")}</span>`).join("")}
578              </div>
579            </div>
580          `:""}
581
582          ${P.messaging_angle?`
583            <div style="margin:8px 0;background:#f0f9ff;border:1px solid #bae6fd;border-radius:6px;padding:8px;">
584              <p style="font-size:11px;text-transform:uppercase;color:#0284c7;margin:0 0 2px;">Messaging Angle</p>
585              <p style="font-size:12px;color:#374151;margin:0;">${b(P.messaging_angle)}</p>
586            </div>
587          `:""}
588        </div>
589      `}).join("")}
590    `})(),pe=(((ds=a==null?void 0:a.frictionData)==null?void 0:ds.dimensions)||[]).flatMap(p=>(p.friction_points||[]).map(Q=>({...Q,where:p.name}))),q=Xa([...o!=null&&o.biggest_blind_spot?[{finding:o.biggest_blind_spot,severity:"high",confidence:o==null?void 0:o.derived_confidence,evidence_count:3}]:[],...o!=null&&o.biggest_friction?[{finding:o.biggest_friction,severity:"high",confidence:o==null?void 0:o.derived_confidence,evidence_count:3}]:[],...pe,...(_t=a==null?void 0:a.forecastData)!=null&&_t.biggest_commercial_confusion?[{finding:a.forecastData.biggest_commercial_confusion,severity:"medium"}]:[]],{hasAnalytics:E,max:5}),ye=Za(Xr((ps=a==null?void 0:a.forecastData)==null?void 0:ps.scenarios,{hasAnalytics:E}),{goal:m.label}),ue=ei([...((o==null?void 0:o.scores)||[]).map(p=>({asset:p.dimension,score:p.score,confidence:p.confidence,evidence:p.evidence,evidence_count:p.evidence_count,why:p.diagnosis})),...o!=null&&o.biggest_strength?[{asset:o.biggest_strength,score:90,confidence:"observed",evidence_count:3,why:"Identified as the strongest observed asset in the analyzed content."}]:[]],{scoreSchema:c}),Ee=[...q.map(p=>p.finding),...ye.map(p=>`${p.action} ${p.why||""}`),...ue.map(p=>`${p.asset} ${p.why}`)],Qe=Ss(Ee,p=>p).length,Ke=p=>!!p&&Ss([...Ee,p],Q=>Q).length===Qe,le=l.filter(p=>!Ke(p)).map(p=>`<li style="margin-bottom:6px;font-size:13px;">${b(p)}</li>`).join("")||"",Se=!!(o!=null&&o.biggest_blind_spot)&&!Ke(o==null?void 0:o.biggest_blind_spot),Ue=q.length?`
591    <h2>Executive Diagnosis</h2>
592    <p style="font-size:12px;color:#6b7280;margin:0 0 12px;">Optimizing for: <strong>${b(m.label)}</strong>${m.assumed?" (assumed — no objective was selected)":""}</p>
593    ${q.map((p,Q)=>`
594      <div class="card" style="background:#f9fafb;border:1px solid #e5e7eb;border-radius:8px;padding:12px;margin-bottom:8px;">
595        <div style="display:flex;justify-content:space-between;gap:8px;">
596          <strong style="font-size:13px;">${Q+1}. ${b(p.finding)}</strong>
597          <span style="font-size:10px;text-transform:uppercase;color:#6b7280;white-space:nowrap;">Impact: ${p.impact}</span>
598        </div>
599        <p style="font-size:11px;color:#6b7280;margin:6px 0 0;">Basis: ${b(p.evidence_basis_label)}${p.where?` | Where: ${b(p.where)}`:""}</p>
600        ${p.next_action?`<p style="font-size:12px;color:#22c55e;margin:4px 0 0;">Next action: ${b(p.next_action)}</p>`:""}
601      </div>
602    `).join("")}
603  `:"",we=ye.length?`
604    <h2>What To Do First</h2>
605    ${["today","this_week","next_30_days"].map(p=>{const Q=ye.filter(P=>P.horizon===p);return Q.length?`
606        <div class="card" style="margin-bottom:10px;">
607          <p style="font-size:11px;text-transform:uppercase;color:#6b7280;margin:0 0 4px;">${b(k[p])}</p>
608          <ul style="padding-left:18px;margin:0;">
609            ${Q.map(P=>`<li style="font-size:12px;margin-bottom:4px;"><strong style="color:${P.priority==="P0"?"#ef4444":P.priority==="P1"?"#d97706":"#6b7280"};">${P.priority}</strong> ${b(P.action)} <span style="color:#6b7280;">(impact ${P.expected_impact} · effort ${P.effort} · confidence ${P.confidence} · revenue ${b(P.revenue_proximity_label)} · basis ${b(P.evidence_basis_label)})</span></li>`).join("")}
610          </ul>
611        </div>
612      `:""}).join("")}
613  `:"",ne=ue.length?`
614    <h2>Protect These Assets</h2>
615    <p style="font-size:12px;color:#6b7280;margin:0 0 8px;">Strong, directly observed positives. Do not change these — they are already doing their job.</p>
616    ${ue.map(p=>`
617      <div class="card" style="background:#ecfdf5;border:1px solid #a7f3d0;border-radius:8px;padding:10px;margin-bottom:6px;">
618        <strong style="font-size:12px;">${b(p.asset)}</strong>
619        <p style="font-size:12px;color:#374151;margin:2px 0 0;">${b(p.why)}</p>
620        <p style="font-size:10px;color:#6b7280;margin:2px 0 0;">Basis: ${b(In[p.evidence_basis])}</p>
621      </div>
622    `).join("")}
623  `:"";return`<!DOCTYPE html>
624<html>
625<head>
626  <meta charset="utf-8">
627  <title>Strategic Diagnosis — Social Brilliance</title>
628  <style>
629    @media print {
630      body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
631      .page-break { page-break-before: always; }
632      h1, h2, h3 { page-break-after: avoid; break-after: avoid; page-break-inside: avoid; }
633      .card, table, tr, li { page-break-inside: avoid; break-inside: avoid; }
634      table { page-break-before: auto; }
635    }
636    body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; max-width: 700px; margin: 0 auto; padding: 40px 24px; color: #111827; line-height: 1.5; }
637    h1 { font-size: 24px; margin-bottom: 4px; }
638    h2 { font-size: 18px; margin-top: 32px; margin-bottom: 12px; border-bottom: 2px solid #e5e7eb; padding-bottom: 8px; }
639    h3 { font-size: 15px; }
640    .card { break-inside: avoid; }
641    .meta { font-size: 12px; color: #9ca3af; margin-bottom: 24px; }
642    .grade-badge { display: inline-block; font-size: 28px; font-weight: 800; padding: 8px 20px; border-radius: 12px; }
643    .verdict { font-size: 15px; margin: 12px 0; font-style: italic; color: #374151; }
644    .gap-row { display: flex; gap: 12px; margin-bottom: 8px; }
645    .gap-label { font-size: 12px; color: #6b7280; min-width: 80px; }
646    .gap-value { font-size: 13px; }
647    table { width: 100%; border-collapse: collapse; margin: 12px 0; }
648    th { text-align: left; padding: 8px 12px; background: #f9fafb; border-bottom: 2px solid #e5e7eb; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; }
649    .footer { margin-top: 48px; padding-top: 16px; border-top: 1px solid #e5e7eb; font-size: 11px; color: #9ca3af; text-align: center; }
650  </style>
651</head>
652<body>
653  <h1>Pre-Spend GTM Intelligence Report</h1>
654  <p class="meta">${f} · Generated by Social Brilliance${s?` · ${b(s.substring(0,100))}`:""}</p>
655
656  ${N}
657
658  ${o?`
659  <div style="background:#f0f9ff;border:1px solid #bae6fd;border-radius:12px;padding:20px;margin-bottom:24px;">
660    <div style="display:flex;align-items:center;gap:16px;">
661      <div class="grade-badge" style="background:${fn(o.overall_grade)}22;color:${fn(o.overall_grade)};">${b(o.overall_grade||"")}</div>
662      <div>
663        <p style="font-size:11px;text-transform:uppercase;letter-spacing:0.1em;color:#6b7280;margin:0;">Overall Grade</p>
664        <p class="verdict">${b(o.headline_verdict||"")}</p>
665        ${o.one_line_repositioning?`<p style="font-size:13px;color:#3b82f6;margin:4px 0 0;">→ ${b(o.one_line_repositioning)}</p>`:""}
666      </div>
667    </div>
668  </div>
669
670  ${o.analysis_scope?`<p style="font-size:12px;color:#6b7280;font-style:italic;margin-bottom:8px;">Scope: ${b(o.analysis_scope)}</p>`:""}
671  ${o.scope_limitation?`<p style="font-size:12px;color:#f59e0b;margin-bottom:12px;">⚠️ ${b(o.scope_limitation)}</p>`:""}
672
673  ${L}
674  ${Ue}
675  ${we}
676  ${ne}
677
678  ${o.what_you_appear_to_be?`
679  <div style="margin-bottom:24px;">
680    <div class="gap-row"><span class="gap-label">Appears as:</span><span class="gap-value">${b(o.what_you_appear_to_be)}</span></div>
681    <div class="gap-row"><span class="gap-label">Wants to be:</span><span class="gap-value">${b(o.what_you_want_to_be||"")}</span></div>
682    <div class="gap-row"><span class="gap-label">Gap:</span><span class="gap-value" style="color:#ef4444;font-weight:600;">${b(o.perception_gap||"")}</span></div>
683  </div>
684  `:""}
685
686  <h2>📊 Dimension Scores</h2>
687  <table>
688    <thead><tr><th>
688Dimension</th><th style="text-align:center;">Score</th></tr></thead>
689    <tbody>${R}</tbody>
690  </table>
691
692  ${Se?`
693  <div style="background:#fffbeb;border:1px solid #fde68a;border-radius:8px;padding:12px;margin:16px 0;">
694    <p style="font-size:11px;text-transform:uppercase;color:#f59e0b;font-weight:700;margin:0 0 4px;">⚠️ Biggest Blind Spot</p>
695    <p style="font-size:13px;color:#374151;margin:0;">${b(o.biggest_blind_spot)}</p>
696  </div>
697  `:""}
698
699  ${le?`
700  <h2>⚡ Quick Wins</h2>
701  <ol style="padding-left:20px;">${le}</ol>
702  `:""}
703  `:""}
704
705  ${d!=null&&d.white_space_summary?`
706  <h2 class="page-break">💡 White Space Analysis</h2>
707  <p style="font-size:14px;background:#fffbeb;border-left:4px solid #f59e0b;padding:12px;border-radius:0 8px 8px 0;">${b(d.white_space_summary)}</p>
708  ${T}
709  `:""}
710
711  ${S?`
712  <h2>📈 Market Opportunities</h2>
713  ${S}
714  `:""}
715
716  ${z?`
717  <h2>⚔️ Competitive Strategy</h2>
718  ${v!=null&&v.biggest_competitive_advantage?`<p style="font-size:14px;background:#f5f3ff;border-left:4px solid #8b5cf6;padding:12px;border-radius:0 8px 8px 0;margin-bottom:12px;"><strong>Biggest advantage:</strong> ${b(v.biggest_competitive_advantage)}</p>`:""}
719  ${z}
720  ${C?`<h3 style="font-size:15px;margin-top:16px;">30-Day Quick Wins</h3><ol style="padding-left:20px;">${C}</ol>`:""}
721  `:""}
722
723  ${K}
724  ${U}
725  ${re}
726  ${xe}
727  ${u}
728
729  <div class="footer">
730    <p>Social Brilliance · socialbrilliance.ai · Pre-Spend GTM Intelligence</p>
731  </div>
732</body>
733</html>`}function ke(t){return t?typeof t=="string"?t.trim():typeof t=="object"&&t.title?String(t.title).trim():"":""}function Ho(t,s){if(!Array.isArray(t)||t.length===0)return null;const n=t.map(i=>We(i==null?void 0:i.score,"dimension_score",{location:"executive-brief.health",schema:s??void 0})).filter(i=>Number.isFinite(i));return n.length?Math.round(n.reduce((i,a)=>
733i+a,0)/n.length):null}function Wo(t){const{health:s,conversionHealth:n,frictionGrade:i}=t,a=t.criticalBlockers??0,o=t.highBlockers??0,c=i!=null&&i.startsWith("F")?20:i!=null&&i.startsWith("D")?35:i!=null&&i.startsWith("C")?55:i!=null&&i.startsWith("B")?72:i!=null&&i.startsWith("A")?88:null,d=n??c,y=s,v=[d,y].filter(w=>typeof w=="number"&&Number.isFinite(w)),f=v.length?Math.min(...v):50;let _;f<=35?_="Critical":f<=55?_="High":f<=75?_="Moderate":_="Low";const N=["Low","Moderate","High","Critical"],m=a>0?"Critical":o>0?"High":null;m&&N.indexOf(m)>N.indexOf(_)&&(_=m);const h=[];typeof d=="number"&&h.push(`conversion health ${d}/100 (higher is healthier)`),typeof y=="number"&&h.push(`overall signal health ${y}/100`),a>0?h.push(`${a} critical blocker${a===1?"":"s"}`):o>0&&h.push(`${o} high-severity blocker${o===1?"":"s"}`);const k=`Qualitative commercial exposure from current signal gaps.${h.length?` Based on ${h.join(", ")}.`:""} No revenue or pipeline data was supplied, so this is a directional risk level — not a financial estimate.`;return{band:_,rationale:k}}function Yo(t){const s=(t==null?void 0:t.severity)??(t==null?void 0:t.priority)??(t==null?void 0:t.estimated_impact)??null;return String(s??"").trim().toLowerCase()||null}function Vo(t){const s=new Set,n=[],i=a=>{if(Array.isArray(a))for(const o of a)!o||typeof o!="object"||s.has(o)||(s.add(o),n.push({severity:Yo(o),row:o}))};if(i(t==null?void 0:t.friction_points),i(t==null?void 0:t.blockers),Array.isArray(t==null?void 0:t.dimensions))for(const a of t.dimensions)i(a==null?void 0:a.friction_points);return i(t==null?void 0:t.revenue_blockers),n}function bn(t,s){const n=s.map(i=>i.toLowerCase());return Vo(t).filter(i=>i.severity&&n.includes(i.severity)).length}function Jo(t){var l,T,S,z,C,K,U,re,xe,u,pe,q,ye;const{diagnosisData:s}=t;if(!s)return null;const n=s.brand_intelligence||{},i=s.competitive_strategy||{},a=s.white_space||{},o=t.forecastData||{},c=t.frictionData||{},d=(t.brand||((l=t.intakeData)==null?void 0:l.brand_name)||((T=t.intakeData)==null?void 0:T.company)||n.brand_name||"Brand").toString(),y=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),v=It(n)??It(s),f=Ho(n.scores,v),_=n.derived_confidence||null,N=ke(o.trajectory_risk)||ke(o.biggest_commercial_confusion)||ke(c.headline)||"Signal gaps are eroding buyer trust before sales conversations begin.",h=[ke(o.revenue_friction_risk),ke(o.if_unchanged),ke(c.headline)].filter(Boolean)[0]||"The current signal pattern points to likely conversion friction — qualified buyers can self-disqualify before reaching sales.",x=((S=a.positioning_gaps)==null?void 0:S[0])||((z=a.opportunities)==null?void 0:z[0]),k=ke(o.fastest_revenue_unlock)||ke(x==null?void 0:x.white_space)||ke(x==null?void 0:x.opportunity)||ke(o.most_undervalued_asset)||"An untapped positioning lane is available with low competitive resistance.",w=ke(o.most_undervalued_asset)||ke(x==null?void 0:x.why_winnable)||ke(x==null?void 0:x.why)||"Capturing this lane requires sharper narrative discipline, not more spend.",$=ke((C=o.top_intervention)==null?void 0:C.title)||ke((U=(K=i.positioning_moves)==null?void 0:K[0])==null?void 0:U.move)||ke((re=n.top_3_fast_improvements)==null?void 0:re[0])||"Tighten the homepage promise and re-sequence the buyer narrative.",V=ke((xe=o.top_intervention)==null?void 0:xe.why)||ke((pe=(u=i.positioning_moves)==null?void 0:u[0])==null?void 0:pe.rationale)||"This is the single change with the highest-priority expected effect across audiences and conversion friction.",G=((q=i.quick_wins_30_days)!=null&&q.length?i.quick_wins_30_days:(ye=c.quick_fixes)!=null&&ye.length?c.quick_fixes.map(ue=>typeof ue=="string"?ue:ue.fix||ue.action):n.top_3_fast_improvements||[]).slice(0,3).map(ue=>String(ue).trim()).filter(Boolean),E=ke(o.headline_forecast)||ke(n.executive_summary)||`${d} has the underlying substance but the market signal is not landing with full force.`,{band:L,rationale:R}=Wo({health:f,conversionHealth:typeof(c.conversion_health_score??c.friction_score)=="number"?We(c.conversion_health_score??c.friction_score,"friction_score",{location:"executive-brief.conversion-health",schema:It(c)??void 0}):null,frictionGrade:c.overall_friction_grade||null,criticalBlockers:bn(c,["critical"]),highBlockers:bn(c,["high"])});return{brand:d,date:y,healthScore:f,headline:E,risk:{title:N,detail:h},opportunity:{title:k,detail:w}
733,move:{title:$,detail:V,first30Days:G},exposureBand:L,exposureRationale:R,confidence:_}}function qe(t){return t?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""}function Qo(t){if(!t)return;const s=window.open("","_blank");if(!s)return;const n=t.healthScore==null?"#6b7280":t.healthScore>=70?"#10b981":t.healthScore>=50?"#f59e0b":"#ef4444",i=t.move.first30Days.map((o,c)=>`<li><strong style="color:#2563eb;">${c+1}.</strong> ${qe(o)}</li>`).join(""),a=`<!DOCTYPE html>
734<html><head><meta charset="utf-8" />
735<title>${qe(t.brand)} — Executive Brief</title>
736<style>
737  @page { size: letter; margin: 0.5in; }
738  * { box-sizing: border-box; }
739  body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; color: #111827; margin: 0; padding: 0; line-height: 1.5; }
740  .page { max-width: 7.5in; margin: 0 auto; }
741  .header { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 12px; border-bottom: 2px solid #111827; margin-bottom: 18px; }
742  .meta-label { font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase; color: #6b7280; font-weight: 600; margin: 0 0 4px; }
743  .brand { font-size: 22px; font-weight: 800; margin: 0; }
744  .date { font-size: 11px; color: #6b7280; margin-top: 4px; }
745  .health { text-align: right; }
746  .health-num { font-size: 28px; font-weight: 800; color: ${n}; line-height: 1; }
747  .health-label { font-size: 9px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.1em; }
748  .verdict { background: #eef2ff; border-left: 4px solid #4f46e5; padding: 12px 16px; border-radius: 0 6px 6px 0; margin-bottom: 18px; }
749  .verdict-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em; color: #4f46e5; margin: 0 0 4px; }
750  .verdict-text { font-size: 13px; font-weight: 500; margin: 0; }
751  .section { display: flex; gap: 12px; margin-bottom: 14px; page-break-inside: avoid; }
752  .accent { width: 4px; border-radius: 2px; flex-shrink: 0; }
753  .section-body { flex: 1; }
754  .section-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em; margin: 0 0 3px; }
755  .section-title { font-size: 14px; font-weight: 700; margin: 0 0 4px; color: #111827; }
756  .section-detail { font-size: 12px; color: #4b5563; margin: 0; }
757  .risk .accent { background: #ef4444; } .risk .section-label { color: #ef4444; }
758  .opp .accent { background: #10b981; } .opp .section-label { color: #10b981; }
759  .move .accent { background: #2563eb; } .move .section-label { color: #2563eb; }
760  .first30 { margin-top: 8px; padding-top: 8px; border-top: 1px solid #dbeafe; }
761  .first30 ul { list-style: none; padding: 0; margin: 4px 0 0; }
762  .first30 li { font-size: 12px; margin-bottom: 4px; }
763  .first30-label { font-size: 9px; font-weight: 700; color: #2563eb; text-transform: uppercase; letter-spacing: 0.15em; }
764  .impact { background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%); border: 1px solid #fcd34d; border-radius: 10px; padding: 16px 18px; margin-top: 14px; page-break-inside: avoid; }
765  .impact-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em; color: #b45309; margin: 0 0 4px; }
766  .impact-band { font-size: 28px; font-weight: 900; color: #111827; margin: 0; line-height: 1; }
767  .impact-rationale { font-size: 10px; color: #78716c; margin: 8px 0 0; line-height: 1.5; }
768  .footer { margin-top: 20px; padding-top: 12px; border-top: 1px solid #e5e7eb; text-align: center; font-size: 9px; color: #9ca3af; }
769  @media print { .no-print { display: none; } }
770  .print-btn { position: fixed; top: 12px; right: 12px; background: #4f46e5; color: white; border: 0; padding: 8px 14px; border-radius: 6px; font-size: 12px; cursor: pointer; font-weight: 600; }
771</style></head>
772<body>
773  <button class="print-btn no-print" onclick="window.print()">Print / Save as PDF</button>
774  <div class="page">
775    <div class="header">
776      <div>
777        <p class="meta-label">Confidential · Executive Brief</p>
778        <h1 class="brand">${qe(t.brand)}</h1>
779        <p class="date">${qe(t.date)}${t.confidence?` · ${qe(t.confidence)} confidence`:""}</p>
780      </div>
781      ${t.healthScore!=null?`
782      <div class="health">
783        <div class="health-num">${t.healthScore}</div>
784        <div class="health-label">Signal Health / 100</div>
785      </div>`:""}
786    </div>
787
788    <div class="verdict">
789      <p class="verdict-label">The Verdict</p>
790      <p class="verdict-text">${qe(t.headline)}</p>
791    </div>
792
793    <div class="section risk">
794      <div class="accent"></div>
795      <div class="section-body">
796        <p class="section-label">Risk</p>
797        <h2 class="section-title">${qe(t.risk.title)}</h2>
798        <p class="section-detail">${qe(t.risk.detail)}</p>
799      </div>
800    </div>
801
802    <div class="section opp">
803      <div class="accent"></div>
804      <div class="section-body">
805        <p class="section-label">Opportunity</p>
806        <h2 class="section-title">${qe(t.opportunity.title)}</h2>
807        <p class="section-detail">${qe(t.opportunity.detail)}</p>
808      </div>
809    </div>
810
811    <div class="section move">
812      <div class="accent"></div>
813      <div class="section-body">
814        <p class="section-label">Recommended Move</p>
815        <h2 class="section-title">${qe(t.move.title)}</h2>
816        <p class="section-detail">${qe(t.move.detail)}</p>
817        ${i?`
818        <div class="first30">
819          <p class="first30-label">First 30 Days</p>
820          <ul>${i}</ul>
821        </div>`:""}
822      </div>
823    </div>
824
825    <div class="impact">
826      <p class="impact-label">Commercial Exposure</p>
827      <p class="impact-band">${qe(t.exposureBand)}</p>
828      <p class="impact-rationale">${qe(t.exposureRationale)}</p>
829    </div>
830
831
832    <div class="footer">
833      Generated by SocialBrilliance.ai · Directional intelligence, not financial guidance · Not for distribution
834    </div>
835  </div>
836  <script>setTimeout(() => window.print(), 400);<\/script>
837</body></html>`;s.document.open(),s.document.write(a),s.document.close()}function Ko({open:t,onClose:s,brief:n}){if(!n)return null;const i=n.healthScore==null?"text-muted-foreground":n.healthScore>=70?"text-emerald-500":n.healthScore>=50?"text-amber-500":"text-red-500";return e.jsx(Un,{open:t,onOpenChange:a=>!a&&s(),children:e.jsxs(Fn,{side:"right",className:"w-full sm:max-w-2xl overflow-y-auto p-0",children:[e.jsxs("div",{className:"sticky top-0 z-10 bg-background/95 backdrop-blur border-b border-border px-6 py-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.15em] text-muted-foreground",children:"Confidential · Executive Brief"}),e.jsx("h2",{className:"text-lg font-bold text-foreground",children:n.brand})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_e,{size:"sm",onClick:()=>Qo(n),className:"gap-1.5",children:[e.jsx(Cs,{className:"w-3.5 h-3.5"}),"CEO PDF"]}),e.jsx(_e,{size:"icon",variant:"ghost",onClick:s,"aria-label":"Close",children:e.jsx(br,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"px-6 py-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:n.date}),e.jsxs("div",{className:"flex items-center gap-3",children:[n.healthScore!=null&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"uppercase tracking-wider text-[10px]",children:"Signal Health"}),e.jsx("strong",{className:Z("text-base",i),children:n.healthScore}
837),e.jsx("span",{className:"text-muted-foreground/60",children:"/100"})]}),n.confidence&&e.jsxs("span",{className:"uppercase tracking-wider text-[10px] px-2 py-0.5 rounded-full bg-secondary/40",children:[n.confidence," confidence"]})]})]}),e.jsxs("div",{className:"bg-primary/5 border-l-4 border-primary rounded-r-lg p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-primary mb-1",children:"The Verdict"}),e.jsx("p",{className:"text-base font-medium text-foreground leading-snug",children:n.headline})]}),e.jsx(Zs,{icon:e.jsx(yr,{className:"w-5 h-5"}),tone:"risk",label:"Risk",title:n.risk.title,detail:n.risk.detail}),e.jsx(Zs,{icon:e.jsx(Lt,{className:"w-5 h-5"}),tone:"opportunity",label:"Opportunity",title:n.opportunity.title,detail:n.opportunity.detail}),e.jsx(Zs,{icon:e.jsx(lt,{className:"w-5 h-5"}),tone:"move",label:"Recommended Move",title:n.move.title,detail:n.move.detail,children:n.move.first30Days.length>0&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-blue-500/10",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-blue-500 mb-2",children:"First 30 Days"}),e.jsx("ul",{className:"space-y-1.5",children:n.move.first30Days.map((a,o)=>e.jsxs("li",{className:"text-sm text-foreground flex gap-2",children:[e.jsxs("span",{className:"text-blue-500 font-bold",children:[o+1,"."]}
837),e.jsx("span",{children:a})]},o))})]})}),e.jsx("div",{className:"bg-gradient-to-br from-amber-500/10 to-orange-500/5 border border-amber-500/20 rounded-xl p-5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/15 flex items-center justify-center shrink-0",children:e.jsx(kt,{className:"w-5 h-5 text-amber-500"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-amber-600 dark:text-amber-500 mb-1",children:"Commercial Exposure"}),e.jsx("p",{className:"text-3xl font-black text-foreground",children:n.exposureBand}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 leading-relaxed",children:n.exposureRationale})]})]})}),e.jsx("div",{className:"pt-4 border-t border-border text-[10px] text-muted-foreground text-center",children:"Generated by SocialBrilliance.ai · Directional intelligence, not financial guidance · Not for distribution"})]})]})})}function Zs({icon:t,tone:s,label:n,title:i,detail:a,children:o}){const c={risk:{bar:"bg-red-500",iconBg:"bg-red-500/10 text-red-500",chip:"text-red-500"},opportunity:{bar:"bg-emerald-500",iconBg:"bg-emerald-500/10 text-emerald-500",chip:"text-emerald-500"},move:{bar:"bg-blue-500",iconBg:"bg-blue-500/10 text-blue-500",chip:"text-blue-500"}}[s];return e.jsxs("div",{className:"relative pl-4",children:[e.jsx("div",{className:Z("absolute left-0 top-1 bottom-1 w-1 rounded-full",c.bar)}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:Z("w-10 h-10 rounded-full flex items-center justify-center shrink-0",c.iconBg),children:t}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:Z("text-[10px] font-semibold uppercase tracking-wider mb-1",c.chip),children:n}),e.jsx("h3",{className:"text-base font-bold text-foreground leading-snug mb-1.5",children:i}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:a}),o]})]})]})}function Xo(){const{user:t}=os(),{toast:s}=Ps(),[n,i]=g.useState(!1);return{shareDiagnosis:g.useCallback(async(o,c,d)=>{i(!0);try{const y=crypto.randomUUID().slice(0,12),{error:v}=await Je.from("shared_diagnoses").insert({share_id:y,diagnosis_id:d||null,sharer_user_id:(t==null?void 0:t.id)||null,diagnosis_data:o,input_text:c});if(v)throw v;const f=`${window.location.origin}/shared/${y}`;try{await navigator.clipboard.writeText(f),s({title:"Link copied!",description:"Share this link with your team."})}catch{s({title:"Share link ready",description:f})}return f}catch(y){return s({variant:"destructive",title:"Sharing failed",description:y.message}),null}finally{i(!1)}},[t,s]),sharing:n}}const Is="sb_strategy_session",Zo=30*60*1e3;function yn(t){try{const{scrapedContent:s,...n}=t,i={...n,savedAt:Date.now()};sessionStorage.setItem(Is,JSON.stringify(i))}catch{}}function el(){try{const t=sessionStorage.getItem(Is);if(!t)return null;const s=JSON.parse(t);return Date.now()-s.savedAt>Zo?(sessionStorage.removeItem(Is),null):s.phase!=="intake"||!!s.intakeData||!!s.diagnosisData||!!s.currentDiagnosisId||Array.isArray(s.messages)&&s.messages.length>1?s:null}catch{return null}}function Et(){try{sessionStorage.removeItem(Is)}catch{}}const _n=[{id:"intake",label:"Scan"},{id:"questions",label:"Context"},{id:"diagnosing",label:"Diagnosis"},{id:"results",label:"Results"},{id:"goal",label:"Path"},{id:"plan",label:"Plan"}];function tl({phase:t,diagnosisData:s,messages:n,isMobileUI:i,sharing:a,title:o="Pre-Spend GTM Intelligence",onBack:c,onShare:d,onPDF:y,onNew:v,onHistory:f,historyCount:_=0}){return e.jsx("div",{className:"sticky top-0 z-30 bg-background/95 backdrop-blur-sm border-b border-border",children:e.jsxs("div",{className:"max-w-3xl mx-auto pl-3 pr-24 md:px-4 py-2 md:py-3 space-y-1.5 md:space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx(_e,{variant:"ghost",size:"icon",onClick:c,className:"shrink-0 w-8 h-8 md:w-9 md:h-9",children:e.jsx(ji,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-sm md:text-base font-bold text-foreground truncate",children:o}),e.jsx("div",{className:"flex gap-0.5 md:gap-1 mt-0.5 md:mt-1",children:_n.map((N,m)=>e.jsx("div",{className:"flex items-center gap-0.5 md:gap-1",children:e.jsx("div",{className:Z("h-1 rounded-full transition-all",_n.findIndex(h=>h.id===t)>=m||["specialist","review","planning"].includes(t)?"bg-primary w-5 md:w-6":"bg-muted w-3 md:w-4")}
837)},N.id))})]})]}),(s||t!=="intake"||n.length>1||f&&_>0)&&e.jsxs("div",{className:"flex items-center gap-1 md:gap-1.5 pl-10 md:pl-11",children:[s&&!i&&e.jsxs(e.Fragment,{children:[e.jsxs(_e,{variant:"outline",size:"sm",className:"text-xs gap-1.5",disabled:a,onClick:d,children:[e.jsx(xr,{className:"w-3 h-3"})," Share"]}),e.jsxs(_e,{variant:"outline",size:"sm",className:"text-xs gap-1.5",onClick:y,children:[e.jsx(Cs,{className:"w-3 h-3"})," PDF"]})]}),f&&_>0&&e.jsxs(_e,{variant:"outline",size:"sm",className:"shrink-0 text-xs gap-1 md:gap-1.5 ml-auto h-7 md:h-8",onClick:f,"aria-label":`Open run history (${_} past runs)`,children:[e.jsx(di,{className:"w-3 h-3"}),e.jsx("span",{className:"hidden sm:inline",children:"History"}),e.jsx("span",{className:"text-[10px] font-bold opacity-70",children:_})]}),(t!=="intake"||n.length>1)&&e.jsxs(_e,{variant:"outline",size:"sm",className:Z("shrink-0 text-xs gap-1 md:gap-1.5 h-7 md:h-8",!(f&&_>0)&&"ml-auto"),onClick:v,children:[e.jsx(qn,{className:"w-3 h-3"})," New"]})]})]})})}const sl={Homepage:"🏠","About / Team":"👥","Services / Solutions":"⚙️",Pricing:"💰","Social Proof":"⭐","Contact / CTA":"📞","Content / Blog":"📝",Programs:"🎓","Process / FAQ":"❓",Careers:"💼",Legal:"📜","Press / Media":"📰",Partners:"🤝","Product / Features":"🚀",Conversion:"🎯",Other:"📄"};function rl({pages:t,siteUrl:s,isLoading:n,onConfirm:i,onCancel:a}){const[o,c]=g.useState(()=>{const h=new Set;return t.forEach(x=>{x.recommended&&h.add(x.url)}),h}),[d,y]=g.useState(!1);g.useMemo(()=>{const h=new Map;for(const x of t){const k=h.get(x.category)||[];k.push(x),h.set(x.category,k)}return h},[t]);const v=t.filter(h=>h.recommended),f=t.filter(h=>!h.recommended),_=h=>{c(x=>{const k=new Set(x);return k.has(h)?k.delete(h):k.add(h),k})},N=()=>{c(new Set(t.filter(h=>h.recommended).map(h=>h.url)))},m=()=>{c(new Set(t.map(h=>h.url)))};return e.jsxs("div",{className:"space-y-4 animate-in fade-in-0 slide-in-from-bottom-2 duration-300",children:[e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-primary/5 border border-primary/20 rounded-xl",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0 mt-0.5",children:e.jsx(Ca,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold text-foreground",children:[t.length," pages discovered on ",(()=>{try{return new URL(s.startsWith("http")?s:`https://${s}`).hostname}catch{return s}})()]}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:"We auto-selected the most strategically valuable pages. Adjust the selection to include or exclude pages before running your deep analysis."})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs("button",{onClick:N,className:"text-[11px] px-2.5 py-1 rounded-md bg-primary/10 text-primary hover:bg-primary/15 transition-colors font-medium",children:[e.jsx(Lt,{className:"w-3 h-3 inline mr-1"}),"Smart Selection (",v.length,")"]}),e.jsxs("button",{onClick:m,className:"text-[11px] px-2.5 py-1 rounded-md bg-muted text-muted-foreground hover:text-foreground transition-colors",children:["Select All (",t.length,")"]}),e.jsxs("span",{className:"text-[11px] text-muted-foreground self-center ml-auto",children:[o.size," page",o.size!==1?"s":""," selected"]})]}),e.jsx("div",{className:"space-y-1",children:v.map(h=>e.jsx(vn,{page:h,selected:o.has(h.url),onToggle:()=>_(h.url)},h.url))}),f.length>0&&e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>y(!d),className:"flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors w-full py-1",children:[d?e.jsx(Bt,{className:"w-3 h-3"}):e.jsx(pr,{className:"w-3 h-3"}),f.length," more page",f.length>1?"s":""," (blog, legal, careers…)"]}),d&&e.jsx("div",{className:"space-y-1 mt-1",children:f.map(h=>e.jsx(vn,{page:h,selected:o.has(h.url),onToggle:()=>_(h.url)},h.url))})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(_e,{onClick:()=>i(Array.from(o)),disabled:o.size===0||n,className:"flex-1 gap-2",size:"lg",children:n?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"w-4 h-4 animate-spin"})," Scraping ",o.size," pages…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Lt,{className:"w-4 h-4"})," Analyze ",o.size," Page",o.size>1?"s":""]})}),e.jsx(_e,{variant:"outline",size:"lg",onClick:a,disabled:n,children:"Skip — Quick Scan"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground text-center",children:"Deep analysis scrapes each selected page for a comprehensive, multi-page diagnosis. Quick Scan uses our default auto-selection."})]})}function vn({page:t,selected:s,onToggle:n}){const i=sl[t.category]||"📄";return e.jsxs("button",{onClick:n,className:Z("w-full flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all text-left",s?"bg-primary/5 border-primary/25 shadow-sm":"bg-card border-border hover:border-primary/15"),children:[e.jsx("div",{className:Z("w-5 h-5 rounded border flex items-center justify-center shrink-0 transition-colors",s?"bg-primary border-primary text-primary-foreground":"border-muted-foreground
837/30"),children:s&&e.jsx(Ta,{className:"w-3 h-3"})}),e.jsx("span",{className:"text-sm shrink-0",children:i}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-xs font-medium text-foreground truncate block",children:t.path}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:t.category})]}),t.recommended&&e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium shrink-0",children:"Recommended"})]})}function nl({phase:t,messages:s,inputValue:n,inputMode:i,isLoading:a,onInputChange:o,onInputModeChange:c,onSend:d,onBriefSubmit:y,onFileUpload:v,onDeepAnalysis:f,onDeepAnalysisConfirm:_,onDeepAnalysisCancel:N,discoveredPages:m,discoveryUrl:h,isDiscovering:x,placeholder:k,suppressed:w,objective:$,onObjectiveChange:V}){const G=g.useRef(null),[E,L]=g.useState([]),[R,l]=g.useState(!!$&&!Qs.some(S=>S.id===$));if(g.useEffect(()=>{const S=G.current;S&&(S.style.height="auto",S.style.height=Math.min(S.scrollHeight,160)+"px")},[n]),t!=="intake"&&t!=="questions")return null;const T=!!w;return e.jsx("div",{className:Z("bg-background/95 backdrop-blur-sm border-t border-border",t!=="intake"||s.length>1?"sticky bottom-0":"mt-auto"),children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-3 space-y-2.5",children:[t==="intake"&&s.length<=1&&e.jsxs("div",{className:"flex gap-1 bg-muted/50 rounded-lg p-0.5 w-fit",children:[e.jsxs("button",{onClick:()=>c("url"),className:Z("text-xs font-medium px-3 py-1.5 rounded-md transition-all inline-flex items-center gap-1.5",i==="url"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Mn,{className:"w-3.5 h-3.5"})," Website / Company"]}),e.jsxs("button",{onClick:()=>c("brief"),className:Z("text-xs font-medium px-3 py-1.5 rounded-md transition-all inline-flex items-center gap-1.5",i==="brief"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Mt,{className:"w-3.5 h-3.5"})," Strategic Brief"]}),e.jsxs("button",{onClick:()=>c("upload"),className:Z("text-xs font-medium px-3 py-1.5 rounded-md transition-all inline-flex items-center gap-1.5",i==="upload"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(pi,{className:"w-3.5 h-3.5"})," Upload File"]})]}),t==="intake"&&s.length<=1&&i==="brief"&&e.jsx(Jn,{onSubmit:y,isLoading:a}),t==="intake"&&s.length<=1&&i==="upload"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload a PDF, deck, or document — we'll extract the content and run your diagnosis."}),e.jsx(ui,{files:E,onFilesChange:S=>{L(S),v&&v(S)}}),E.length>0&&e.jsxs(_e,{size:"sm",disabled:a,onClick:()=>{v&&v(E),d()},className:"gap-1.5",children:[a?e.jsx(Pt,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(mr,{className:"w-3.5 h-3.5"}),"Analyze Uploaded File",E.length>1?"s":""]})]}),m&&m.length>0&&h&&e.jsx(rl,{pages:m,siteUrl:h,isLoading:a,onConfirm:S=>_==null?void 0:_(S),onCancel:()=>N==null?void 0:N()}),!T&&!m&&(i==="url"||t==="questions"||s.length>1)&&e.jsxs(e.Fragment,{children:[t==="intake"&&s.length<=1&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex flex-wrap gap-2",children:[{label:"Paste your LinkedIn",value:"",icon:!0},{label:"Try: tesla.com",value:"tesla.com"},{label:"Try: Notion",value:"Notion"}].map(S=>e.jsxs("button",{onClick:()=>{var z,C;S.value?(o(S.value),(z=G.current)==null||z.focus()):(C=G.current)==null||C.focus()},className:"text-xs px-3 py-1.5 rounded-full border border-primary/20 bg-primary/5 text-primary hover:bg-primary/10 transition-colors inline-flex items-center gap-1.5",children:[S.icon&&e.jsx(Pn,{className:"w-3 h-3"}),S.label]},S.label))})}),V&&e.jsxs("div",{className:"mb-2 space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-bold mr-0.5",children:"Optimizing for"}),e.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"(optional — defaults to General GTM readiness)"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[Qs.map(S=>e.jsx("button",{type:"button",onClick:()=>{l(!1),V(S.id)},className:Z("text-[11px] px-2 py-1 rounded-full border transition-colors",!R&&$===S.id?"bg-primary/10 border-primary/40 text-foreground font-semibold":"border-border/50 text-muted-foreground hover:text-foreground"),children:S.label},S.id)),e.jsx("button",{type:"button",onClick:()=>l(S=>!S),className:Z("text-[11px] px-2 py-1 rounded-full border transition-colors",R?"bg-primary/10 border-primary/40 text-foreground font-semibold":"border-border/50 text-muted-foreground hover:text-foreground"),children:"Custom"})]}),R&&e.jsx("input",{type:"text",value:$&&!Qs.some(S=>S.id===$)?$:"",onChange:S=>V(S.target.value),placeholder:"Describe the outcome this report should optimize for…",className:"w-full rounded-lg border border-border/60 bg-background px-2.5 py-1.5 text-xs"})]}),e.jsxs("form",{onSubmit:S=>{S.preventDefault(),d()},className:"flex gap-2 items-end",children:[e.jsx(Ln,{ref:G,value:n,onChange:S=>o(S.target.value),onKeyDown:S=>{S.key==="Enter"&&!S.shiftKey&&(S.preventDefault(),n.trim()&&d())},placeholder:k||(t==="intake"?"Paste URL, LinkedIn profile, or company name…":"Type your answers…"),disabled:a||x,rows:2,className:"flex-1 min-h-[48px] max-h-[160px] resize-none text-sm"}),e.jsx(_e,{type:"submit",size:"icon",className:"shrink-0 h-10 w-10",disabled:a||x||!n.trim(),children:a||x?e.jsx(Pt,{className:"w-4 h-4 animate-spin"}):e.jsx(mr,{className:"w-4 h-4"})})]})]})]})})}const ea=g.forwardRef(function({isMobile:s,diagnosisData:n,planData:i,sharing:a,onShare:o,onPDF:c,onExecBrief:d,onRestart:y,canRestart:v=!1,toast:f,showAppLinks:_=!1,onNavigate:N,isAuthenticated:m=!1},h){const[x,k]=g.useState(!1),[w,$]=g.useState(!1),V=_&&!n;g.useEffect(()=>{var R;if(!s||typeof window>"u")return;const L=()=>{var T;
837const l=((T=window.visualViewport)==null?void 0:T.height)??window.innerHeight;$(window.innerHeight-l>140)};return L(),(R=window.visualViewport)==null||R.addEventListener("resize",L),window.addEventListener("resize",L),()=>{var l;(l=window.visualViewport)==null||l.removeEventListener("resize",L),window.removeEventListener("resize",L)}},[s]);const G=[{label:"Brand & Watch",items:[{label:"Diagnose",icon:lt,path:"/strategy"},{label:"Brand",icon:ws,path:"/twin"},{label:"Watch",icon:Ra,path:"/narrative"}]},{label:"Compose",items:[{label:"Compose",icon:cr,path:"/composer"},{label:"Hook Intelligence",icon:Aa,path:"/hooks"},{label:"Calendar",icon:za,path:"/calendar"}]},{label:"Research",items:[{label:"Signal Index",icon:kt,path:"/signal-to-noise-index"},{label:"Flagship Report",icon:Mt,path:"/research/annual-signal-to-noise-report-2026"},{label:"Rankings",icon:Ea,path:"/signal-to-noise-index/rankings"},{label:"Investors",icon:wi,path:"/investors"}]},{label:"Account",items:m?[{label:"Today",icon:Qr,path:"/dashboard"},{label:"Settings",icon:Ia,path:"/settings"}]:[{label:"Sign in",icon:Pa,path:"/auth"}]}],E=(L,R)=>{const l=document.querySelector(L),T=document.querySelector(".overflow-y-auto.overscroll-contain");if(!l){f({title:`${R} not ready`,description:"This section appears once your results are available."});return}if(T){const S=T.getBoundingClientRect(),z=l.getBoundingClientRect(),C=T.scrollTop+(z.top-S.top)-12;T.scrollTo({top:Math.max(0,C),behavior:"smooth"})}else l.scrollIntoView({behavior:"smooth",block:"start"})};return s?V&&w?null:e.jsxs(e.Fragment,{children:[x&&e.jsx("div",{className:"fixed inset-0 z-[79]",onClick:()=>k(!1)}),e.jsxs("div",{ref:h,className:Z("fixed right-3 z-[120] flex items-end gap-1.5 pointer-events-auto","bottom-[calc(env(safe-area-inset-bottom)+6.25rem)] flex-col"),children:[x&&e.jsxs("div",{className:Z("flex flex-col gap-1.5 max-h-[70vh] overflow-y-auto animate-in fade-in duration-200 bg-card/95 backdrop-blur-md border border-border rounded-2xl p-2 shadow-xl","slide-in-from-bottom-2"),children:[v&&y&&e.jsxs("button",{onClick:()=>{y(),k(!1)},className:"h-9 px-3 rounded-full hover:bg-secondary/50 flex items-center gap-1.5 text-[11px] font-semibold touch-manipulation transition-colors",children:[e.jsx(ur,{className:"w-3.5 h-3.5"})," Analyze another site"]}),n&&e.jsxs(e.Fragment,{children:[v&&y&&e.jsx("div",{className:"my-0.5 h-px bg-border"}),d&&e.jsxs("button",{onClick:()=>{d(),k(!1)},className:"h-9 px-3 rounded-full bg-primary/10 hover:bg-primary/20 flex items-center gap-1.5 text-[11px] font-bold text-primary touch-manipulation transition-colors",children:[e.jsx(sn,{className:"w-3.5 h-3.5"})," Executive Brief"]}),e.jsxs("button",{onClick:()=>{o(),k(!1)},disabled:a,className:"h-9 px-3 rounded-full hover:bg-secondary/50 flex items-center gap-1.5 text-[11px] font-semibold touch-manipulation transition-colors",children:[e.jsx(xr,{className:"w-3.5 h-3.5"})," Share"]}),e.jsxs("button",{onClick:()=>{c(),k(!1)},className:"h-9 px-3 rounded-full hover:bg-secondary/50 flex items-center gap-1.5 text-[11px] font-semibold touch-manipulation transition-colors",children:[e.jsx(Cs,{className:"w-3.5 h-3.5"})," PDF"]}),e.jsxs("button",{onClick:()=>{E('[data-section="diagnosis"]',"Scorecard"),k(!1)},className:"h-9 px-3 rounded-full hover:bg-secondary/50 flex items-center gap-1.5 text-[11px] font-semibold touch-manipulation transition-colors",children:[e.jsx(ws,{className:"w-3.5 h-3.5"})," Scorecard"]}),e.jsxs("button",{onClick:()=>{E('[data-section="opportunity"]',"Opportunities"),k(!1)},className:"h-9 px-3 rounded-full hover:bg-secondary/50 flex items-center gap-1.5 text-[11px] font-semibold touch-manipulation transition-colors",children:[e.jsx(rn,{className:"w-3.5 h-3.5"})," Opportunities"]}),i&&e.jsxs("button",{onClick:()=>{E('[data-section="plan"]',"Plan"),k(!1)},className:"h-9 px-3 rounded-full hover:bg-secondary/50 flex items-center gap-1.5 text-[11px] font-semibold touch-manipulation transition-colors",children:[e.jsx(lt,{className:"w-3.5 h-3.5"})," Plan"]})]}),_&&N&&e.jsxs(e.Fragment,{children:[n&&e.jsx("div",{className:"my-0.5 h-px bg-border"}),G.map(L=>e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"px-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground
837/80",children:L.label}),L.items.map(R=>e.jsxs("button",{onClick:()=>{N(R.path),k(!1)},className:"h-9 px-3 rounded-full hover:bg-secondary/50 flex items-center gap-1.5 text-[11px] font-semibold touch-manipulation transition-colors",children:[e.jsx(R.icon,{className:"w-3.5 h-3.5"})," ",R.label]},R.path))]},L.label))]})]}),e.jsx("button",{onClick:()=>k(L=>!L),className:Z("rounded-full shadow-md flex items-center justify-center touch-manipulation transition-all",V?"h-10 w-10 px-0 bg-background/95 backdrop-blur-sm text-muted-foreground border border-border hover:text-foreground":Z("h-12 bg-primary text-primary-foreground border border-primary/30 hover:bg-primary/90",x?"w-12 px-0":"pl-3 pr-3 gap-2")),"aria-label":V?"Main menu":"Section shortcuts",children:x?e.jsx(Bt,{className:V?"w-4 h-4":"w-5 h-5"}):V?e.jsx(Jr,{className:"w-4 h-4"}):e.jsxs(e.Fragment,{children:[e.jsx(Jr,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs font-semibold",children:"Sections"})]})})]})]}):e.jsxs("div",{ref:h,className:"fixed right-4 bottom-20 z-[80] flex flex-col gap-1.5 pointer-events-auto",children:[v&&y&&e.jsx("button",{onClick:y,className:"w-9 h-9 rounded-full bg-card border border-border shadow-lg flex items-center justify-center hover:bg-secondary/50 transition-colors touch-manipulation",title:"Analyze another site",children:e.jsx(ur,{className:"w-4 h-4"})}),d&&n&&e.jsx("button",{onClick:d,className:"w-9 h-9 rounded-full bg-primary text-primary-foreground shadow-lg flex items-center justify-center hover:bg-primary/90 transition-colors touch-manipulation ring-2 ring-primary/30",title:"Executive Brief (CEO-ready)",children:e.jsx(sn,{className:"w-4 h-4"})}),e.jsx("button",{onClick:o,disabled:a,className:"w-9 h-9 rounded-full bg-primary text-primary-foreground shadow-lg flex items-center justify-center hover:bg-primary/90 transition-colors touch-manipulation",title:"Share",children:e.jsx(xr,{className:"w-4 h-4"})}),e.jsx("button",{onClick:c,className:"w-9 h-9 rounded-full bg-primary text-primary-foreground shadow-lg flex items-center justify-center hover:bg-primary/90 transition-colors touch-manipulation",title:"PDF",children:e.jsx(Cs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>E('[data-section="diagnosis"]',"Scorecard"),className:"w-9 h-9 rounded-full bg-card border border-border shadow-lg flex items-center justify-center text-xs hover:bg-secondary/50 transition-colors touch-manipulation",title:"Scorecard",children:e.jsx(ws,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>E('[data-section="opportunity"]',"Opportunities"),className:"w-9 h-9 rounded-full bg-card border border-border shadow-lg flex items-center justify-center text-xs hover:bg-secondary/50 transition-colors touch-manipulation",title:"Opportunities",children:e.jsx(rn,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>E('[data-section="whitespace"]',"White Space"),className:"w-9 h-9 rounded-full bg-card border border-border shadow-lg flex items-center justify-center text-xs hover:bg-secondary/50 transition-colors touch-manipulation",title:"White Space",children:e.jsx(Qr,{className:"w-4 h-4"})}),i&&e.jsx("button",{onClick:()=>E('[data-section="plan"]',"Plan"),className:"w-9 h-9 rounded-full bg-card border border-border shadow-lg flex items-center justify-center text-xs hover:bg-secondary/50 transition-colors touch-manipulation",title:"Plan",children:e.jsx(lt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>{const L=document.querySelector(".overflow-y-auto.overscroll-contain");if(L){L.scrollTo({top:0,behavior:"smooth"});return}window.scrollTo({top:0,behavior:"smooth"})},className:"w-9 h-9 rounded-full bg-primary text-primary-foreground shadow-lg flex items-center justify-center hover:bg-primary/90 transition-colors touch-manipulation",title:"Back to top",children:e.jsx(Bt,{className:"w-4 h-4"})})]})});ea.displayName="FloatingNav";const jn=[{id:"weekly",label:"📅 Weekly Review",desc:"Wins, misses, urgent adjustments"},{id:"monthly",label:"📊 Monthly Review",desc:"Positioning, channels, leads, conversions"},{id:"quarterly",label:"🎯 Quarterly Review",desc:"Category position, strategic drift, goal reassessment"}];function al({isMobile:t,planData:s,onRunSpecialist:n,onRunReview:i}){const[a,o]=g.useState(!1);return t?e.jsx("div",{className:"sticky bottom-0 bg-background/95 backdrop-blur-sm border-t border-border",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4",children:[e.jsxs("button",{onClick:()=>o(c=>!c),className:"w-full flex items-center justify-between py-2.5 touch-manipulation",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"🔬 Deep-dive agents"}),e.jsx(Bt,{className:Z("w-4 h-4 text-muted-foreground transition-transform",a?"":"rotate-180")}
837)]}),a&&e.jsxs("div",{className:"pb-3 space-y-3 animate-in slide-in-from-bottom-2 duration-200",children:[e.jsx("div",{className:"space-y-2",children:nn.map(c=>e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted-foreground font-medium mb-1",children:c.label}),e.jsx("div",{className:"flex gap-1.5 flex-wrap",children:c.agents.map(d=>e.jsxs("button",{onClick:()=>{n(d.id),o(!1)},className:"inline-flex items-center gap-1 px-2.5 py-1.5 rounded-full text-[11px] font-medium border border-border bg-card hover:bg-primary/10 hover:border-primary/30 hover:text-primary active:scale-95 transition-all",children:[e.jsx(d.icon,{className:"w-3 h-3"}),d.label]},d.id))})]},c.id))}),s&&e.jsxs("div",{className:"border-t border-border pt-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground font-medium mb-1",children:"📋 Reviews"}),e.jsx("div",{className:"flex gap-1.5 flex-wrap",children:jn.map(c=>e.jsxs("button",{onClick:()=>{i(c.id),o(!1)},className:"inline-flex items-center gap-1 px-2.5 py-1.5 rounded-full text-[11px] font-medium border border-border bg-card hover:bg-primary/10 hover:border-primary/30 hover:text-primary active:scale-95 transition-all",children:[e.jsx(ns,{className:"w-3 h-3"}),c.label]},c.id))})]})]})]})}):e.jsx("div",{className:"sticky bottom-0 bg-background/95 backdrop-blur-sm border-t border-border",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-3 space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-muted-foreground font-semibold uppercase tracking-wider mb-2",children:"🔬 Deep-dive agents"}),e.jsx("div",{className:"space-y-2",children:nn.map(c=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground font-medium w-16 shrink-0 truncate",children:c.label}),e.jsx("div",{className:"flex gap-1.5 overflow-x-auto scrollbar-hide",children:c.agents.map(d=>e.jsxs("button",{onClick:()=>n(d.id),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium border border-border bg-card hover:bg-primary/10 hover:border-primary/30 hover:text-primary active:scale-95 transition-all whitespace-nowrap",children:[e.jsx(d.icon,{className:"w-3 h-3"}),d.label]},d.id))})]},c.id))})]}),s&&e.jsxs("div",{className:"border-t border-border pt-2.5",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground font-semibold uppercase tracking-wider mb-2",children:"📋 Periodic Reviews"}),e.jsx("div",{className:"flex gap-1.5 overflow-x-auto scrollbar-hide",children:jn.map(c=>e.jsxs("button",{onClick:()=>i(c.id),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium border border-border bg-card hover:bg-primary/10 hover:border-primary/30 hover:text-primary active:scale-95 transition-all whitespace-nowrap",children:[e.jsx(ns,{className:"w-3 h-3"}),c.label]},c.id))})]})]})})}function il({session:t,onResume:s,onDismiss:n}){const i=t.originalInput||"previous analysis",a=!!t.diagnosisData,o=a?"Results ready":t.phase==="diagnosing"?"In progress":"Partial scan",c=a?"bg-emerald-500":"bg-amber-500";return e.jsxs("div",{className:"bg-primary/5 border border-primary/20 rounded-xl px-3 py-2.5 flex items-center gap-3 animate-in slide-in-from-top-2 duration-300",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("p",{className:"text-xs font-semibold text-foreground truncate flex items-center gap-1.5",children:[e.jsx("span",{className:Z("w-1.5 h-1.5 rounded-full shrink-0",c)}),o,": ",e.jsx("span",{className:"text-muted-foreground font-normal truncate",children:i})]})}),e.jsx("button",{onClick:s,className:"shrink-0 text-[11px] font-semibold px-3 py-1.5 rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",children:"Resume"}),e.jsx("button",{onClick:n,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors text-xs","aria-label":"Dismiss",children:"✕"})]})}function vs({label:t,onRetry:s}){return e.jsxs("div",{className:"bg-destructive/5 border border-destructive/20 rounded-xl px-4 py-3 flex items-center justify-between gap-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:t})," failed to load"]}),e.jsxs("button",{onClick:s,className:"shrink-0 text-xs font-semibold px-3 py-1.5 rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 transition-colors flex items-center gap-1.5",children:[e.jsx(ns,{className:"w-3 h-3"})," Retry"]})]})}function ol({assetKey:t,requiresUpgrade:s,basis:n,source:i="diagnosis_result",position:a="above_report",diagnosisId:o}){const c=Wn(t),d=Vi(t),y=g.useRef(!1);return g.useEffect(()=>{y.current||(y.current=!0,de(se.DIAGNOSIS_ASSET_PREVIEW_SHOWN,{recommended_asset:t,requires_upgrade:s,source:i,position:a,diagnosis_id:o??null}))},[t,s,i,a,o]),e.jsxs("div",{"data-testid":"recommended-asset-preview",className:"rounded-xl border border-primary/30 bg-secondary/40 p-3 space-y-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mt,{className:"w-3.5 h-3.5 text-primary shrink-0","aria-hidden":"true"}),e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Your next deliverable"}),s&&e.jsxs("span",{"data-testid":"recommended-asset-locked",className:"ml-auto inline-flex items-center gap-1 rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-semibold text-primary",children:[e.jsx(La,{className:"w-2.5 h-2.5","aria-hidden":"true"})," Unlocks on checkout"]})]}),e.jsx("p",{className:"text-sm font-bold text-foreground",children:c.label}),e.jsx("ul",{className:"space-y-1.5",children:d.map(v=>e.jsxs("li",{className:"rounded-lg bg-background/70 px-2.5 py-2",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:v}),e.jsxs("div",{className:"mt-1 space-y-1","aria-hidden":"true",children:[e.jsx("div",{className:"h-2 rounded bg-muted/80 w-11/12"}),e.jsx("div",{className:"h-2 rounded bg-muted/60 w-7/12"})]})]},v))}),n&&e.jsxs("p",{"data-testid":"recommended-asset-basis",className:"text-[11px] text-muted-foreground",children:["Written to fix: “",n,"”"]}
837)]})}const ll="/composer?source=strategy_diagnosis&autostart=1",wn="pro",wt="diagnosis_to_composer";function cl({diagnosisData:t,diagnosisId:s,inputText:n,requiresUpgrade:i,onAnalyzeAnother:a,onChooseStrategicPath:o,returnTo:c="/strategy",source:d="diagnosis_result",position:y="after_report"}){const v=An(),f=g.useRef(!1),_=g.useRef(!1),[N,m]=g.useState(!1),[h,x]=g.useState(!1),k=g.useRef(null),w=g.useRef(null),$=zn(),[V,G]=g.useState(!1),[E]=g.useState(()=>Yi()),{user:L}=os(),{toast:R}=Ps(),[l,T]=g.useState(!1),S=mi(t),z=S.findings.length,C=E?"apply_to_draft":"one_click_asset",K=Ji(S.findings,n??null),U=E?null:K.key,re=Qi(U),xe=g.useRef(!1);g.useEffect(()=>{E||xe.current||z===0||(xe.current=!0,de(se.STRATEGY_RECOMMENDED_ASSET_SHOWN,{recommended_asset:K.key,inferred:K.inferred,finding_count:z,position:y,source:d}))},[E,z,K.key,K.inferred,y,d]),g.useEffect(()=>{const le=w.current;if(!le||f.current)return;const Se=()=>{if(f.current)return;f.current=!0;const we={cta_id:wt,variant:C,position:y,requires_upgrade:i,source:d,viewport:$?"mobile":"desktop"};de(se.DIAGNOSIS_NEXT_ACTION_VIEW,{...we,finding_count:z,has_draft:E}),de(se.DIAGNOSIS_RESULT_CTA_VIEW,we)};if(typeof IntersectionObserver>"u"){const we=le.getBoundingClientRect(),ne=typeof window<"u"?window.innerHeight:0;we.top<ne&&we.bottom>0&&Se();return}const Ue=new IntersectionObserver(we=>{const ne=we.some(I=>I.isIntersecting);m(ne),ne&&(x(!0),Se())},{threshold:.5});return Ue.observe(le),()=>Ue.disconnect()},[i,z,E,d,$,C,y]);const u=le=>de(se.DIAGNOSIS_NEXT_ACTION_CLICK,{action:le,source:d,position:y,finding_count:z,requires_upgrade:i,viewport:$?"mobile":"desktop"}),pe=async le=>{const Se=!!(le&&le.forceFree===!0);if(_.current)return;if(_.current=!0,Ee){u("view_composer_pro"),Ks({type:"diagnosis",origin:"strategy",returnTo:c,hasDraft:E,diagnosisId:s??null,diagnosisInput:n??null,findings:S.findings,recommendedAsset:U}),await Ns(se.DIAGNOSIS_RESULT_CTA_CLICK,{cta_id:wt,variant:"composer_pro_pilot",position:y,action:"view_composer_pro",source:d,requires_upgrade:i,finding_count:z,viewport:$?"mobile":"desktop",destination:Ee}),v(Ee);return}if(i&&U&&!E&&!Se){u("upgrade_to_create_asset"),Ks({type:"diagnosis",origin:"strategy",returnTo:c,hasDraft:!1,diagnosisId:s??null,diagnosisInput:n??null,findings:S.findings,recommendedAsset:U}),Ki(U),on(U),T(!0),de(se.DIAGNOSIS_UPGRADE_INITIATED,{recommended_asset:U,requires_upgrade:!0,source:"strategy_diagnosis",plan:wn,authenticated:!!L,diagnosis_id:s??null,position:y}),await Ns(se.DIAGNOSIS_RESULT_CTA_CLICK,{cta_id:wt,variant:C,position:y,action:"upgrade_to_create_asset",source:d,requires_upgrade:!0,finding_count:z,viewport:$?"mobile":"desktop",recommended_asset:U,destination:"checkout"});const ne=await Da({plan:wn,billing:"monthly",returnTo:ll,source:"strategy_diagnosis",isAuthenticated:!!L,navigate:v});ne.ok||(T(!1),_.current=!1,R({title:"Could not start checkout",description:ne.error||"Please try again in a moment.",variant:"destructive"}));return}const Ue=U&&!Se?"/composer?source=diagnosis&autostart=1":"/composer?source=diagnosis",we=E?"apply_findings_to_draft":"one_click_generate_asset";u(we),Ks({type:"diagnosis",origin:"strategy",returnTo:c,hasDraft:E,diagnosisId:s??null,diagnosisInput:n??null,findings:S.findings,recommendedAsset:U}),U&&!Se&&(on(U),de(se.DIAGNOSIS_ONE_CLICK_GENERATION_REQUESTED,{recommended_asset:U,inferred:K.inferred,finding_count:z,position:y,viewport:$?"mobile":"desktop"})),de(se.DIAGNOSIS_CONNECTED_TO_COMPOSER,{finding_count:z,has_draft:E,destination:Ue,position:y,variant:C,viewport:$?"mobile":"desktop",recommended_asset:U}),de(se.DIAGNOSIS_TO_AUTHORING_START,{cta_id:wt,variant:C,position:y,finding_count:z,has_draft:E,viewport:$?"mobile":"desktop",recommended_asset:U,destination:Ue}),await Ns(se.DIAGNOSIS_RESULT_CTA_CLICK,{cta_id:wt,variant:C,position:y,action:we,source:d,requires_upgrade:i,finding_count:z,viewport:$?"mobile":"desktop",recommended_asset:U,destination:Ue}),v(Ue)},q=E?"Apply these fixes to my draft":Xi(U),ye=Ba("diagnosis_next_action_cta",q),ue=ye.text||q,Ee=ye.destination,Qe=i&&!!U&&!E&&!Ee,Ke=Ee?"See plans — your audit and findings stay saved for the Composer.":Qe?`Your ${re} is written right after checkout — findings included.`:E?`Free — your ${z||""} findings are applied to the draft you already have.`.replace("  "," "):`Free — we'll use your diagnosis to write a ready-to-edit ${re}.`;return e.jsxs("div",{ref:k,"data-testid":"diagnosis-next-action",className:"scroll-mt-24 rounded-2xl border border-primary/25 bg-card p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Executive summary"}),e.jsx("h3",{className:"text-sm font-bold text-foreground mt-0.5 truncate",children:n||"Your Signal Audit"})]}),S.score!==null&&e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsxs("p",{className:"text-2xl font-bold font-mono text-foreground leading-none",children:[S.score,e.jsx("span",{className:"text-sm font-semibold text-muted-foreground",children:" / 100"})]}),S.grade&&e.jsxs("p",{className:"text-[11px] font-semibold text-primary mt-0.5",children:["Grade ",
837S.grade]})]})]}),S.lost&&e.jsxs("div",{className:"rounded-xl border border-warning/30 bg-warning/5 p-3",children:[e.jsxs("p",{className:"flex items-center gap-1.5 text-[11px] font-semibold text-warning",children:[e.jsx(jr,{className:"w-3.5 h-3.5"})," Biggest issue"]}),e.jsx("p",{className:"text-xs font-semibold text-foreground mt-1",children:S.lost.label}),S.lost.detail&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:S.lost.detail})]}),z>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mb-1.5",children:"Fix these first"}),e.jsx("ol",{className:"space-y-1.5",children:S.findings.map((le,Se)=>e.jsxs("li",{className:"rounded-lg bg-secondary px-3 py-2 text-xs text-secondary-foreground",children:[e.jsxs("span",{className:"font-semibold",children:[Se+1,". ",le.label]}),le.detail&&le.detail!==le.label&&e.jsx("span",{className:"block text-muted-foreground mt-0.5",children:le.detail})]},Se))})]}),e.jsxs("div",{className:"space-y-2",children:[U&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{"data-testid":"diagnosis-recommended-asset",className:"text-[11px] text-muted-foreground",children:["Recommended next asset:"," ",e.jsx("span",{className:"font-semibold text-foreground",children:Wn(U).label}),K.inferred&&K.basis&&e.jsxs("span",{children:[" — from “",K.basis,"”"]})]}),e.jsx(ol,{assetKey:U,requiresUpgrade:Qe,basis:K.inferred?K.basis:null,source:d,position:y,diagnosisId:s??null})]}),e.jsxs(_e,{ref:w,"data-testid":"diagnosis-primary-cta","data-cta-id":wt,"aria-label":ue,onClick:()=>pe(),disabled:l,className:"w-full min-h-[48px] gap-2 gradient-primary text-primary-foreground font-semibold",children:[e.jsx(cr,{className:"w-4 h-4","aria-hidden":"true"}),ue,!ue.includes("→")&&e.jsx(or,{className:"w-4 h-4","aria-hidden":"true"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground text-center",children:Ke}),Qe&&e.jsx("button",{"data-testid":"diagnosis-free-composer-fallback",onClick:()=>pe({forceFree:!0}),className:"block w-full text-center text-[11px] text-muted-foreground hover:text-foreground underline underline-offset-2",children:"Or write it yourself in the Composer"})]}),S.working&&e.jsxs("div",{"data-testid":"diagnosis-whats-working",className:"rounded-xl border border-success/25 bg-success/5 p-3",children:[e.jsxs("p",{className:"flex items-center gap-1.5 text-[11px] font-semibold text-success",children:[e.jsx(kt,{className:"w-3.5 h-3.5"})," What's working"]}),e.jsx("p",{className:"text-xs font-semibold text-foreground mt-1",children:S.working.label}),S.working.detail&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:S.working.detail})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[o&&e.jsxs("button",{onClick:()=>{u("build_action_plan"),o()},className:"inline-flex items-center gap-1.5 self-start text-xs text-muted-foreground hover:text-foreground underline underline-offset-2",children:[e.jsx(lt,{className:"w-3.5 h-3.5","aria-hidden":"true"}),"Build my action plan"]}),i?!V&&e.jsx("button",{onClick:()=>{u("run_another_analysis_upgrade"),G(!0)},className:"text-xs text-muted-foreground hover:text-foreground underline underline-offset-2 self-start",children:"Run another deep analysis"}):e.jsxs("button",{onClick:()=>{u("analyze_another"),a()},className:"inline-flex items-center gap-1.5 self-start text-xs text-muted-foreground hover:text-foreground underline underline-offset-2",children:[e.jsx(ns,{className:"w-3.5 h-3.5","aria-hidden":"true"}),"Run another deep analysis"]})]}),$&&h&&!N&&e.jsx("div",{"data-testid":"diagnosis-sticky-cta",className:"fixed inset-x-0 bottom-0 z-[120] pointer-events-auto border-t border-border bg-background/95 backdrop-blur px-3 pt-2 pb-[calc(0.5rem+env(safe-area-inset-bottom))]",children:e.jsxs(_e,{"data-cta-id":wt,"aria-label":ue,onClick:pe,className:"w-full min-h-[48px] gap-2 gradient-primary text-primary-foreground font-semibold",children:[e.jsx(cr,{className:"w-4 h-4","aria-hidden":"true"}),ue,e.jsx(or,{className:"w-4 h-4","aria-hidden":"true"})]})}),V&&e.jsx(xi,{outcome:"Run another deep Signal Audit",benefit:"Your completed audit above stays available — Pro adds more monthly Deep Analyses.",returnTo:c,source:"diagnosis_next_action",onDismiss:()=>G(!1)})]})}const ta="strategy_anon_quota_wall";function dl({onContinue:t,onViewDiagnosis:s}){const n=g.useRef(!1);return g.useEffect(()=>{n.current||(n.current=!0,de(se.STRATEGY_QUOTA_WALL_VIEWED,{source:ta}))},[]),e.jsxs("div",{"data-testid":"quota-wall",className:"rounded-2xl border border-primary/25 bg-card p-6 sm:p-8 shadow-lg space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Lt,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-foreground leading-tight",children:"Your free Signal Audit is complete"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You got the full diagnosis — the next one is ready when you are."})]})]}
837),e.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:"You already ran one complete audit and came back for another — that second diagnosis is built and waiting behind a free account. Your audit, answers, and context stay right here; nothing is lost."}),e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsx(_e,{"data-testid":"quota-wall-cta",onClick:t,className:"w-full min-h-[48px] text-base font-semibold",children:"Continue with SocialBrilliance →"}),s&&e.jsxs("button",{type:"button","data-testid":"quota-wall-secondary",onClick:s,className:"w-full text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center justify-center gap-1.5 py-1",children:[e.jsx(ur,{className:"w-3 h-3"}),"Review my completed audit first"]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70 text-center",children:"Free account · your completed audit stays saved on this device"})]})}const Nn=5e4,pl={"clinical-trials":{label:"Clinical Trials & Patient Recruitment",strategyTitle:"Clinical Trials Messaging Intelligence",intro:"Paste a trial listing, sponsor page, or LinkedIn profile and I’ll diagnose trust leaks, clarity gaps, and patient-recruitment friction in minutes."},"startup-founders":{label:"Startup Founders",strategyTitle:"Founder Signal Intelligence",intro:"Paste your homepage, pitch, or founder profile and I’ll diagnose how investors and buyers actually read your signal."},"law-firms":{label:"Law Firms",strategyTitle:"Legal Brand Intelligence",intro:"Paste your firm website and I’ll diagnose authority, trust, and differentiation gaps in your positioning."},"health-tech":{label:"Health Tech",strategyTitle:"Health Tech Messaging Intelligence",intro:"Paste your product or company page and I’ll diagnose credibility, clarity, and adoption friction in your message."},edtech:{label:"EdTech",strategyTitle:"EdTech Narrative Intelligence",intro:"Paste your site or pitch and I’ll diagnose how district buyers, educators, and operators interpret your message."},"enterprise-saas":{label:"Enterprise SaaS",strategyTitle:"Enterprise SaaS GTM Intelligence",intro:"Paste your website and I’ll diagnose message-market fit, trust signal strength, and conversion friction across enterprise buyers."},"venture-capital":{label:"Venture Capital",strategyTitle:"VC Portfolio Signal Intelligence",intro:"Paste a portfolio company URL and I’ll diagnose signal quality, differentiation, and GTM risk in minutes."},consultants:{label:"Consultants",strategyTitle:"Consultant Positioning Intelligence",intro:"Paste your site or profile and I’ll diagnose authority, offer clarity, and premium positioning strength."}},ul={investors:{title:"Portfolio Signal Intelligence",intro:"Paste a portfolio company URL, pitch deck, or investor profile and I'll diagnose how the market reads the brand — signal clarity, trust friction, and positioning gaps.",placeholder:"Paste portfolio company URL or investor profile…"},enterprise:{title:"Enterprise GTM Signal Audit",intro:"Paste your product page, company site, or competitive URL and I'll diagnose market signal strength, conversion friction, and positioning gaps before your next launch.",placeholder:"Paste enterprise product URL or company site…"},agencies:{title:"Client Signal Diagnostic",intro:"Paste a client URL, campaign page, or competitor site and I'll diagnose positioning clarity, trust signals, and messaging gaps — so you can sell upstream strategy, not just execution.",placeholder:"Paste client URL, campaign page, or competitor site…"},"signal-index":{title:"Signal Index Benchmark Audit",intro:"Paste your company URL and I'll score you across the signal framework — compare against category leaders and get strategic recommendations.",placeholder:"Paste your company URL to benchmark…"},compare:{title:"Competitive Signal Audit",intro:"Paste a company URL and I'll show you how your signal compares — positioning clarity, trust, differentiation, and competitive white space.",placeholder:"Paste company URL to compare…"},shared:{title:"Your Signal Diagnosis",intro:"You just saw someone else's diagnosis. Now run your own — paste a URL and see how the market reads your brand in minutes.",placeholder:"Paste your URL, LinkedIn profile, or company name…"}
837,"annual-report":{title:"Custom Signal Audit",intro:"Run your own free audit and see how your company scores across the signal framework — the same methodology behind the Annual Startup Signal Report.",placeholder:"Paste your company URL or LinkedIn profile…"},dashboard:{title:"Signal Audit",intro:"Run a fresh diagnosis — paste a URL and I'll show you how the market reads the brand across clarity, trust, differentiation, and message-market fit.",placeholder:"Paste URL, LinkedIn profile, or company name…"},landing:{title:"Signal Audit",intro:"Start your first signal diagnosis from the main experience — paste a URL, profile, or message draft and get a context-aware strategic read in minutes.",placeholder:"Paste URL, LinkedIn profile, or message draft…"},index:{title:"Strategic Intelligence Advisor",intro:"Paste a URL or message draft to run the same diagnosis flow used across your workspace — optimized for fast action and operator-grade recommendations.",placeholder:"Paste URL, LinkedIn profile, or draft copy…"},"index-nav":{title:"Quick Audit Entry",intro:"You launched from quick navigation — paste a URL, company name, or draft message and run a focused signal audit immediately.",placeholder:"Paste URL, company name, or draft text…"},pricing:{title:"Try Before You Upgrade",intro:"Paste your URL or message draft and run a free diagnosis before choosing a plan.",placeholder:"Paste URL, LinkedIn profile, or message draft…"},rankings:{title:"Ranking Benchmark Audit",intro:"Paste your company URL to benchmark your score against ranked companies and identify the highest-leverage improvements.",placeholder:"Paste your company URL to compare rankings…"},about:{title:"Run Your Signal Audit",intro:"See the methodology in action on your own brand — paste a URL, profile, or messaging draft to get a live diagnosis.",placeholder:"Paste URL, profile, or messaging draft…"},auth:{title:"Guest Signal Audit",intro:"No account required for a first pass — paste your URL or draft and run a context-aware diagnosis.",placeholder:"Paste URL, LinkedIn profile, or draft text…"},"company-profile":{title:"Company Signal Deep-Dive",intro:"You came from a company profile comparison flow — paste your own URL or profile to run a side-by-side-ready diagnosis.",placeholder:"Paste your company URL or LinkedIn profile…"},"landing-hero":{title:"Hero Entry Signal Audit",intro:"You launched from the hero showcase — paste a URL or message draft to get your first strategic diagnosis.",placeholder:"Paste URL, profile, or message draft…"},"landing-feature":{title:"Feature-Driven Signal Audit",intro:"You launched from feature exploration — paste a URL or narrative draft and run a personalized diagnostic flow.",placeholder:"Paste URL, profile, or narrative draft…"},"landing-scenarios":{title:"Scenario-Based Signal Audit",intro:"You launched from industry scenarios — paste a URL, profile, or message draft to get an audience-aware strategic read.",placeholder:"Paste URL, profile, or scenario message draft…"},"landing-sample":{title:"Sample-to-Your-Own Audit",intro:"You viewed a sample diagnosis — now paste your own URL, profile, or message draft to generate your personalized version.",placeholder:"Paste your URL, profile, or message draft…"},"payment-success":{title:"Your Pro Signal Audit",intro:"Your Pro access is active. Paste a website, company, or LinkedIn profile and run your first deep analysis now.",placeholder:"Paste website, LinkedIn URL, or company name…"}};function kn(t){if(!t)return null;const s=t.toLowerCase().trim(),n=ul[s];return n?{slug:s,...n}:null}function Sn(t){if(!t)return null;const s=t.toLowerCase().trim(),n=pl[s];return n?{slug:s,...n}:null}function rs(t,s){return t?`**${t.strategyTitle}**
838
839${t.intro}`:s?`**${s.title}**
840
841${s.intro}`:`**Signal Audit**
842
843I read your public content and show you how the market likely reads your brand — clarity, trust, differentiation, and message-market fit.
844
845Use a company website URL or LinkedIn profile, or switch to **Strategic Brief** to analyze a pitch, deck, campaign, or any narrative asset.`}const ml=220;function xl(t){const s=t.trim();return s.includes(`
846`)||s.length>=ml}function gl(t){return t.length<=Nn?t:t.slice(0,Nn)+`
847
848[Content truncated for processing — full profile was analyzed during intake.]`}const fl=new Set(["strategy-diagnosis","strategy-forecast","strategy-agents","strategy-audience","strategy-pers
848onas","strategy-plan"]);function hl(t){const s=t.trim();return s.length<2?!1:s.startsWith("http")||s.includes(".")?s.replace(/^https?:\/\//,"").length>2:s.length>=2}function er(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`strategy-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function sa(t){const s=t instanceof Error?t.message:String(t||"unknown");return/took too long and was stopped/i.test(s)?"budget_exhausted":/all retry attempts failed/i.test(s)?"retry_exhausted":/timed out|abort/i.test(s)?"timeout":/quota|limit|upgrade|meter|run/i.test(s)?"meter_or_quota":/network|fetch|service unavailable|failed to fetch/i.test(s)?"network_or_service":/json|parse/i.test(s)?"parse_error":/content|profile|website|scrape|fetch website/i.test(s)?"source_unavailable":"unknown"}const bl=["invalid_token","previous_attempt_failed","request_already_completed","reservation_expired","caller_mismatch","wrong_scope","wrong_feature"];function fr(t){const s=String(t||"").toLowerCase();return/request_in_progress/.test(s)?!1:bl.some(n=>s.includes(n))}async function yl(t){if(!t)return t;const s=(t==null?void 0:t.context)instanceof Response?t.context:void 0,n=(t==null?void 0:t.status)??(s==null?void 0:s.status);let i=null;if(s)try{const c=await s.clone().json();c&&typeof c.reason=="string"&&(i=c.reason)}catch{}if(!n&&!i)return t;const a=[i?`reason=${i}`:null,n?`status=${n}`:null].filter(Boolean).join(" "),o=new Error(`${t.message||"Edge Function error"} (${a})`);return Object.assign(o,{status:n,meterReason:i,cause:t})}function tr(t){const s=String(t||"").toLowerCase();return/begin_timeout|begin_run_timeout|timed out|timeout/.test(s)?"begin_timeout":/request_in_progress|already running|in_progress/.test(s)?"claim_in_progress":/request_already_completed/.test(s)?"duplicate_completed":/anonymous_identity_required/.test(s)?"identity_required":/unauthenticated|sign in required/.test(s)?"auth_required":/previous_attempt_failed|reservation_expired|invalid_token|token_expired|caller_mismatch|wrong_scope|wrong_feature/.test(s)?"dead_credentials":/meter_network|network_error|failed to fetch|fetch failed/.test(s)?"meter_network":/meter_service|502|504/.test(s)?"meter_service":/meter_unavailable|service unavailable|503/.test(s)?"meter_unavailable":/meter_rejected/.test(s)?"meter_rejected":/quota|limit|upgrade/.test(s)?"quota_exhausted":"meter_or_quota"}function _l(t){const s=String((t==null?void 0:t.message)||"").toLowerCase(),n=String((t==null?void 0:t.meterReason)||"").toLowerCase(),i=Number((t==null?void 0:t.status)||0);return fr(n)||fr(s)?"claim_failure":/request_in_progress|already running/.test(n)?"claim_in_progress":/ai_timeout|504|gateway timeout|timed out|timeout|aborted|abort/.test(s)||/ai call failed after all retries/.test(s)?"diagnosis_timeout":/request_in_progress|already running/.test(s)?"claim_in_progress":/limit_reached|quota|anonymous_limit/.test(n)?"quota_exhausted":/invalid_token|token|claim/.test(s)?"claim_failure":/service unavailable|bad gateway|502|503|500|internal server error/.test(s)?"diagnosis_service":/failed to fetch|network|load failed/.test(s)?"diagnosis_network":i>=500?"diagnosis_service":i>=400?`diagnosis_rejected_${i}`:sa(t)}const Dt=new Map;function _c(){return Dt.size}function vc(t){return Dt.get(t)}function jc(t){ra(t)}function ra(t){Dt.set(t.clientRequestId,{...t,runToken:t.releaseMode==="tokenless"?null:t.runToken})}function sr(t){Dt.delete(t)}function $n(){for(const t of Dt.values()){const s=t.releaseMode==="tokenless"?null:t.runToken;Ha(ks.strategyDiagnosis,s,t.clientRequestId,t.accessToken)}Dt.clear()}let yt=null;function wc(t){yt=t}const vl=new Set(["strategy-diagnosis"]),rr=45e3,nr=45e3,ar=11e4,jl=7e4,wl=15e4,ir=3e3,Nl="The scan took too long and was stopped. Please try again.";async function ze(t,s,n=2,i=9e4,a={}){vl.has(t)&&(n=0),typeof s.content=="string"&&(s={...s,content:gl(s.content)}),fl.has(t)&&(s={...s,run_token:yt,deviceId:De()});const{deadlineAt:o}=a,c=()=>o===void 0?1/0:o-Date.now(),d=()=>({data:null,error:new Error(Nl)});for(let y=0;y<=n;y++){const v=c();if(v<=ir)return d();const f=Math.min(i,v);let _,N;try{const m=new AbortController;_=setTimeout(()=>m.abort(),f);const h=Je.functions.invoke(t,{body:s,signal:m.signal}),x=new Promise((G,E)=>{N=setTimeout(()=>E(Object.assign(new Error(`Request timed out after ${Math.round(f/1e3)}s`),{name:"AbortError"})),f+2e3)}),{data:k,error:w}=await Promise.race([h,x]);if(clearTimeout(_),N&&clearTimeout(N),!w)return{data:k,error:null};const $=await yl(w),V=($==null?void 0:$.status)??(w==null?void 0:w.status);if(V&&V>=400&&V<500)return{data:k,error:$};if(y<n){const G=(y+1)*1500;if(c()<=G+ir)return d();console.warn(`[${t}] Attempt ${y+1} failed, retrying…`),await new Promise(E=>setTimeout(E,G))}else return{data:k,error:$}}catch(m){_&&clearTimeout(_),N&&clearTimeout(N);const h=(m==null?void 0:m.name)==="AbortError"||/timed out/i.test((m==null?void 0:m.message)||"");if(y<n){const x=(y+1)*1500;if(c()<=x+ir)return d();await new Promise(k=>setTimeout(k,x));continue}return h?{data:null,error:new Error(`Request timed out after ${Math.round(f/1e3)}s`)}:{data:null,error:m}}}return{data:null,error:new Error("All retry attempts failed")}}function na(t){return`msg-${Date.now().toString(36)}-${t.toString(36)}-${Math.random().toString(36).slice(2,8)}`}function js(t){const s=new Set;return t.map((n,i)=>{let a=n.id;return(!a||s.has(a))&&(a=na(i)),s.add(a),a===n.id?n:{...n,id:a}})}function Cn(t){return!t||typeof t!="string"?[]:t.split(/[,;\n|/]+| and /gi).map(s=>s.trim()).filter(s=>s.length>1).slice(0,12)}function Nc(){var Fr,qr,Gr,Hr,Wr;const t=An(),{user:s,session:n}=os(),i=Ma(),{recordUsage:a}=Oa("strategy"),o=g.useRef(null),[c,d]=Ua(),{toast:y}=Ps(),v=g.useRef(null),f=g.useRef(el()),_=Sn(c.get("industry")),N=kn(c.get("source")),[m,h]=g.useState(_),[x,k]=g.useState(N),[w,$]=g.useState(()=>{var r,j;return(j=(r=f.current)==null?void 0:r.messages)!=null&&j.length?js(f.current.messages):[W("assistant",rs(_,N),"text")]}),[V,G]=g.useState(""),[E,L]=g.useState("url"),R=g.useRef(null),[l,T]=g.useState(()=>{try{return sessionStorage.getItem("sb_report_objective")||null}catch{return null}}),S=r=>{const j=r.trim()?r:null;T(j);try{j?sessionStorage.setItem("sb_report_objective",j):sessionStorage.removeItem("sb_report_objective")}catch{}},[z,C]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.phase)||"intake"}),[K,U]=g.useState(!1),[re,xe]=g.useState(null),[u,pe]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.intakeData)??null}),[q,ye]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.diagnosisData)??null}),[ue,Ee]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.forecastData)??null}),[Qe,Ke]=g.useState(!1),[le,Se]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.frictionData)??null}),[Ue,we]=g.useState(!1),[ne,I]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.positioningData)??null}),[Ce,at]=g.useState(!1),[Pe,ut]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.narrativeData)??null}),[Ot,St]=g.useState(!1),[Fe,mt]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.personaData)??null}),[Ut,$t]=g.useState(!1),[ls,Ct]=g.useState(null),[cs,xt]=g.useState(!1),[ds,_t]=g.useState(null),[ps,p]=g.useState(!1),[Q,P]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.planData)??null}),[ge,J]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.isWebsite)??!1}),[O,Te]=g.useState(!1),[D,X]=g.useState(null),[Ie,M]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.originalInput)??""}),ae=(D==null?void 0:D.outcomeId)||(D==null?void 0:D.outcome)||l||(u==null?void 0:u.objective)||(u==null?void 0:u.outcome)||(u==null?void 0:u.desired_outcome)||null;dr(ae);const it=[...(D==null?void 0:D.competitors)||[],...Cn(u==null?void 0:u.competitors)].filter((r,j,A)=>A.indexOf(r)===j),gt={competitorReferences:Number(((Fr=ne==null?void 0:ne.evidence_inventory)==null?void 0:Fr.competitor_references)??((Gr=(qr=q==null?void 0:q.brand_intelligence)==null?void 0:qr.evidence_inventory)==null?void 0:Gr.competitor_references)??0)||0,contentNames:(ne==null?void 0:ne.competitor_names_in_content)||((Hr=q==null?void 0:q.competitive_strategy)==null?void 0:Hr.competitor_names_in_content)||[],userProvidedNames:it,hasExternalSource:!!((Wr=ne==null?void 0:ne.external_sources)!=null&&Wr.length)},kr=_r(ue,!1),[Ye,Ls]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.currentDiagnosisId)??null}),[vt,Xe]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.briefingDismissed)??!1}),[us,Ze]=g.useState(new Set),[aa,Bs]=g.useState(0),[ia,Ft]=g.useState(!1),[Ds,qt]=g.useState(null),[oa,ms]=g.useState(!1),[Sr,$r]=g.useState(!1),[Ms,Os]=g.useState(null),[la,ca]=g.useState(null),xs=Fa(r=>r.settings),[Cr,Gt]=g.useState(null),[Ht,Tr]=g.useState(""),[ft,Us]=g.useState(()=>{var r;return((r=f.current)==null?void 0:r.deepAnalysisPages)??null}),[da,Rr]=g.useState(!1),jt=g.useRef(0),he=g.useCallback(r=>jt.current===r,[]),Fs=g.useRef(!1),et=g.useRef(null);g.useEffect(()=>{re||!Ye||Je.from("strategy_diagnoses").select("content").eq("id",Ye).maybeSingle().then(({data:r})=>{r!=null&&r.content&&xe(r.content)})},[Ye,re]),g.useEffect(()=>{$(r=>{const j=js(r);return j.some((A,F)=>{var B;return A.id!==((B=r[F])==null?void 0:B.id)})?j:r})},[]);const Ar=g.useRef(!1);g.useEffect(()=>{var r;(r=f.current)!=null&&r.diagnosisData&&!Ar.current&&(Ar.current=!0,y({title:"✅ Session restored",description:"Your in-progress diagnosis was recovered."}))},[]),g.useEffect(()=>{["strategy-intake","strategy-diagnosis","strategy-forecast","strategy-agents","strategy-plan","strategy-audience","strategy-pers
848onas"].forEach(r=>Je.functions.invoke(r,{body:{warmup:!0}}).catch(()=>{}))},[]);const Wt=g.useRef();g.useEffect(()=>(Wt.current&&clearTimeout(Wt.current),Wt.current=setTimeout(()=>{var r,j;yn({messages:w,phase:z,intakeData:u,diagnosisData:q,forecastData:ue,frictionData:le,positioningData:ne,narrativeData:Pe,personaData:Fe,planData:Q,isWebsite:ge,originalInput:Ie,currentDiagnosisId:Ye,briefingDismissed:vt,deepAnalysisPages:ft,runToken:((r=o.current)==null?void 0:r.token)??null,runTokenAt:((j=o.current)==null?void 0:j.createdAt)??null})},500),()=>{Wt.current&&clearTimeout(Wt.current)}),[w,z,u,q,ue,le,ne,Pe,Fe,Q,ge,Ie,Ye,vt,ft]),qa();const{history:Ve,saveDiagnosis:pa,updateDiagnosis:qs}=Qn(),{shareDiagnosis:zr,sharing:Er}=Xo(),ua=zn(),ma=typeof window<"u"?window.matchMedia("(max-width: 767px)").matches:!1,Yt=ua||ma,xa=Yt?!0:!!q||w.some(r=>["diagnosis","opportunity_map","whitespace_map","plan"].includes(r.type));g.useEffect(()=>{const r=f.current;r!=null&&r.runToken&&r.runTokenAt&&Date.now()-r.runTokenAt<60*60*1e3&&(o.current={token:r.runToken,createdAt:r.runTokenAt},yt=r.runToken)},[]),g.useEffect(()=>{const r=()=>$n();return window.addEventListener("pagehide",r),()=>{window.removeEventListener("pagehide",r),$n()}},[]);const ga=60*60*1e3,Ir=g.useCallback(()=>{o.current=null,yt=null,et.current=null},[]),Vt=g.useCallback(async r=>{const j=r??er(),A=o.current;if(A&&Date.now()-A.createdAt<ga)return yt=A.token,r&&(et.current=j),{ok:!0,reason:"reused",clientRequestId:j};o.current=null,yt=null;const F=await a(ks.strategyDiagnosis,j);if(!F.ok){const B=en(F.reason,"This analysis");
848return y({variant:"destructive",title:B.title,description:B.description}),{ok:!1,reason:F.reason,detail:F.detail??null,clientRequestId:F.clientRequestId||j}}return F.runToken&&(o.current={token:F.runToken,createdAt:Date.now()},yt=F.runToken),et.current=F.clientRequestId||j,{ok:!0,reason:F.reason,clientRequestId:F.clientRequestId||j}},[a,y]),tt=g.useCallback(()=>{jt.current+=1,o.current=null,yt=null,et.current=null,ye(null),pe(null),Ee(null),Se(null),I(null),ut(null),mt(null),Ct(null),xt(!1),_t(null),p(!1),P(null),xe(null),Ls(null),Ze(new Set),Ke(!1),we(!1),at(!1),St(!1),$t(!1),Te(!1),X(null),Us(null),Gt(null),Tr("")},[]),Pr=g.useCallback(r=>{if(!m)return r;const j=`Industry focus: ${m.label}`;return r.includes(j)?r:r?`${j}
849${r}`:j},[m]),Gs=g.useRef(null);g.useEffect(()=>{const r=Sn(c.get("industry"));if(!r){h(null),Gs.current=null;return}h(r),k(null),Gs.current!==r.slug&&(Gs.current=r.slug,tt(),$([W("assistant",rs(r,null),"text")]),C("intake"),G(""),L("url"),qt(null),Ft(!0),Xe(!0),Et())},[c,tt]);const Hs=g.useRef(null);g.useEffect(()=>{if(c.get("industry"))return;const r=kn(c.get("source"));if(!r){k(null),Hs.current=null;return}k(r),Hs.current!==r.slug&&(Hs.current=r.slug,tt(),$([W("assistant",rs(null,r),"text")]),C("intake"),G(""),L("url"),qt(null),Ft(!0),Xe(!0),Et())},[c,tt]);const Lr=g.useCallback(()=>{setTimeout(()=>{var r;return(r=v.current)==null?void 0:r.scrollIntoView({behavior:"smooth"})},100)},[]);g.useEffect(()=>{Lr()},[w,Lr]);const ce=g.useCallback(r=>{$(j=>j.some(A=>A.id===r.id)?[...j,{...r,id:na(j.length)}]:[...j,r])},[]),Br=g.useCallback(r=>{tt();const j=[W("assistant",rs(m,x),"text"),W("user",r.input_text||"Pasted content","text")];if(r.scorecard){const A=je({brand_intelligence:r.scorecard,...r.message_gap?{message_gaps:r.message_gap}:{},...r.strategic_content?{strategic_content:r.strategic_content}:{},...r.audit_result?{audit:r.audit_result}:{}},"history-diagnosis");ye(A),r.forecast_data&&Ee(je(r.forecast_data,"history-forecast")),r.friction_data&&Se(je(r.friction_data,"history-friction")),r.positioning_data&&I(je(r.positioning_data,"history-positioning")),r.narrative_data&&ut(je(r.narrative_data,"history-narrative")),r.persona_data&&mt(je(r.persona_data,"history-persona")),j.push(W("assistant","","diagnosis",A)),j.push(W("assistant","","opportunity_map",A)),j.push(W("assistant","","whitespace_map",A)),j.push(W("assistant","","goal_select",null)),C("goal")}else C("intake");r.content&&xe(r.content),J(r.is_website),$(js(j)),Xe(!0)},[tt]);g.useEffect(()=>{const r=localStorage.getItem("sb_compare_context");if(r){localStorage.removeItem("sb_compare_context");try{const j=JSON.parse(r);j.companyName&&$([W("assistant",`**Compare your company against ${j.companyName} (${j.companyScore}/100)**
850
851Paste your website URL or LinkedIn profile below and I'll run your signal audit, then show how you stack up against ${j.companyName} across the signal framework.`,"text")])}catch{}}},[]);const Dr=g.useRef(!1);g.useEffect(()=>{const r=c.get("url"),j=c.get("industry"),A=c.get("source");r&&!Dr.current&&(Dr.current=!0,Xe(!0),d({...j?{industry:j}:{},...A?{source:A}:{}},{replace:!0}),setTimeout(()=>ht(r),300))},[c]);const gs=g.useCallback(async r=>{if(!re||!q||!(await Vt()).ok)return;const A={signal_forecast:{setLoading:Ke,setData:Ee,dbField:"forecast_data"},conversion_friction:{setLoading:we,setData:Se,dbField:"friction_data"},competitive_positioning:{setLoading:at,setData:I,dbField:"positioning_data"},narrative_architecture:{setLoading:St,setData:ut,dbField:"narrative_data"},audience_persona:{setLoading:$t,setData:mt,dbField:"persona_data"}}[r];if(A){Ze(F=>{const B=new Set(F);return B.delete(r),B}),A.setLoading(!0);try{const F=r==="signal_forecast"?"strategy-forecast":"strategy-agents",{data:B,error:Y}=await ze(F,{action:r,content:re,context:q});if(!Y&&(B!=null&&B.result)){const H=je(JSON.parse(B.result),`retry-agent:${r}`);A.setData(H),Ye&&qs(Ye,{[A.dbField]:H})}else Ze(H=>new Set(H).add(r))}catch{Ze(F=>new Set(F).add(r))}finally{A.setLoading(!1)}}},[re,q,Ye,qs]),Mr=async r=>{const j=r.trim();if(!j)return;const A=++jt.current;Rr(!0),Gt(null),Tr(j);try{const{data:F,error:B}=await ze("scrape-profile",{url:j,action:"discover"},1,rr,{deadlineAt:Date.now()+ar});if(!he(A))return;if(B||!(F!=null&&F.success)){y({title:"Discovery failed",description:"Couldn't discover pages. Running quick scan instead.",variant:"destructive"}),ht(j);return}const Y=F.pages||[];if(Y.length<=1){y({title:"Limited public pages",description:"This site has few publicly accessible pages — running a focused single-page analysis instead."}),ht(j);return}Gt(Y)}catch{if(!he(A))return;y({title:"Discovery failed",description:"Falling back to quick scan.",variant:"destructive"}),ht(j)}finally{he(A)&&Rr(!1)}},fa=async r=>{var B;Gt(null),Us(r);const j=Ht;M(j),tt();const A=jt.current;Xe(!0),Et(),$([]),Bs(Y=>Y+1),ce(W("user",`${j} (Deep Analysis — ${r.length} pages)`,"text")),U(!0),J(!0),ce(W("system",`Scraping ${r.length} pages for deep analysis…`,"scanning"));const F=Date.now()+wl;try{const{data:Y,error:H}=await ze("scrape-profile",{url:j,action:"scrape_selected",selected_urls:r},1,jl,{deadlineAt:F});if(!he(A))return;if(H)throw new Error(H.message||"Could not scrape selected pages.");if(!(Y!=null&&Y.success))throw new Error((Y==null?void 0:Y.error)||"Could not scrape selected pages");const $e=Y.content;xe($e),$(me=>me.map(Ne=>Ne.type==="scanning"?W("system","Analyzing context & identifying opportunities…","scanning"):Ne));const{data:Ge,error:be}
851=await ze("strategy-intake",{content:$e,industry:m==null?void 0:m.label,industry_slug:m==null?void 0:m.slug},1,nr,{deadlineAt:F});if(!he(A))return;if(be)throw new Error(be.message||"Analysis service unavailable.");const ve=JSON.parse(Ge.result);if(pe(ve),$(me=>me.filter(Ne=>Ne.type!=="scanning")),ve.profile_meta&&(ve.profile_meta.person_name||ve.profile_meta.company_name)){const me={...ve.profile_meta,title_role:null,company_name:null};ce(W("assistant","","profile_welcome",me))}ce(W("assistant","","intake",ve.initial_findings)),(B=ve.smart_questions)!=null&&B.length?(ce(W("assistant","","questions",ve.smart_questions)),C("questions"),de(se.STRATEGY_SMART_QUESTIONS_PRESENTED,{client_request_id:et.current,question_count:ve.smart_questions.length,mode:"deep",meter_device_id:De()})):Jt($e,"")}catch(Y){if(!he(A))return;$(H=>H.map($e=>$e.type==="scanning"?W("system",Y.message||"Deep analysis failed.","scan_error",{retryType:"intake",input:j}):$e)),C("intake")}finally{he(A)&&U(!1)}},ha=()=>{Gt(null),Ht&&ht(Ht)},ht=async(r,j)=>{var Ge;const A=r.trim(),F=!(j!=null&&j.prevalidated);if(Fs.current||K){F&&de(se.STRATEGY_AUDIT_VALIDATION_ERROR,{reason:"request_in_progress",surface:"strategy_input"});return}if(!hl(A)){F&&de(se.STRATEGY_AUDIT_VALIDATION_ERROR,{reason:A?"unusable_target":"empty",surface:"strategy_input"}),y({variant:"destructive",title:"Enter a valid audit target",description:"Use a website, LinkedIn URL, or company name."});return}Fs.current=!0;const B=er();M(A),tt(),R.current={objective:l,competitors:it},et.current=B;const Y=jt.current;Xe(!0),Et(),$([]),Bs(be=>be+1),ce(W("user",A,"text")),U(!0),ce(W("system","Scanning digital presence…","scanning"));let H="init";const $e=Date.now()+ar;try{const be=A.startsWith("http")||A.includes("linkedin.com")||A.includes("."),ve=A.includes("linkedin.com");J(be&&!ve),await Ns(se.STRATEGY_AUDIT_REQUEST_STARTED,{client_request_id:B,is_url:be,is_linkedin:ve,meter_device_id:De()}),H="scrape";const{data:me,error:Ne}=await ze("scrape-profile",be?{url:A}:{name:A},1,rr,{deadlineAt:$e});if(!he(Y)){de(se.STRATEGY_AUDIT_START_FAILURE,{client_request_id:B,stage:H,reason:"superseded"});return}if(Ne)throw new Error(Ne.message||"Could not reach scanning service.");if(!(me!=null&&me.success))throw new Error((me==null?void 0:me.error)||"Could not find profile info");const Me=me.content;xe(Me),$(oe=>{const Re=[...oe];for(let He=Re.length-1;He>=0;He--)if(Re[He].type==="scanning"){Re[He]=W("system","Analyzing context & identifying opportunities…","scanning");break}return Re}),H="intake";const{data:ie,error:te}=await ze("strategy-intake",{content:Me,industry:m==null?void 0:m.label,industry_slug:m==null?void 0:m.slug},1,nr,{deadlineAt:$e});if(!he(Y)){de(se.STRATEGY_AUDIT_START_FAILURE,{client_request_id:B,stage:H,reason:"superseded"});return}
851if(te)throw new Error(te.message||"Analysis service unavailable.");H="parse";const ee=JSON.parse(ie.result);if(pe(ee),de(se.STRATEGY_AUDIT_START_SUCCESS,{client_request_id:B,is_url:be,is_linkedin:ve,meter_reason:"deferred_to_diagnosis",meter_device_id:De()}),$(oe=>oe.filter(Re=>Re.type!=="scanning")),ee.profile_meta&&(ee.profile_meta.person_name||ee.profile_meta.company_name)){const oe={...ee.profile_meta,title_role:null,company_name:null};ce(W("assistant","","profile_welcome",oe))}ce(W("assistant","","intake",ee.initial_findings)),(Ge=ee.smart_questions)!=null&&Ge.length?(ce(W("assistant","","questions",ee.smart_questions)),C("questions"),de(se.STRATEGY_SMART_QUESTIONS_PRESENTED,{client_request_id:B,question_count:ee.smart_questions.length,mode:"url",meter_device_id:De()})):await Jt(Me,"",B)}catch(be){if(!he(Y))return;const ve=sa(be);de(se.STRATEGY_AUDIT_START_FAILURE,{client_request_id:B,stage:H,reason:ve,message:String((be==null?void 0:be.message)||"unknown").slice(0,120),meter_device_id:De()}),y({variant:"destructive",title:"Audit could not start",description:(be==null?void 0:be.message)||"Try again, or use a different public URL."}),$(me=>me.map(Ne=>Ne.type==="scanning"?W("system",be.message||"The analysis timed out.","scan_error",{retryType:"intake",input:A,clientRequestId:B}):Ne)),C("intake")}finally{U(!1),Fs.current=!1}},Ws=async r=>{var be,ve;const j=((be=Vn.find(me=>me.id===r.outcome))==null?void 0:be.label)||r.outcome,A=`Strategic Brief: ${r.assetType} → ${r.audiences.join(", ")} (${j})`;M(A),tt();const F=jt.current;Te(!0);const B=Cn(r.competitors);X({assetType:r.assetType,audiences:r.audiences,outcome:j,outcomeId:r.outcome,competitors:B,toneOfVoice:r.toneOfVoice,regulated:r.regulated,industry:r.industry});const Y={objective:r.outcome||null,competitors:B};R.current=Y,Xe(!0),Et(),$([]),Bs(me=>me+1);const H=[];H.push("=== STRATEGIC BRIEF ==="),H.push(`Asset Type: ${r.assetType}`),H.push(`Target Audience: ${r.audiences.join(", ")}`),H.push(`Desired Outcome: ${j}`),r.industry&&H.push(`Industry: ${r.industry}`),r.companyStage&&H.push(`Company/Stage: ${r.companyStage}`),r.geography&&H.push(`Geography: ${r.geography}`),r.competitors&&H.push(`Competitors: ${r.competitors}`),r.toneOfVoice&&H.push(`Tone: ${r.toneOfVoice}`),r.regulated&&H.push("Regulated/Sensitive Space: Yes"),r.platform&&H.push(`Platform: ${r.platform}`),r.audienceSophistication&&H.push(`Audience Sophistication: ${r.audienceSophistication}`),r.riskTolerance&&H.push(`Risk Tolerance: ${r.riskTolerance}`),r.desiredCTA&&H.push(`Desired CTA: ${r.desiredCTA}`),r.hardConstraints&&H.push(`Hard Constraints: ${r.hardConstraints}`),H.push(`
852=== CONTENT TO ANALYZE ===
853`),H.push(r.content);const $e=H.join(`
854`);ce(W("user",A,"text")),U(!0),J(!1),ce(W("system","Analyzing context & identifying opportunities…","scanning"));const Ge=Date.now()+ar;try{xe($e);let me=$e;if(r.brandLink)try{const{data:te}=await ze("scrape-profile",{url:r.brandLink},1,rr,{deadlineAt:Ge});if(!he(F))return;te!=null&&te.success&&te.content&&(me=$e+`
855
856=== BRAND WEBSITE CONTEXT ===
857`+te.content,xe(me))}catch{}const{data:Ne,error:Me}=await ze("strategy-intake",{content:me,is_brief:!0,brief_meta:{assetType:r.assetType,audiences:r.audiences,outcome:r.outcome}},1,nr,{deadlineAt:Ge});if(!he(F))return;
857if(Me)throw new Error(Me.message||"Analysis service unavailable.");const ie=JSON.parse(Ne.result);pe(ie),$(te=>te.filter(ee=>ee.type!=="scanning")),ce(W("assistant","","intake",ie.initial_findings)),(ve=ie.smart_questions)!=null&&ve.length?(ce(W("assistant","","questions",ie.smart_questions)),C("questions"),de(se.STRATEGY_SMART_QUESTIONS_PRESENTED,{client_request_id:et.current,question_count:ie.smart_questions.length,mode:"brief",meter_device_id:De()})):Jt(me,`Brief context: ${r.assetType} for ${r.audiences.join(", ")}. Outcome: ${j}.`,void 0,Y)}catch(me){if(!he(F))return;$(Ne=>Ne.map(Me=>Me.type==="scanning"?W("system",me.message||"Analysis failed.","scan_error",{retryType:"intake",input:A}):Me)),C("intake")}finally{he(F)&&U(!1)}},Or=async r=>{de(se.STRATEGY_SMART_QUESTION_ANSWERED,{client_request_id:et.current,answered:r.trim().length>0,meter_device_id:De()}),ce(W("user",r,"text")),await Jt(re,r)},Jt=async(r,j,A,F)=>{var $e,Ge,be,ve,me,Ne,Me;const B=jt.current,Y=A??et.current??er(),H=await Vt(Y);if(!H.ok){de(se.STRATEGY_AUDIT_START_FAILURE,{client_request_id:Y,stage:"meter",reason:tr(H.reason),message:H.reason||"reservation_refused",meter_detail:H.detail??null,meter_device_id:De()}),de(se.STRATEGY_DIAGNOSIS_COMPUTE_FAILURE,{client_request_id:Y,stage:"meter",reason:tr(H.reason),meter_device_id:De(),meter_detail:H.detail??null}),H.reason!=="request_in_progress"&&await Kr(ks.strategyDiagnosis,null,Y),sr(Y),fr(H.reason)?Ir():H.reason!=="request_in_progress"&&et.current===Y&&(et.current=null);const ie=en(H.reason,"This analysis");tr(H.reason)==="quota_exhausted"?$(ee=>[...ee.filter(oe=>oe.type!=="scanning"),W("assistant","","quota_wall",null)]):ie.retryable?($(ee=>[...ee.filter(oe=>oe.type!=="scanning"),W("system",`${ie.title} — ${ie.description}`,"scan_error",{retryType:"diagnosis",content:r,context:j})]),C(j?"questions":"diagnosing")):ce(W("assistant",`**${ie.title}** — ${ie.description}`,"text")),U(!1);return}ra({clientRequestId:Y,runToken:null,accessToken:(n==null?void 0:n.access_token)??null,releaseMode:"tokenless"}),U(!0),C("diagnosing"),de(se.STRATEGY_DIAGNOSIS_COMPUTE_STARTED,{client_request_id:Y,mode:O?"brief":"url",has_user_context:!!j,meter_device_id:De()}),ce(W("system",`Running multi-agent diagnosis…
858
859🔍 Scanning digital presence
860🧪 Detecting buyer-language patterns
861🔒 Mapping proof and trust signals
862📊 Modeling audience reactions
863⚡ Estimating conversion friction
864🎯 Mapping competitive positioning
865📈 Simulating growth trajectory
866🧠 Synthesizing forecast`,"scanning"));try{const ie=(($e=u==null?void 0:u.initial_findings)==null?void 0:$e.entity_type)||"company",te=F??R.current,ee=te?te.objective:l,oe=dr(ee),Re=((Ge=te==null?void 0:te.competitors)!=null&&Ge.length?te.competitors:it)||[],He=Pr(`Primary report objective: ${oe.label}${oe.assumed?" (assumed default — the user did not select one; optimize for general GTM readiness)":" (explicitly selected by the user)"}
867${j}`),{data:dt,error:bt}=await ze("strategy-diagnosis",{content:r,context:He,entity_type:ie,client_request_id:Y},1,15e4);if(bt)throw bt instanceof Error?bt:new Error(String((bt==null?void 0:bt.message)||"Diagnosis failed."));if(sr(Y),!he(B))return;const Oe=je(JSON.parse(dt.result),"strategy-diagnosis");ye(Oe);const wa=((be=w.find(fe=>fe.role==="user"))==null?void 0:be.content)||"",Ys=await pa({input_text:wa,input_mode:"search",is_website:ge,content:r,scorecard:Oe.brand_intelligence});if(Ls(Ys),(ve=Oe.brand_intelligence)!=null&&ve.scores){const fe=Oe.brand_intelligence.scores,Le=Math.round(fe.reduce((Rt,Kt)=>Rt+Kt.score,0)/fe.length*10)/10,st=localStorage.getItem("li_device_id")||"unknown";Je.from("brand_snapshots").insert({device_id:st,brand_score:Math.round(Le),analysis:Oe.brand_intelligence})}const Tt=Ve.find(fe=>{var Le;return((Le=fe.scorecard)==null?void 0:Le.scores)&&fe.id!=="pending"});if($(fe=>fe.filter(Le=>Le.type!=="scanning")),ce(W("assistant","","diagnosis",Oe)),(me=Tt==null?void 0:Tt.scorecard)!=null&&me.scores&&((Ne=Oe.brand_intelligence)!=null&&Ne.scores)){const fe=Math.round(Tt.scorecard.scores.reduce((ot,Be)=>ot+Be.score,0)/Tt.scorecard.scores.length*10)/10,Le=Math.round(Oe.brand_intelligence.scores.reduce((ot,Be)=>
867ot+Be.score,0)/Oe.brand_intelligence.scores.length*10)/10,st=Math.round((Le-fe)*10)/10,Rt=st>0?"📈":st<0?"📉":"➡️",Kt=st>0?`+${st}`:`${st}`;ce(W("assistant",`${Rt} **Score Trend:** ${fe} → ${Le} (${Kt})
868
869${Oe.brand_intelligence.scores.map(ot=>{var Yr,Vr;const Be=(Vr=(Yr=Tt.scorecard)==null?void 0:Yr.scores)==null?void 0:Vr.find(Na=>Na.dimension===ot.dimension),hs=Be?ot.score-Be.score:0,At=hs>0?"↑":hs<0?"↓":"→";return`• **${ot.dimension}**: ${(Be==null?void 0:Be.score)??"–"} → ${ot.score} ${At}`}).join(`
870`)}`,"text"))}if(!he(B))return;y({title:"✅ Core diagnosis complete!",description:"Your scorecard is ready. Deep-dive agents are still generating."});const Qt=(fe,Le,st,Rt,Kt)=>{Rt(!0);const ot=Le==="strategy-forecast"?12e4:9e4;ze(Le,{action:fe,content:r,context:Oe,entity_type:ie,objective:oe.label,objective_assumed:oe.assumed,competitors:Re},1,ot).then(({data:Be,error:hs})=>{if(he(B))if(!hs&&(Be!=null&&Be.result))try{const At=je(JSON.parse(Be.result),`agent:${fe}`);st(At),Ys&&qs(Ys,{[Kt]:At})}catch{}else Ze(At=>new Set(At).add(fe))}).catch(()=>{he(B)&&Ze(Be=>new Set(Be).add(fe))}).finally(()=>{he(B)&&Rt(!1)})};Qt("signal_forecast","strategy-forecast",Ee,Ke,"forecast_data"),Qt("conversion_friction","strategy-agents",Se,we,"friction_data"),Qt("competitive_positioning","strategy-agents",I,at,"positioning_data"),Qt("narrative_architecture","strategy-agents",ut,St,"narrative_data"),Qt("audience_persona","strategy-agents",mt,$t,"persona_data"),O&&((Me=D==null?void 0:D.audiences)!=null&&Me.length)&&(xt(!0),ze("strategy-audience",{content:r,audiences:D.audiences,asset_type:D.assetType,outcome:D.outcome}).then(({data:fe,error:Le})=>{if(he(B))if(!Le&&(fe!=null&&fe.result))try{Ct(je(JSON.parse(fe.result),"audience-reaction"))}catch{}else Ze(st=>new Set(st).add("audience_reaction"))}).catch(()=>{he(B)&&Ze(fe=>new Set(fe).add("audience_reaction"))}).finally(()=>{he(B)&&xt(!1)}),p(!0),ze("strategy-personas",{content:r,audiences:D.audiences,asset_type:D.assetType,outcome:D.outcome,industry:D.industry,tone:D.toneOfVoice,regulated:D.regulated}).then(({data:fe,error:Le})=>{if(he(B)&&!Le&&fe!=null&&fe.result)try{_t(je(JSON.parse(fe.result),"persona-suggestions"))}catch{}}).catch(()=>{}).finally(()=>{he(B)&&p(!1)})),de(se.STRATEGY_DIAGNOSIS_COMPUTE_SUCCESS,{client_request_id:Y,mode:O?"brief":"url",meter_device_id:De()}),de(se.STRATEGY_AUDIT_RESULT_RENDERED,{client_request_id:Y,mode:O?"brief":"url",meter_device_id:De()}),"Notification"in window&&Notification.permission==="granted"?new Notification("Diagnosis Complete",{body:"Your strategic intelligence report is ready.",icon:"/pwa-192.png"}):"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission(),O?C("results"):(setTimeout(()=>{he(B)&&(ce(W("assistant","","opportunity_map",Oe)),ce(W("assistant","","whitespace_map",Oe)))},300),setTimeout(()=>{he(B)&&(ce(W("assistant","","goal_select",null)),C("goal"))},600))}catch(ie){if(await Kr(ks.strategyDiagnosis,null,Y),sr(Y),!he(B))return;Ir();const te=_l(ie);de(se.STRATEGY_AUDIT_START_FAILURE,{client_request_id:Y,stage:"diagnosis",reason:te,message:String((ie==null?void 0:ie.message)||"unknown").slice(0,120),meter_device_id:De()}),de(se.STRATEGY_DIAGNOSIS_COMPUTE_FAILURE,{client_request_id:Y,stage:"diagnosis",reason:te,meter_device_id:De()}),y({variant:"destructive",title:"Diagnosis failed",description:(ie==null?void 0:ie.message)||"Try again from the error card."}),$(ee=>ee.map(oe=>oe.type==="scanning"?W("system",ie.message||"Diagnosis timed out.","scan_error",{retryType:"diagnosis",content:r,context:Pr(j)}):oe)),C(j?"questions":"diagnosing")}finally{he(B)&&U(!1)}},ba=async r=>{const j=an.find(A=>A.id===r);if(ca(r),ce(W("user",`I want to focus on: ${j==null?void 0:j.label} — ${j==null?void 0:j.desc}`,"text")),!!(await Vt()).ok){U(!0),C("planning"),ce(W("system","Generating your strategic action plan…","scanning"));try{const{data:A,error:F}=await ze("strategy-plan",{action:"generate_plan",content:re,context:q,goal:r});if(F)throw new Error(F.message||"Plan generation failed.");const B=JSON.parse(A.result);P(B),$(Y=>Y.filter(H=>H.type!=="scanning")),ce(W("assistant","","plan",B)),setTimeout(()=>{ce(W("assistant","","priority_board",B)),ce(W("assistant","","command_center",B))},300),C("plan")}catch(A){$(F=>
870F.filter(B=>B.type!=="scanning")),y({variant:"destructive",title:"Plan generation failed",description:A.message})}finally{U(!1)}}},ya=async r=>{const j=Ni.find(A=>A.id===r);if((await Vt()).ok){ce(W("user",`Run ${j==null?void 0:j.label}`,"text")),U(!0),ce(W("system",`Running ${j==null?void 0:j.label} Agent…`,"scanning"));try{const{data:A,error:F}=await ze("strategy-plan",{action:"specialist",content:re,context:q,agent_type:r});if(F)throw new Error(F.message||"Agent failed.");const B=JSON.parse(A.result);$(Y=>Y.filter(H=>H.type!=="scanning")),ce(W("assistant","","specialist",{type:r,label:j==null?void 0:j.label,result:B})),C("specialist")}catch(A){$(F=>F.filter(B=>B.type!=="scanning")),y({variant:"destructive",title:`${j==null?void 0:j.label} failed`,description:A.message})}finally{U(!1)}}},_a=async r=>{if((await Vt()).ok){ce(W("user",`Run ${r} review`,"text")),U(!0),ce(W("system",`Running ${r} review analysis…`,"scanning"));try{const{data:j,error:A}=await ze("strategy-plan",{action:"review",content:re,context:{diagnosis:q,plan:Q},review_type:r});if(A)throw new Error(A.message||"Review failed.");const F=JSON.parse(j.result);$(B=>B.filter(Y=>Y.type!=="scanning")),ce(W("assistant","","review",F)),ce(W("assistant","","executive_brief",F)),C("review")}catch(j){$(A=>A.filter(F=>F.type!=="scanning")),y({variant:"destructive",title:"Review failed",description:j.message})}finally{U(!1)}}},va=g.useCallback(r=>{const j=(m==null?void 0:m.slug)==="clinical-trials";return{content:r,assetType:"messaging",audiences:j?["patients","clinical ops"]:["general audience"],outcome:j?"trust":"clarity",industry:m==null?void 0:m.label,toneOfVoice:j?"empathetic":void 0}},[m]),ja=()=>{if(!V.trim()||K)return;const r=V.trim();if(G(""),z==="intake"){if(E==="url"&&xl(r)){Ws(va(r));return}const A=r.startsWith("http")||r.includes("linkedin.com")||r.includes(".")&&!r.includes(" "),F=r.includes("linkedin.com");if(E==="url"&&A&&!F&&w.length<=1){Mr(r);return}ht(r);return}z==="questions"&&Or(r)},fs=()=>{(q||u)&&(qt({messages:w,phase:z,intakeData:u,diagnosisData:q,forecastData:ue,frictionData:le,positioningData:ne,narrativeData:Pe,personaData:Fe,planData:Q,isWebsite:ge,originalInput:Ie,currentDiagnosisId:Ye,briefingDismissed:vt,deepAnalysisPages:ft,savedAt:Date.now()}),Ft(!1)),$([W("assistant",rs(m,x),"text")]),C("intake"),G(""),L("url"),tt(),Xe(!0),Et()},Ur=r=>{var j,A,F,B,Y,H,$e,Ge,be,ve,me,Ne,Me;if(r.type==="scanning")return e.jsx(ki,{content:r.content,onRestart:fs},r.id);if(r.type==="scan_error")return e.jsx(Si,{content:r.content,onRetry:()=>{var oe,Re,He,dt;if($(bt=>bt.filter(Oe=>Oe.id!==r.id)),((oe=r.data)==null?void 0:oe.retryType)==="intake"&&((Re=r.data)!=null&&Re.input)){ht(r.data.input);return}const te=((He=r.data)==null?void 0:He.content)||re,ee=((dt=r.data)==null?void 0:dt.context)||"";te&&Jt(te,ee)}},r.id);if(r.role==="user"){if(r.content.startsWith("Q: ")){const ie=r.content.split(`
871
872`).map(te=>{var oe,Re;const ee=te.split(`
873`);return{q:((oe=ee[0])==null?void 0:oe.replace("Q: ",""))||"",a:((Re=ee[1])==null?void 0:Re.replace("A: ",""))||""}}).filter(te=>te.a);if(ie.length>0)return e.jsx("div",{className:"flex justify-end",children:e.jsxs("div",{className:"bg-primary text-primary-foreground rounded-2xl rounded-tr-sm px-4 py-3 max-w-[85%] space-y-1.5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider opacity-70 font-semibold",children:"Your Context"}),ie.map((te,ee)=>e.jsxs("div",{className:"text-xs",children:[e.jsxs("span",{className:"opacity-70",children:[te.q,":"]})," ",e.jsx("span",{className:"font-medium",children:te.a})]},ee))]})},r.id)}return e.jsx($i,{content:r.content},r.id)}if(r.type==="text")return e.jsx(Ci,{content:r.content},r.id);if(r.type==="quota_wall")return e.jsx(dl,{onContinue:()=>{const ie={plan:"pro",billing:"monthly",returnTo:"/strategy"};Wa(ie),de(se.PRICING_PLAN_CLICK,{plan:"pro",billing:"monthly",source:ta}),t(Ya(ie))},onViewDiagnosis:q?()=>{var ie;(ie=document.querySelector('[data-section="diagnosis"]'))==null||ie.scrollIntoView({behavior:"smooth",block:"start"})}:void 0},r.id);if(r.type==="profile_welcome")return e.jsx(Ti,{data:r.data},r.id);if(r.type==="intake")return null;if(r.type==="questions")return e.jsx(Ri,{questions:r.data,onSubmit:Or,isLoading:K},r.id);if(r.type==="diagnosis"){if(O)return e.jsx("div",{"data-section":"diagnosis",className:"space-y-3",children:e.jsx(Do,{data:r.data,audienceData:ls,audienceLoading:cs,frictionData:le,frictionLoading:Ue,positioningData:ne,positioningLoading:Ce,narrativeData:Pe,narrativeLoading:Ot,personaData:Fe,personaLoading:Ut,forecastData:ue,forecastLoading:Qe,userCompetitors:it,evidenceInventory:(ne==null?void 0:ne.evidence_inventory)||((j=r.data)==null?void 0:j.evidence_inventory),analyticsConnected:!1,inputText:Ie,intakeData:u,personaSuggestions:ds,personaSuggestionsLoading:ps,onGeneratePersonas:()=>{var te;
873!re||!D||(p(!0),ze("strategy-personas",{content:re,audiences:D.audiences,asset_type:D.assetType,outcome:D.outcome,industry:((te=u==null?void 0:u.initial_findings)==null?void 0:te.industry)||(u==null?void 0:u.industry),tone:D.toneOfVoice,regulated:D.regulated}).then(({data:ee,error:oe})=>{if(!oe&&(ee!=null&&ee.result))try{_t(je(JSON.parse(ee.result),"persona-suggestions-regenerate"))}catch{}}).catch(()=>{}).finally(()=>p(!1)))},onGenerateCustomPersona:te=>{var ee;!re||!D||(p(!0),ze("strategy-personas",{content:re,audiences:D.audiences,asset_type:D.assetType,outcome:D.outcome,industry:((ee=u==null?void 0:u.initial_findings)==null?void 0:ee.industry)||(u==null?void 0:u.industry),tone:D.toneOfVoice,regulated:D.regulated,custom_persona:te}).then(({data:oe,error:Re})=>{if(!Re&&(oe!=null&&oe.result))try{const He=je(JSON.parse(oe.result),"persona-suggestions-custom");_t(dt=>dt?{...dt,suggested_personas:[...dt.suggested_personas||[],...He.suggested_personas||[]],persona_strategy:He.persona_strategy||dt.persona_strategy}:He)}catch{}}).catch(()=>{}).finally(()=>p(!1)))},onRetryAudience:()=>{var te;!re||!((te=D==null?void 0:D.audiences)!=null&&te.length)||(Ze(ee=>{const oe=new Set(ee);return oe.delete("audience_reaction"),oe}),xt(!0),ze("strategy-audience",{content:re,audiences:D.audiences,asset_type:D.assetType,outcome:D.outcome}).then(({data:ee,error:oe})=>{if(!oe&&(ee!=null&&ee.result))try{Ct(je(JSON.parse(ee.result),"audience-reaction-retry"))}catch{}else Ze(Re=>new Set(Re).add("audience_reaction"))}).catch(()=>Ze(ee=>new Set(ee).add("audience_reaction"))).finally(()=>xt(!1)))}})},r.id);const ie=e.jsx(cl,{diagnosisData:r.data,diagnosisId:Ye,inputText:Ie,requiresUpgrade:!s||i.runsRemaining!==null&&i.runsRemaining<=0,onAnalyzeAnother:fs,onChooseStrategicPath:()=>{const te=document.querySelector('[data-section="goal_select"]');te&&te.scrollIntoView({behavior:"smooth"})},returnTo:"/strategy",position:"above_report"});return e.jsxs("div",{"data-section":"diagnosis",className:"space-y-3",children:[ie,e.jsx(Ai,{data:r.data,inputText:Ie,intakeData:u,forecastData:ue,forecastLoading:Qe,pagesAnalyzed:ft,frictionData:le,narrativeData:Pe,objective:ae,analyticsConnected:!1}),le?e.jsx(zi,{data:le}):Ue?e.jsx(es,{label:"Analyzing conversion friction…"}):us.has("conversion_friction")&&e.jsx(vs,{label:"Conversion Friction",onRetry:()=>gs("conversion_friction")}),ne?e.jsx(Ei,{data:ne,guard:gt}):Ce?e.jsx(es,{label:"Mapping competitive positioning…"}):us.has("competitive_positioning")&&e.jsx(vs,{label:"Competitive Positioning",onRetry:()=>gs("competitive_positioning")}),Pe?e.jsx(Ii,{data:Pe,fixContext:{brand:((A=u==null?void 0:u.initial_findings)==null?void 0:A.brand)||(u==null?void 0:u.brand),audience:((F=u==null?void 0:u.initial_findings)==null?void 0:F.audience)||(u==null?void 0:u.audience),tone:((B=u==null?void 0:u.initial_findings)==null?void 0:B.tone)||(u==null?void 0:u.tone),industry:((Y=u==null?void 0:u.initial_findings)==null?void 0:Y.industry)||(u==null?void 0:u.industry)}}):Ot?e.jsx(es,{label:"Building narrative architecture…"}):us.has("narrative_architecture")&&e.jsx(vs,{label:"Narrative Architecture",onRetry:()=>gs("narrative_architecture")}),Fe?e.jsx(Pi,{data:Fe}):Ut?e.jsx(es,{label:"Synthesizing audience personas…"}):us.has("audience_persona")&&e.jsx(vs,{label:"Audience Personas",onRetry:()=>gs("audience_persona")}),e.jsxs("details",{className:"group",children:[e.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:"Show detailed breakdown ▸"}),e.jsx("div",{className:"mt-2",children:e.jsx(Li,{data:r.data})})]})]},r.id)}return r.type==="goal_select"?e.jsx("div",{"data-section":"goal_select",children:e.jsx(Bi,{onSelect:ba,isLoading:K,inputText:Ie,isWebsite:ge,diagnosisId:Ye,diagnosisData:q})},r.id):r.type==="plan"?e.jsx("div",{"data-section":"plan",children:e.jsx(Di,{data:r.data,fixContext:{brand:((H=u==null?void 0:u.initial_findings)==null?void 0:H.brand)||(u==null?void 0:u.brand),audience:(($e=u==null?void 0:u.initial_findings)==null?void 0:$e.audience)||(u==null?void 0:u.audience),tone:((Ge=u==null?void 0:u.initial_findings)==null?void 0:Ge.tone)||(u==null?void 0:u.tone),industry:((be=u==null?void 0:u.initial_findings)==null?void 0:be.industry)||(u==null?void 0:u.industry)}})},r.id):r.type==="specialist"?e.jsx(Mi,{data:r.data},r.id):r.type==="review"?e.jsx(Oi,{data:r.data,fixContext:{brand:((ve=u==null?void 0:u.initial_findings)==null?void 0:ve.brand)||(u==null?void 0:u.brand),audience:((me=u==null?void 0:u.initial_findings)==null?void 0:me.audie
873nce)||(u==null?void 0:u.audience),tone:((Ne=u==null?void 0:u.initial_findings)==null?void 0:Ne.tone)||(u==null?void 0:u.tone),industry:((Me=u==null?void 0:u.initial_findings)==null?void 0:Me.industry)||(u==null?void 0:u.industry)}},r.id):r.type==="opportunity_map"?e.jsxs("div",{"data-section":"opportunity",className:"space-y-3",children:[kr&&e.jsx(Ui,{data:kr}),!ue&&Qe&&e.jsx(es,{label:"Identifying fastest unlock…"}),e.jsx(Fi,{data:r.data})]},r.id):r.type==="whitespace_map"?e.jsx("div",{"data-section":"whitespace",children:e.jsx(qi,{data:r.data})},r.id):r.type==="priority_board"?e.jsx(Gi,{data:r.data},r.id):r.type==="command_center"?e.jsx(Hi,{data:r.data},r.id):r.type==="executive_brief"?e.jsx(Wi,{data:r.data},r.id):null};return e.jsxs("div",{className:Z("bg-background flex flex-col h-screen max-h-screen",z==="intake"&&w.length<=1?"h-auto max-h-none":""),children:[e.jsx(tl,{phase:z,diagnosisData:q,messages:w,isMobileUI:Yt,sharing:Er,title:(m==null?void 0:m.strategyTitle)||(x==null?void 0:x.title)||"Signal Audit",onBack:()=>t(s?"/dashboard":"/"),onShare:()=>{var r;return zr({...q,forecastData:ue,frictionData:le,positioningData:ne,narrativeData:Pe,personaData:Fe,pagesAnalyzed:ft,objective:ae},((r=w.find(j=>j.role==="user"))==null?void 0:r.content)||"")},onPDF:()=>{var r;return hn(q,(r=w.find(j=>j.role==="user"))==null?void 0:r.content,{forecastData:ue,frictionData:le,positioningData:ne,narrativeData:Pe,personaData:Fe,intakeData:u,analyticsConnected:!1,pagesAnalyzed:ft,objective:ae,userCompetitors:it})},onNew:fs,onHistory:()=>ms(!0),historyCount:Ve.length}),e.jsx(Un,{open:oa,onOpenChange:ms,children:e.jsxs(Fn,{side:"right",className:"w-full sm:max-w-md overflow-y-auto",children:[e.jsxs(yi,{className:"space-y-1.5 text-left",children:[e.jsxs(_i,{className:"flex items-center gap-2",children:["🕓 Run History",e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(",Ve.length,")"]})]}),e.jsx(vi,{className:"text-xs",children:"Replay any past diagnosis without rescanning. Your current session is preserved if you want to resume it later."})]}),e.jsxs("div",{className:"mt-5",children:[Ve.length===0?e.jsx("div",{className:"text-center py-12 text-sm text-muted-foreground",children:"No past runs yet. Diagnoses you complete will appear here."}):e.jsx(un,{history:Ve.filter(r=>r.id!==Ye),onLoad:r=>{Br(r),Os(null),ms(!1),y({title:"✨ Run restored",description:"Loaded a previous successful diagnosis."})},onCompareToCurrent:q?r=>{Os(r),ms(!1),y({title:"🔍 Compare mode",description:"Showing differences vs your current session."})}:void 0}),!q&&Ve.length>0&&e.jsx("p",{className:"mt-3 text-[10px] text-muted-foreground italic text-center",children:"Run a diagnosis first to compare it against past runs."})]})]})}),e.jsx("div",{className:Z("overflow-y-auto overscroll-contain",z==="intake"&&w.length<=1?"":"flex-1 min-h-0"),style:{WebkitOverflowScrolling:"touch"},children:e.jsx(Ga,{mode:"wait",children:e.jsxs(Tn.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.3,ease:"easeOut"},className:"max-w-3xl mx-auto px-4 py-4 space-y-4",children:[Ms&&q&&(()=>{const r=an.find(Y=>Y.id===la),A={audience:bi(xs.audiencePreset).label,postGoal:r?`${r.label} — ${r.desc}`:void 0,language:xs.language,tone:(D==null?void 0:D.toneOfVoice)||xs.tone,industry:(m==null?void 0:m.label)||(D==null?void 0:D.industry)||xs.industry,assetType:D==null?void 0:D.assetType,audiences:D==null?void 0:D.audiences,inputMode:O?"brief":ge?"url":"text"},F=gn({input_text:Ie,input_mode:A.inputMode,is_website:ge,scorecard:q==null?void 0:q.brand_intelligence,forecast_data:ue,friction_data:le,positioning_data:ne,narrative_data:Pe,persona_data:Fe},A),B=gn(Ms);return e.jsx(yo,{current:{input_text:Ie,scorecard:q!=null&&q.brand_intelligence?{scores:q.brand_intelligence.scores,overall_grade:q.brand_intelligence.overall_grade}:null,forecast_data:ue,friction_data:le,positioning_data:ne,narrative_data:Pe,settings:F},previous:{...Ms,settings:B},onClose:()=>Os(null)})})(),z==="intake"&&w.length<=1&&Ds&&!ia&&e.jsx(il,{session:Ds,onResume:()=>{var j;const r=Ds;tt(),(j=r.messages)!=null&&j.length&&$(js(r.messages)),C(r.phase||"intake"),pe(r.intakeData),ye(r.diagnosisData?je(r.diagnosisData,"resumed-session"):r.diagnosisData),Ee(r.forecastData?je(r.forecastData,"resumed-forecast"):r.forecastData),Se(r.frictionData?je(r.frictionData,"resumed-friction"):r.frictionData),I(r.positioningData?je(r.positioningData,"resumed-positioning"):r.positioningData),ut(r.narrativeData?je(r.narrativeData,"resumed-narrative"):r.narrativeData),mt(r.personaData?je(r.personaData,"resumed-persona"):r.personaData),P(r.planData?je(r.planData,"resumed-plan"):r.planData),J(r.isWebsite),M(r.originalInput),Ls(r.currentDiagnosisId),Xe(r.briefingDismissed),Us(r.deepAnalysisPages??null),qt(null),Ft(!1),yn(r),y({title:"✅ Session resumed",description:"Your previous diagnosis has been restored."})},onDismiss:()=>{Ft(!0),qt(null)}}),z==="intake"&&w.length<=1&&Ve.length===0&&!vt&&e.jsx("div",{className:"mb-3 min-h-[390px] md:min-
873h-[480px] flex items-start",children:e.jsx(to,{isSubmitting:K,onSubmitUrl:r=>{Xe(!0),G(r),ht(r,{prevalidated:!0})}})}),z==="intake"&&!vt&&Ve.length>0&&e.jsx(Xn,{onDismiss:()=>Xe(!0)}),z==="intake"&&w.length<=1&&E==="url"&&(vt||Ve.length>0)&&w.map(Ur),z==="intake"&&w.length<=1&&E==="brief"&&e.jsx(Jn,{onSubmit:Ws,isLoading:K}),(z!=="intake"||w.length>1)&&w.map(Ur),z==="intake"&&w.length<=1&&Ve.length>0&&e.jsx(un,{history:Ve,onLoad:Br}),e.jsx("div",{ref:v})]},aa)})}),e.jsx(nl,{suppressed:z==="intake"&&w.length<=1&&Ve.length===0&&!vt&&!V.trim(),phase:z,messages:w,inputValue:V,inputMode:E,isLoading:K,onInputChange:G,onInputModeChange:L,objective:l,onObjectiveChange:S,onSend:ja,onBriefSubmit:Ws,onDeepAnalysis:Mr,onDeepAnalysisConfirm:fa,onDeepAnalysisCancel:ha,discoveredPages:Cr,discoveryUrl:Ht,isDiscovering:da,placeholder:m?m.slug==="clinical-trials"?"Paste trial URL, LinkedIn, or recruitment message draft…":`Paste ${m.label.toLowerCase()} URL, page, profile, or message draft…`:(x==null?void 0:x.placeholder)||void 0}),(z==="plan"||z==="specialist"||z==="review")&&!K&&e.jsx(al,{isMobile:Yt,planData:Q,onRunSpecialist:ya,onRunReview:_a}),xa&&e.jsx(ea,{isMobile:Yt,diagnosisData:q,planData:Q,sharing:Er,onRestart:fs,canRestart:!!(q||u||Cr||Ht||w.length>1||z!=="intake"),onShare:()=>{var r;return zr({...q,forecastData:ue,frictionData:le,positioningData:ne,narrativeData:Pe,personaData:Fe,pagesAnalyzed:ft,objective:ae},((r=w.find(j=>j.role==="user"))==null?void 0:r.content)||"")},onPDF:()=>{var r;return hn(q,(r=w.find(j=>j.role==="user"))==null?void 0:r.content,{forecastData:ue,frictionData:le,positioningData:ne,narrativeData:Pe,personaData:Fe,intakeData:u,analyticsConnected:!1,pagesAnalyzed:ft,objective:ae,userCompetitors:it})},onExecBrief:q?()=>$r(!0):void 0,toast:y,showAppLinks:Yt||!s,onNavigate:t,isAuthenticated:!!s}),e.jsx(Ko,{open:Sr,onClose:()=>$r(!1),brief:Sr?Jo({diagnosisData:q,forecastData:ue,frictionData:le,positioningData:ne,intakeData:u,brand:(u==null?void 0:u.brand_name)||(u==null?void 0:u.company)}):null})]})}export{Nl as BUDGET_EXHAUSTED_MESSAGE,bl as DEAD_RUN_TOKEN_REASONS,wl as DEEP_PRE_DIAGNOSIS_TOTAL_BUDGET_MS,jl as DEEP_SCRAPE_ATTEMPT_TIMEOUT_MS,nr as INTAKE_ATTEMPT_TIMEOUT_MS,ir as MIN_ATTEMPT_WINDOW_MS,vl as NO_AUTO_RETRY_FUNCTIONS,ar as PRE_DIAGNOSIS_TOTAL_BUDGET_MS,rr as SCRAPE_ATTEMPT_TIMEOUT_MS,_c as __pendingReservationCountForTest,vc as __pendingReservationForTest,wc as __setStrategyRunTokenForTest,jc as __trackPendingReservationForTest,Nc as default,_l as diagnosisFailureReason,yl as enrichInvokeError,fr as isDeadRunTokenReason,tr as meterFailureReason,Cn as parseCompetitorList,$n as releasePendingReservationsOnUnload};

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.