1import{r as a,j as e}from"./vendor-react-CUX7D0C7.js";import{B as h,f as re,I as F}from"./index-CKW83pDQ.js";import{T as ne}from"./textarea-C-fFoRNJ.js";import{M as ae}from"./MetaTags-AnSKdbb-.js";import{A as oe,aO as H,Z as B,t as ie,aP as Y,aQ as de}from"./vendor-icons-kZFcvpIB.js";import"./vendor-pdf-CFaLvvvW.js";import"./vendor-ui-DV1JMX9G.js";import"./vendor-charts-Dis8PKHX.js";const ce="supreme_coder~linkedin-post",le=["https://www.linkedin.com/search/results/content/?datePosted=past-24h&keywords=hard+decision+founder&origin=FACETED_SEARCH","https://www.linkedin.com/search/results/content/?datePosted=past-24h&keywords=letting+people+go+founder&origin=FACETED_SEARCH","https://www.linkedin.com/search/results/content/?datePosted=past-24h&keywords=stepping+down+CEO&origin=FACETED_SEARCH","https://www.linkedin.com/search/results/content/?datePosted=past-24h&keywords=restructure+founder&origin=FACETED_SEARCH","https://www.linkedin.com/search/results/content/?datePosted=past-24h&keywords=difficult+decision+founder+CEO&origin=FACETED_SEARCH","https://www.linkedin.com/search/results/content/?datePosted=past-24h&keywords=burnout+founder+leader&origin=FACETED_SEARCH","https://www.linkedin.com/search/results/content/?datePosted=past-24h&keywords=runway+founder+difficult&origin=FACETED_SEARCH","https://www.linkedin.com/search/results/content/?datePosted=past-24h&keywords=pivot+hard+founder&origin=FACETED_SEARCH"],z=`You are a LinkedIn signal analyser for Patrick Voorma, founder of The Deep Brief â an AI coaching platform for leaders under pressure. 2 3You will receive a list of LinkedIn posts. Identify the highest-pressure moments from senior leaders and generate high-signal comments. 4 5SCORING: 6- Pressure intensity (1-10): Real tension, weight, difficulty visible in the post 7- Decision proximity (low/medium/high): Is a hard decision implied or imminent 8- ICP relevance (low/medium/high): Founder, CEO, MD, Senior Operator, Investor only 9 10SELECTION: Return TOP 5 only. Skip: viral content, listicles, motivational fluff, sales posts, newsletter announcements, low-seniority authors, anything without genuine tension. 11 12COMMENT TONE - Patrick Voorma voice: 13Direct, calm, surgical. No fluff, no emojis, no motivational cliches. 3-6 sentences. One sentence reframes the core tension. One sentence sharpens the implied decision. No praise language. No generic agreement. No pitching. Never mention The Deep Brief. Never include a link. Never sound like a chatbot. 14 15DM (only if pressure score >= 7): 3-4 sentences. No pitch, no link. Reference the specific tension. Sound human. 16 17OUTPUT FORMAT - return ONLY a valid JSON array. No preamble, no markdown. Start with [ end with ]. 18[{"author":"Full Name","title":"Their role","url":"post URL","summary":"2-3 sentence summary","why_relevant":"Why relevant","pressure_score":8,"decision_proximity":"high","icp_relevance":"high","comment":"Suggested comment","dm":"DM text or null"}]`,me=`You are a LinkedIn signal analyser for Patrick Voorma, founder of The Deep Brief. 19 20Analyse the LinkedIn post provided and return a single scored result with a comment in Patrick's voice. 21 22COMMENT TONE: Direct, calm, surgical. No fluff, no emojis. 3-6 sentences. One sentence reframes the core tension. One sentence sharpens the implied decision. No praise. No pitching. Never mention The Deep Brief. Never sound like a chatbot. 23 24DM (only if score >= 7): 3-4 sentences. No pitch, no link. Reference specific tension. Sound human. 25 26OUTPUT FORMAT - return ONLY a valid JSON array with one object. No preamble, no markdown. 27[{"author":"Name or Unknown","title":"Role or Unknown","url":null,"summary":"What is happening","why_relevant":"Why this matters","pressure_score":7,"decision_proximity":"medium","icp_relevance":"high","comment":"Suggested comment","dm":"DM or null"}]`;function I(s){const p=s.text||(s.content||[]).filter(l=>l.type==="text").map(l=>l.text).join(` 28`);if(!p)throw new Error("No response returned");const o=p.replace(/```json\s*/gi,"").replace(/```\s*/g,""),x=o.indexOf("["),c=o.lastIndexOf("]");if(x===-1||c===-1)throw new Error("No results found â try again.");
28const f=JSON.parse(o.slice(x,c+1));if(!Array.isArray(f)||f.length===0)throw new Error("No matching posts found.");return f}function pe({r:s,i:p,isTop:o,copied:x,copyText:c}){const f=m=>m>=8?"text-red-400":m>=6?"text-orange-400":"text-yellow-600",l=m=>m>=8?"border-red-500/40":m>=6?"border-orange-500/40":"border-yellow-600/40",C=m=>({high:"bg-red-500/10 text-red-400 border border-red-500/20",medium:"bg-orange-500/10 text-orange-400 border border-orange-500/20",low:"bg-yellow-600/10 text-yellow-600 border border-yellow-600/20"})[m]||"bg-muted text-muted-foreground";return e.jsxs("div",{className:"rounded-xl border bg-card overflow-hidden transition-colors "+(o?"border-red-500/25":"border-border"),children:[e.jsxs("div",{className:"px-5 py-4 border-b border-border flex items-start justify-between "+(o?"bg-red-500/3":""),children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[o&&e.jsx("span",{className:"text-[9px] font-bold tracking-widest text-red-400 bg-red-500/10 px-1.5 py-0.5 rounded uppercase",children:"Priority"}),e.jsx("span",{className:"font-semibold text-sm",children:s.author})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.title})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded uppercase tracking-wide "+C(s.decision_proximity),children:s.decision_proximity}),e.jsxs("div",{className:"w-10 h-10 rounded-full border-2 flex flex-col items-center justify-center "+l(s.pressure_score),children:[e.jsx("span",{className:"text-sm font-black leading-none "+f(s.pressure_score),children:s.pressure_score}),e.jsx("span",{className:"text-[8px] text-muted-foreground",children:"/10"})]})]})]}),e.jsxs("div",{className:"px-5 py-3 border-b border-border",children:[e.jsx("div",{className:"text-[10px] font-bold tracking-widest text-muted-foreground/60 uppercase mb-2",children:"Situation"}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:s.summary}),s.url&&e.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline mt-2 inline-block opacity-70",children:"View post â"})]}),e.jsxs("div",{className:"px-5 py-3 "+(s.dm?"border-b border-border":""),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"text-[10px] font-bold tracking-widest text-muted-foreground/60 uppercase",children:"Suggested Comment"}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-6 text-xs px-2 text-primary",onClick:()=>c(s.comment,"c-"+p),children:x==="c-"+p?"â Copied":"Copy"})]}),e.jsx("p",{className:"text-sm leading-relaxed italic border-l-2 border-primary/25 pl-3",children:s.comment})]}),s.dm&&e.jsxs("div",{className:"px-5 py-3 bg-muted/20",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"text-[10px] font-bold tracking-widest text-muted-foreground/60 uppercase",children:"Follow-up DM · Score ⥠7"}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-6 text-xs px-2 text-primary",onClick:()=>c(s.dm,"d-"+p),children:x==="d-"+p?"â Copied":"Copy"})]}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:s.dm})]})]})}function Se(){const[s,p]=a.useState("apify"),[o,x]=a.useState(()=>{try{return sessionStorage.getItem("radar_apify_key")||""}catch{return""}}),[c,f]=a.useState(()=>{try{return sessionStorage.getItem("radar_li_cookie")||""}catch{return""}}),[l,C]=a.useState(()=>{try{return sessionStorage.getItem("radar_ua")||navigator.userAgent}catch{return navigator.userAgent}}),[m,W]=a.useState(!1),[ue,xe]=a.useState(!1),[J,O]=a.useState([]),[K,P]=a.useState([]),[V,_]=a.useState([]),[b,Z]=a.useState(""),[d,g]=a.useState(!1),[L,i]=a.useState(""),[A,u]=a.useState(null),[q,D]=a.useState(null);a.useEffect(()=>{try{o&&sessionStorage.setItem("radar_apify_key",o),c&&sessionStorage.setItem("radar_li_cookie",c),l&&sessionStorage.setItem("radar_ua",l)}catch{}},[o,c,l]);const G=(t,r)=>{navigator.clipboard.writeText(t),D(r),setTimeout(()=>D(null),2e3)},w=o.trim()&&c.trim(),Q=a.useCallback(async()=>
28{if(!w){u("Enter both your Apify API token and LinkedIn cookie first.");return}g(!0),u(null),P([]);try{i("Launching Apify LinkedIn scraper...");const t=await fetch("/api/apify/launch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apifyToken:o.trim(),actorId:ce,input:{urls:le,maxResults:100}})});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error("Apify launch failed: "+(n.error&&n.error.message?n.error.message:typeof n.error=="string"?n.error:"HTTP "+t.status))}const r=await t.json(),N=r.data.id,v=r.data.defaultDatasetId;i("Scraping LinkedIn posts â takes 2â4 minutes...");let S=0;for(;S<72;){await new Promise(R=>setTimeout(R,5e3)),S++;const y=(await(await fetch("/api/apify/run/"+N+"?apifyToken="+encodeURIComponent(o.trim()))).json()).data.status,T=Math.round(S*5);if(i("Scraping ("+y+") â "+T+"s elapsed..."),y==="SUCCEEDED")break;if(["FAILED","ABORTED","TIMED-OUT"].includes(y))throw new Error("Apify run "+y.toLowerCase()+". Check your cookie is valid and try again.")}if(S>=72)throw new Error("Timed out. The scraper may still be running â check Apify console.");i("Fetching scraped posts...");const k=await(await fetch("/api/apify/dataset/"+v+"?apifyToken="+encodeURIComponent(o.trim())+"&limit=100")).json();if(!k||k.length===0)throw new Error("No posts returned. Your LinkedIn cookie may have expired â extract a fresh one from LinkedIn and try again.");const se=k.slice(0,60).map((n,U)=>{const y=(n.authorName||n.author||n.name||"Unknown").trim(),T=(n.authorHeadline||n.headline||n.title||"").trim(),R=(n.text||n.content||n.postText||n.description||"").trim().slice(0,600),te=n.url||n.postUrl||n.link||null;return U+1+". AUTHOR: "+y+" | TITLE: "+T+" | URL: "+(te||"n/a")+` 29POST: `+R}).join(` 30 31--- 32 33`);i("Scoring "+Math.min(k.length,60)+" posts for pressure signals...");const E=await(await fetch("/api/admin/score-posts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system:z,prompt:"Here are "+Math.min(k.length,60)+` LinkedIn posts scraped from keyword searches. Return the TOP 5 highest-pressure posts from senior leaders (Founder/CEO/MD/Senior Operator only). Ignore low-seniority authors and anything without real tension. 34 35`+se})})).json();if(E.error)throw new Error("Claude error: "+E.error.message);P(I(E)),i("")}catch(t){u(t.message),i("")}finally{g(!1)}},[o,c,l,w]),$=a.useCallback(async()=>{g(!0),u(null),O([]),i("Scanning LinkedIn via web search...");try{const r=await(await fetch("/api/admin/web-scan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system:z,messages:[{role:"user",content:`Search LinkedIn for real pressure posts from senior leaders in the last 48-72 hours: 361. site:linkedin.com/posts founder "hard decision" 372. site:linkedin.com/posts CEO "board" 383. site:linkedin.com/posts "letting people go" founder 394. site:linkedin.com/posts "stepping down" 405. site:linkedin.com/posts "restructure" founder CEO 416. site:linkedin.com/posts "burnout" founder CEO 427. site:linkedin.com/posts founder "running out" OR "runway" 438. site:linkedin.com/posts "pivoting" founder "hard" 44Return TOP 5 highest-pressure posts. Real tension only.`}]})})).json();if(r.error)throw new Error(r.error.message||r.error);O(I(r)),i("")}catch(t){u(t.message),i("")}finally{g(!1)}},[]),X=a.useCallback(async()=>{if(b.trim()){g(!0),u(null),_([]),i("Analysing post...");try{const r=await(await fetch("/api/admin/score-posts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system:me,prompt:`Analyse this LinkedIn post: 45 46`+b.trim()})})).json();if(r.error)throw new Error(r.error.message||r.error);_(I({content:[{type:"text",text:r.text}]})),i("")}catch(t){u(t.message),i("")}finally{g(!1)}}},[b]),j=s==="apify"?K:s==="scan"?J:V,M=[...j].sort((t,r)=>r.pressure_score-t.pressure_score).slice(0,3),ee=[{id:"apify",label:"Apify Scan",icon:B,badge:"BEST"},{id:"scan",label:"Web Scan",icon:ie,badge:null},{id:"paste",label:"Paste Post",icon:Y,badge:null}];return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(ae,{title:"Pressure Radar | Admin"}),e.jsx("div",{className:"border-b border-border bg-card/50 px-6 py-4",children:e.jsxs("div",{className:"max-w-5xl mx-auto flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs(re,{href:"/admin",children:[e.jsx(oe,{className:"w-4 h-4 mr-1"})," Admin"]})}),e.jsx("div",{className:"h-4 w-px bg-border"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4 text-primary"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-sm font-semibold",children:"Pressure Radar"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"LinkedIn signal detection"})]})]})]}),s==="apify"&&e.jsxs(h,{onClick:Q,disabled:d||!w,size:"sm",className:"gap-2",children:[e.jsx("span",{className:d?"animate-spin inline-block":"",children:d?"â³":"â¶"}),d?"Running...":"Run Apify Scan"]}),s==="scan"&&e.jsxs(h,{onClick:$,disabled:d,size:"sm",className:"gap-2",children:[e.jsx("span",{className:d?"animate-spin inline-block":"",children:d?"â³":"â¶"}),d?"Scanning...":"Run Web Scan"]}),s==="paste"&&e.jsxs(h,{onClick:X,disabled:d||!b.trim(),size:"sm",className:"gap-2",children:[e.jsx("span",{className:d?"animate-spin inline-block":"",children:d?"â³":"â¶"}),d?"Analysing...":"Analyse Post"]})]})}),e.jsx("div",{className:"border-b border-border bg-card/30",children:e.jsx("div",{className:"max-w-5xl mx-auto px-6 flex",children:ee.map(({id:t,label:r,icon:N,badge:v})=>e.jsxs("button",{onClick:()=>{p(t),u(null),i("")},className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors "+(s===t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:[e.jsx(N,{className:"w-3.5 h-3.5"})," ",r,v&&e.jsx("span",{className:"text-[9px] bg-primary/15 text-primary px-1.5 py-0.5 rounded font-bold tracking-wide",children:v})]},t))})}),e.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-6 space-y-5",children:[s==="apify"&&e.jsxs("div",{className:"bg-card border border-border rounded-xl p-5 space-y-5",children:[e.jsx("div",{className:"text-xs font-bold tracking-widest text-muted-foreground
46/60 uppercase",children:"Credentials â stored this session only"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:"Apify API Token"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(F,{type:m?"text":"password",value:o,onChange:t=>x(t.target.value),placeholder:"apify_api_xxxxxxxxxxxx",className:"font-mono text-xs"}),e.jsx(h,{variant:"outline",size:"sm",onClick:()=>W(!m),className:"shrink-0",children:m?"Hide":"Show"})]}),e.jsx("p",{className:"text-xs text-muted-foreground/60",children:e.jsx("a",{href:"https://console.apify.com/settings/integrations",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Apify Console â Settings â API & Integrations"})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"User Agent"}),e.jsx("span",{className:"text-[9px] bg-muted text-muted-foreground px-1.5 py-0.5 rounded font-bold",children:"AUTO-FILLED"})]}),e.jsx(F,{value:l,onChange:t=>C(t.target.value),className:"font-mono text-xs"}),e.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Must match the browser you extracted the cookie from. Auto-filled with your current browser."})]}),e.jsxs("div",{className:"text-xs text-muted-foreground/50 pt-1 border-t border-border",children:["Actor: ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"supreme_coder/linkedin-post"})," · ~$0.10â0.50 per scan · 2â4 min runtime"]})]}),s==="paste"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-widest",children:"Paste LinkedIn post text"}),e.jsx(ne,{value:b,onChange:t=>Z(t.target.value),placeholder:`Paste the full text of a LinkedIn post here. 47 48The AI will score it for pressure intensity, decision proximity, and ICP relevance, then generate a comment and DM in Patrick's voice.`,className:"min-h-[160px] text-sm resize-none"})]}),s==="scan"&&e.jsx("div",{className:"text-xs text-muted-foreground/60 bg-muted/30 border border-border rounded-lg px-4 py-3",children:"Web scan uses Bing to find indexed LinkedIn posts. Coverage is limited â LinkedIn blocks most indexing. Use Apify Scan for reliable results."}),L&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary bg-primary/5 border border-primary/20 rounded-lg px-4 py-3",children:[e.jsx("span",{className:"animate-spin inline-block text-base",children:"â³"})," ",L]}),A&&e.jsx("div",{className:"text-sm text-red-400 bg-red-500/8 border border-red-500/20 rounded-lg px-4 py-3",children:A}),j.length>0&&s!=="paste"&&e.jsxs("div",{className:"bg-red-500/5 border border-red-500/20 rounded-lg p-4",children:[e.jsx("div",{className:"text-xs font-bold tracking-widest text-red-400 mb-3 uppercase",children:"â² Comment on these first"}),e.jsx("div",{className:"space-y-3",children:M.map((t,r)=>e.jsxs("div",{className:"flex gap-3 items-start",children:[e.jsx("span",{className:"text-red-400 font-black text-lg leading-tight min-w-[16px]",children:r+1}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-semibold",children:[t.author," ",e.jsxs("span",{className:"text-muted-foreground font-normal",children:["· ",t.pressure_score,"/10"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed",children:t.summary})]})]},r))})]}),j.length===0&&!d&&!A&&e.jsxs("div",{className:"text-center py-20 text-muted-foreground",children:[s==="paste"?e.jsx(Y,{className:"w-10 h-10 mx-auto mb-4 opacity-20"}):s==="apify"?e.jsx(B,{className:"w-10 h-10 mx-auto mb-4 opacity-20"}):e.jsx(H,{className:"w-10 h-10 mx-auto mb-4 opacity-20"}),e.jsx("p",{className:"text-sm font-medium",children:s==="paste"?"Nothing analysed yet":s==="apify"?w?"Ready to scan":"Enter credentials above to begin":"No signal detected"}),e.jsx("p",{className:"text-xs mt-1 opacity-60",children:s==="paste"?"Paste a post above and click Analyse":s==="apify"?w?"Click Run Apify Scan to find live pressure posts":"Apify token + LinkedIn cookie required":"Click Run Web Scan"})]}),e.jsx("div",{className:"space-y-4",children:j.map((t,r)=>e.jsx(pe,{r:t,i:r,isTop:s!=="paste"&&M.some(N=>N.author===t.author),copied:q,copyText:G},r))})]})]})}export{Se as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.