content-grade 1.0.15 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 StanislavBG
3
+ Copyright (c) 2026 ContentGrade
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -823,7 +823,7 @@ async function cmdInit() {
823
823
  console.log(` ${CY}content-grade start${R}`);
824
824
  blank();
825
825
  }
826
- console.log(` ${D}Pro tier: 100 analyses/day + batch mode — ${CY}content-grade.github.io/Content-Grade${R}`);
826
+ console.log(` ${D}Pro tier: 100 analyses/day + batch mode — ${CY}content-grade.onrender.com${R}`);
827
827
  blank();
828
828
  }
829
829
 
@@ -852,7 +852,7 @@ async function cmdActivate() {
852
852
  console.log(` ${D} · ${CY}content-grade batch <dir>${R}${D} — analyze entire directories${R}`);
853
853
  console.log(` ${D} · 100 checks/day (vs 50 free)${R}`);
854
854
  blank();
855
- console.log(` ${D}Get a license: ${CY}content-grade.github.io/Content-Grade${R}${D} → Pricing${R}`);
855
+ console.log(` ${D}Get a license: ${CY}content-grade.onrender.com${R}${D} → Pricing${R}`);
856
856
  blank();
857
857
 
858
858
  let key;
@@ -900,11 +900,12 @@ async function cmdActivate() {
900
900
  }
901
901
 
902
902
  // Validate key against server before storing
903
- const serverUrl = process.env.CONTENT_GRADE_SERVER_URL || 'https://content-grade.github.io';
903
+ const serverUrl = process.env.CONTENT_GRADE_SERVER_URL || 'https://content-grade.onrender.com';
904
904
  blank();
905
905
  process.stdout.write(` ${D}Validating key...${R}`);
906
906
 
907
907
  let validated = false;
908
+ let activatedTier = 'pro'; // default assumption if server is unreachable
908
909
  try {
909
910
  const response = await fetch(`${serverUrl}/api/license/validate`, {
910
911
  method: 'POST',
@@ -914,10 +915,17 @@ async function cmdActivate() {
914
915
  const data = await response.json();
915
916
  if (data.valid) {
916
917
  validated = true;
918
+ // Map server productKey to local tier
919
+ const productKeyToTier = {
920
+ contentgrade_starter: 'starter',
921
+ contentgrade_pro: 'pro',
922
+ contentgrade_team: 'team',
923
+ };
924
+ activatedTier = productKeyToTier[data.productKey] || 'pro';
917
925
  } else {
918
926
  process.stdout.write('\n');
919
927
  blank();
920
- fail(data.message || 'Invalid or expired license key. Visit content-grade.github.io/Content-Grade to check your subscription.');
928
+ fail(data.message || 'Invalid or expired license key. Visit content-grade.onrender.com to check your subscription.');
921
929
  blank();
922
930
  process.exit(1);
923
931
  }
@@ -933,11 +941,13 @@ async function cmdActivate() {
933
941
 
934
942
  const config = loadConfig();
935
943
  config.licenseKey = key;
944
+ config.tier = activatedTier;
936
945
  config.activatedAt = new Date().toISOString();
937
946
  saveConfig(config);
938
947
 
948
+ const tierLimit = TIER_LIMITS[activatedTier] || TIER_LIMITS.free;
939
949
  blank();
940
- ok(`Pro access activated! Your daily limit is now 100 analyses.`);
950
+ ok(`${(TIER_NAMES[activatedTier] || activatedTier).split(' —')[0]} activated! Your daily limit is now ${tierLimit} analyses.`);
941
951
  blank();
942
952
  console.log(` ${B}Try it:${R}`);
943
953
  console.log(` ${CY} content-grade batch ./posts/${R} ${D}# analyze all files${R}`);
@@ -959,7 +969,7 @@ async function cmdBatch(dirPath) {
959
969
  console.log(` ${B}Unlock batch mode:${R}`);
960
970
  console.log(` ${CY}content-grade activate${R} ${D}(enter your license key)${R}`);
961
971
  blank();
962
- console.log(` ${D}Get a license: ${CY}content-grade.github.io/Content-Grade${R}`);
972
+ console.log(` ${D}Get a license: ${CY}content-grade.onrender.com${R}`);
963
973
  blank();
964
974
  process.exit(1);
965
975
  }
@@ -1340,7 +1350,7 @@ async function cmdMetrics() {
1340
1350
  function cmdHelp() {
1341
1351
  banner();
1342
1352
  console.log(` ${D}AI-powered content quality scoring — readability, SEO, structure analysis${R}`);
1343
- console.log(` ${D}v${_version} · ${CY}content-grade.github.io/Content-Grade${R}`);
1353
+ console.log(` ${D}v${_version} · ${CY}content-grade.onrender.com${R}`);
1344
1354
  blank();
1345
1355
  console.log(` ${B}QUICK START${R}`);
1346
1356
  blank();
@@ -1443,7 +1453,7 @@ function cmdHelp() {
1443
1453
  console.log(` · Email subject line optimizer`);
1444
1454
  console.log(` · Audience archetype decoder`);
1445
1455
  blank();
1446
- console.log(` Purchase at: ${CY}content-grade.github.io/Content-Grade${R}`);
1456
+ console.log(` Purchase at: ${CY}content-grade.onrender.com${R}`);
1447
1457
  console.log(` Then unlock: ${CY}content-grade activate <your-license-key>${R}`);
1448
1458
  blank();
1449
1459
  }
package/bin/telemetry.js CHANGED
@@ -72,13 +72,13 @@ export function initTelemetry() {
72
72
  return { installId: cfg.installId, isNew: false, optedOut: false };
73
73
  }
74
74
 
75
- // First run — generate anonymous install ID, opt-in by default (like Next.js, Astro)
76
- // Users can opt out: content-grade telemetry off, --no-telemetry, or CONTENT_GRADE_NO_TELEMETRY=1
75
+ // First run — generate anonymous install ID, opt-out by default (privacy-first)
76
+ // Users can opt in: content-grade telemetry on
77
77
  const installId = generateId();
78
78
  saveConfig({
79
79
  installId,
80
80
  installedAt: new Date().toISOString(),
81
- telemetryEnabled: true,
81
+ telemetryEnabled: false,
82
82
  });
83
83
 
84
84
  return { installId, isNew: true, optedOut: false };
@@ -75,4 +75,4 @@ They start with context.
75
75
 
76
76
  Readers don't care about your context yet.
77
77
  ---
78
- Start with the hook. Earn the context.`,value:l,onChange:x=>c(x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.metaKey||x.ctrlKey)&&T()}}),r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:8},children:[r.jsxs("span",{style:{fontSize:10,color:"#444"},children:[w," tweet",w!==1?"s":""," · ",l.length,"/5000 chars · Ctrl+Enter to grade"]}),r.jsx("button",{onClick:T,disabled:a||l.trim().length<20,style:{padding:"8px 20px",background:a||l.trim().length<20?"#333":Ae,color:"#fff",fontWeight:600,fontSize:13,border:"none",borderRadius:8,cursor:a||l.trim().length<20?"not-allowed":"pointer",opacity:a||l.trim().length<20?.5:1},children:a?"Grading...":"Grade Thread"})]})]}),h&&r.jsx("div",{style:{background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:10,padding:12,marginBottom:16,color:"#ef5350",fontSize:12},children:h}),u&&r.jsxs("div",{children:[r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:24,textAlign:"center",marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,marginBottom:10},children:[r.jsx("span",{style:{fontSize:56,fontWeight:900,color:"#fff"},children:u.total_score}),r.jsxs("div",{style:{textAlign:"left"},children:[r.jsx("div",{style:{fontSize:32,fontWeight:900,color:A},children:u.grade}),r.jsx("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"/ 100"})]})]}),r.jsxs("p",{style:{color:Ae,fontSize:14,fontWeight:600,fontStyle:"italic",maxWidth:480,margin:"0 auto 16px"},children:['"',u.verdict,'"']}),r.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10,flexWrap:"wrap"},children:[r.jsx(Ot,{shareText:`My thread scored ${u.total_score}/100 on ThreadGrader. Grade yours → https://contentintelligence.ai`,accentColor:Ae}),r.jsx("button",{onClick:_,style:{padding:"7px 14px",background:j?"#0a2a3a":"#1a3a5a",color:j?"#4caf50":Ae,border:`1px solid ${j?"#1a5a2a":"#1a5a7a"}`,borderRadius:8,cursor:"pointer",fontSize:12,fontWeight:600},children:j?"✓ Tweeted!":"Tweet Your Score"})]})]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:14},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,margin:0},children:"Hook Analysis"}),r.jsx("span",{style:{fontSize:9,padding:"2px 8px",borderRadius:4,background:"#4caf5020",color:"#4caf50",border:"1px solid #4caf5033",fontFamily:"monospace",fontWeight:600,letterSpacing:1},children:"FREE"})]}),r.jsx(Dd,{pillarKey:"hook",pillar:u.pillar_scores.hook})]}),u.rewrites&&u.rewrites.length>0&&r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,margin:0},children:"Best Hook Rewrite"}),r.jsx("span",{style:{fontSize:9,padding:"2px 8px",borderRadius:4,background:"#4caf5020",color:"#4caf50",border:"1px solid #4caf5033",fontFamily:"monospace",fontWeight:600,letterSpacing:1},children:"FREE"})]}),r.jsxs("div",{style:{padding:14,borderRadius:8,background:"#0d0d1a",border:"1px solid #1a1a2e"},children:[r.jsx("div",{style:{fontSize:10,color:Ae,fontWeight:700,marginBottom:8,textTransform:"uppercase",letterSpacing:1},children:u.rewrites[0].label}),r.jsx("p",{style:{color:"#ddd",fontSize:13,margin:"0 0 8px",lineHeight:1.6,whiteSpace:"pre-line"},children:u.rewrites[0].text}),r.jsx("p",{style:{color:"#666",fontSize:11,margin:0,fontStyle:"italic"},children:u.rewrites[0].why_better})]})]}),r.jsx(rr,{tool:"thread-grader",score:u.total_score}),r.jsxs(cn,{accentColor:Ae,label:"Full Thread Analysis",children:[r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:16},children:"Full Pillar Breakdown"}),Object.entries(u.pillar_scores).map(([x,B])=>r.jsx(Dd,{pillarKey:x,pillar:B},x))]}),u.tweet_breakdown&&u.tweet_breakdown.length>0&&r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Tweet-by-Tweet Breakdown"}),r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[r.jsx("thead",{children:r.jsx("tr",{style:{borderBottom:"1px solid #1a1a2e"},children:["#","Preview","Score","Note"].map(x=>r.jsx("th",{style:{padding:"6px 8px",textAlign:"left",color:"#555",fontWeight:600,fontSize:10,textTransform:"uppercase",letterSpacing:1},children:x},x))})}),r.jsx("tbody",{children:u.tweet_breakdown.map((x,B)=>{const C=x.score>=8?"#4caf50":x.score>=5?"#ffd54f":"#ef5350";return r.jsxs("tr",{style:{borderBottom:"1px solid #0d0d1a"},children:[r.jsx("td",{style:{padding:"8px",color:"#555",fontFamily:"monospace",fontWeight:700},children:x.tweet_index}),r.jsx("td",{style:{padding:"8px",color:"#aaa",maxWidth:200},children:r.jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.text_preview})}),r.jsxs("td",{style:{padding:"8px",color:C,fontWeight:700},children:[x.score,"/10"]}),r.jsx("td",{style:{padding:"8px",color:"#777",fontSize:11},children:x.note})]},B)})})]})]}),u.rewrites&&u.rewrites.length>1&&r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"All Hook Rewrites"}),u.rewrites.slice(1).map((x,B)=>r.jsxs("div",{style:{padding:14,borderRadius:8,background:"#0d0d1a",border:"1px solid #1a1a2e",marginBottom:8},children:[r.jsx("div",{style:{fontSize:10,color:Ae,fontWeight:700,marginBottom:8,textTransform:"uppercase",letterSpacing:1},children:x.label}),r.jsx("p",{style:{color:"#ddd",fontSize:13,margin:"0 0 8px",lineHeight:1.6,whiteSpace:"pre-line"},children:x.text}),r.jsx("p",{style:{color:"#666",fontSize:11,margin:0,fontStyle:"italic"},children:x.why_better})]},B))]}),u.upgrade_hook&&r.jsx("div",{style:{background:"#0a1e2e",border:"1px solid #1a3a5a",borderRadius:14,padding:16,textAlign:"center"},children:r.jsx("p",{style:{color:Ae,fontSize:12,fontWeight:500,margin:0},children:u.upgrade_hook})})]}),r.jsx(kn,{accentColor:Ae})]})]})}function Dh({onTryHybrid:l}){const[c,a]=v.useState(""),[f,u]=v.useState(""),[g,h]=v.useState(!1),[y,j]=v.useState(null),[R,w]=v.useState(null);async function T(){if(!(!c.trim()||!f.trim())){h(!0),j(null),w(null);try{const x=await fetch(`${ge}/demos/thread-grader/compare`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadA:c.trim(),threadB:f.trim()})}),B=await x.json();if(!x.ok)throw new Error(B.error||`HTTP ${x.status}`);j(B)}catch(x){w(x instanceof Error?x.message:"Comparison failed.")}finally{h(!1)}}}const _=c.trim().length>=20&&f.trim().length>=20,A=y==null?void 0:y.comparison.pillar_winners;return r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{display:"flex",gap:12,marginBottom:12},children:["A","B"].map(x=>{const B=x==="A"?c:f,C=x==="A"?a:u;return r.jsxs("div",{style:{flex:1},children:[r.jsxs("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:6},children:["Thread ",x," · ",xs(B)," tweet",xs(B)!==1?"s":""]}),r.jsx("textarea",{style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:10,padding:"10px 12px",fontSize:13,color:"#e0e0e0",resize:"none",outline:"none",fontFamily:"inherit",boxSizing:"border-box",lineHeight:1.5},rows:8,placeholder:`Thread ${x} — separate tweets with ---`,value:B,onChange:W=>C(W.target.value)})]},x)})}),r.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:20},children:r.jsx("button",{onClick:T,disabled:g||!_,style:{padding:"8px 20px",background:g||!_?"#333":Ae,color:"#fff",fontWeight:600,fontSize:13,border:"none",borderRadius:8,cursor:g||!_?"not-allowed":"pointer",opacity:g||!_?.5:1},children:g?"Comparing...":"Compare"})}),R&&r.jsx("div",{style:{background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:10,padding:12,marginBottom:16,color:"#ef5350",fontSize:12},children:R}),y&&r.jsxs("div",{children:[y.comparison.winner!=="tie"?r.jsxs("div",{style:{background:"#0d1f0d",border:"1px solid #1e4a1e",borderRadius:10,padding:"12px 20px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"center",gap:16},children:[r.jsxs("div",{style:{textAlign:"center"},children:[r.jsxs("div",{style:{color:"#4caf50",fontWeight:800,fontSize:15},children:["Thread ",y.comparison.winner," wins"]}),r.jsxs("div",{style:{color:"#2e7d32",fontSize:11,marginTop:2},children:["+",y.comparison.margin," pts"]})]}),r.jsx(Ot,{shareText:`Thread ${y.comparison.winner} won my A/B test on ThreadGrader by ${y.comparison.margin} points. Grade yours → https://contentintelligence.ai`,accentColor:"#4caf50"})]}):r.jsx("div",{style:{background:"#1a1a2e",border:"1px solid #2a2a4e",borderRadius:10,padding:"10px 16px",marginBottom:16,textAlign:"center",color:"#ffd54f",fontWeight:700,fontSize:13},children:"It's a tie — both threads score equally"}),r.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16},children:[r.jsx($d,{label:"Thread A",result:y.threadA,isWinner:y.comparison.winner==="A",isDimmed:y.comparison.winner==="B"}),r.jsx($d,{label:"Thread B",result:y.threadB,isWinner:y.comparison.winner==="B",isDimmed:y.comparison.winner==="A"})]}),A&&r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Pillar Winners"}),r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[r.jsx("thead",{children:r.jsx("tr",{style:{borderBottom:"1px solid #1a1a2e"},children:["Pillar","A Score","B Score","Winner"].map(x=>r.jsx("th",{style:{padding:"6px 8px",textAlign:"left",color:"#555",fontWeight:600,fontSize:10,textTransform:"uppercase",letterSpacing:1},children:x},x))})}),r.jsx("tbody",{children:Object.keys(Gr).map(x=>{const B=A[x],C=y.threadA.pillar_scores[x].score,W=y.threadB.pillar_scores[x].score;return r.jsxs("tr",{style:{borderBottom:"1px solid #0d0d1a"},children:[r.jsx("td",{style:{padding:"8px",color:"#aaa"},children:Gr[x]}),r.jsx("td",{style:{padding:"8px",color:B==="A"?"#4caf50":"#666",fontWeight:B==="A"?700:400},children:C}),r.jsx("td",{style:{padding:"8px",color:B==="B"?"#4caf50":"#666",fontWeight:B==="B"?700:400},children:W}),r.jsx("td",{style:{padding:"8px",color:B==="tie"?"#ffd54f":"#4caf50",fontWeight:700},children:B==="tie"?"Tie":`Thread ${B}`})]},x)})})]})]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:10},children:"Analysis"}),r.jsx("p",{style:{color:"#bbb",fontSize:13,lineHeight:1.6,margin:"0 0 10px"},children:y.comparison.verdict}),y.comparison.strategic_analysis&&r.jsxs("p",{style:{color:"#777",fontSize:12,lineHeight:1.5,margin:0,borderTop:"1px solid #1a1a2e",paddingTop:10},children:[r.jsx("span",{style:{color:Ae,fontWeight:600},children:"Next thread: "}),y.comparison.strategic_analysis]})]}),r.jsxs("div",{style:{background:"#0a1e2e",border:"1px solid #1a3a5a",borderRadius:14,padding:20},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:Ae,textTransform:"uppercase",letterSpacing:2,marginBottom:10},children:"Suggested Hybrid Hook"}),r.jsx("p",{style:{color:"#e0e0e0",fontSize:13,fontWeight:600,lineHeight:1.6,marginBottom:14},children:y.comparison.suggested_hybrid}),r.jsx("button",{onClick:()=>{const x=y.comparison.suggested_hybrid.split(" | ")[0].trim();l(x)},style:{padding:"7px 16px",background:Ae,color:"#fff",fontWeight:600,fontSize:12,border:"none",borderRadius:8,cursor:"pointer"},children:"Try this hook →"})]})]})]})}function $h(){const[l,c]=v.useState("grade"),[a,f]=v.useState("");return r.jsxs("div",{style:{padding:24,maxWidth:760,margin:"0 auto"},children:[r.jsxs("div",{style:{textAlign:"center",marginBottom:28},children:[r.jsx("div",{style:{fontSize:9,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:6,fontFamily:"monospace"},children:"ContentGrade Suite"}),r.jsxs("h1",{style:{fontSize:28,fontWeight:800,color:"#e0e0e0",letterSpacing:-.5},children:["Thread",r.jsx("span",{style:{color:Ae},children:"Grader"})]}),r.jsxs("p",{style:{color:"#777",fontSize:14,marginTop:6},children:["Paste your thread. Get a ",r.jsx("span",{style:{color:"#ccc",fontWeight:500},children:"viral potential score"})," before you post."]}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:6,marginTop:12},children:["Hook Strength (30)","Tension Chain (25)","Payoff (25)","Share Trigger (20)"].map(u=>r.jsx("span",{style:{fontSize:10,padding:"3px 10px",borderRadius:12,background:"#12121f",color:"#666",border:"1px solid #1a1a2e"},children:u},u))})]}),r.jsxs("div",{style:{display:"flex",gap:4,background:"#12121f",border:"1px solid #1a1a2e",borderRadius:10,padding:4,marginBottom:24,width:"fit-content"},children:[r.jsx("button",{onClick:()=>c("grade"),style:{padding:"7px 18px",borderRadius:8,border:"none",cursor:"pointer",fontSize:12,fontWeight:600,background:l==="grade"?Ae:"transparent",color:l==="grade"?"#fff":"#666",transition:"background 0.2s, color 0.2s"},children:"Grade Thread"}),r.jsxs("button",{onClick:()=>c("compare"),style:{padding:"7px 18px",borderRadius:8,border:"none",cursor:"pointer",fontSize:12,fontWeight:600,background:l==="compare"?"#0a1e2e":"transparent",color:l==="compare"?Ae:"#444",transition:"background 0.2s, color 0.2s",display:"flex",alignItems:"center",gap:6},children:["A/B Compare",r.jsx("span",{style:{fontSize:8,padding:"1px 6px",borderRadius:4,background:`${Ae}22`,color:Ae,border:`1px solid ${Ae}33`,fontFamily:"monospace",fontWeight:700,letterSpacing:.5},children:"PRO"})]})]}),l==="grade"&&r.jsx(Mh,{threadText:a,setThreadText:f}),l==="compare"&&r.jsx("div",{children:r.jsx(cn,{accentColor:Ae,label:"A/B Compare Mode",children:r.jsx(Dh,{onTryHybrid:u=>{f(u),c("grade")}})})}),r.jsx("div",{style:{marginTop:40,textAlign:"center",fontSize:10,color:"#333"},children:"Viral thread scoring using Hook · Tension · Payoff · Share frameworks · Powered by local Claude session"})]})}const Ye="#10b981",vs={"A+":"#4caf50",A:"#4caf50","A-":"#4caf50","B+":"#4a90d9",B:"#4a90d9","B-":"#4a90d9","C+":"#ffd54f",C:"#ffd54f","C-":"#ffd54f",D:"#ff9800",F:"#ef5350"},Uh={AIDA:"#7c4dff",PAS:"#ff6b35","Hormozi Value Equation":"#10b981","Cialdini Reciprocity":"#4a90d9","Storytelling Arc":"#ffd54f"};function Ss(l){for(const[c,a]of Object.entries(Uh))if(l.toLowerCase().includes(c.toLowerCase().split(" ")[0].toLowerCase()))return a;return Ye}function Ud({email:l,locked:c}){const[a,f]=v.useState(!c&&l.position===1),u=Ss(l.framework_used);return r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:12,marginBottom:10,overflow:"hidden"},children:[r.jsxs("div",{onClick:()=>!c&&f(h=>!h),style:{padding:"14px 16px",display:"flex",alignItems:"center",gap:10,cursor:c?"default":"pointer"},children:[r.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:Ye+"22",border:`1px solid ${Ye}44`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,fontSize:11,fontWeight:800,color:Ye,fontFamily:"monospace"},children:l.position}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#e0e0e0",marginBottom:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.subject_line}),r.jsx("div",{style:{fontSize:10,color:"#555",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.preview_text})]}),r.jsx("span",{style:{fontSize:9,padding:"2px 8px",borderRadius:4,background:u+"20",color:u,border:`1px solid ${u}44`,fontFamily:"monospace",fontWeight:700,letterSpacing:.5,flexShrink:0,whiteSpace:"nowrap"},children:l.framework_used.split(" ")[0].toUpperCase()}),!c&&r.jsx("div",{style:{color:"#444",fontSize:14,flexShrink:0},children:a?"▲":"▼"})]}),a&&!c&&r.jsx("div",{style:{padding:"0 16px 16px",borderTop:"1px solid #1a1a2e"},children:r.jsxs("div",{style:{paddingTop:14},children:[r.jsxs("div",{style:{background:u+"0d",border:`1px solid ${u}22`,borderRadius:8,padding:"8px 12px",marginBottom:14,fontSize:11,color:u,lineHeight:1.5},children:[r.jsxs("span",{style:{fontWeight:700},children:[l.framework_used,":"]})," ",l.framework_explanation]}),r.jsx("div",{style:{fontSize:13,color:"#ccc",lineHeight:1.7,marginBottom:14,whiteSpace:"pre-line",padding:"12px 14px",background:"#0d0d1a",borderRadius:8,border:"1px solid #1a1a2e"},children:l.body}),r.jsxs("div",{style:{marginBottom:14},children:[r.jsx("div",{style:{fontSize:10,color:"#555",marginBottom:6,textTransform:"uppercase",letterSpacing:1},children:"CTA Button"}),r.jsx("div",{style:{display:"inline-block",padding:"8px 20px",borderRadius:8,background:Ye,color:"#000",fontWeight:700,fontSize:12},children:l.cta})]}),r.jsxs("div",{style:{display:"flex",gap:12},children:[r.jsxs("div",{style:{flex:1,padding:"10px 14px",borderRadius:8,background:"#0d0d1a",border:"1px solid #1a1a2e",textAlign:"center"},children:[r.jsx("div",{style:{fontSize:16,fontWeight:800,color:"#4caf50"},children:l.estimated_open_rate}),r.jsx("div",{style:{fontSize:9,color:"#555",marginTop:2,textTransform:"uppercase",letterSpacing:1},children:"Est. Open Rate"})]}),r.jsxs("div",{style:{flex:1,padding:"10px 14px",borderRadius:8,background:"#0d0d1a",border:"1px solid #1a1a2e",textAlign:"center"},children:[r.jsx("div",{style:{fontSize:16,fontWeight:800,color:Ye},children:l.estimated_click_rate}),r.jsx("div",{style:{fontSize:9,color:"#555",marginTop:2,textTransform:"uppercase",letterSpacing:1},children:"Est. Click Rate"})]})]})]})})]})}function Hh({result:l}){const c=vs[l.grade]??"#777";return r.jsxs("div",{children:[r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:24,marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:12},children:[r.jsx("span",{style:{fontSize:52,fontWeight:900,color:"#fff"},children:l.overall_score}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:28,fontWeight:900,color:c},children:l.grade}),r.jsx("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"Sequence Score"})]})]}),r.jsxs("p",{style:{color:Ye,fontSize:13,fontWeight:500,fontStyle:"italic",margin:0},children:['"',l.sequence_strategy,'"']})]}),r.jsxs("div",{style:{marginBottom:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:6},children:[r.jsx("span",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"Email 1 — Hook"}),r.jsx("span",{style:{fontSize:9,padding:"2px 8px",borderRadius:4,background:"#4caf5020",color:"#4caf50",border:"1px solid #4caf5033",fontFamily:"monospace",fontWeight:600,letterSpacing:1},children:"FREE"})]}),r.jsx(Ud,{email:l.emails[0],locked:!1})]}),r.jsx(rr,{tool:"email-forge",score:l.overall_score,accentColor:Ye}),r.jsxs("div",{style:{marginTop:10},children:[r.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:6},children:r.jsx("span",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"Emails 2–5 — Build · Value · Urgency · Close"})}),l.emails.slice(1).map(a=>r.jsx(Ud,{email:a,locked:!1},a.position))]}),r.jsx(kn,{accentColor:Ye})]})}function Vh(){const[l,c]=v.useState(""),[a,f]=v.useState(""),[u,g]=v.useState("cold_outreach"),[h,y]=v.useState("professional"),[j,R]=v.useState(!1),[w,T]=v.useState(null),[_,A]=v.useState(null),x=l.trim().length>=10&&a.trim().length>=5;async function B(){if(x){R(!0),T(null),A(null);try{const W=await fetch(`${ge}/demos/email-forge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({product:l.trim(),audience:a.trim(),goal:u,tone:h})}),P=await W.json();if(!W.ok)throw new Error(P.error||`HTTP ${W.status}`);T(P)}catch(W){A(W instanceof Error?W.message:"Generation failed.")}finally{R(!1)}}}const C={background:"#12121f",border:"1px solid #1a1a2e",borderRadius:8,padding:"10px 12px",fontSize:13,color:"#e0e0e0",outline:"none",fontFamily:"inherit",width:"100%",appearance:"none",cursor:"pointer"};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{marginBottom:20},children:[r.jsxs("div",{style:{marginBottom:12},children:[r.jsx("label",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:1.5,display:"block",marginBottom:6},children:"Product / Service"}),r.jsx("textarea",{style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:8,padding:"10px 12px",fontSize:13,color:"#e0e0e0",resize:"vertical",outline:"none",fontFamily:"inherit",boxSizing:"border-box",lineHeight:1.6},rows:3,placeholder:"e.g. A SaaS tool that automates customer onboarding emails, cutting setup time from 2 hours to 5 minutes",value:l,onChange:W=>c(W.target.value)})]}),r.jsxs("div",{style:{marginBottom:12},children:[r.jsx("label",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:1.5,display:"block",marginBottom:6},children:"Target Audience"}),r.jsx("input",{type:"text",style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:8,padding:"10px 12px",fontSize:13,color:"#e0e0e0",outline:"none",fontFamily:"inherit",boxSizing:"border-box"},placeholder:"e.g. B2B SaaS founders with 10-50 person teams",value:a,onChange:W=>f(W.target.value)})]}),r.jsxs("div",{style:{display:"flex",gap:12,marginBottom:12},children:[r.jsxs("div",{style:{flex:1},children:[r.jsx("label",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:1.5,display:"block",marginBottom:6},children:"Goal"}),r.jsxs("select",{style:C,value:u,onChange:W=>g(W.target.value),children:[r.jsx("option",{value:"cold_outreach",children:"Cold Outreach"}),r.jsx("option",{value:"nurture",children:"Nurture Sequence"}),r.jsx("option",{value:"launch",children:"Product Launch"}),r.jsx("option",{value:"re-engagement",children:"Re-engagement"})]})]}),r.jsxs("div",{style:{flex:1},children:[r.jsx("label",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:1.5,display:"block",marginBottom:6},children:"Tone"}),r.jsxs("select",{style:C,value:h,onChange:W=>y(W.target.value),children:[r.jsx("option",{value:"professional",children:"Professional"}),r.jsx("option",{value:"casual",children:"Casual"}),r.jsx("option",{value:"urgent",children:"Urgent"}),r.jsx("option",{value:"storytelling",children:"Storytelling"})]})]})]}),r.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:r.jsx("button",{onClick:B,disabled:j||!x,style:{padding:"10px 24px",background:j||!x?"#333":Ye,color:j||!x?"#666":"#000",fontWeight:700,fontSize:13,border:"none",borderRadius:8,cursor:j||!x?"not-allowed":"pointer",opacity:j||!x?.6:1},children:j?"Generating...":"Generate Sequence →"})})]}),_&&r.jsx("div",{style:{background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:10,padding:12,marginBottom:16,color:"#ef5350",fontSize:12},children:_}),w&&r.jsx(Hh,{result:w})]})}function Gh(){const[l,c]=v.useState(""),[a,f]=v.useState(""),[u,g]=v.useState("cold_outreach"),[h,y]=v.useState("professional"),[j,R]=v.useState(""),[w,T]=v.useState(""),[_,A]=v.useState("cold_outreach"),[x,B]=v.useState("professional"),[C,W]=v.useState(!1),[P,Q]=v.useState(null),[F,ie]=v.useState(null),[re,fe]=v.useState(null),[je,Le]=v.useState(null),xe=l.trim().length>=10&&a.trim().length>=5&&j.trim().length>=10&&w.trim().length>=5;async function Ue(){if(xe){W(!0),Q(null),ie(null);try{const X=await fetch(`${ge}/demos/email-forge/compare`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({product_a:l.trim(),audience_a:a.trim(),goal_a:u,tone_a:h,product_b:j.trim(),audience_b:w.trim(),goal_b:_,tone_b:x})}),K=await X.json();if(!X.ok)throw new Error(K.error||`HTTP ${X.status}`);Q(K)}catch(X){ie(X instanceof Error?X.message:"Comparison failed.")}finally{W(!1)}}}const Fe={background:"#12121f",border:"1px solid #1a1a2e",borderRadius:6,padding:"6px 8px",fontSize:11,color:"#ccc",outline:"none",fontFamily:"inherit",width:"100%",appearance:"none"};function Te({label:X,product:K,setProduct:se,audience:ce,setAudience:D,goal:J,setGoal:$,tone:k,setTone:L}){return r.jsxs("div",{style:{flex:1},children:[r.jsxs("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:8},children:["Sequence ",X]}),r.jsx("textarea",{style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:8,padding:"8px 10px",fontSize:12,color:"#e0e0e0",resize:"none",outline:"none",fontFamily:"inherit",boxSizing:"border-box",lineHeight:1.5},rows:4,placeholder:"Product/service description",value:K,onChange:te=>se(te.target.value)}),r.jsx("input",{type:"text",style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:8,padding:"7px 10px",fontSize:12,color:"#e0e0e0",marginTop:6,outline:"none",fontFamily:"inherit",boxSizing:"border-box"},placeholder:"Target audience",value:ce,onChange:te=>D(te.target.value)}),r.jsxs("div",{style:{display:"flex",gap:6,marginTop:6},children:[r.jsxs("select",{style:Fe,value:J,onChange:te=>$(te.target.value),children:[r.jsx("option",{value:"cold_outreach",children:"Cold Outreach"}),r.jsx("option",{value:"nurture",children:"Nurture"}),r.jsx("option",{value:"launch",children:"Launch"}),r.jsx("option",{value:"re-engagement",children:"Re-engage"})]}),r.jsxs("select",{style:Fe,value:k,onChange:te=>L(te.target.value),children:[r.jsx("option",{value:"professional",children:"Professional"}),r.jsx("option",{value:"casual",children:"Casual"}),r.jsx("option",{value:"urgent",children:"Urgent"}),r.jsx("option",{value:"storytelling",children:"Story"})]})]})]})}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",gap:12,marginBottom:12},children:[r.jsx(Te,{label:"A",product:l,setProduct:c,audience:a,setAudience:f,goal:u,setGoal:g,tone:h,setTone:y}),r.jsx(Te,{label:"B",product:j,setProduct:R,audience:w,setAudience:T,goal:_,setGoal:A,tone:x,setTone:B})]}),r.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:20},children:r.jsx("button",{onClick:Ue,disabled:C||!xe,style:{padding:"8px 20px",background:C||!xe?"#333":Ye,color:C||!xe?"#666":"#000",fontWeight:700,fontSize:13,border:"none",borderRadius:8,cursor:C||!xe?"not-allowed":"pointer",opacity:C||!xe?.6:1},children:C?"Comparing...":"Compare Sequences"})}),F&&r.jsx("div",{style:{background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:10,padding:12,marginBottom:16,color:"#ef5350",fontSize:12},children:F}),P&&r.jsxs("div",{children:[r.jsxs("div",{style:{background:"#0d1f0d",border:"1px solid #1e4a1e",borderRadius:10,padding:"14px 20px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsxs("div",{children:[r.jsxs("div",{style:{color:"#4caf50",fontWeight:800,fontSize:15},children:["Sequence ",P.comparison.winner," wins"]}),r.jsxs("div",{style:{color:"#2e7d32",fontSize:11,marginTop:2},children:["+",P.comparison.margin," pts · ",P.comparison.reasoning]})]}),r.jsx("div",{style:{textAlign:"right"},children:r.jsxs("div",{style:{fontSize:22,fontWeight:900,color:"#fff"},children:[P.comparison.winner==="A"?P.sequence_a.overall_score:P.sequence_b.overall_score,r.jsx("span",{style:{fontSize:12,color:"#555",marginLeft:4},children:"vs"}),P.comparison.winner==="A"?P.sequence_b.overall_score:P.sequence_a.overall_score]})})]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Email-by-Email Breakdown"}),r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[r.jsx("thead",{children:r.jsx("tr",{style:{borderBottom:"1px solid #1a1a2e"},children:["Email","Subject A","Subject B","Winner","Reason"].map(X=>r.jsx("th",{style:{padding:"6px 8px",textAlign:"left",color:"#555",fontWeight:600,fontSize:10,textTransform:"uppercase",letterSpacing:1},children:X},X))})}),r.jsx("tbody",{children:P.comparison.per_email_comparison.map(X=>{const K=P.sequence_a.emails.find(ce=>ce.position===X.position),se=P.sequence_b.emails.find(ce=>ce.position===X.position);return r.jsxs("tr",{style:{borderBottom:"1px solid #0d0d1a"},children:[r.jsx("td",{style:{padding:"8px",color:"#555",fontFamily:"monospace",fontWeight:700},children:X.position}),r.jsx("td",{style:{padding:"8px",color:X.winner==="A"?"#4caf50":"#555",fontSize:11,maxWidth:150},children:r.jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(K==null?void 0:K.subject_line)??"—"})}),r.jsx("td",{style:{padding:"8px",color:X.winner==="B"?"#4caf50":"#555",fontSize:11,maxWidth:150},children:r.jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(se==null?void 0:se.subject_line)??"—"})}),r.jsxs("td",{style:{padding:"8px",color:"#4caf50",fontWeight:700},children:["Seq ",X.winner]}),r.jsx("td",{style:{padding:"8px",color:"#777",fontSize:11},children:X.reason})]},X.position)})})]})]}),r.jsxs("div",{style:{background:P.comparison.winner==="A"?"#0a1e0a":"#12121f",border:`1px solid ${P.comparison.winner==="A"?"#1e4a1e":"#1a1a2e"}`,borderRadius:14,padding:16,marginBottom:12},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[r.jsx("span",{style:{fontSize:11,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"Sequence A"}),P.comparison.winner==="A"&&r.jsx("span",{style:{fontSize:9,padding:"2px 7px",borderRadius:4,background:"#4caf5020",color:"#4caf50",border:"1px solid #4caf5033",fontFamily:"monospace",fontWeight:700},children:"WINNER"}),r.jsx("span",{style:{marginLeft:"auto",fontSize:20,fontWeight:900,color:"#fff"},children:P.sequence_a.overall_score}),r.jsx("span",{style:{fontSize:14,fontWeight:900,color:vs[P.sequence_a.grade]??"#777"},children:P.sequence_a.grade})]}),P.sequence_a.emails.map(X=>{const K=Ss(X.framework_used);return r.jsxs("div",{onClick:()=>fe(re===X.position?null:X.position),style:{padding:"8px 12px",marginBottom:6,background:"#0d0d1a",border:"1px solid #1a1a2e",borderRadius:8,cursor:"pointer",display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{fontSize:10,color:Ye,fontFamily:"monospace",fontWeight:700,width:16},children:X.position}),r.jsx("span",{style:{flex:1,fontSize:12,color:"#ccc",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:X.subject_line}),r.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:3,background:K+"20",color:K,border:`1px solid ${K}33`,fontFamily:"monospace",flexShrink:0},children:X.framework_used.split(" ")[0]})]},X.position)})]}),r.jsxs("div",{style:{background:P.comparison.winner==="B"?"#0a1e0a":"#12121f",border:`1px solid ${P.comparison.winner==="B"?"#1e4a1e":"#1a1a2e"}`,borderRadius:14,padding:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[r.jsx("span",{style:{fontSize:11,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"Sequence B"}),P.comparison.winner==="B"&&r.jsx("span",{style:{fontSize:9,padding:"2px 7px",borderRadius:4,background:"#4caf5020",color:"#4caf50",border:"1px solid #4caf5033",fontFamily:"monospace",fontWeight:700},children:"WINNER"}),r.jsx("span",{style:{marginLeft:"auto",fontSize:20,fontWeight:900,color:"#fff"},children:P.sequence_b.overall_score}),r.jsx("span",{style:{fontSize:14,fontWeight:900,color:vs[P.sequence_b.grade]??"#777"},children:P.sequence_b.grade})]}),P.sequence_b.emails.map(X=>{const K=Ss(X.framework_used);return r.jsxs("div",{onClick:()=>Le(je===X.position?null:X.position),style:{padding:"8px 12px",marginBottom:6,background:"#0d0d1a",border:"1px solid #1a1a2e",borderRadius:8,cursor:"pointer",display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{fontSize:10,color:Ye,fontFamily:"monospace",fontWeight:700,width:16},children:X.position}),r.jsx("span",{style:{flex:1,fontSize:12,color:"#ccc",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:X.subject_line}),r.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:3,background:K+"20",color:K,border:`1px solid ${K}33`,fontFamily:"monospace",flexShrink:0},children:X.framework_used.split(" ")[0]})]},X.position)})]})]})]})}function Qh(){const[l,c]=v.useState("generate");return r.jsxs("div",{style:{padding:24,maxWidth:760,margin:"0 auto"},children:[r.jsxs("div",{style:{textAlign:"center",marginBottom:28},children:[r.jsx("div",{style:{fontSize:9,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:6,fontFamily:"monospace"},children:"ContentGrade Suite — Generate"}),r.jsxs("h1",{style:{fontSize:28,fontWeight:800,color:"#e0e0e0",letterSpacing:-.5},children:["Email",r.jsx("span",{style:{color:Ye},children:"Forge"})]}),r.jsxs("p",{style:{color:"#777",fontSize:14,marginTop:6},children:["Input your product and audience. Get a ",r.jsx("span",{style:{color:"#ccc",fontWeight:500},children:"5-email conversion sequence"})," using proven frameworks."]}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:6,marginTop:12},children:["AIDA","PAS","Hormozi","Cialdini","Storytelling Arc"].map(a=>r.jsx("span",{style:{fontSize:10,padding:"3px 10px",borderRadius:12,background:"#12121f",color:"#666",border:"1px solid #1a1a2e"},children:a},a))})]}),r.jsxs("div",{style:{display:"flex",gap:4,background:"#12121f",border:"1px solid #1a1a2e",borderRadius:10,padding:4,marginBottom:24,width:"fit-content"},children:[r.jsx("button",{onClick:()=>c("generate"),style:{padding:"7px 18px",borderRadius:8,border:"none",cursor:"pointer",fontSize:12,fontWeight:600,background:l==="generate"?Ye:"transparent",color:l==="generate"?"#000":"#666",transition:"background 0.2s, color 0.2s"},children:"Generate"}),r.jsx("button",{onClick:()=>c("compare"),style:{padding:"7px 18px",borderRadius:8,border:"none",cursor:"pointer",fontSize:12,fontWeight:600,background:l==="compare"?"#0a1e2e":"transparent",color:l==="compare"?Ye:"#444",transition:"background 0.2s, color 0.2s"},children:"A/B Compare"})]}),l==="generate"&&r.jsx(Vh,{}),l==="compare"&&r.jsx(Gh,{}),r.jsx("div",{style:{marginTop:40,textAlign:"center",fontSize:10,color:"#333"},children:"Email sequence generation using AIDA · PAS · Hormozi · Cialdini · Storytelling frameworks · Powered by local Claude session"})]})}const Ce="#00c853",du={A:"#4caf50",B:"#4a90d9",C:"#ffd54f",D:"#ff9800",F:"#ef5350"},us={high:"#4caf50",medium:"#ffd54f",low:"#ef5350"},fs={low:"#4caf50",medium:"#ffd54f",high:"#ef5350"};function ii({label:l,score:c}){const a=c>=75?"#4caf50":c>=50?"#ffd54f":"#ef5350";return r.jsxs("div",{style:{textAlign:"center"},children:[r.jsx("div",{style:{fontSize:22,fontWeight:900,color:a},children:c}),r.jsx("div",{style:{fontSize:10,color:"#555",marginTop:2},children:l})]})}function Kh({archetype:l}){var c;return r.jsxs("div",{style:{background:"#0d0d1a",border:"1px solid #1a1a2e",borderRadius:10,padding:16,marginBottom:10},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[r.jsx("div",{style:{flex:1},children:r.jsx("span",{style:{fontSize:13,fontWeight:700,color:Ce},children:l.name})}),r.jsxs("span",{style:{fontSize:18,fontWeight:900,color:"#e0e0e0"},children:[l.percentage,"%"]})]}),r.jsx("div",{style:{height:4,background:"#1a1a2e",borderRadius:2,marginBottom:10,overflow:"hidden"},children:r.jsx("div",{style:{height:"100%",background:Ce,borderRadius:2,width:`${l.percentage}%`}})}),r.jsx("p",{style:{fontSize:12,color:"#aaa",lineHeight:1.5,margin:"0 0 8px"},children:l.description}),((c=l.evidence)==null?void 0:c.length)>0&&r.jsxs("div",{style:{fontSize:10,color:"#555",fontStyle:"italic",borderLeft:`2px solid ${Ce}44`,paddingLeft:8},children:['"',l.evidence[0],'"']})]})}function qh(){var T,_,A,x,B,C,W,P,Q,F,ie,re,fe,je,Le,xe,Ue,Fe,Te,X,K,se,ce,D,J,$,k,L,te,le;const[l,c]=v.useState(""),[a,f]=v.useState(!1),[u,g]=v.useState(null),[h,y]=v.useState(null);async function j(){if(!(l.trim().length<50)){f(!0),g(null),y(null);try{const H=await fetch(`${ge}/demos/audience-decoder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:l.trim()})}),ne=await H.json();if(!H.ok)throw new Error(ne.error||`HTTP ${H.status}`);g(ne)}catch(H){y(H instanceof Error?H.message:"Analysis failed.")}finally{f(!1)}}}const R=u?du[((T=u.grade)==null?void 0:T[0])??""]??"#777":"#777",w=l.trim().length>=50;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{marginBottom:20},children:[r.jsx("textarea",{style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:10,padding:"12px 14px",fontSize:14,color:"#e0e0e0",resize:"vertical",outline:"none",fontFamily:"inherit",boxSizing:"border-box",minHeight:180},rows:8,placeholder:"Paste your last 10-20 tweets, threads, or posts — one per line or separated by ---",value:l,onChange:H=>c(H.target.value)}),r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:8},children:[r.jsxs("span",{style:{fontSize:10,color:"#444"},children:[l.length," chars · minimum 50 chars"]}),r.jsx("button",{onClick:j,disabled:a||!w,style:{padding:"9px 22px",background:a||!w?"#333":Ce,color:"#000",fontWeight:700,fontSize:13,border:"none",borderRadius:8,cursor:a||!w?"not-allowed":"pointer",opacity:a||!w?.5:1},children:a?"Decoding...":"Decode My Audience"})]})]}),h&&r.jsx("div",{style:{background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:10,padding:12,marginBottom:16,color:"#ef5350",fontSize:12},children:h}),u&&r.jsxs("div",{children:[r.jsxs("div",{style:{background:"#12121f",border:`1px solid ${Ce}44`,borderRadius:14,padding:24,textAlign:"center",marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,marginBottom:12},children:[r.jsx("span",{style:{fontSize:56,fontWeight:900,color:"#fff"},children:u.overall_score}),r.jsxs("div",{style:{textAlign:"left"},children:[r.jsx("div",{style:{fontSize:32,fontWeight:900,color:R},children:u.grade}),r.jsx("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"/ 100"})]})]}),r.jsx("p",{style:{color:Ce,fontSize:15,fontWeight:600,maxWidth:480,margin:"0 auto 14px",lineHeight:1.4},children:u.headline}),r.jsx(Ot,{shareText:`My audience decoded: ${u.headline} — Analyzed free on AudienceDecoder`,accentColor:Ce})]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:14},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,margin:0},children:"Audience Archetypes"}),r.jsx("span",{style:{fontSize:9,padding:"2px 8px",borderRadius:4,background:"#4caf5020",color:"#4caf50",border:"1px solid #4caf5033",fontFamily:"monospace",fontWeight:600,letterSpacing:1},children:"FREE"})]}),(_=u.audience_archetypes)==null?void 0:_.map((H,ne)=>r.jsx(Kh,{archetype:H},ne))]}),r.jsx(rr,{tool:"audience-decoder",score:u.overall_score,accentColor:Ce}),r.jsxs(cn,{accentColor:Ce,label:"Full Audience Intelligence Report",priceLabel:"Unlock Deep Report — $49",children:[r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:16},children:"Engagement Model"}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:16},children:[r.jsx(ii,{label:"Hook Effectiveness",score:((x=(A=u.engagement_model)==null?void 0:A.hook_effectiveness)==null?void 0:x.score)??0}),r.jsx(ii,{label:"CTA Effectiveness",score:((C=(B=u.engagement_model)==null?void 0:B.cta_effectiveness)==null?void 0:C.score)??0}),r.jsx(ii,{label:"Controversy Index",score:((P=(W=u.engagement_model)==null?void 0:W.controversy_index)==null?void 0:P.score)??0}),r.jsx(ii,{label:"Shareability",score:((Q=u.engagement_model)==null?void 0:Q.shareability_score)??0})]}),((ie=(F=u.engagement_model)==null?void 0:F.cta_effectiveness)==null?void 0:ie.recommendation)&&r.jsxs("div",{style:{background:"#0d0d1a",borderRadius:8,padding:12},children:[r.jsx("span",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:1},children:"CTA Recommendation: "}),r.jsx("span",{style:{fontSize:12,color:"#aaa"},children:u.engagement_model.cta_effectiveness.recommendation})]})]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Content Patterns"}),r.jsxs("div",{style:{display:"flex",gap:12,marginBottom:14},children:[r.jsxs("div",{style:{flex:1,background:"#0d1f0d",border:"1px solid #1e4a1e",borderRadius:8,padding:12},children:[r.jsx("div",{style:{fontSize:10,color:"#2e7d32",textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Working Well"}),(fe=(re=u.content_patterns)==null?void 0:re.top_performing_themes)==null?void 0:fe.map((H,ne)=>r.jsxs("div",{style:{fontSize:12,color:"#aaa",marginBottom:4},children:[r.jsx("span",{style:{color:"#4caf50",fontWeight:600},children:H.theme}),r.jsxs("span",{style:{color:"#555"},children:[" · ",H.frequency,"x · ",H.avg_engagement_signal]})]},ne))]}),r.jsxs("div",{style:{flex:1,background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:8,padding:12},children:[r.jsx("div",{style:{fontSize:10,color:"#c62828",textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Underperforming"}),(Le=(je=u.content_patterns)==null?void 0:je.underperforming_themes)==null?void 0:Le.map((H,ne)=>r.jsxs("div",{style:{fontSize:12,color:"#aaa",marginBottom:4},children:[r.jsx("span",{style:{color:"#ef5350",fontWeight:600},children:H.theme}),r.jsxs("span",{style:{color:"#555"},children:[" · ",H.frequency,"x · ",H.avg_engagement_signal]})]},ne))]})]}),r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsxs("div",{style:{background:"#0d0d1a",borderRadius:8,padding:"8px 12px",fontSize:11,color:"#aaa"},children:[r.jsx("span",{style:{color:"#555"},children:"Best format: "}),r.jsx("span",{style:{color:Ce,fontWeight:600},children:(xe=u.content_patterns)==null?void 0:xe.optimal_format})]}),r.jsxs("div",{style:{background:"#0d0d1a",borderRadius:8,padding:"8px 12px",fontSize:11,color:"#aaa"},children:[r.jsx("span",{style:{color:"#555"},children:"Best length: "}),r.jsx("span",{style:{color:Ce,fontWeight:600},children:(Ue=u.content_patterns)==null?void 0:Ue.optimal_length})]}),r.jsxs("div",{style:{background:"#0d0d1a",borderRadius:8,padding:"8px 12px",fontSize:11,color:"#aaa"},children:[r.jsx("span",{style:{color:"#555"},children:"Tone: "}),r.jsx("span",{style:{color:"#ccc"},children:(Te=(Fe=u.content_patterns)==null?void 0:Fe.voice_analysis)==null?void 0:Te.tone})]})]})]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Growth Opportunities"}),(X=u.growth_opportunities)==null?void 0:X.map((H,ne)=>r.jsxs("div",{style:{background:"#0d0d1a",border:"1px solid #1a1a2e",borderRadius:8,padding:14,marginBottom:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,marginBottom:6},children:[r.jsxs("span",{style:{fontSize:10,color:"#555",fontFamily:"monospace",flexShrink:0,marginTop:2},children:["#",ne+1]}),r.jsx("div",{style:{flex:1,fontSize:13,color:"#e0e0e0",fontWeight:600},children:H.opportunity}),r.jsxs("div",{style:{display:"flex",gap:4,flexShrink:0},children:[r.jsxs("span",{style:{fontSize:9,padding:"2px 7px",borderRadius:4,background:us[H.impact]+"20",color:us[H.impact],border:`1px solid ${us[H.impact]}44`,fontWeight:700},children:[H.impact," impact"]}),r.jsxs("span",{style:{fontSize:9,padding:"2px 7px",borderRadius:4,background:fs[H.effort]+"20",color:fs[H.effort],border:`1px solid ${fs[H.effort]}44`,fontWeight:700},children:[H.effort," effort"]})]})]}),r.jsx("p",{style:{fontSize:11,color:"#666",margin:0,lineHeight:1.5},children:H.explanation})]},ne))]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:0},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Content Calendar"}),r.jsx("div",{style:{display:"flex",gap:10,marginBottom:14},children:[{label:"Threads/week",val:(se=(K=u.content_calendar)==null?void 0:K.weekly_mix)==null?void 0:se.threads},{label:"Posts/week",val:(D=(ce=u.content_calendar)==null?void 0:ce.weekly_mix)==null?void 0:D.single_posts},{label:"Questions/week",val:($=(J=u.content_calendar)==null?void 0:J.weekly_mix)==null?void 0:$.questions}].map(({label:H,val:ne})=>r.jsxs("div",{style:{flex:1,background:"#0d0d1a",borderRadius:8,padding:12,textAlign:"center"},children:[r.jsx("div",{style:{fontSize:22,fontWeight:900,color:Ce},children:ne??0}),r.jsx("div",{style:{fontSize:10,color:"#555",marginTop:2},children:H})]},H))}),((L=(k=u.content_calendar)==null?void 0:k.theme_rotation)==null?void 0:L.length)>0&&r.jsxs("div",{style:{marginBottom:12},children:[r.jsx("div",{style:{fontSize:10,color:"#444",textTransform:"uppercase",letterSpacing:1,marginBottom:8},children:"Theme Rotation"}),u.content_calendar.theme_rotation.map((H,ne)=>r.jsx("div",{style:{fontSize:12,color:"#aaa",marginBottom:4,paddingLeft:8,borderLeft:`2px solid ${Ce}44`},children:H},ne))]}),((le=(te=u.content_calendar)==null?void 0:te.gaps_to_fill)==null?void 0:le.length)>0&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:10,color:"#444",textTransform:"uppercase",letterSpacing:1,marginBottom:8},children:"Content Gaps to Fill"}),u.content_calendar.gaps_to_fill.map((H,ne)=>r.jsxs("div",{style:{fontSize:11,color:"#888",marginBottom:4,display:"flex",alignItems:"flex-start",gap:6},children:[r.jsx("span",{style:{color:"#ffd54f",flexShrink:0},children:"→"})," ",H]},ne))]})]})]}),r.jsx(kn,{accentColor:Ce,product:"audiencedecoder"})]})]})}function Yh(){var _,A,x,B,C;const[l,c]=v.useState(""),[a,f]=v.useState(""),[u,g]=v.useState(!1),[h,y]=v.useState(null),[j,R]=v.useState(null);async function w(){if(!(l.trim().length<50||a.trim().length<50)){g(!0),y(null),R(null);try{const W=await fetch(`${ge}/demos/audience-decoder/compare`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content_a:l.trim(),content_b:a.trim()})}),P=await W.json();if(!W.ok)throw new Error(P.error||`HTTP ${W.status}`);y(P)}catch(W){R(W instanceof Error?W.message:"Comparison failed.")}finally{g(!1)}}}const T=l.trim().length>=50&&a.trim().length>=50;return r.jsx(cn,{accentColor:Ce,label:"Profile Compare Mode",priceLabel:"Unlock Deep Report — $49",children:r.jsxs("div",{children:[r.jsx("div",{style:{display:"flex",gap:12,marginBottom:12},children:["A","B"].map(W=>{const P=W==="A"?l:a,Q=W==="A"?c:f;return r.jsxs("div",{style:{flex:1},children:[r.jsxs("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:6},children:["Creator ",W]}),r.jsx("textarea",{style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:10,padding:"10px 12px",fontSize:12,color:"#e0e0e0",resize:"vertical",outline:"none",fontFamily:"inherit",boxSizing:"border-box"},rows:8,placeholder:`Paste Creator ${W}'s content...`,value:P,onChange:F=>Q(F.target.value)})]},W)})}),r.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:20},children:r.jsx("button",{onClick:w,disabled:u||!T,style:{padding:"9px 22px",background:u||!T?"#333":Ce,color:"#000",fontWeight:700,fontSize:13,border:"none",borderRadius:8,cursor:u||!T?"not-allowed":"pointer",opacity:u||!T?.5:1},children:u?"Comparing...":"Compare Profiles"})}),j&&r.jsx("div",{style:{background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:10,padding:12,marginBottom:16,color:"#ef5350",fontSize:12},children:j}),h&&r.jsxs("div",{children:[r.jsx("div",{style:{display:"flex",gap:12,marginBottom:16},children:["A","B"].map(W=>{var F;const P=W==="A"?h.analysis_a:h.analysis_b,Q=du[((F=P==null?void 0:P.grade)==null?void 0:F[0])??""]??"#777";return r.jsxs("div",{style:{flex:1,background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:16,textAlign:"center"},children:[r.jsxs("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:8},children:["Creator ",W]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,marginBottom:8},children:[r.jsx("span",{style:{fontSize:40,fontWeight:900,color:"#fff"},children:P==null?void 0:P.overall_score}),r.jsx("span",{style:{fontSize:22,fontWeight:900,color:Q},children:P==null?void 0:P.grade})]}),r.jsx("p",{style:{fontSize:11,color:Ce,margin:0,lineHeight:1.4},children:P==null?void 0:P.headline})]},W)})}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Comparative Analysis"}),r.jsxs("div",{style:{display:"flex",gap:12,marginBottom:14},children:[r.jsxs("div",{style:{flex:1,background:"#0d0d1a",borderRadius:8,padding:12,textAlign:"center"},children:[r.jsxs("div",{style:{fontSize:22,fontWeight:900,color:"#ffd54f"},children:[(_=h.comparison)==null?void 0:_.audience_overlap,"%"]}),r.jsx("div",{style:{fontSize:10,color:"#555",marginTop:2},children:"Audience Overlap"})]}),r.jsxs("div",{style:{flex:1,background:"#0d0d1a",borderRadius:8,padding:12,textAlign:"center"},children:[r.jsx("div",{style:{fontSize:22,fontWeight:900,color:Ce},children:(A=h.comparison)==null?void 0:A.differentiation_score}),r.jsx("div",{style:{fontSize:10,color:"#555",marginTop:2},children:"Differentiation Score"})]}),r.jsxs("div",{style:{flex:1,background:"#0d0d1a",borderRadius:8,padding:12,textAlign:"center"},children:[r.jsx("div",{style:{fontSize:15,fontWeight:800,color:"#4a90d9",textTransform:"capitalize"},children:(x=h.comparison)==null?void 0:x.collaboration_potential}),r.jsx("div",{style:{fontSize:10,color:"#555",marginTop:2},children:"Collab Potential"})]})]}),((B=h.comparison)==null?void 0:B.winner_by_category)&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:10,color:"#444",textTransform:"uppercase",letterSpacing:1,marginBottom:8},children:"Category Winners"}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:Object.entries(h.comparison.winner_by_category).map(([W,P])=>r.jsxs("div",{style:{background:"#0d0d1a",border:"1px solid #1a1a2e",borderRadius:6,padding:"5px 10px",fontSize:11},children:[r.jsxs("span",{style:{color:"#666"},children:[W,": "]}),r.jsx("span",{style:{color:P==="tie"?"#ffd54f":Ce,fontWeight:700},children:P==="tie"?"Tie":`Creator ${P}`})]},W))})]}),((C=h.comparison)==null?void 0:C.strategic_advice)&&r.jsxs("div",{style:{marginTop:14,background:"#0d0d1a",borderRadius:8,padding:12},children:[r.jsx("div",{style:{fontSize:10,color:"#444",textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Strategic Advice"}),r.jsx("p",{style:{fontSize:12,color:"#aaa",margin:0,lineHeight:1.6},children:h.comparison.strategic_advice})]})]})]})]})})}function Jh(){const[l,c]=v.useState("score");return r.jsxs("div",{style:{padding:24,maxWidth:720,margin:"0 auto"},children:[r.jsxs("div",{style:{textAlign:"center",marginBottom:28},children:[r.jsx("div",{style:{fontSize:9,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:6,fontFamily:"monospace"},children:"Content Intelligence Stack"}),r.jsxs("h1",{style:{fontSize:28,fontWeight:800,color:"#e0e0e0",letterSpacing:-.5},children:["Audience",r.jsx("span",{style:{color:Ce},children:"Decoder"})]}),r.jsxs("p",{style:{color:"#777",fontSize:14,marginTop:6},children:["Paste your content. Discover who reads you, what resonates, and"," ",r.jsx("span",{style:{color:"#ccc",fontWeight:500},children:"exactly what to post next."})]}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:6,marginTop:12},children:["Audience Archetypes","Content Patterns","Engagement Model","Growth Opportunities","Content Calendar"].map(a=>r.jsx("span",{style:{fontSize:10,padding:"3px 10px",borderRadius:12,background:"#12121f",color:"#666",border:"1px solid #1a1a2e"},children:a},a))})]}),r.jsxs("div",{style:{display:"flex",gap:4,background:"#12121f",border:"1px solid #1a1a2e",borderRadius:10,padding:4,marginBottom:24,width:"fit-content"},children:[r.jsx("button",{onClick:()=>c("score"),style:{padding:"7px 18px",borderRadius:8,border:"none",cursor:"pointer",fontSize:12,fontWeight:600,background:l==="score"?Ce:"transparent",color:l==="score"?"#000":"#666",transition:"background 0.2s, color 0.2s"},children:"Decode"}),r.jsxs("button",{onClick:()=>c("compare"),style:{padding:"7px 18px",borderRadius:8,border:"none",cursor:"pointer",fontSize:12,fontWeight:600,background:l==="compare"?"#0a2e1a":"transparent",color:l==="compare"?"#00c853":"#444",transition:"background 0.2s, color 0.2s",display:"flex",alignItems:"center",gap:6},children:["Compare Creators",r.jsx("span",{style:{fontSize:8,padding:"1px 6px",borderRadius:4,background:Ce+"33",color:Ce,border:`1px solid ${Ce}44`,fontFamily:"monospace",fontWeight:700,letterSpacing:.5},children:"PRO"})]})]}),l==="score"&&r.jsx(qh,{}),l==="compare"&&r.jsx(Yh,{}),r.jsx("div",{style:{marginTop:40,textAlign:"center",fontSize:10,color:"#333"},children:"Audience intelligence for creators · Powered by local Claude session"})]})}function Yn({children:l,style:c}){return r.jsx("div",{style:{background:"#0d0d1a",border:"1px solid #12121f",borderRadius:12,padding:"16px 20px",...c},children:l})}function Jn({children:l}){return r.jsx("div",{style:{fontSize:10,fontWeight:800,color:"#444",textTransform:"uppercase",letterSpacing:2,fontFamily:"monospace",marginBottom:12},children:l})}function Oe({label:l,value:c,sub:a,color:f="#e0e0e0"}){return r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:11,color:"#444",marginBottom:3},children:l}),r.jsx("div",{style:{fontSize:22,fontWeight:800,color:f,fontFamily:"monospace",lineHeight:1},children:c}),a&&r.jsx("div",{style:{fontSize:10,color:"#333",marginTop:3},children:a})]})}function ps({label:l,value:c,max:a,color:f}){const u=a>0?Math.round(c/a*100):0;return r.jsxs("div",{style:{marginBottom:14},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4},children:[r.jsx("span",{style:{fontSize:11,color:"#888"},children:l}),r.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"#ccc",fontFamily:"monospace"},children:[c.toLocaleString()," ",r.jsxs("span",{style:{color:"#444"},children:["(",u,"%)"]})]})]}),r.jsx("div",{style:{height:5,background:"#1a1a2e",borderRadius:3,overflow:"hidden"},children:r.jsx("div",{style:{height:"100%",width:`${u}%`,background:f,borderRadius:3}})})]})}function Xh(){var x,B;const[l,c]=v.useState(null),[a,f]=v.useState(null),[u,g]=v.useState(!0),[h,y]=v.useState(null),[j,R]=v.useState(null),w=v.useCallback(async()=>{g(!0),y(null);try{const[C,W]=await Promise.all([fetch(`${ge}/analytics/summary`),fetch(`${ge}/analytics/npm-stats`)]);if(!C.ok)throw new Error(`Analytics summary: ${C.status}`);const P=await C.json();if(c(P),W.ok&&W.status!==204){const Q=await W.json();f(Q)}R(new Date)}catch(C){y(String(C))}finally{g(!1)}},[]);if(v.useEffect(()=>{w()},[w]),u)return r.jsx("div",{style:{padding:40,textAlign:"center",color:"#333",fontSize:12},children:"Loading metrics..."});if(h)return r.jsxs("div",{style:{padding:40,textAlign:"center"},children:[r.jsx("div",{style:{color:"#ef5350",fontSize:13,marginBottom:8},children:"Failed to load metrics"}),r.jsx("div",{style:{color:"#444",fontSize:11,fontFamily:"monospace"},children:h}),r.jsx("button",{onClick:w,style:{marginTop:16,padding:"8px 20px",background:"#1a1a2e",color:"#7c4dff",border:"1px solid #7c4dff44",borderRadius:8,cursor:"pointer",fontSize:12,fontWeight:700},children:"Retry"})]});const T=(l==null?void 0:l.funnel.free_limit_hits_30d)??0,_=(x=a==null?void 0:a.latest)==null?void 0:x.npm,A=(B=a==null?void 0:a.latest)==null?void 0:B.github;return r.jsxs("div",{style:{padding:"24px 28px",maxWidth:900,margin:"0 auto"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:28},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:18,fontWeight:800,color:"#e0e0e0"},children:"Metrics"}),r.jsx("div",{style:{fontSize:11,color:"#333",marginTop:2},children:l&&`Last 30 days · ${l.period.from} → ${l.period.to}`})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[j&&r.jsx("span",{style:{fontSize:10,color:"#333"},children:j.toLocaleTimeString()}),r.jsx("button",{onClick:w,style:{padding:"6px 14px",background:"#12121f",color:"#7c4dff",border:"1px solid #7c4dff33",borderRadius:7,cursor:"pointer",fontSize:11,fontWeight:700},children:"Refresh"})]})]}),r.jsxs(Yn,{style:{marginBottom:16},children:[r.jsx(Jn,{children:"Conversion Funnel — 30d"}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:20,marginBottom:24},children:[r.jsx(Oe,{label:"Free limit hits",value:((l==null?void 0:l.funnel.free_limit_hits_30d)??0).toLocaleString(),sub:"users reached paywall",color:"#ffd54f"}),r.jsx(Oe,{label:"Upgrade clicks",value:((l==null?void 0:l.funnel.upgrade_clicks_30d)??0).toLocaleString(),sub:"clicked Pro CTA",color:"#7c4dff"}),r.jsx(Oe,{label:"Checkouts completed",value:((l==null?void 0:l.funnel.checkout_completions_30d)??0).toLocaleString(),sub:"paid customers",color:"#4caf50"}),r.jsx(Oe,{label:"Conversion rate",value:`${(l==null?void 0:l.funnel.conversion_rate_pct)??0}%`,sub:"upgrade click → paid",color:((l==null?void 0:l.funnel.conversion_rate_pct)??0)>=5?"#4caf50":((l==null?void 0:l.funnel.conversion_rate_pct)??0)>=2?"#ffd54f":"#ef5350"})]}),r.jsx(ps,{label:"Free limit hit",value:(l==null?void 0:l.funnel.free_limit_hits_30d)??0,max:T||1,color:"#ffd54f"}),r.jsx(ps,{label:"Upgrade clicked",value:(l==null?void 0:l.funnel.upgrade_clicks_30d)??0,max:T||1,color:"#7c4dff"}),r.jsx(ps,{label:"Checkout completed",value:(l==null?void 0:l.funnel.checkout_completions_30d)??0,max:T||1,color:"#4caf50"})]}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:16},children:[r.jsxs(Yn,{children:[r.jsx(Jn,{children:"CLI Telemetry — 30d"}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:16},children:[r.jsx(Oe,{label:"Unique installs",value:((l==null?void 0:l.cli.unique_installs_30d)??0).toLocaleString()}),r.jsx(Oe,{label:"Total commands",value:((l==null?void 0:l.cli.total_commands_30d)??0).toLocaleString()}),r.jsx(Oe,{label:"Success rate",value:`${(l==null?void 0:l.cli.success_rate_pct)??0}%`,color:((l==null?void 0:l.cli.success_rate_pct)??0)>=90?"#4caf50":"#ffd54f"}),r.jsx(Oe,{label:"Avg duration",value:l!=null&&l.cli.avg_duration_ms?`${(l.cli.avg_duration_ms/1e3).toFixed(1)}s`:"—"})]}),l!=null&&l.cli.command_breakdown&&l.cli.command_breakdown.length>0?r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:10,color:"#333",marginBottom:8},children:"By command"}),l.cli.command_breakdown.map(C=>r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0",borderBottom:"1px solid #0d0d1a"},children:[r.jsx("span",{style:{fontSize:11,color:"#888",fontFamily:"monospace"},children:C.command}),r.jsxs("span",{style:{fontSize:11,color:"#ccc",fontFamily:"monospace"},children:[C.count," ",r.jsxs("span",{style:{color:"#333"},children:["(",(C.avg_ms/1e3).toFixed(1),"s avg)"]})]})]},C.command))]}):r.jsxs("div",{style:{fontSize:11,color:"#333",textAlign:"center",padding:"8px 0"},children:["No CLI events yet. Telemetry fires on first ",r.jsx("code",{style:{color:"#555"},children:"content-grade"})," run."]})]}),r.jsxs(Yn,{children:[r.jsx(Jn,{children:"Web Tools — Today"}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:16},children:[r.jsx(Oe,{label:"Requests today",value:((l==null?void 0:l.web.today.total_requests)??0).toLocaleString()}),r.jsx(Oe,{label:"Unique IPs today",value:((l==null?void 0:l.web.today.unique_ips)??0).toLocaleString()})]}),l!=null&&l.web.tool_usage_7d&&l.web.tool_usage_7d.length>0?r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:10,color:"#333",marginBottom:8},children:"By tool (7d)"}),l.web.tool_usage_7d.slice(0,6).map(C=>r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0",borderBottom:"1px solid #0d0d1a"},children:[r.jsx("span",{style:{fontSize:11,color:"#888",fontFamily:"monospace"},children:C.endpoint.replace("/api/demos/","")}),r.jsx("span",{style:{fontSize:11,color:"#ccc",fontFamily:"monospace"},children:C.total.toLocaleString()})]},C.endpoint))]}):r.jsx("div",{style:{fontSize:11,color:"#333",textAlign:"center",padding:"8px 0"},children:"No web tool usage tracked yet."}),(l==null?void 0:l.web.daily_active_users_7d)&&l.web.daily_active_users_7d.length>1&&r.jsxs("div",{style:{marginTop:16},children:[r.jsx("div",{style:{fontSize:10,color:"#333",marginBottom:8},children:"Daily unique IPs (7d)"}),r.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:3,height:32},children:[...l.web.daily_active_users_7d].reverse().map(C=>{const W=Math.max(...l.web.daily_active_users_7d.map(Q=>Q.unique_ips),1),P=Math.max(2,Math.round(C.unique_ips/W*32));return r.jsx("div",{title:`${C.date}: ${C.unique_ips} unique IPs`,style:{flex:1,height:P,background:"#7c4dff55",borderRadius:2,minWidth:8}},C.date)})})]})]})]}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:16},children:[r.jsxs(Yn,{children:[r.jsx(Jn,{children:"npm Downloads"}),_?r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:12,marginBottom:12},children:[r.jsx(Oe,{label:"This week",value:_.last_week.toLocaleString()}),r.jsx(Oe,{label:"This month",value:_.last_month.toLocaleString()}),r.jsx(Oe,{label:"All time",value:_.last_year.toLocaleString()})]}),r.jsxs("div",{style:{fontSize:10,color:"#333"},children:["Package: ",r.jsx("code",{style:{color:"#555"},children:"content-grade"}),_.status==="awaiting_first_download"&&r.jsx("span",{style:{color:"#ffd54f",marginLeft:8},children:"awaiting first download"})]})]}):r.jsxs("div",{style:{fontSize:11,color:"#333",padding:"8px 0"},children:["No npm snapshot yet. Run:"," ",r.jsx("code",{style:{color:"#555",fontSize:10},children:"npm run metrics"})]}),a&&r.jsxs("div",{style:{marginTop:12,fontSize:10,color:"#222"},children:[a.snapshot_count," snapshot",a.snapshot_count!==1?"s":""," ·"," ","last updated ",a.newest_snapshot?new Date(a.newest_snapshot).toLocaleDateString():"—"]})]}),r.jsxs(Yn,{children:[r.jsx(Jn,{children:"GitHub Traffic"}),A?r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginBottom:12},children:[r.jsx(Oe,{label:"Stars",value:A.engagement.stars.toLocaleString(),color:"#ffd54f"}),r.jsx(Oe,{label:"Forks",value:A.engagement.forks.toLocaleString()}),r.jsx(Oe,{label:"Views (14d)",value:A.views.count_14d.toLocaleString()}),r.jsx(Oe,{label:"Clones (14d)",value:A.clones.count_14d.toLocaleString()})]}),A.top_referrers.length>0&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:10,color:"#333",marginBottom:6},children:"Top referrers"}),A.top_referrers.slice(0,4).map(C=>r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,color:"#555",padding:"2px 0"},children:[r.jsx("span",{children:C.referrer}),r.jsx("span",{style:{fontFamily:"monospace",color:"#444"},children:C.count})]},C.referrer))]})]}):r.jsxs("div",{style:{fontSize:11,color:"#333",padding:"8px 0"},children:["No GitHub snapshot yet. Run:"," ",r.jsx("code",{style:{color:"#555",fontSize:10},children:"npm run metrics"})]})]})]}),r.jsxs(Yn,{children:[r.jsx(Jn,{children:"Email Leads — 30d"}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},children:[r.jsx(Oe,{label:"Email captures",value:((l==null?void 0:l.leads.email_captures_30d)??0).toLocaleString(),sub:"total email submissions"}),r.jsx(Oe,{label:"Unique emails",value:((l==null?void 0:l.leads.unique_emails_30d)??0).toLocaleString(),sub:"distinct leads"})]})]}),r.jsxs("div",{style:{marginTop:16,fontSize:10,color:"#222",textAlign:"right"},children:["Generated: ",l!=null&&l.generated_at?new Date(l.generated_at).toLocaleString():"—"]})]})}const Zh=[{path:"/headline",label:"HeadlineGrader"},{path:"/page-roast",label:"PageRoast"},{path:"/ad-scorer",label:"AdScorer"},{path:"/thread",label:"ThreadGrader"},{path:"/email-forge",label:"EmailForge"},{path:"/audience",label:"AudienceDecoder"},{path:"/metrics",label:"Metrics",operatorOnly:!0}];function eg(){const{email:l,isPro:c,loading:a,setEmail:f}=ou(),[u,g]=v.useState(!1),[h,y]=v.useState(""),[j,R]=v.useState(!1),[w,T]=v.useState(null),[_,A]=v.useState(!1),[x,B]=v.useState(!1);ws.useEffect(()=>{!l||!c||(A(!0),fetch(`${ge}/license/my-keys?email=${encodeURIComponent(l)}`).then(F=>F.json()).then(F=>{const ie=F.keys,re=ie==null?void 0:ie.find(fe=>fe.status==="active");T((re==null?void 0:re.key)??null)}).catch(()=>T(null)).finally(()=>A(!1)))},[l,c]);async function C(F){try{await navigator.clipboard.writeText(F),B(!0),setTimeout(()=>B(!1),2e3)}catch{}}async function W(){if(l){R(!0);try{const ie=await(await fetch(`${ge}/stripe/billing-portal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:l,returnUrl:window.location.href})})).json();ie.url?window.location.href=ie.url:alert(ie.error??"Could not open billing portal.")}catch{alert("Billing portal unavailable. Try again later.")}finally{R(!1)}}}function P(){const F=h.trim().toLowerCase();F.includes("@")&&(f(F),g(!1),y(""))}function Q(){f(""),g(!1)}return a?r.jsx("span",{style:{fontSize:10,color:"#333",marginLeft:8},children:"..."}):l?r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:6,marginLeft:"auto",flexShrink:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c&&r.jsx("span",{style:{fontSize:9,fontWeight:800,color:"#7c4dff",background:"#7c4dff18",border:"1px solid #7c4dff44",borderRadius:5,padding:"2px 7px",letterSpacing:.8,textTransform:"uppercase"},children:"PRO"}),r.jsx("span",{style:{fontSize:10,color:"#555",maxWidth:130,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l}),c&&r.jsx("button",{onClick:W,disabled:j,style:{fontSize:10,color:"#7c4dff",background:"transparent",border:"1px solid #7c4dff44",borderRadius:5,padding:"3px 8px",cursor:"pointer",whiteSpace:"nowrap",fontWeight:600},children:j?"...":"Manage Billing"}),r.jsx("button",{onClick:Q,style:{fontSize:10,color:"#444",background:"transparent",border:"none",cursor:"pointer",padding:"2px 4px"},title:"Sign out",children:"×"})]}),c&&r.jsx("div",{style:{fontSize:10,color:"#555"},children:_?r.jsx("span",{style:{color:"#333"},children:"Loading key..."}):w?r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[r.jsx("code",{style:{background:"#0d0d1a",border:"1px solid #1a1a2e",borderRadius:4,padding:"2px 8px",fontSize:10,color:"#7c4dff",fontFamily:"monospace",letterSpacing:.5},children:w}),r.jsx("button",{onClick:()=>C(w),style:{fontSize:9,color:x?"#44bb88":"#555",background:"transparent",border:"1px solid #1a1a2e",borderRadius:4,padding:"2px 6px",cursor:"pointer"},children:x?"Copied!":"Copy"})]}):r.jsx("span",{style:{color:"#333",fontSize:9},children:"Key will appear here after purchase"})})]}):u?r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginLeft:"auto",flexShrink:0},children:[r.jsx("input",{autoFocus:!0,type:"email",placeholder:"your@email.com",value:h,onChange:F=>y(F.target.value),onKeyDown:F=>{F.key==="Enter"&&P(),F.key==="Escape"&&(g(!1),y(""))},style:{background:"#0d0d1a",border:"1px solid #2a2a3e",borderRadius:6,padding:"5px 10px",fontSize:11,color:"#e0e0e0",outline:"none",fontFamily:"inherit",width:170}}),r.jsx("button",{onClick:P,disabled:!h.includes("@"),style:{fontSize:10,fontWeight:700,color:"#7c4dff",background:"#7c4dff18",border:"1px solid #7c4dff44",borderRadius:5,padding:"4px 10px",cursor:"pointer",opacity:h.includes("@")?1:.5},children:"Sign In"}),r.jsx("button",{onClick:()=>{g(!1),y("")},style:{fontSize:10,color:"#444",background:"transparent",border:"none",cursor:"pointer"},children:"×"})]}):r.jsx("button",{onClick:()=>g(!0),style:{marginLeft:"auto",fontSize:10,fontWeight:600,color:"#555",background:"transparent",border:"1px solid #1a1a2e",borderRadius:5,padding:"4px 10px",cursor:"pointer",whiteSpace:"nowrap",flexShrink:0},children:"Sign In"})}function tg(){return r.jsxs("nav",{style:{background:"#080810",borderBottom:"1px solid #12121f",padding:"0 24px",display:"flex",alignItems:"center",gap:4,overflowX:"auto",flexShrink:0},children:[r.jsx("span",{style:{fontSize:12,fontWeight:800,color:"#555",marginRight:16,whiteSpace:"nowrap",letterSpacing:1},children:"CG"}),Zh.map(({path:l,label:c,...a})=>{const f="operatorOnly"in a&&a.operatorOnly;return r.jsx(Sh,{to:l,style:({isActive:u})=>({padding:"12px 14px",fontSize:12,fontWeight:600,color:u?"#e0e0e0":f?"#2a2a3e":"#444",textDecoration:"none",borderBottom:u?"2px solid #7c4dff":"2px solid transparent",whiteSpace:"nowrap"}),children:c},l)}),r.jsx(eg,{})]})}function ng(){return r.jsx(Ch,{children:r.jsx(mh,{children:r.jsxs("div",{style:{display:"flex",flexDirection:"column",minHeight:"100vh"},children:[r.jsx(tg,{}),r.jsx("main",{style:{flex:1,overflowY:"auto"},children:r.jsxs(ah,{children:[r.jsx(Rt,{path:"/",element:r.jsx(Ld,{to:"/headline",replace:!0})}),r.jsx(Rt,{path:"/headline",element:r.jsx(Bh,{})}),r.jsx(Rt,{path:"/page-roast",element:r.jsx(Lh,{})}),r.jsx(Rt,{path:"/ad-scorer",element:r.jsx(Fh,{})}),r.jsx(Rt,{path:"/thread",element:r.jsx($h,{})}),r.jsx(Rt,{path:"/email-forge",element:r.jsx(Qh,{})}),r.jsx(Rt,{path:"/audience",element:r.jsx(Jh,{})}),r.jsx(Rt,{path:"/metrics",element:r.jsx(Xh,{})}),r.jsx(Rt,{path:"*",element:r.jsx(Ld,{to:"/headline",replace:!0})})]})})]})})})}xp.createRoot(document.getElementById("root")).render(r.jsx(ws.StrictMode,{children:r.jsx(ng,{})}));
78
+ Start with the hook. Earn the context.`,value:l,onChange:x=>c(x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.metaKey||x.ctrlKey)&&T()}}),r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:8},children:[r.jsxs("span",{style:{fontSize:10,color:"#444"},children:[w," tweet",w!==1?"s":""," · ",l.length,"/5000 chars · Ctrl+Enter to grade"]}),r.jsx("button",{onClick:T,disabled:a||l.trim().length<20,style:{padding:"8px 20px",background:a||l.trim().length<20?"#333":Ae,color:"#fff",fontWeight:600,fontSize:13,border:"none",borderRadius:8,cursor:a||l.trim().length<20?"not-allowed":"pointer",opacity:a||l.trim().length<20?.5:1},children:a?"Grading...":"Grade Thread"})]})]}),h&&r.jsx("div",{style:{background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:10,padding:12,marginBottom:16,color:"#ef5350",fontSize:12},children:h}),u&&r.jsxs("div",{children:[r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:24,textAlign:"center",marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,marginBottom:10},children:[r.jsx("span",{style:{fontSize:56,fontWeight:900,color:"#fff"},children:u.total_score}),r.jsxs("div",{style:{textAlign:"left"},children:[r.jsx("div",{style:{fontSize:32,fontWeight:900,color:A},children:u.grade}),r.jsx("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"/ 100"})]})]}),r.jsxs("p",{style:{color:Ae,fontSize:14,fontWeight:600,fontStyle:"italic",maxWidth:480,margin:"0 auto 16px"},children:['"',u.verdict,'"']}),r.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10,flexWrap:"wrap"},children:[r.jsx(Ot,{shareText:`My thread scored ${u.total_score}/100 on ThreadGrader. Grade yours → https://contentintelligence.ai`,accentColor:Ae}),r.jsx("button",{onClick:_,style:{padding:"7px 14px",background:j?"#0a2a3a":"#1a3a5a",color:j?"#4caf50":Ae,border:`1px solid ${j?"#1a5a2a":"#1a5a7a"}`,borderRadius:8,cursor:"pointer",fontSize:12,fontWeight:600},children:j?"✓ Tweeted!":"Tweet Your Score"})]})]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:14},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,margin:0},children:"Hook Analysis"}),r.jsx("span",{style:{fontSize:9,padding:"2px 8px",borderRadius:4,background:"#4caf5020",color:"#4caf50",border:"1px solid #4caf5033",fontFamily:"monospace",fontWeight:600,letterSpacing:1},children:"FREE"})]}),r.jsx(Dd,{pillarKey:"hook",pillar:u.pillar_scores.hook})]}),u.rewrites&&u.rewrites.length>0&&r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,margin:0},children:"Best Hook Rewrite"}),r.jsx("span",{style:{fontSize:9,padding:"2px 8px",borderRadius:4,background:"#4caf5020",color:"#4caf50",border:"1px solid #4caf5033",fontFamily:"monospace",fontWeight:600,letterSpacing:1},children:"FREE"})]}),r.jsxs("div",{style:{padding:14,borderRadius:8,background:"#0d0d1a",border:"1px solid #1a1a2e"},children:[r.jsx("div",{style:{fontSize:10,color:Ae,fontWeight:700,marginBottom:8,textTransform:"uppercase",letterSpacing:1},children:u.rewrites[0].label}),r.jsx("p",{style:{color:"#ddd",fontSize:13,margin:"0 0 8px",lineHeight:1.6,whiteSpace:"pre-line"},children:u.rewrites[0].text}),r.jsx("p",{style:{color:"#666",fontSize:11,margin:0,fontStyle:"italic"},children:u.rewrites[0].why_better})]})]}),r.jsx(rr,{tool:"thread-grader",score:u.total_score}),r.jsxs(cn,{accentColor:Ae,label:"Full Thread Analysis",children:[r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:16},children:"Full Pillar Breakdown"}),Object.entries(u.pillar_scores).map(([x,B])=>r.jsx(Dd,{pillarKey:x,pillar:B},x))]}),u.tweet_breakdown&&u.tweet_breakdown.length>0&&r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Tweet-by-Tweet Breakdown"}),r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[r.jsx("thead",{children:r.jsx("tr",{style:{borderBottom:"1px solid #1a1a2e"},children:["#","Preview","Score","Note"].map(x=>r.jsx("th",{style:{padding:"6px 8px",textAlign:"left",color:"#555",fontWeight:600,fontSize:10,textTransform:"uppercase",letterSpacing:1},children:x},x))})}),r.jsx("tbody",{children:u.tweet_breakdown.map((x,B)=>{const C=x.score>=8?"#4caf50":x.score>=5?"#ffd54f":"#ef5350";return r.jsxs("tr",{style:{borderBottom:"1px solid #0d0d1a"},children:[r.jsx("td",{style:{padding:"8px",color:"#555",fontFamily:"monospace",fontWeight:700},children:x.tweet_index}),r.jsx("td",{style:{padding:"8px",color:"#aaa",maxWidth:200},children:r.jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.text_preview})}),r.jsxs("td",{style:{padding:"8px",color:C,fontWeight:700},children:[x.score,"/10"]}),r.jsx("td",{style:{padding:"8px",color:"#777",fontSize:11},children:x.note})]},B)})})]})]}),u.rewrites&&u.rewrites.length>1&&r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"All Hook Rewrites"}),u.rewrites.slice(1).map((x,B)=>r.jsxs("div",{style:{padding:14,borderRadius:8,background:"#0d0d1a",border:"1px solid #1a1a2e",marginBottom:8},children:[r.jsx("div",{style:{fontSize:10,color:Ae,fontWeight:700,marginBottom:8,textTransform:"uppercase",letterSpacing:1},children:x.label}),r.jsx("p",{style:{color:"#ddd",fontSize:13,margin:"0 0 8px",lineHeight:1.6,whiteSpace:"pre-line"},children:x.text}),r.jsx("p",{style:{color:"#666",fontSize:11,margin:0,fontStyle:"italic"},children:x.why_better})]},B))]}),u.upgrade_hook&&r.jsx("div",{style:{background:"#0a1e2e",border:"1px solid #1a3a5a",borderRadius:14,padding:16,textAlign:"center"},children:r.jsx("p",{style:{color:Ae,fontSize:12,fontWeight:500,margin:0},children:u.upgrade_hook})})]}),r.jsx(kn,{accentColor:Ae})]})]})}function Dh({onTryHybrid:l}){const[c,a]=v.useState(""),[f,u]=v.useState(""),[g,h]=v.useState(!1),[y,j]=v.useState(null),[R,w]=v.useState(null);async function T(){if(!(!c.trim()||!f.trim())){h(!0),j(null),w(null);try{const x=await fetch(`${ge}/demos/thread-grader/compare`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadA:c.trim(),threadB:f.trim()})}),B=await x.json();if(!x.ok)throw new Error(B.error||`HTTP ${x.status}`);j(B)}catch(x){w(x instanceof Error?x.message:"Comparison failed.")}finally{h(!1)}}}const _=c.trim().length>=20&&f.trim().length>=20,A=y==null?void 0:y.comparison.pillar_winners;return r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{display:"flex",gap:12,marginBottom:12},children:["A","B"].map(x=>{const B=x==="A"?c:f,C=x==="A"?a:u;return r.jsxs("div",{style:{flex:1},children:[r.jsxs("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:6},children:["Thread ",x," · ",xs(B)," tweet",xs(B)!==1?"s":""]}),r.jsx("textarea",{style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:10,padding:"10px 12px",fontSize:13,color:"#e0e0e0",resize:"none",outline:"none",fontFamily:"inherit",boxSizing:"border-box",lineHeight:1.5},rows:8,placeholder:`Thread ${x} — separate tweets with ---`,value:B,onChange:W=>C(W.target.value)})]},x)})}),r.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:20},children:r.jsx("button",{onClick:T,disabled:g||!_,style:{padding:"8px 20px",background:g||!_?"#333":Ae,color:"#fff",fontWeight:600,fontSize:13,border:"none",borderRadius:8,cursor:g||!_?"not-allowed":"pointer",opacity:g||!_?.5:1},children:g?"Comparing...":"Compare"})}),R&&r.jsx("div",{style:{background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:10,padding:12,marginBottom:16,color:"#ef5350",fontSize:12},children:R}),y&&r.jsxs("div",{children:[y.comparison.winner!=="tie"?r.jsxs("div",{style:{background:"#0d1f0d",border:"1px solid #1e4a1e",borderRadius:10,padding:"12px 20px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"center",gap:16},children:[r.jsxs("div",{style:{textAlign:"center"},children:[r.jsxs("div",{style:{color:"#4caf50",fontWeight:800,fontSize:15},children:["Thread ",y.comparison.winner," wins"]}),r.jsxs("div",{style:{color:"#2e7d32",fontSize:11,marginTop:2},children:["+",y.comparison.margin," pts"]})]}),r.jsx(Ot,{shareText:`Thread ${y.comparison.winner} won my A/B test on ThreadGrader by ${y.comparison.margin} points. Grade yours → https://contentintelligence.ai`,accentColor:"#4caf50"})]}):r.jsx("div",{style:{background:"#1a1a2e",border:"1px solid #2a2a4e",borderRadius:10,padding:"10px 16px",marginBottom:16,textAlign:"center",color:"#ffd54f",fontWeight:700,fontSize:13},children:"It's a tie — both threads score equally"}),r.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16},children:[r.jsx($d,{label:"Thread A",result:y.threadA,isWinner:y.comparison.winner==="A",isDimmed:y.comparison.winner==="B"}),r.jsx($d,{label:"Thread B",result:y.threadB,isWinner:y.comparison.winner==="B",isDimmed:y.comparison.winner==="A"})]}),A&&r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Pillar Winners"}),r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[r.jsx("thead",{children:r.jsx("tr",{style:{borderBottom:"1px solid #1a1a2e"},children:["Pillar","A Score","B Score","Winner"].map(x=>r.jsx("th",{style:{padding:"6px 8px",textAlign:"left",color:"#555",fontWeight:600,fontSize:10,textTransform:"uppercase",letterSpacing:1},children:x},x))})}),r.jsx("tbody",{children:Object.keys(Gr).map(x=>{const B=A[x],C=y.threadA.pillar_scores[x].score,W=y.threadB.pillar_scores[x].score;return r.jsxs("tr",{style:{borderBottom:"1px solid #0d0d1a"},children:[r.jsx("td",{style:{padding:"8px",color:"#aaa"},children:Gr[x]}),r.jsx("td",{style:{padding:"8px",color:B==="A"?"#4caf50":"#666",fontWeight:B==="A"?700:400},children:C}),r.jsx("td",{style:{padding:"8px",color:B==="B"?"#4caf50":"#666",fontWeight:B==="B"?700:400},children:W}),r.jsx("td",{style:{padding:"8px",color:B==="tie"?"#ffd54f":"#4caf50",fontWeight:700},children:B==="tie"?"Tie":`Thread ${B}`})]},x)})})]})]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:10},children:"Analysis"}),r.jsx("p",{style:{color:"#bbb",fontSize:13,lineHeight:1.6,margin:"0 0 10px"},children:y.comparison.verdict}),y.comparison.strategic_analysis&&r.jsxs("p",{style:{color:"#777",fontSize:12,lineHeight:1.5,margin:0,borderTop:"1px solid #1a1a2e",paddingTop:10},children:[r.jsx("span",{style:{color:Ae,fontWeight:600},children:"Next thread: "}),y.comparison.strategic_analysis]})]}),r.jsxs("div",{style:{background:"#0a1e2e",border:"1px solid #1a3a5a",borderRadius:14,padding:20},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:Ae,textTransform:"uppercase",letterSpacing:2,marginBottom:10},children:"Suggested Hybrid Hook"}),r.jsx("p",{style:{color:"#e0e0e0",fontSize:13,fontWeight:600,lineHeight:1.6,marginBottom:14},children:y.comparison.suggested_hybrid}),r.jsx("button",{onClick:()=>{const x=y.comparison.suggested_hybrid.split(" | ")[0].trim();l(x)},style:{padding:"7px 16px",background:Ae,color:"#fff",fontWeight:600,fontSize:12,border:"none",borderRadius:8,cursor:"pointer"},children:"Try this hook →"})]})]})]})}function $h(){const[l,c]=v.useState("grade"),[a,f]=v.useState("");return r.jsxs("div",{style:{padding:24,maxWidth:760,margin:"0 auto"},children:[r.jsxs("div",{style:{textAlign:"center",marginBottom:28},children:[r.jsx("div",{style:{fontSize:9,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:6,fontFamily:"monospace"},children:"ContentGrade Suite"}),r.jsxs("h1",{style:{fontSize:28,fontWeight:800,color:"#e0e0e0",letterSpacing:-.5},children:["Thread",r.jsx("span",{style:{color:Ae},children:"Grader"})]}),r.jsxs("p",{style:{color:"#777",fontSize:14,marginTop:6},children:["Paste your thread. Get a ",r.jsx("span",{style:{color:"#ccc",fontWeight:500},children:"viral potential score"})," before you post."]}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:6,marginTop:12},children:["Hook Strength (30)","Tension Chain (25)","Payoff (25)","Share Trigger (20)"].map(u=>r.jsx("span",{style:{fontSize:10,padding:"3px 10px",borderRadius:12,background:"#12121f",color:"#666",border:"1px solid #1a1a2e"},children:u},u))})]}),r.jsxs("div",{style:{display:"flex",gap:4,background:"#12121f",border:"1px solid #1a1a2e",borderRadius:10,padding:4,marginBottom:24,width:"fit-content"},children:[r.jsx("button",{onClick:()=>c("grade"),style:{padding:"7px 18px",borderRadius:8,border:"none",cursor:"pointer",fontSize:12,fontWeight:600,background:l==="grade"?Ae:"transparent",color:l==="grade"?"#fff":"#666",transition:"background 0.2s, color 0.2s"},children:"Grade Thread"}),r.jsxs("button",{onClick:()=>c("compare"),style:{padding:"7px 18px",borderRadius:8,border:"none",cursor:"pointer",fontSize:12,fontWeight:600,background:l==="compare"?"#0a1e2e":"transparent",color:l==="compare"?Ae:"#444",transition:"background 0.2s, color 0.2s",display:"flex",alignItems:"center",gap:6},children:["A/B Compare",r.jsx("span",{style:{fontSize:8,padding:"1px 6px",borderRadius:4,background:`${Ae}22`,color:Ae,border:`1px solid ${Ae}33`,fontFamily:"monospace",fontWeight:700,letterSpacing:.5},children:"PRO"})]})]}),l==="grade"&&r.jsx(Mh,{threadText:a,setThreadText:f}),l==="compare"&&r.jsx("div",{children:r.jsx(cn,{accentColor:Ae,label:"A/B Compare Mode",children:r.jsx(Dh,{onTryHybrid:u=>{f(u),c("grade")}})})}),r.jsx("div",{style:{marginTop:40,textAlign:"center",fontSize:10,color:"#333"},children:"Viral thread scoring using Hook · Tension · Payoff · Share frameworks · Powered by local Claude session"})]})}const Ye="#10b981",vs={"A+":"#4caf50",A:"#4caf50","A-":"#4caf50","B+":"#4a90d9",B:"#4a90d9","B-":"#4a90d9","C+":"#ffd54f",C:"#ffd54f","C-":"#ffd54f",D:"#ff9800",F:"#ef5350"},Uh={AIDA:"#7c4dff",PAS:"#ff6b35","Hormozi Value Equation":"#10b981","Cialdini Reciprocity":"#4a90d9","Storytelling Arc":"#ffd54f"};function Ss(l){for(const[c,a]of Object.entries(Uh))if(l.toLowerCase().includes(c.toLowerCase().split(" ")[0].toLowerCase()))return a;return Ye}function Ud({email:l,locked:c}){const[a,f]=v.useState(!c&&l.position===1),u=Ss(l.framework_used);return r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:12,marginBottom:10,overflow:"hidden"},children:[r.jsxs("div",{onClick:()=>!c&&f(h=>!h),style:{padding:"14px 16px",display:"flex",alignItems:"center",gap:10,cursor:c?"default":"pointer"},children:[r.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:Ye+"22",border:`1px solid ${Ye}44`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,fontSize:11,fontWeight:800,color:Ye,fontFamily:"monospace"},children:l.position}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#e0e0e0",marginBottom:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.subject_line}),r.jsx("div",{style:{fontSize:10,color:"#555",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.preview_text})]}),r.jsx("span",{style:{fontSize:9,padding:"2px 8px",borderRadius:4,background:u+"20",color:u,border:`1px solid ${u}44`,fontFamily:"monospace",fontWeight:700,letterSpacing:.5,flexShrink:0,whiteSpace:"nowrap"},children:l.framework_used.split(" ")[0].toUpperCase()}),!c&&r.jsx("div",{style:{color:"#444",fontSize:14,flexShrink:0},children:a?"▲":"▼"})]}),a&&!c&&r.jsx("div",{style:{padding:"0 16px 16px",borderTop:"1px solid #1a1a2e"},children:r.jsxs("div",{style:{paddingTop:14},children:[r.jsxs("div",{style:{background:u+"0d",border:`1px solid ${u}22`,borderRadius:8,padding:"8px 12px",marginBottom:14,fontSize:11,color:u,lineHeight:1.5},children:[r.jsxs("span",{style:{fontWeight:700},children:[l.framework_used,":"]})," ",l.framework_explanation]}),r.jsx("div",{style:{fontSize:13,color:"#ccc",lineHeight:1.7,marginBottom:14,whiteSpace:"pre-line",padding:"12px 14px",background:"#0d0d1a",borderRadius:8,border:"1px solid #1a1a2e"},children:l.body}),r.jsxs("div",{style:{marginBottom:14},children:[r.jsx("div",{style:{fontSize:10,color:"#555",marginBottom:6,textTransform:"uppercase",letterSpacing:1},children:"CTA Button"}),r.jsx("div",{style:{display:"inline-block",padding:"8px 20px",borderRadius:8,background:Ye,color:"#000",fontWeight:700,fontSize:12},children:l.cta})]}),r.jsxs("div",{style:{display:"flex",gap:12},children:[r.jsxs("div",{style:{flex:1,padding:"10px 14px",borderRadius:8,background:"#0d0d1a",border:"1px solid #1a1a2e",textAlign:"center"},children:[r.jsx("div",{style:{fontSize:16,fontWeight:800,color:"#4caf50"},children:l.estimated_open_rate}),r.jsx("div",{style:{fontSize:9,color:"#555",marginTop:2,textTransform:"uppercase",letterSpacing:1},children:"Est. Open Rate"})]}),r.jsxs("div",{style:{flex:1,padding:"10px 14px",borderRadius:8,background:"#0d0d1a",border:"1px solid #1a1a2e",textAlign:"center"},children:[r.jsx("div",{style:{fontSize:16,fontWeight:800,color:Ye},children:l.estimated_click_rate}),r.jsx("div",{style:{fontSize:9,color:"#555",marginTop:2,textTransform:"uppercase",letterSpacing:1},children:"Est. Click Rate"})]})]})]})})]})}function Hh({result:l}){const c=vs[l.grade]??"#777";return r.jsxs("div",{children:[r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:24,marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:12},children:[r.jsx("span",{style:{fontSize:52,fontWeight:900,color:"#fff"},children:l.overall_score}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:28,fontWeight:900,color:c},children:l.grade}),r.jsx("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"Sequence Score"})]})]}),r.jsxs("p",{style:{color:Ye,fontSize:13,fontWeight:500,fontStyle:"italic",margin:0},children:['"',l.sequence_strategy,'"']})]}),r.jsxs("div",{style:{marginBottom:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:6},children:[r.jsx("span",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"Email 1 — Hook"}),r.jsx("span",{style:{fontSize:9,padding:"2px 8px",borderRadius:4,background:"#4caf5020",color:"#4caf50",border:"1px solid #4caf5033",fontFamily:"monospace",fontWeight:600,letterSpacing:1},children:"FREE"})]}),r.jsx(Ud,{email:l.emails[0],locked:!1})]}),r.jsx(rr,{tool:"email-forge",score:l.overall_score,accentColor:Ye}),r.jsxs("div",{style:{marginTop:10},children:[r.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:6},children:r.jsx("span",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"Emails 2–5 — Build · Value · Urgency · Close"})}),l.emails.slice(1).map(a=>r.jsx(Ud,{email:a,locked:!1},a.position))]}),r.jsx(kn,{accentColor:Ye})]})}function Vh(){const[l,c]=v.useState(""),[a,f]=v.useState(""),[u,g]=v.useState("cold_outreach"),[h,y]=v.useState("professional"),[j,R]=v.useState(!1),[w,T]=v.useState(null),[_,A]=v.useState(null),x=l.trim().length>=10&&a.trim().length>=5;async function B(){if(x){R(!0),T(null),A(null);try{const W=await fetch(`${ge}/demos/email-forge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({product:l.trim(),audience:a.trim(),goal:u,tone:h})}),P=await W.json();if(!W.ok)throw new Error(P.error||`HTTP ${W.status}`);T(P)}catch(W){A(W instanceof Error?W.message:"Generation failed.")}finally{R(!1)}}}const C={background:"#12121f",border:"1px solid #1a1a2e",borderRadius:8,padding:"10px 12px",fontSize:13,color:"#e0e0e0",outline:"none",fontFamily:"inherit",width:"100%",appearance:"none",cursor:"pointer"};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{marginBottom:20},children:[r.jsxs("div",{style:{marginBottom:12},children:[r.jsx("label",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:1.5,display:"block",marginBottom:6},children:"Product / Service"}),r.jsx("textarea",{style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:8,padding:"10px 12px",fontSize:13,color:"#e0e0e0",resize:"vertical",outline:"none",fontFamily:"inherit",boxSizing:"border-box",lineHeight:1.6},rows:3,placeholder:"e.g. A SaaS tool that automates customer onboarding emails, cutting setup time from 2 hours to 5 minutes",value:l,onChange:W=>c(W.target.value)})]}),r.jsxs("div",{style:{marginBottom:12},children:[r.jsx("label",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:1.5,display:"block",marginBottom:6},children:"Target Audience"}),r.jsx("input",{type:"text",style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:8,padding:"10px 12px",fontSize:13,color:"#e0e0e0",outline:"none",fontFamily:"inherit",boxSizing:"border-box"},placeholder:"e.g. B2B SaaS founders with 10-50 person teams",value:a,onChange:W=>f(W.target.value)})]}),r.jsxs("div",{style:{display:"flex",gap:12,marginBottom:12},children:[r.jsxs("div",{style:{flex:1},children:[r.jsx("label",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:1.5,display:"block",marginBottom:6},children:"Goal"}),r.jsxs("select",{style:C,value:u,onChange:W=>g(W.target.value),children:[r.jsx("option",{value:"cold_outreach",children:"Cold Outreach"}),r.jsx("option",{value:"nurture",children:"Nurture Sequence"}),r.jsx("option",{value:"launch",children:"Product Launch"}),r.jsx("option",{value:"re-engagement",children:"Re-engagement"})]})]}),r.jsxs("div",{style:{flex:1},children:[r.jsx("label",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:1.5,display:"block",marginBottom:6},children:"Tone"}),r.jsxs("select",{style:C,value:h,onChange:W=>y(W.target.value),children:[r.jsx("option",{value:"professional",children:"Professional"}),r.jsx("option",{value:"casual",children:"Casual"}),r.jsx("option",{value:"urgent",children:"Urgent"}),r.jsx("option",{value:"storytelling",children:"Storytelling"})]})]})]}),r.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:r.jsx("button",{onClick:B,disabled:j||!x,style:{padding:"10px 24px",background:j||!x?"#333":Ye,color:j||!x?"#666":"#000",fontWeight:700,fontSize:13,border:"none",borderRadius:8,cursor:j||!x?"not-allowed":"pointer",opacity:j||!x?.6:1},children:j?"Generating...":"Generate Sequence →"})})]}),_&&r.jsx("div",{style:{background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:10,padding:12,marginBottom:16,color:"#ef5350",fontSize:12},children:_}),w&&r.jsx(Hh,{result:w})]})}function Gh(){const[l,c]=v.useState(""),[a,f]=v.useState(""),[u,g]=v.useState("cold_outreach"),[h,y]=v.useState("professional"),[j,R]=v.useState(""),[w,T]=v.useState(""),[_,A]=v.useState("cold_outreach"),[x,B]=v.useState("professional"),[C,W]=v.useState(!1),[P,Q]=v.useState(null),[F,ie]=v.useState(null),[re,fe]=v.useState(null),[je,Le]=v.useState(null),xe=l.trim().length>=10&&a.trim().length>=5&&j.trim().length>=10&&w.trim().length>=5;async function Ue(){if(xe){W(!0),Q(null),ie(null);try{const X=await fetch(`${ge}/demos/email-forge/compare`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({product_a:l.trim(),audience_a:a.trim(),goal_a:u,tone_a:h,product_b:j.trim(),audience_b:w.trim(),goal_b:_,tone_b:x})}),K=await X.json();if(!X.ok)throw new Error(K.error||`HTTP ${X.status}`);Q(K)}catch(X){ie(X instanceof Error?X.message:"Comparison failed.")}finally{W(!1)}}}const Fe={background:"#12121f",border:"1px solid #1a1a2e",borderRadius:6,padding:"6px 8px",fontSize:11,color:"#ccc",outline:"none",fontFamily:"inherit",width:"100%",appearance:"none"};function Te({label:X,product:K,setProduct:se,audience:ce,setAudience:D,goal:J,setGoal:$,tone:k,setTone:L}){return r.jsxs("div",{style:{flex:1},children:[r.jsxs("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:8},children:["Sequence ",X]}),r.jsx("textarea",{style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:8,padding:"8px 10px",fontSize:12,color:"#e0e0e0",resize:"none",outline:"none",fontFamily:"inherit",boxSizing:"border-box",lineHeight:1.5},rows:4,placeholder:"Product/service description",value:K,onChange:te=>se(te.target.value)}),r.jsx("input",{type:"text",style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:8,padding:"7px 10px",fontSize:12,color:"#e0e0e0",marginTop:6,outline:"none",fontFamily:"inherit",boxSizing:"border-box"},placeholder:"Target audience",value:ce,onChange:te=>D(te.target.value)}),r.jsxs("div",{style:{display:"flex",gap:6,marginTop:6},children:[r.jsxs("select",{style:Fe,value:J,onChange:te=>$(te.target.value),children:[r.jsx("option",{value:"cold_outreach",children:"Cold Outreach"}),r.jsx("option",{value:"nurture",children:"Nurture"}),r.jsx("option",{value:"launch",children:"Launch"}),r.jsx("option",{value:"re-engagement",children:"Re-engage"})]}),r.jsxs("select",{style:Fe,value:k,onChange:te=>L(te.target.value),children:[r.jsx("option",{value:"professional",children:"Professional"}),r.jsx("option",{value:"casual",children:"Casual"}),r.jsx("option",{value:"urgent",children:"Urgent"}),r.jsx("option",{value:"storytelling",children:"Story"})]})]})]})}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",gap:12,marginBottom:12},children:[r.jsx(Te,{label:"A",product:l,setProduct:c,audience:a,setAudience:f,goal:u,setGoal:g,tone:h,setTone:y}),r.jsx(Te,{label:"B",product:j,setProduct:R,audience:w,setAudience:T,goal:_,setGoal:A,tone:x,setTone:B})]}),r.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:20},children:r.jsx("button",{onClick:Ue,disabled:C||!xe,style:{padding:"8px 20px",background:C||!xe?"#333":Ye,color:C||!xe?"#666":"#000",fontWeight:700,fontSize:13,border:"none",borderRadius:8,cursor:C||!xe?"not-allowed":"pointer",opacity:C||!xe?.6:1},children:C?"Comparing...":"Compare Sequences"})}),F&&r.jsx("div",{style:{background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:10,padding:12,marginBottom:16,color:"#ef5350",fontSize:12},children:F}),P&&r.jsxs("div",{children:[r.jsxs("div",{style:{background:"#0d1f0d",border:"1px solid #1e4a1e",borderRadius:10,padding:"14px 20px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsxs("div",{children:[r.jsxs("div",{style:{color:"#4caf50",fontWeight:800,fontSize:15},children:["Sequence ",P.comparison.winner," wins"]}),r.jsxs("div",{style:{color:"#2e7d32",fontSize:11,marginTop:2},children:["+",P.comparison.margin," pts · ",P.comparison.reasoning]})]}),r.jsx("div",{style:{textAlign:"right"},children:r.jsxs("div",{style:{fontSize:22,fontWeight:900,color:"#fff"},children:[P.comparison.winner==="A"?P.sequence_a.overall_score:P.sequence_b.overall_score,r.jsx("span",{style:{fontSize:12,color:"#555",marginLeft:4},children:"vs"}),P.comparison.winner==="A"?P.sequence_b.overall_score:P.sequence_a.overall_score]})})]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Email-by-Email Breakdown"}),r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[r.jsx("thead",{children:r.jsx("tr",{style:{borderBottom:"1px solid #1a1a2e"},children:["Email","Subject A","Subject B","Winner","Reason"].map(X=>r.jsx("th",{style:{padding:"6px 8px",textAlign:"left",color:"#555",fontWeight:600,fontSize:10,textTransform:"uppercase",letterSpacing:1},children:X},X))})}),r.jsx("tbody",{children:P.comparison.per_email_comparison.map(X=>{const K=P.sequence_a.emails.find(ce=>ce.position===X.position),se=P.sequence_b.emails.find(ce=>ce.position===X.position);return r.jsxs("tr",{style:{borderBottom:"1px solid #0d0d1a"},children:[r.jsx("td",{style:{padding:"8px",color:"#555",fontFamily:"monospace",fontWeight:700},children:X.position}),r.jsx("td",{style:{padding:"8px",color:X.winner==="A"?"#4caf50":"#555",fontSize:11,maxWidth:150},children:r.jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(K==null?void 0:K.subject_line)??"—"})}),r.jsx("td",{style:{padding:"8px",color:X.winner==="B"?"#4caf50":"#555",fontSize:11,maxWidth:150},children:r.jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(se==null?void 0:se.subject_line)??"—"})}),r.jsxs("td",{style:{padding:"8px",color:"#4caf50",fontWeight:700},children:["Seq ",X.winner]}),r.jsx("td",{style:{padding:"8px",color:"#777",fontSize:11},children:X.reason})]},X.position)})})]})]}),r.jsxs("div",{style:{background:P.comparison.winner==="A"?"#0a1e0a":"#12121f",border:`1px solid ${P.comparison.winner==="A"?"#1e4a1e":"#1a1a2e"}`,borderRadius:14,padding:16,marginBottom:12},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[r.jsx("span",{style:{fontSize:11,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"Sequence A"}),P.comparison.winner==="A"&&r.jsx("span",{style:{fontSize:9,padding:"2px 7px",borderRadius:4,background:"#4caf5020",color:"#4caf50",border:"1px solid #4caf5033",fontFamily:"monospace",fontWeight:700},children:"WINNER"}),r.jsx("span",{style:{marginLeft:"auto",fontSize:20,fontWeight:900,color:"#fff"},children:P.sequence_a.overall_score}),r.jsx("span",{style:{fontSize:14,fontWeight:900,color:vs[P.sequence_a.grade]??"#777"},children:P.sequence_a.grade})]}),P.sequence_a.emails.map(X=>{const K=Ss(X.framework_used);return r.jsxs("div",{onClick:()=>fe(re===X.position?null:X.position),style:{padding:"8px 12px",marginBottom:6,background:"#0d0d1a",border:"1px solid #1a1a2e",borderRadius:8,cursor:"pointer",display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{fontSize:10,color:Ye,fontFamily:"monospace",fontWeight:700,width:16},children:X.position}),r.jsx("span",{style:{flex:1,fontSize:12,color:"#ccc",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:X.subject_line}),r.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:3,background:K+"20",color:K,border:`1px solid ${K}33`,fontFamily:"monospace",flexShrink:0},children:X.framework_used.split(" ")[0]})]},X.position)})]}),r.jsxs("div",{style:{background:P.comparison.winner==="B"?"#0a1e0a":"#12121f",border:`1px solid ${P.comparison.winner==="B"?"#1e4a1e":"#1a1a2e"}`,borderRadius:14,padding:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[r.jsx("span",{style:{fontSize:11,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"Sequence B"}),P.comparison.winner==="B"&&r.jsx("span",{style:{fontSize:9,padding:"2px 7px",borderRadius:4,background:"#4caf5020",color:"#4caf50",border:"1px solid #4caf5033",fontFamily:"monospace",fontWeight:700},children:"WINNER"}),r.jsx("span",{style:{marginLeft:"auto",fontSize:20,fontWeight:900,color:"#fff"},children:P.sequence_b.overall_score}),r.jsx("span",{style:{fontSize:14,fontWeight:900,color:vs[P.sequence_b.grade]??"#777"},children:P.sequence_b.grade})]}),P.sequence_b.emails.map(X=>{const K=Ss(X.framework_used);return r.jsxs("div",{onClick:()=>Le(je===X.position?null:X.position),style:{padding:"8px 12px",marginBottom:6,background:"#0d0d1a",border:"1px solid #1a1a2e",borderRadius:8,cursor:"pointer",display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{fontSize:10,color:Ye,fontFamily:"monospace",fontWeight:700,width:16},children:X.position}),r.jsx("span",{style:{flex:1,fontSize:12,color:"#ccc",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:X.subject_line}),r.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:3,background:K+"20",color:K,border:`1px solid ${K}33`,fontFamily:"monospace",flexShrink:0},children:X.framework_used.split(" ")[0]})]},X.position)})]})]})]})}function Qh(){const[l,c]=v.useState("generate");return r.jsxs("div",{style:{padding:24,maxWidth:760,margin:"0 auto"},children:[r.jsxs("div",{style:{textAlign:"center",marginBottom:28},children:[r.jsx("div",{style:{fontSize:9,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:6,fontFamily:"monospace"},children:"ContentGrade Suite — Generate"}),r.jsxs("h1",{style:{fontSize:28,fontWeight:800,color:"#e0e0e0",letterSpacing:-.5},children:["Email",r.jsx("span",{style:{color:Ye},children:"Forge"})]}),r.jsxs("p",{style:{color:"#777",fontSize:14,marginTop:6},children:["Input your product and audience. Get a ",r.jsx("span",{style:{color:"#ccc",fontWeight:500},children:"5-email conversion sequence"})," using proven frameworks."]}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:6,marginTop:12},children:["AIDA","PAS","Hormozi","Cialdini","Storytelling Arc"].map(a=>r.jsx("span",{style:{fontSize:10,padding:"3px 10px",borderRadius:12,background:"#12121f",color:"#666",border:"1px solid #1a1a2e"},children:a},a))})]}),r.jsxs("div",{style:{display:"flex",gap:4,background:"#12121f",border:"1px solid #1a1a2e",borderRadius:10,padding:4,marginBottom:24,width:"fit-content"},children:[r.jsx("button",{onClick:()=>c("generate"),style:{padding:"7px 18px",borderRadius:8,border:"none",cursor:"pointer",fontSize:12,fontWeight:600,background:l==="generate"?Ye:"transparent",color:l==="generate"?"#000":"#666",transition:"background 0.2s, color 0.2s"},children:"Generate"}),r.jsx("button",{onClick:()=>c("compare"),style:{padding:"7px 18px",borderRadius:8,border:"none",cursor:"pointer",fontSize:12,fontWeight:600,background:l==="compare"?"#0a1e2e":"transparent",color:l==="compare"?Ye:"#444",transition:"background 0.2s, color 0.2s"},children:"A/B Compare"})]}),l==="generate"&&r.jsx(Vh,{}),l==="compare"&&r.jsx(Gh,{}),r.jsx("div",{style:{marginTop:40,textAlign:"center",fontSize:10,color:"#333"},children:"Email sequence generation using AIDA · PAS · Hormozi · Cialdini · Storytelling frameworks · Powered by local Claude session"})]})}const Ce="#00c853",du={A:"#4caf50",B:"#4a90d9",C:"#ffd54f",D:"#ff9800",F:"#ef5350"},us={high:"#4caf50",medium:"#ffd54f",low:"#ef5350"},fs={low:"#4caf50",medium:"#ffd54f",high:"#ef5350"};function ii({label:l,score:c}){const a=c>=75?"#4caf50":c>=50?"#ffd54f":"#ef5350";return r.jsxs("div",{style:{textAlign:"center"},children:[r.jsx("div",{style:{fontSize:22,fontWeight:900,color:a},children:c}),r.jsx("div",{style:{fontSize:10,color:"#555",marginTop:2},children:l})]})}function Kh({archetype:l}){var c;return r.jsxs("div",{style:{background:"#0d0d1a",border:"1px solid #1a1a2e",borderRadius:10,padding:16,marginBottom:10},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[r.jsx("div",{style:{flex:1},children:r.jsx("span",{style:{fontSize:13,fontWeight:700,color:Ce},children:l.name})}),r.jsxs("span",{style:{fontSize:18,fontWeight:900,color:"#e0e0e0"},children:[l.percentage,"%"]})]}),r.jsx("div",{style:{height:4,background:"#1a1a2e",borderRadius:2,marginBottom:10,overflow:"hidden"},children:r.jsx("div",{style:{height:"100%",background:Ce,borderRadius:2,width:`${l.percentage}%`}})}),r.jsx("p",{style:{fontSize:12,color:"#aaa",lineHeight:1.5,margin:"0 0 8px"},children:l.description}),((c=l.evidence)==null?void 0:c.length)>0&&r.jsxs("div",{style:{fontSize:10,color:"#555",fontStyle:"italic",borderLeft:`2px solid ${Ce}44`,paddingLeft:8},children:['"',l.evidence[0],'"']})]})}function qh(){var T,_,A,x,B,C,W,P,Q,F,ie,re,fe,je,Le,xe,Ue,Fe,Te,X,K,se,ce,D,J,$,k,L,te,le;const[l,c]=v.useState(""),[a,f]=v.useState(!1),[u,g]=v.useState(null),[h,y]=v.useState(null);async function j(){if(!(l.trim().length<50)){f(!0),g(null),y(null);try{const H=await fetch(`${ge}/demos/audience-decoder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:l.trim()})}),ne=await H.json();if(!H.ok)throw new Error(ne.error||`HTTP ${H.status}`);g(ne)}catch(H){y(H instanceof Error?H.message:"Analysis failed.")}finally{f(!1)}}}const R=u?du[((T=u.grade)==null?void 0:T[0])??""]??"#777":"#777",w=l.trim().length>=50;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{marginBottom:20},children:[r.jsx("textarea",{style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:10,padding:"12px 14px",fontSize:14,color:"#e0e0e0",resize:"vertical",outline:"none",fontFamily:"inherit",boxSizing:"border-box",minHeight:180},rows:8,placeholder:"Paste your last 10-20 tweets, threads, or posts — one per line or separated by ---",value:l,onChange:H=>c(H.target.value)}),r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:8},children:[r.jsxs("span",{style:{fontSize:10,color:"#444"},children:[l.length," chars · minimum 50 chars"]}),r.jsx("button",{onClick:j,disabled:a||!w,style:{padding:"9px 22px",background:a||!w?"#333":Ce,color:"#000",fontWeight:700,fontSize:13,border:"none",borderRadius:8,cursor:a||!w?"not-allowed":"pointer",opacity:a||!w?.5:1},children:a?"Decoding...":"Decode My Audience"})]})]}),h&&r.jsx("div",{style:{background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:10,padding:12,marginBottom:16,color:"#ef5350",fontSize:12},children:h}),u&&r.jsxs("div",{children:[r.jsxs("div",{style:{background:"#12121f",border:`1px solid ${Ce}44`,borderRadius:14,padding:24,textAlign:"center",marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,marginBottom:12},children:[r.jsx("span",{style:{fontSize:56,fontWeight:900,color:"#fff"},children:u.overall_score}),r.jsxs("div",{style:{textAlign:"left"},children:[r.jsx("div",{style:{fontSize:32,fontWeight:900,color:R},children:u.grade}),r.jsx("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2},children:"/ 100"})]})]}),r.jsx("p",{style:{color:Ce,fontSize:15,fontWeight:600,maxWidth:480,margin:"0 auto 14px",lineHeight:1.4},children:u.headline}),r.jsx(Ot,{shareText:`My audience decoded: ${u.headline} — Analyzed free on AudienceDecoder`,accentColor:Ce})]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:14},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,margin:0},children:"Audience Archetypes"}),r.jsx("span",{style:{fontSize:9,padding:"2px 8px",borderRadius:4,background:"#4caf5020",color:"#4caf50",border:"1px solid #4caf5033",fontFamily:"monospace",fontWeight:600,letterSpacing:1},children:"FREE"})]}),(_=u.audience_archetypes)==null?void 0:_.map((H,ne)=>r.jsx(Kh,{archetype:H},ne))]}),r.jsx(rr,{tool:"audience-decoder",score:u.overall_score,accentColor:Ce}),r.jsxs(cn,{accentColor:Ce,label:"Full Audience Intelligence Report",priceLabel:"Unlock Deep Report — $49",children:[r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:16},children:"Engagement Model"}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:16},children:[r.jsx(ii,{label:"Hook Effectiveness",score:((x=(A=u.engagement_model)==null?void 0:A.hook_effectiveness)==null?void 0:x.score)??0}),r.jsx(ii,{label:"CTA Effectiveness",score:((C=(B=u.engagement_model)==null?void 0:B.cta_effectiveness)==null?void 0:C.score)??0}),r.jsx(ii,{label:"Controversy Index",score:((P=(W=u.engagement_model)==null?void 0:W.controversy_index)==null?void 0:P.score)??0}),r.jsx(ii,{label:"Shareability",score:((Q=u.engagement_model)==null?void 0:Q.shareability_score)??0})]}),((ie=(F=u.engagement_model)==null?void 0:F.cta_effectiveness)==null?void 0:ie.recommendation)&&r.jsxs("div",{style:{background:"#0d0d1a",borderRadius:8,padding:12},children:[r.jsx("span",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:1},children:"CTA Recommendation: "}),r.jsx("span",{style:{fontSize:12,color:"#aaa"},children:u.engagement_model.cta_effectiveness.recommendation})]})]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Content Patterns"}),r.jsxs("div",{style:{display:"flex",gap:12,marginBottom:14},children:[r.jsxs("div",{style:{flex:1,background:"#0d1f0d",border:"1px solid #1e4a1e",borderRadius:8,padding:12},children:[r.jsx("div",{style:{fontSize:10,color:"#2e7d32",textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Working Well"}),(fe=(re=u.content_patterns)==null?void 0:re.top_performing_themes)==null?void 0:fe.map((H,ne)=>r.jsxs("div",{style:{fontSize:12,color:"#aaa",marginBottom:4},children:[r.jsx("span",{style:{color:"#4caf50",fontWeight:600},children:H.theme}),r.jsxs("span",{style:{color:"#555"},children:[" · ",H.frequency,"x · ",H.avg_engagement_signal]})]},ne))]}),r.jsxs("div",{style:{flex:1,background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:8,padding:12},children:[r.jsx("div",{style:{fontSize:10,color:"#c62828",textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Underperforming"}),(Le=(je=u.content_patterns)==null?void 0:je.underperforming_themes)==null?void 0:Le.map((H,ne)=>r.jsxs("div",{style:{fontSize:12,color:"#aaa",marginBottom:4},children:[r.jsx("span",{style:{color:"#ef5350",fontWeight:600},children:H.theme}),r.jsxs("span",{style:{color:"#555"},children:[" · ",H.frequency,"x · ",H.avg_engagement_signal]})]},ne))]})]}),r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsxs("div",{style:{background:"#0d0d1a",borderRadius:8,padding:"8px 12px",fontSize:11,color:"#aaa"},children:[r.jsx("span",{style:{color:"#555"},children:"Best format: "}),r.jsx("span",{style:{color:Ce,fontWeight:600},children:(xe=u.content_patterns)==null?void 0:xe.optimal_format})]}),r.jsxs("div",{style:{background:"#0d0d1a",borderRadius:8,padding:"8px 12px",fontSize:11,color:"#aaa"},children:[r.jsx("span",{style:{color:"#555"},children:"Best length: "}),r.jsx("span",{style:{color:Ce,fontWeight:600},children:(Ue=u.content_patterns)==null?void 0:Ue.optimal_length})]}),r.jsxs("div",{style:{background:"#0d0d1a",borderRadius:8,padding:"8px 12px",fontSize:11,color:"#aaa"},children:[r.jsx("span",{style:{color:"#555"},children:"Tone: "}),r.jsx("span",{style:{color:"#ccc"},children:(Te=(Fe=u.content_patterns)==null?void 0:Fe.voice_analysis)==null?void 0:Te.tone})]})]})]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Growth Opportunities"}),(X=u.growth_opportunities)==null?void 0:X.map((H,ne)=>r.jsxs("div",{style:{background:"#0d0d1a",border:"1px solid #1a1a2e",borderRadius:8,padding:14,marginBottom:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,marginBottom:6},children:[r.jsxs("span",{style:{fontSize:10,color:"#555",fontFamily:"monospace",flexShrink:0,marginTop:2},children:["#",ne+1]}),r.jsx("div",{style:{flex:1,fontSize:13,color:"#e0e0e0",fontWeight:600},children:H.opportunity}),r.jsxs("div",{style:{display:"flex",gap:4,flexShrink:0},children:[r.jsxs("span",{style:{fontSize:9,padding:"2px 7px",borderRadius:4,background:us[H.impact]+"20",color:us[H.impact],border:`1px solid ${us[H.impact]}44`,fontWeight:700},children:[H.impact," impact"]}),r.jsxs("span",{style:{fontSize:9,padding:"2px 7px",borderRadius:4,background:fs[H.effort]+"20",color:fs[H.effort],border:`1px solid ${fs[H.effort]}44`,fontWeight:700},children:[H.effort," effort"]})]})]}),r.jsx("p",{style:{fontSize:11,color:"#666",margin:0,lineHeight:1.5},children:H.explanation})]},ne))]}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:0},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Content Calendar"}),r.jsx("div",{style:{display:"flex",gap:10,marginBottom:14},children:[{label:"Threads/week",val:(se=(K=u.content_calendar)==null?void 0:K.weekly_mix)==null?void 0:se.threads},{label:"Posts/week",val:(D=(ce=u.content_calendar)==null?void 0:ce.weekly_mix)==null?void 0:D.single_posts},{label:"Questions/week",val:($=(J=u.content_calendar)==null?void 0:J.weekly_mix)==null?void 0:$.questions}].map(({label:H,val:ne})=>r.jsxs("div",{style:{flex:1,background:"#0d0d1a",borderRadius:8,padding:12,textAlign:"center"},children:[r.jsx("div",{style:{fontSize:22,fontWeight:900,color:Ce},children:ne??0}),r.jsx("div",{style:{fontSize:10,color:"#555",marginTop:2},children:H})]},H))}),((L=(k=u.content_calendar)==null?void 0:k.theme_rotation)==null?void 0:L.length)>0&&r.jsxs("div",{style:{marginBottom:12},children:[r.jsx("div",{style:{fontSize:10,color:"#444",textTransform:"uppercase",letterSpacing:1,marginBottom:8},children:"Theme Rotation"}),u.content_calendar.theme_rotation.map((H,ne)=>r.jsx("div",{style:{fontSize:12,color:"#aaa",marginBottom:4,paddingLeft:8,borderLeft:`2px solid ${Ce}44`},children:H},ne))]}),((le=(te=u.content_calendar)==null?void 0:te.gaps_to_fill)==null?void 0:le.length)>0&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:10,color:"#444",textTransform:"uppercase",letterSpacing:1,marginBottom:8},children:"Content Gaps to Fill"}),u.content_calendar.gaps_to_fill.map((H,ne)=>r.jsxs("div",{style:{fontSize:11,color:"#888",marginBottom:4,display:"flex",alignItems:"flex-start",gap:6},children:[r.jsx("span",{style:{color:"#ffd54f",flexShrink:0},children:"→"})," ",H]},ne))]})]})]}),r.jsx(kn,{accentColor:Ce,product:"audiencedecoder"})]})]})}function Yh(){var _,A,x,B,C;const[l,c]=v.useState(""),[a,f]=v.useState(""),[u,g]=v.useState(!1),[h,y]=v.useState(null),[j,R]=v.useState(null);async function w(){if(!(l.trim().length<50||a.trim().length<50)){g(!0),y(null),R(null);try{const W=await fetch(`${ge}/demos/audience-decoder/compare`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content_a:l.trim(),content_b:a.trim()})}),P=await W.json();if(!W.ok)throw new Error(P.error||`HTTP ${W.status}`);y(P)}catch(W){R(W instanceof Error?W.message:"Comparison failed.")}finally{g(!1)}}}const T=l.trim().length>=50&&a.trim().length>=50;return r.jsx(cn,{accentColor:Ce,label:"Profile Compare Mode",priceLabel:"Unlock Deep Report — $49",children:r.jsxs("div",{children:[r.jsx("div",{style:{display:"flex",gap:12,marginBottom:12},children:["A","B"].map(W=>{const P=W==="A"?l:a,Q=W==="A"?c:f;return r.jsxs("div",{style:{flex:1},children:[r.jsxs("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:6},children:["Creator ",W]}),r.jsx("textarea",{style:{width:"100%",background:"#12121f",border:"1px solid #1a1a2e",borderRadius:10,padding:"10px 12px",fontSize:12,color:"#e0e0e0",resize:"vertical",outline:"none",fontFamily:"inherit",boxSizing:"border-box"},rows:8,placeholder:`Paste Creator ${W}'s content...`,value:P,onChange:F=>Q(F.target.value)})]},W)})}),r.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:20},children:r.jsx("button",{onClick:w,disabled:u||!T,style:{padding:"9px 22px",background:u||!T?"#333":Ce,color:"#000",fontWeight:700,fontSize:13,border:"none",borderRadius:8,cursor:u||!T?"not-allowed":"pointer",opacity:u||!T?.5:1},children:u?"Comparing...":"Compare Profiles"})}),j&&r.jsx("div",{style:{background:"#2e1a1a",border:"1px solid #5a2a2a",borderRadius:10,padding:12,marginBottom:16,color:"#ef5350",fontSize:12},children:j}),h&&r.jsxs("div",{children:[r.jsx("div",{style:{display:"flex",gap:12,marginBottom:16},children:["A","B"].map(W=>{var F;const P=W==="A"?h.analysis_a:h.analysis_b,Q=du[((F=P==null?void 0:P.grade)==null?void 0:F[0])??""]??"#777";return r.jsxs("div",{style:{flex:1,background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:16,textAlign:"center"},children:[r.jsxs("div",{style:{fontSize:10,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:8},children:["Creator ",W]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,marginBottom:8},children:[r.jsx("span",{style:{fontSize:40,fontWeight:900,color:"#fff"},children:P==null?void 0:P.overall_score}),r.jsx("span",{style:{fontSize:22,fontWeight:900,color:Q},children:P==null?void 0:P.grade})]}),r.jsx("p",{style:{fontSize:11,color:Ce,margin:0,lineHeight:1.4},children:P==null?void 0:P.headline})]},W)})}),r.jsxs("div",{style:{background:"#12121f",border:"1px solid #1a1a2e",borderRadius:14,padding:20,marginBottom:16},children:[r.jsx("h2",{style:{fontSize:11,fontWeight:600,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:14},children:"Comparative Analysis"}),r.jsxs("div",{style:{display:"flex",gap:12,marginBottom:14},children:[r.jsxs("div",{style:{flex:1,background:"#0d0d1a",borderRadius:8,padding:12,textAlign:"center"},children:[r.jsxs("div",{style:{fontSize:22,fontWeight:900,color:"#ffd54f"},children:[(_=h.comparison)==null?void 0:_.audience_overlap,"%"]}),r.jsx("div",{style:{fontSize:10,color:"#555",marginTop:2},children:"Audience Overlap"})]}),r.jsxs("div",{style:{flex:1,background:"#0d0d1a",borderRadius:8,padding:12,textAlign:"center"},children:[r.jsx("div",{style:{fontSize:22,fontWeight:900,color:Ce},children:(A=h.comparison)==null?void 0:A.differentiation_score}),r.jsx("div",{style:{fontSize:10,color:"#555",marginTop:2},children:"Differentiation Score"})]}),r.jsxs("div",{style:{flex:1,background:"#0d0d1a",borderRadius:8,padding:12,textAlign:"center"},children:[r.jsx("div",{style:{fontSize:15,fontWeight:800,color:"#4a90d9",textTransform:"capitalize"},children:(x=h.comparison)==null?void 0:x.collaboration_potential}),r.jsx("div",{style:{fontSize:10,color:"#555",marginTop:2},children:"Collab Potential"})]})]}),((B=h.comparison)==null?void 0:B.winner_by_category)&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:10,color:"#444",textTransform:"uppercase",letterSpacing:1,marginBottom:8},children:"Category Winners"}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:Object.entries(h.comparison.winner_by_category).map(([W,P])=>r.jsxs("div",{style:{background:"#0d0d1a",border:"1px solid #1a1a2e",borderRadius:6,padding:"5px 10px",fontSize:11},children:[r.jsxs("span",{style:{color:"#666"},children:[W,": "]}),r.jsx("span",{style:{color:P==="tie"?"#ffd54f":Ce,fontWeight:700},children:P==="tie"?"Tie":`Creator ${P}`})]},W))})]}),((C=h.comparison)==null?void 0:C.strategic_advice)&&r.jsxs("div",{style:{marginTop:14,background:"#0d0d1a",borderRadius:8,padding:12},children:[r.jsx("div",{style:{fontSize:10,color:"#444",textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Strategic Advice"}),r.jsx("p",{style:{fontSize:12,color:"#aaa",margin:0,lineHeight:1.6},children:h.comparison.strategic_advice})]})]})]})]})})}function Jh(){const[l,c]=v.useState("score");return r.jsxs("div",{style:{padding:24,maxWidth:720,margin:"0 auto"},children:[r.jsxs("div",{style:{textAlign:"center",marginBottom:28},children:[r.jsx("div",{style:{fontSize:9,color:"#555",textTransform:"uppercase",letterSpacing:2,marginBottom:6,fontFamily:"monospace"},children:"Content Intelligence Stack"}),r.jsxs("h1",{style:{fontSize:28,fontWeight:800,color:"#e0e0e0",letterSpacing:-.5},children:["Audience",r.jsx("span",{style:{color:Ce},children:"Decoder"})]}),r.jsxs("p",{style:{color:"#777",fontSize:14,marginTop:6},children:["Paste your content. Discover who reads you, what resonates, and"," ",r.jsx("span",{style:{color:"#ccc",fontWeight:500},children:"exactly what to post next."})]}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:6,marginTop:12},children:["Audience Archetypes","Content Patterns","Engagement Model","Growth Opportunities","Content Calendar"].map(a=>r.jsx("span",{style:{fontSize:10,padding:"3px 10px",borderRadius:12,background:"#12121f",color:"#666",border:"1px solid #1a1a2e"},children:a},a))})]}),r.jsxs("div",{style:{display:"flex",gap:4,background:"#12121f",border:"1px solid #1a1a2e",borderRadius:10,padding:4,marginBottom:24,width:"fit-content"},children:[r.jsx("button",{onClick:()=>c("score"),style:{padding:"7px 18px",borderRadius:8,border:"none",cursor:"pointer",fontSize:12,fontWeight:600,background:l==="score"?Ce:"transparent",color:l==="score"?"#000":"#666",transition:"background 0.2s, color 0.2s"},children:"Decode"}),r.jsxs("button",{onClick:()=>c("compare"),style:{padding:"7px 18px",borderRadius:8,border:"none",cursor:"pointer",fontSize:12,fontWeight:600,background:l==="compare"?"#0a2e1a":"transparent",color:l==="compare"?"#00c853":"#444",transition:"background 0.2s, color 0.2s",display:"flex",alignItems:"center",gap:6},children:["Compare Creators",r.jsx("span",{style:{fontSize:8,padding:"1px 6px",borderRadius:4,background:Ce+"33",color:Ce,border:`1px solid ${Ce}44`,fontFamily:"monospace",fontWeight:700,letterSpacing:.5},children:"PRO"})]})]}),l==="score"&&r.jsx(qh,{}),l==="compare"&&r.jsx(Yh,{}),r.jsx("div",{style:{marginTop:40,textAlign:"center",fontSize:10,color:"#333"},children:"Audience intelligence for creators · Powered by local Claude session"})]})}function Yn({children:l,style:c}){return r.jsx("div",{style:{background:"#0d0d1a",border:"1px solid #12121f",borderRadius:12,padding:"16px 20px",...c},children:l})}function Jn({children:l}){return r.jsx("div",{style:{fontSize:10,fontWeight:800,color:"#444",textTransform:"uppercase",letterSpacing:2,fontFamily:"monospace",marginBottom:12},children:l})}function Oe({label:l,value:c,sub:a,color:f="#e0e0e0"}){return r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:11,color:"#444",marginBottom:3},children:l}),r.jsx("div",{style:{fontSize:22,fontWeight:800,color:f,fontFamily:"monospace",lineHeight:1},children:c}),a&&r.jsx("div",{style:{fontSize:10,color:"#333",marginTop:3},children:a})]})}function ps({label:l,value:c,max:a,color:f}){const u=a>0?Math.round(c/a*100):0;return r.jsxs("div",{style:{marginBottom:14},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4},children:[r.jsx("span",{style:{fontSize:11,color:"#888"},children:l}),r.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"#ccc",fontFamily:"monospace"},children:[c.toLocaleString()," ",r.jsxs("span",{style:{color:"#444"},children:["(",u,"%)"]})]})]}),r.jsx("div",{style:{height:5,background:"#1a1a2e",borderRadius:3,overflow:"hidden"},children:r.jsx("div",{style:{height:"100%",width:`${u}%`,background:f,borderRadius:3}})})]})}function Xh(){var x,B;const[l,c]=v.useState(null),[a,f]=v.useState(null),[u,g]=v.useState(!0),[h,y]=v.useState(null),[j,R]=v.useState(null),w=v.useCallback(async()=>{g(!0),y(null);try{const[C,W]=await Promise.all([fetch(`${ge}/analytics/summary`),fetch(`${ge}/analytics/npm-stats`)]);if(!C.ok)throw new Error(`Analytics summary: ${C.status}`);const P=await C.json();if(c(P),W.ok&&W.status!==204){const Q=await W.json();f(Q)}R(new Date)}catch(C){y(String(C))}finally{g(!1)}},[]);if(v.useEffect(()=>{w()},[w]),u)return r.jsx("div",{style:{padding:40,textAlign:"center",color:"#333",fontSize:12},children:"Loading metrics..."});if(h)return r.jsxs("div",{style:{padding:40,textAlign:"center"},children:[r.jsx("div",{style:{color:"#ef5350",fontSize:13,marginBottom:8},children:"Failed to load metrics"}),r.jsx("div",{style:{color:"#444",fontSize:11,fontFamily:"monospace"},children:h}),r.jsx("button",{onClick:w,style:{marginTop:16,padding:"8px 20px",background:"#1a1a2e",color:"#7c4dff",border:"1px solid #7c4dff44",borderRadius:8,cursor:"pointer",fontSize:12,fontWeight:700},children:"Retry"})]});const T=(l==null?void 0:l.funnel.free_limit_hits_30d)??0,_=(x=a==null?void 0:a.latest)==null?void 0:x.npm,A=(B=a==null?void 0:a.latest)==null?void 0:B.github;return r.jsxs("div",{style:{padding:"24px 28px",maxWidth:900,margin:"0 auto"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:28},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:18,fontWeight:800,color:"#e0e0e0"},children:"Metrics"}),r.jsx("div",{style:{fontSize:11,color:"#333",marginTop:2},children:l&&`Last 30 days · ${l.period.from} → ${l.period.to}`})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[j&&r.jsx("span",{style:{fontSize:10,color:"#333"},children:j.toLocaleTimeString()}),r.jsx("button",{onClick:w,style:{padding:"6px 14px",background:"#12121f",color:"#7c4dff",border:"1px solid #7c4dff33",borderRadius:7,cursor:"pointer",fontSize:11,fontWeight:700},children:"Refresh"})]})]}),r.jsxs(Yn,{style:{marginBottom:16},children:[r.jsx(Jn,{children:"Conversion Funnel — 30d"}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:20,marginBottom:24},children:[r.jsx(Oe,{label:"Free limit hits",value:((l==null?void 0:l.funnel.free_limit_hits_30d)??0).toLocaleString(),sub:"users reached paywall",color:"#ffd54f"}),r.jsx(Oe,{label:"Upgrade clicks",value:((l==null?void 0:l.funnel.upgrade_clicks_30d)??0).toLocaleString(),sub:"clicked Pro CTA",color:"#7c4dff"}),r.jsx(Oe,{label:"Checkouts completed",value:((l==null?void 0:l.funnel.checkout_completions_30d)??0).toLocaleString(),sub:"paid customers",color:"#4caf50"}),r.jsx(Oe,{label:"Conversion rate",value:`${(l==null?void 0:l.funnel.conversion_rate_pct)??0}%`,sub:"upgrade click → paid",color:((l==null?void 0:l.funnel.conversion_rate_pct)??0)>=5?"#4caf50":((l==null?void 0:l.funnel.conversion_rate_pct)??0)>=2?"#ffd54f":"#ef5350"})]}),r.jsx(ps,{label:"Free limit hit",value:(l==null?void 0:l.funnel.free_limit_hits_30d)??0,max:T||1,color:"#ffd54f"}),r.jsx(ps,{label:"Upgrade clicked",value:(l==null?void 0:l.funnel.upgrade_clicks_30d)??0,max:T||1,color:"#7c4dff"}),r.jsx(ps,{label:"Checkout completed",value:(l==null?void 0:l.funnel.checkout_completions_30d)??0,max:T||1,color:"#4caf50"})]}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:16},children:[r.jsxs(Yn,{children:[r.jsx(Jn,{children:"CLI Telemetry — 30d"}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:16},children:[r.jsx(Oe,{label:"Unique installs",value:((l==null?void 0:l.cli.unique_installs_30d)??0).toLocaleString()}),r.jsx(Oe,{label:"Total commands",value:((l==null?void 0:l.cli.total_commands_30d)??0).toLocaleString()}),r.jsx(Oe,{label:"Success rate",value:`${(l==null?void 0:l.cli.success_rate_pct)??0}%`,color:((l==null?void 0:l.cli.success_rate_pct)??0)>=90?"#4caf50":"#ffd54f"}),r.jsx(Oe,{label:"Avg duration",value:l!=null&&l.cli.avg_duration_ms?`${(l.cli.avg_duration_ms/1e3).toFixed(1)}s`:"—"})]}),l!=null&&l.cli.command_breakdown&&l.cli.command_breakdown.length>0?r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:10,color:"#333",marginBottom:8},children:"By command"}),l.cli.command_breakdown.map(C=>r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0",borderBottom:"1px solid #0d0d1a"},children:[r.jsx("span",{style:{fontSize:11,color:"#888",fontFamily:"monospace"},children:C.command}),r.jsxs("span",{style:{fontSize:11,color:"#ccc",fontFamily:"monospace"},children:[C.count," ",r.jsxs("span",{style:{color:"#333"},children:["(",(C.avg_ms/1e3).toFixed(1),"s avg)"]})]})]},C.command))]}):r.jsxs("div",{style:{fontSize:11,color:"#333",textAlign:"center",padding:"8px 0"},children:["No CLI events yet. Telemetry fires on first ",r.jsx("code",{style:{color:"#555"},children:"content-grade"})," run."]})]}),r.jsxs(Yn,{children:[r.jsx(Jn,{children:"Web Tools — Today"}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:16},children:[r.jsx(Oe,{label:"Requests today",value:((l==null?void 0:l.web.today.total_requests)??0).toLocaleString()}),r.jsx(Oe,{label:"Unique IPs today",value:((l==null?void 0:l.web.today.unique_ips)??0).toLocaleString()})]}),l!=null&&l.web.tool_usage_7d&&l.web.tool_usage_7d.length>0?r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:10,color:"#333",marginBottom:8},children:"By tool (7d)"}),l.web.tool_usage_7d.slice(0,6).map(C=>r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0",borderBottom:"1px solid #0d0d1a"},children:[r.jsx("span",{style:{fontSize:11,color:"#888",fontFamily:"monospace"},children:C.endpoint.replace("/api/demos/","")}),r.jsx("span",{style:{fontSize:11,color:"#ccc",fontFamily:"monospace"},children:C.total.toLocaleString()})]},C.endpoint))]}):r.jsx("div",{style:{fontSize:11,color:"#333",textAlign:"center",padding:"8px 0"},children:"No web tool usage tracked yet."}),(l==null?void 0:l.web.daily_active_users_7d)&&l.web.daily_active_users_7d.length>1&&r.jsxs("div",{style:{marginTop:16},children:[r.jsx("div",{style:{fontSize:10,color:"#333",marginBottom:8},children:"Daily unique IPs (7d)"}),r.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:3,height:32},children:[...l.web.daily_active_users_7d].reverse().map(C=>{const W=Math.max(...l.web.daily_active_users_7d.map(Q=>Q.unique_ips),1),P=Math.max(2,Math.round(C.unique_ips/W*32));return r.jsx("div",{title:`${C.date}: ${C.unique_ips} unique IPs`,style:{flex:1,height:P,background:"#7c4dff55",borderRadius:2,minWidth:8}},C.date)})})]})]})]}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:16},children:[r.jsxs(Yn,{children:[r.jsx(Jn,{children:"npm Downloads"}),_?r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:12,marginBottom:12},children:[r.jsx(Oe,{label:"This week",value:_.last_week.toLocaleString()}),r.jsx(Oe,{label:"This month",value:_.last_month.toLocaleString()}),r.jsx(Oe,{label:"All time",value:_.last_year.toLocaleString()})]}),r.jsxs("div",{style:{fontSize:10,color:"#333"},children:["Package: ",r.jsx("code",{style:{color:"#555"},children:"content-grade"}),_.status==="awaiting_first_download"&&r.jsx("span",{style:{color:"#ffd54f",marginLeft:8},children:"awaiting first download"})]})]}):r.jsxs("div",{style:{fontSize:11,color:"#333",padding:"8px 0"},children:["No npm snapshot yet. Run:"," ",r.jsx("code",{style:{color:"#555",fontSize:10},children:"npm run metrics"})]}),a&&r.jsxs("div",{style:{marginTop:12,fontSize:10,color:"#222"},children:[a.snapshot_count," snapshot",a.snapshot_count!==1?"s":""," ·"," ","last updated ",a.newest_snapshot?new Date(a.newest_snapshot).toLocaleDateString():"—"]})]}),r.jsxs(Yn,{children:[r.jsx(Jn,{children:"GitHub Traffic"}),A?r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginBottom:12},children:[r.jsx(Oe,{label:"Stars",value:A.engagement.stars.toLocaleString(),color:"#ffd54f"}),r.jsx(Oe,{label:"Forks",value:A.engagement.forks.toLocaleString()}),r.jsx(Oe,{label:"Views (14d)",value:A.views.count_14d.toLocaleString()}),r.jsx(Oe,{label:"Clones (14d)",value:A.clones.count_14d.toLocaleString()})]}),A.top_referrers.length>0&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:10,color:"#333",marginBottom:6},children:"Top referrers"}),A.top_referrers.slice(0,4).map(C=>r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,color:"#555",padding:"2px 0"},children:[r.jsx("span",{children:C.referrer}),r.jsx("span",{style:{fontFamily:"monospace",color:"#444"},children:C.count})]},C.referrer))]})]}):r.jsxs("div",{style:{fontSize:11,color:"#333",padding:"8px 0"},children:["No GitHub snapshot yet. Run:"," ",r.jsx("code",{style:{color:"#555",fontSize:10},children:"npm run metrics"})]})]})]}),r.jsxs(Yn,{children:[r.jsx(Jn,{children:"Email Leads — 30d"}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},children:[r.jsx(Oe,{label:"Email captures",value:((l==null?void 0:l.leads.email_captures_30d)??0).toLocaleString(),sub:"total email submissions"}),r.jsx(Oe,{label:"Unique emails",value:((l==null?void 0:l.leads.unique_emails_30d)??0).toLocaleString(),sub:"distinct leads"})]})]}),r.jsxs("div",{style:{marginTop:16,fontSize:10,color:"#222",textAlign:"right"},children:["Generated: ",l!=null&&l.generated_at?new Date(l.generated_at).toLocaleString():"—"]})]})}const Zh=[{path:"/headline",label:"HeadlineGrader"},{path:"/page-roast",label:"PageRoast"},{path:"/ad-scorer",label:"AdScorer"},{path:"/thread",label:"ThreadGrader"},{path:"/email-forge",label:"EmailForge"},{path:"/audience",label:"AudienceDecoder"},{path:"/metrics",label:"Metrics",operatorOnly:!0}];function eg(){const{email:l,isPro:c,loading:a,setEmail:f}=ou(),[u,g]=v.useState(!1),[h,y]=v.useState(""),[j,R]=v.useState(!1),[w,T]=v.useState(null),[_,A]=v.useState(!1),[x,B]=v.useState(!1);ws.useEffect(()=>{!l||!c||(A(!0),fetch(`${ge}/license/my-keys?email=${encodeURIComponent(l)}`).then(F=>F.json()).then(F=>{const ie=F.keys,re=ie==null?void 0:ie.find(fe=>fe.status==="active");T((re==null?void 0:re.key)??null)}).catch(()=>T(null)).finally(()=>A(!1)))},[l,c]);async function C(F){try{await navigator.clipboard.writeText(F),B(!0),setTimeout(()=>B(!1),2e3)}catch{}}async function W(){if(l){R(!0);try{const ie=await(await fetch(`${ge}/stripe/billing-portal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:l,returnUrl:window.location.href})})).json();ie.url?window.location.href=ie.url:alert(ie.error??"Could not open billing portal.")}catch{alert("Billing portal unavailable. Try again later.")}finally{R(!1)}}}function P(){const F=h.trim().toLowerCase();F.includes("@")&&(f(F),g(!1),y(""))}function Q(){f(""),g(!1)}return a?r.jsx("span",{style:{fontSize:10,color:"#333",marginLeft:8},children:"..."}):l?r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:6,marginLeft:"auto",flexShrink:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c&&r.jsx("span",{style:{fontSize:9,fontWeight:800,color:"#7c4dff",background:"#7c4dff18",border:"1px solid #7c4dff44",borderRadius:5,padding:"2px 7px",letterSpacing:.8,textTransform:"uppercase"},children:"PRO"}),r.jsx("span",{style:{fontSize:10,color:"#555",maxWidth:130,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l}),c&&r.jsx("button",{onClick:W,disabled:j,style:{fontSize:10,color:"#7c4dff",background:"transparent",border:"1px solid #7c4dff44",borderRadius:5,padding:"3px 8px",cursor:"pointer",whiteSpace:"nowrap",fontWeight:600},children:j?"...":"Manage Billing"}),r.jsx("button",{onClick:Q,style:{fontSize:10,color:"#444",background:"transparent",border:"none",cursor:"pointer",padding:"2px 4px"},title:"Sign out",children:"×"})]}),c&&r.jsx("div",{style:{fontSize:10,color:"#555"},children:_?r.jsx("span",{style:{color:"#333"},children:"Loading key..."}):w?r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[r.jsx("code",{style:{background:"#0d0d1a",border:"1px solid #1a1a2e",borderRadius:4,padding:"2px 8px",fontSize:10,color:"#7c4dff",fontFamily:"monospace",letterSpacing:.5},children:w}),r.jsx("button",{onClick:()=>C(w),style:{fontSize:9,color:x?"#44bb88":"#555",background:"transparent",border:"1px solid #1a1a2e",borderRadius:4,padding:"2px 6px",cursor:"pointer"},children:x?"Copied!":"Copy"})]}):r.jsx("span",{style:{color:"#333",fontSize:9},children:"Key will appear here after purchase"})})]}):u?r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginLeft:"auto",flexShrink:0},children:[r.jsx("input",{autoFocus:!0,type:"email",placeholder:"your@email.com",value:h,onChange:F=>y(F.target.value),onKeyDown:F=>{F.key==="Enter"&&P(),F.key==="Escape"&&(g(!1),y(""))},style:{background:"#0d0d1a",border:"1px solid #2a2a3e",borderRadius:6,padding:"5px 10px",fontSize:11,color:"#e0e0e0",outline:"none",fontFamily:"inherit",width:170}}),r.jsx("button",{onClick:P,disabled:!h.includes("@"),style:{fontSize:10,fontWeight:700,color:"#7c4dff",background:"#7c4dff18",border:"1px solid #7c4dff44",borderRadius:5,padding:"4px 10px",cursor:"pointer",opacity:h.includes("@")?1:.5},children:"Sign In"}),r.jsx("button",{onClick:()=>{g(!1),y("")},style:{fontSize:10,color:"#444",background:"transparent",border:"none",cursor:"pointer"},children:"×"})]}):r.jsx("button",{onClick:()=>g(!0),style:{marginLeft:"auto",fontSize:10,fontWeight:600,color:"#555",background:"transparent",border:"1px solid #1a1a2e",borderRadius:5,padding:"4px 10px",cursor:"pointer",whiteSpace:"nowrap",flexShrink:0},children:"Sign In"})}function tg(){return r.jsxs("nav",{style:{background:"#080810",borderBottom:"1px solid #12121f",padding:"0 24px",display:"flex",alignItems:"center",gap:4,overflowX:"auto",flexShrink:0},children:[r.jsx("span",{style:{fontSize:12,fontWeight:800,color:"#555",marginRight:16,whiteSpace:"nowrap",letterSpacing:1},children:"CG"}),Zh.map(({path:l,label:c,...a})=>{const f="operatorOnly"in a&&a.operatorOnly;return r.jsx(Sh,{to:l,style:({isActive:u})=>({padding:"12px 14px",fontSize:12,fontWeight:600,color:u?"#e0e0e0":f?"#2a2a3e":"#444",textDecoration:"none",borderBottom:u?"2px solid #7c4dff":"2px solid transparent",whiteSpace:"nowrap"}),children:c},l)}),r.jsx(eg,{})]})}function ng(){return r.jsx(Ch,{children:r.jsx(mh,{basename:"/app",children:r.jsxs("div",{style:{display:"flex",flexDirection:"column",minHeight:"100vh"},children:[r.jsx(tg,{}),r.jsx("main",{style:{flex:1,overflowY:"auto"},children:r.jsxs(ah,{children:[r.jsx(Rt,{path:"/",element:r.jsx(Ld,{to:"/headline",replace:!0})}),r.jsx(Rt,{path:"/headline",element:r.jsx(Bh,{})}),r.jsx(Rt,{path:"/page-roast",element:r.jsx(Lh,{})}),r.jsx(Rt,{path:"/ad-scorer",element:r.jsx(Fh,{})}),r.jsx(Rt,{path:"/thread",element:r.jsx($h,{})}),r.jsx(Rt,{path:"/email-forge",element:r.jsx(Qh,{})}),r.jsx(Rt,{path:"/audience",element:r.jsx(Jh,{})}),r.jsx(Rt,{path:"/metrics",element:r.jsx(Xh,{})}),r.jsx(Rt,{path:"*",element:r.jsx(Ld,{to:"/headline",replace:!0})})]})})]})})})}xp.createRoot(document.getElementById("root")).render(r.jsx(ws.StrictMode,{children:r.jsx(ng,{})}));
package/dist/index.html CHANGED
@@ -14,7 +14,7 @@
14
14
  }
15
15
  #root { min-height: 100vh; }
16
16
  </style>
17
- <script type="module" crossorigin src="/assets/index-Bc3ZrBgH.js"></script>
17
+ <script type="module" crossorigin src="/assets/index-BRA1tEKE.js"></script>
18
18
  </head>
19
19
  <body>
20
20
  <div id="root"></div>