PageSourceSearch

https://blacksheepbi.com/assets/PlatformPR-BmiYggy9.js

js blacksheepbi.com collected 2026-09-30 08:27:10 UTC 50,317 bytes, 10 lines download raw bytes

1import{r as d,j as e}from"./ui-CPW3-RCR.js";import{a0 as $e,a as H,g as W,u as Pe,G as ee,L as R,R as ve,d as x,aL as se,c as ie,_ as Ie,a2 as le,aQ as Ee,ap as De,e as J,W as xe,aN as Re,k as ye,s as _,bP as Te,X as ze,P as te,ao as X,ab as je,a9 as Ke,y as E,J as D,I as V,B as A,aD as ce,Z as U,a4 as de,aA as ne,H as we,l as Be,aZ as Qe,m as Ue,n as qe,o as Ge,M as ue,cz as Ve,j as Ne,bN as Je,T as We,N as _e,c3 as Fe,a_ as Se,a$ as ke,b0 as oe,b1 as F}from"./index-BraPXa8T.js";import{S as Ce}from"./settings-2-Pmo5V7b-.js";import{T as me}from"./trending-down-BWyGfEbB.js";import{M as He}from"./index-BfRVBusC.js";import{M as be,F as Oe}from"./meh-Ch4LSzOE.js";import{C as Xe}from"./circle-check-big-DG-il0rr.js";import{D as Ze}from"./DepartmentBrainPanel-BXjmvOXs.js";import{L as Ye}from"./list-plus-DKimy7Aa.js";import{S as es,a as ss,b as ts,c as as,d as Y}from"./select-DubWVshT.js";import{p as rs}from"./charts-DCB9_QAo.js";import{R as Ae}from"./radio-B3F-GtdU.js";import{M as ns}from"./minus-CCCsL8N7.js";import"./supabase-B2z4OhLQ.js";import"./vendor-CIXof4MH.js";import"./useSmartScroll-Da1xVHwy.js";import"./scroll-area-BQtXZnuf.js";import"./index-BdQq_4o_.js";import"./useDemoLocale-COy7_g6Y.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const is=$e("Twitter",[["path",{d:"M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z",key:"pff0z6"}]]);function O({value:l,label:a,invertColor:s}){const m=Math.max(0,Math.min(100,l)),r=-90+m/100*180,N=(f=>s?f<=30?"hsl(var(--success))":f<=60?"hsl(var(--warning, 45 93% 47%))":"hsl(var(--destructive))":f>=70?"hsl(var(--success))":f>=40?"hsl(var(--warning, 45 93% 47%))":"hsl(var(--destructive))")(m);return e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:"relative w-20 h-11 overflow-hidden",children:e.jsxs("svg",{viewBox:"0 0 100 55",className:"w-full h-full",children:[e.jsx("path",{d:"M 10 50 A 40 40 0 0 1 90 50",fill:"none",stroke:"hsl(var(--muted))",strokeWidth:"8",strokeLinecap:"round"}),e.jsx("path",{d:"M 10 50 A 40 40 0 0 1 90 50",fill:"none",stroke:N,strokeWidth:"8",strokeLinecap:"round",strokeDasharray:`${m/100*126} 126`}),e.jsx("line",{x1:"50",y1:"50",x2:"50",y2:"18",stroke:"hsl(var(--foreground))",strokeWidth:"2",strokeLinecap:"round",transform:`rotate(${r}, 50, 50)`}),e.jsx("circle",{cx:"50",cy:"50",r:"3",fill:"hsl(var(--foreground))"})]})}),e.jsx("span",{className:"text-base font-bold",style:{color:N},children:m}),e.jsx("span",{className:"text-[10px] text-muted-foreground text-center leading-tight",children:a})]})}function ls({status:l,t:a}){return l==="success"?e.jsxs("span",{className:"flex items-center gap-0.5 text-success text-[10px]",children:[e.jsx(Xe,{className:"w-3 h-3"})," ",a("pr.found")]}):l==="no_data"||l==="no_results"?e.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground text-[10px]",children:[e.jsx(je,{className:"w-3 h-3"})," ",a("pr.empty")]}):l==="not_connected"?e.jsxs("span",{className:"flex items-center gap-0.5 text-warning text-[10px]",children:[e.jsx(Ke,{className:"w-3 h-3"})," ",a("pr.notConnected")]}):e.jsxs("span",{className:"flex items-center gap-0.5 text-destructive text-[10px]",children:[e.jsx(je,{className:"w-3 h-3"})," ",a("pr.error")]})}function cs({clientId:l,config:a,onSaved:s,t:m}){const[r,p]=d.useState((a==null?void 0:a.brand_name)||""),[N,f]=d.useState((a==null?void 0:a.brand_aliases)||[]),[P,v]=d.useState((a==null?void 0:a.website_url)||""),[L,y]=d.useState(""),[w,M]=d.useState(!1);d.useEffect(()=>{a&&(p(a.brand_name),f(a.brand_aliases||[]),v(a.website_url||""))},[a]);const k=async()=>{if(r.trim()){M(!0);try{const{error:n}=await _.from("client_brand_config").upsert({client_id:l,brand_name:r.trim(),brand_aliases:N,website_url:P.trim()||null},{onConflict:"client_id"});if(n)throw n;x.success(m("pr.configSaved")),s()}catch(n){x.error(n.message)}finally{M(!1)}}},S=()=>
6{L.trim()&&!N.includes(L.trim())&&(f([...N,L.trim()]),y(""))};return e.jsxs("div",{className:"px-4 py-3 border-t border-border bg-secondary/20 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ce,{className:"w-3.5 h-3.5 text-primary"}),e.jsx("h4",{className:"text-xs font-semibold",children:m("pr.brandConfig")})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-muted-foreground mb-0.5 block",children:m("pr.brandNameExact")}),e.jsx("input",{value:r,onChange:n=>p(n.target.value),className:"w-full bg-background border border-border rounded px-2 py-1 text-sm outline-none focus:border-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-muted-foreground mb-0.5 block",children:m("pr.websiteUrl")}),e.jsx("input",{value:P,onChange:n=>v(n.target.value),placeholder:"https://...",className:"w-full bg-background border border-border rounded px-2 py-1 text-sm outline-none focus:border-primary",dir:"ltr"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-muted-foreground mb-0.5 block",children:m("pr.brandAliases")}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:N.map((n,g)=>e.jsxs("span",{className:"bg-secondary rounded-full px-2 py-0.5 text-[11px] flex items-center gap-1",children:[n,e.jsx("button",{onClick:()=>f(N.filter((j,$)=>$!==g)),className:"text-muted-foreground hover:text-destructive",children:e.jsx(ze,{className:"w-3 h-3"})})]},g))}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{value:L,onChange:n=>y(n.target.value),onKeyDown:n=>n.key==="Enter"&&S(),placeholder:m("pr.addAlias"),className:"flex-1 bg-background border border-border rounded px-2 py-1 text-[11px] outline-none"}),e.jsx("button",{onClick:S,className:"text-primary",children:e.jsx(te,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("button",{onClick:k,disabled:w||!r.trim(),className:"flex items-center gap-1 px-3 py-1.5 rounded-md text-[11px] font-medium gradient-brand text-primary-foreground disabled:opacity-50",children:[w?e.jsx(R,{className:"w-3 h-3 animate-spin"}):e.jsx(X,{className:"w-3 h-3"})," ",m("pr.saveConfig")]})]})}function ds(){var he,pe,ge;const{selectedClient:l}=H(),{language:a,t:s}=W(),{clearanceLevel:m}=Pe(),[r,p]=d.useState(null),[N,f]=d.useState(!1),[P,v]=d.useState([]),[L,y]=d.useState(""),[w,M]=d.useState(!1),[k,S]=d.useState(!1),[n,g]=d.useState(!1),[j,$]=d.useState(!1),[I,K]=d.useState(""),[T,B]=d.useState(""),[Q,i]=d.useState(!1),t=m<=3,h=async()=>{var c;if(l){f(!0),p(null);try{const{data:u,error:G}=await _.functions.invoke("brand-sentiment",{body:{client_id:l.id,client_name:l.name,website_url:l.website_url,language:a}});if(G)throw G;if(u!=null&&u.error)throw new Error(u.error);p(u),(c=u==null?void 0:u.brandConfig)!=null&&c.isFirstScan&&t&&g(!0)}catch(u){x.error(u.message)}finally{f(!1)}}},b=async()=>{const c=L.trim();if(!c||w||!r||!l)return;const u={role:"user",content:c},G=[...P,u];v(G),y(""),M(!0);try{const{data:re,error:fe}=await _.functions.invoke("unified-ai-chat",{body:{messages:G,client_id:l.id,client_name:l.name,unified_context:{connectedPlatforms:["pr_sentiment"],prSentiment:r},language:a}});if(fe)throw fe;v(Me=>[...Me,{role:"assistant",content:re.reply}])}catch(re){x.error(re.message)}finally{M(!1)}},C=async()=>{var c;if(!(!T.trim()||!r||!l||Q)){i(!0);try{const{data:u,error:G}=await _.functions.invoke("unified-ai-chat",{body:{messages:[{role:"user",content:`Refine the brand sentiment analysis for "${((c=r.brandConfig)==null?void 0:c.brand_name)||l.name}": ${T.trim()}
7
8Current: ${r.aiAnalysis}
9
10Return only updated analysis.`}],client_id:l.id,client_name:l.name,unified_context:{connectedPlatforms:["pr_sentiment"],prSentiment:r},language:a}});if(G)throw G;p({...r,aiAnalysis:u.reply}),B(""),x.success(s("pr.analysisUpdated"))}catch(u){x.error(u.message)}finally{i(!1)}}},q=()=>{r&&I.trim()&&(p({...r,aiAnalysis:I.trim()}),$(!1),x.success(s("pr.analysisEditedManually")))},o={positive:e.jsx(Te,{className:"w-5 h-5 text-success"}),negative:e.jsx(Oe,{className:"w-5 h-5 text-destructive"}),neutral:e.jsx(be,{className:"w-5 h-5 text-muted-foreground"}),mixed:e.jsx(be,{className:"w-5 h-5 text-warning"})},z={positive:"text-success",negative:"text-destructive",neutral:"text-muted-foreground",mixed:"text-warning"},ae=c=>c>=70?"text-success":c>=40?"text-warning":"text-destructive",Z={positive:"pr.positive",negative:"pr.negative",neutral:"pr.neutral",mixed:"pr.mixed"},Le=c=>s(Z[c]||"pr.neutral");return e.jsxs("div",{className:"panel overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-sm font-semibold",children:s("pr.title")}),(r==null?void 0:r.brandConfig)&&e.jsx("span",{className:"text-[10px] bg-secondary rounded-full px-2 py-0.5 text-muted-foreground",children:r.brandConfig.brand_name})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[t&&r&&e.jsx("button",{onClick:()=>g(!n),className:"flex items-center gap-1 px-2 py-1 rounded-md text-[11px] text-muted-foreground hover:text-foreground border border-border",children:e.jsx(Ce,{className:"w-3 h-3"})}),e.jsxs("button",{onClick:h,disabled:N,className:"flex items-center gap-1 px-2.5 py-1 rounded-md text-[11px] font-medium gradient-brand text-primary-foreground disabled:opacity-50",children:[N?e.jsx(R,{className:"w-3 h-3 animate-spin"}):e.jsx(ve,{className:"w-3 h-3"}),s(r?"pr.refresh":"pr.scanNow")]})]})]}),n&&t&&l&&e.jsx(cs,{clientId:l.id,config:(r==null?void 0:r.brandConfig)||null,onSaved:()=>{g(!1),x.info(s("pr.configSaved"))},t:s}),!r&&!N&&e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(ee,{className:"w-8 h-8 text-muted-foreground mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("pr.scanPrompt")})]}),N&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(R,{className:"w-6 h-6 animate-spin text-primary mx-auto"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("pr.scanning")})]})}),r&&!N&&e.jsxs("div",{className:"space-y-0",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 p-4",children:[e.jsxs("div",{className:"bg-secondary/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"flex items-center justify-center gap-1 mb-1",children:o[r.overallSentiment]}),e.jsx("p",{className:`text-lg font-bold ${z[r.overallSentiment]}`,children:s(Z[r.overallSentiment])}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("pr.overallSentiment")})]}),e.jsxs("div",{className:"bg-secondary/50 rounded-lg p-3 text-center",children:[e.jsx("p",{className:`text-2xl font-bold ${ae(r.sentimentScore)}`,children:r.sentimentScore}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("pr.brandScore")})]}),e.jsxs("div",{className:"bg-secondary/50 rounded-lg p-3 text-center",children:[e.jsx(se,{className:"w-4 h-4 text-success mx-auto mb-1"}),e.jsx("p",{className:"text-lg font-bold text-success",children:r.positiveSignals.length}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("pr.positiveSignals")})]}),e.jsxs("div",{className:"bg-secondary/50 rounded-lg p-3 text-center",children:[e.jsx(me,{className:"w-4 h-4 text-destructive mx-auto mb-1"}),e.jsx("p",{className:"text-lg font-bold text-destructive",children:r.negativeSignals.length}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("pr.negativeSignals")})]})]}),r.gauges&&e.jsxs("div",{className:"px-4 py-4 border-t border-border",children:[e.jsxs("h4",{className:"text-xs font-semibold mb-3",children:["📊 ",s("pr.gaugesTitle")]}
10),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-5 gap-4",children:[e.jsx(O,{value:r.gauges.brandTrust,label:s("pr.brandTrust")}),e.jsx(O,{value:r.gauges.onlineReputation,label:s("pr.onlineReputation")}),e.jsx(O,{value:r.gauges.customerSatisfaction,label:s("pr.customerSatisfaction")}),e.jsx(O,{value:r.gauges.mediaPresence,label:s("pr.mediaPresence")}),e.jsx(O,{value:r.gauges.crisisRisk,label:s("pr.crisisRisk"),invertColor:!0})]})]}),e.jsxs("div",{className:"px-4 py-3 border-t border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"w-3.5 h-3.5 text-primary"}),e.jsx("h4",{className:"text-xs font-semibold",children:s("pr.aiAnalysis")})]}),t&&!j&&e.jsxs("button",{onClick:()=>{$(!0),K(r.aiAnalysis)},className:"flex items-center gap-1 text-[10px] text-primary hover:underline",children:[e.jsx(Ie,{className:"w-3 h-3"})," ",s("pr.edit")]})]}),j?e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{value:I,onChange:c=>K(c.target.value),className:"w-full bg-secondary rounded-lg p-2 text-sm min-h-[80px] outline-none border border-border focus:border-primary"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>$(!1),className:"px-2 py-1 text-[11px] rounded bg-secondary text-muted-foreground",children:s("pr.cancel")}),e.jsx("button",{onClick:q,className:"px-2 py-1 text-[11px] rounded gradient-brand text-primary-foreground",children:s("pr.save")})]})]}):e.jsx("p",{className:"text-sm leading-relaxed text-foreground/90",children:r.aiAnalysis}),t&&!j&&e.jsx("div",{className:"mt-3",children:e.jsxs("div",{className:"flex items-center gap-2 bg-secondary rounded-lg px-3 py-1.5",children:[e.jsx("input",{value:T,onChange:c=>B(c.target.value),onKeyDown:c=>c.key==="Enter"&&C(),placeholder:s("pr.refinePrompt"),className:"flex-1 bg-transparent text-[11px] placeholder:text-muted-foreground outline-none"}),e.jsx("button",{onClick:C,disabled:Q||!T.trim(),className:"text-primary hover:text-primary/80 disabled:opacity-40",children:Q?e.jsx(R,{className:"w-3 h-3 animate-spin"}):e.jsx(ie,{className:"w-3 h-3"})})]})})]}),r.scanSources&&r.scanSources.length>0&&e.jsxs("div",{className:"border-t border-border",children:[e.jsxs("button",{onClick:()=>S(!k),className:"w-full flex items-center justify-between px-4 py-2 text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(le,{className:"w-3 h-3"}),e.jsxs("span",{children:[s("pr.scanSources")," (",r.scanSources.length," ",s("pr.sources"),")"]})]}),k?e.jsx(Ee,{className:"w-3 h-3"}):e.jsx(De,{className:"w-3 h-3"})]}),k&&e.jsx("div",{className:"px-4 pb-3 space-y-1.5",children:r.scanSources.map((c,u)=>e.jsxs("div",{className:"bg-secondary/40 rounded-lg px-3 py-2 flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[11px] font-medium",children:c.source}),c.query&&e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate mt-0.5",dir:"ltr",children:['"',c.query,'"']})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:c.resultsCount}),e.jsx(ls,{status:c.status,t:s})]})]},u))})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-0 border-t border-border",children:[r.positiveSignals.length>0&&e.jsxs("div",{className:"p-4 border-e border-border",children:[e.jsxs("h4",{className:"text-xs font-semibold text-success mb-2 flex items-center gap-1",children:[e.jsx(se,{className:"w-3 h-3"})," ",s("pr.positiveVoice")]}),e.jsx("ul",{className:"space-y-1",children:r.positiveSignals.map((c,u)=>e.jsxs("li",{className:"text-[11px] text-foreground/80 flex items-start gap-1",children:[e.jsx("span",{className:"text-success mt-0.5",children:"✓"})," ",c]},u))})]}),r.negativeSignals.length>0&&e.jsxs("div",{className:"p-4",children:[e.jsxs("h4",{className:"text-xs font-semibold text-destructive mb-2 flex items-center gap-1",children:[e.jsx(me,{className:"w-3 h-3"})," ",s("pr.negativeVoice")]}),e.jsx("ul",{className:"space-y-1",children:r.negativeSignals.map((c,u)=>
10e.jsxs("li",{className:"text-[11px] text-foreground/80 flex items-start gap-1",children:[e.jsx("span",{className:"text-destructive mt-0.5",children:"✗"})," ",c]},u))})]})]}),((he=r.brandedSearches)==null?void 0:he.length)>0&&e.jsxs("div",{className:"p-4 border-t border-border",children:[e.jsxs("h4",{className:"text-xs font-semibold mb-2 flex items-center gap-1",children:[e.jsx(J,{className:"w-3 h-3"})," ",s("pr.brandedSearches")]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.brandedSearches.slice(0,15).map((c,u)=>e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] ${c.sentiment==="positive"?"bg-success/10 text-success":c.sentiment==="negative"?"bg-destructive/10 text-destructive":"bg-secondary text-muted-foreground"}`,children:c.query},u))})]}),r.rawBrandQueries&&r.rawBrandQueries.length>0&&e.jsxs("div",{className:"p-4 border-t border-border",children:[e.jsxs("h4",{className:"text-xs font-semibold mb-2 flex items-center gap-1",children:[e.jsx(J,{className:"w-3 h-3"})," ",s("pr.scBrandQueries")]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-[11px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-muted-foreground border-b border-border",children:[e.jsx("th",{className:"text-start py-1 pe-3",children:s("pr.query")}),e.jsx("th",{className:"text-center py-1 px-2",children:s("pr.clicks")}),e.jsx("th",{className:"text-center py-1 px-2",children:s("pr.impressions")}),e.jsx("th",{className:"text-center py-1 px-2",children:s("pr.position")})]})}),e.jsx("tbody",{children:r.rawBrandQueries.slice(0,10).map((c,u)=>e.jsxs("tr",{className:"border-b border-border/50",children:[e.jsx("td",{className:"py-1 pe-3 font-medium",children:c.query}),e.jsx("td",{className:"text-center py-1 px-2",children:c.clicks}),e.jsx("td",{className:"text-center py-1 px-2",children:c.impressions}),e.jsx("td",{className:"text-center py-1 px-2",children:c.position.toFixed(1)})]},u))})]})})]}),((pe=r.webMentions)==null?void 0:pe.length)>0&&e.jsxs("div",{className:"p-4 border-t border-border",children:[e.jsxs("h4",{className:"text-xs font-semibold mb-2 flex items-center gap-1",children:[e.jsx(ee,{className:"w-3 h-3"})," ",s("pr.webMentions")," (",r.totalWebMentions||r.webMentions.length,")"]}),e.jsx("div",{className:"space-y-2",children:r.webMentions.slice(0,8).map((c,u)=>e.jsx("div",{className:"bg-secondary/30 rounded-lg px-3 py-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"text-[11px] font-medium hover:text-primary transition-colors flex items-center gap-1",children:[c.title,e.jsx(xe,{className:"w-2.5 h-2.5 shrink-0"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5 line-clamp-2",children:c.summary})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[9px] font-medium ${c.sentiment==="positive"?"bg-success/10 text-success":c.sentiment==="negative"?"bg-destructive/10 text-destructive":"bg-secondary text-muted-foreground"}`,children:Le(c.sentiment)})]})},u))})]}),((ge=r.recommendations)==null?void 0:ge.length)>0&&e.jsxs("div",{className:"p-4 border-t border-border",children:[e.jsxs("h4",{className:"text-xs font-semibold mb-2",children:["💡 ",s("pr.recommendations")]}),e.jsx("ul",{className:"space-y-1",children:r.recommendations.map((c,u)=>e.jsxs("li",{className:"text-[11px] text-foreground/80 flex items-start gap-1.5",children:[e.jsxs("span",{className:"text-primary mt-0.5 font-bold",children:[u+1,"."]})," ",c]},u))})]}),e.jsxs("div",{className:"border-t border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border",children:[e.jsx(Re,{className:"w-3.5 h-3.5 text-primary"}),e.jsx("span",{className:"text-xs font-semibold",children:s("pr.askAboutPR")})]}),P.length>0&&e.jsxs("div",{className:"max-h-[200px] overflow-y-auto px-4 py-2 space-y-2",children:[P.map((c,u)=>e.jsx("div",{className:`max-w-[90%] ${c.role==="user"?"ms-auto":"me-auto"}`,children:e.jsx("div",{className:`px-3 py-1.5 rounded-lg text-[12px] leading-relaxed ${c.role==="user"?"gradient-brand text-primary-foreground":"bg-secondary text-foreground"}`,children:c.role==="assistant"?e.jsx("div",{className:"ai-prose",children:e.jsx(He,{children:c.content})}):c.content})},u)),w&&e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx(R,{className:"w-3 h-3 animate-spin"})," ",s("pr.analyzing")]})]}),e.jsx("div",{className:"px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-2 bg-secondary rounded-lg px-3 py-1.5",children:[e.jsx("input",{value:L,onChange:c=>y(c.target.value),onKeyDown:c=>c.key==="Enter"&&b(),placeholder:s("pr.chatPlaceholder"),className:"flex-1 bg-transparent text-sm placeholder:text-muted-foreground outline-none"}),e.jsx("button",{onClick:b,disabled:w||!L.trim(),className:"text-primary hover:text-primary/80 transition-colors disabled:opacity-40",children:e.jsx(ye,{className:"w-3.5 h-3.5"})})]})})]})]})]})}function os(){const{language:l}=W(),{selectedClient:a}
10=H(),s=l==="he",[m,r]=d.useState(""),[p,N]=d.useState(""),[f,P]=d.useState([]),[v,L]=d.useState(!1),[y,w]=d.useState(new Set),M=async()=>{var n;if(m.trim()){if(!a){x.error(s?"נא לבחור לקוח":"Please select a client");return}L(!0);try{const{data:g,error:j}=await _.functions.invoke("pr-ai-cited-media",{body:{topic:m,country:p,language:l,client_id:a.id}});if(j)throw j;if(g!=null&&g.error)throw new Error(g.error);P(g.outlets||[]),(n=g.outlets)!=null&&n.length||x.info(s?"לא נמצאו תוצאות":"No results found")}catch(g){console.error(g),x.error(g.message||"Search failed")}finally{L(!1)}}},k=async n=>{if(!a)return;const g=n.domain;w(j=>new Set(j).add(g));try{const{error:j}=await _.from("pr_media_outlets").insert({client_id:a.id,name:n.name,domain:n.domain,description:n.description,ai_citation_score:n.ai_citation_score,monthly_traffic:n.monthly_traffic,category:n.category,country:n.country,topics:n.topics||[],metadata:{why_cited:n.why_cited}});if(j)throw j;x.success(s?`${n.name} נשמר`:`${n.name} saved`)}catch(j){x.error(j.message)}finally{w(j=>{const $=new Set(j);return $.delete(g),$})}},S=n=>n>=80?"text-emerald-400 bg-emerald-500/10 border-emerald-500/20":n>=60?"text-blue-400 bg-blue-500/10 border-blue-500/20":n>=40?"text-amber-400 bg-amber-500/10 border-amber-500/20":"text-muted-foreground bg-muted/50 border-border";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(E,{className:"border-border bg-card/50",children:e.jsxs(D,{className:"p-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(J,{className:"absolute start-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(V,{placeholder:s?"הכנס נושא או תעשייה (למשל: קוסמטיקה, פינטק, SaaS)":"Enter topic or industry (e.g. cosmetics, fintech, SaaS)",value:m,onChange:n=>r(n.target.value),onKeyDown:n=>n.key==="Enter"&&M(),className:"ps-9"})]}),e.jsx(V,{placeholder:s?"מדינה (אופציונלי)":"Country (optional)",value:p,onChange:n=>N(n.target.value),className:"w-full sm:w-40"}),e.jsxs(A,{onClick:M,disabled:v||!m.trim(),className:"gap-2",children:[v?e.jsx(R,{className:"w-4 h-4 animate-spin"}):e.jsx(ce,{className:"w-4 h-4"}),s?"חפש מדיה":"Find Media"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:s?"AI מזהה את אתרי המדיה שמצוטטים הכי הרבה על ידי מודלים כמו ChatGPT, Gemini ו-Perplexity":"AI identifies which media outlets are most cited by LLMs like ChatGPT, Gemini, and Perplexity"})]})}),f.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s?`${f.length} אתרי מדיה נמצאו`:`${f.length} media outlets found`}),e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>f.forEach(n=>k(n)),className:"gap-1 text-xs",children:[e.jsx(X,{className:"w-3 h-3"}),s?"שמור הכל":"Save All"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:f.map((n,g)=>{var j;return e.jsx(E,{className:"border-border bg-card/50 hover:bg-card/80 transition-colors",children:e.jsxs(D,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(ee,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold truncate",children:n.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.domain})]})]}),e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:e.jsxs(U,{variant:"outline",className:`text-[10px] ${S(n.ai_citation_score)}`,children:[e.jsx(se,{className:"w-3 h-3 me-1"}),n.ai_citation_score]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:n.description}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(U,{variant:"secondary",className:"text-[10px]",children:n.category}),n.monthly_traffic&&e.jsxs(U,{variant:"outline",className:"text-[10px]",children:[n.monthly_traffic," ",s?"ביקורים":"visits"]}),n.country&&e.jsx(U,{variant:"outline",className:"text-[10px]",children:n.country})]}),n.why_cited&&e.jsx("p",{className:"text-[11px] text-muted-foreground italic border-s-2 border-primary/30 ps-2",children:n.why_cited}),((j=n.topics)==null?void 0:j.length)>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:n.topics.slice(0,4).map(($,I)=>e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-muted/50 rounded text-muted-foreground",children:$},I))}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsxs(A,{size:"sm",variant:"outline",className:"text-xs gap-1 h-7",onClick:()=>k(n),disabled:y.has(n.domain),children:[y.has(n.domain)?e.jsx(R,{className:"w-3 h-3 animate-spin"}):e.jsx(X,{className:"w-3 h-3"}),s?"שמור":"Save"]}),n.domain&&e.jsxs(A,{size:"sm",variant:"ghost",className:"text-xs gap-1 h-7",onClick:()=>window.open(`https://${n.domain}`,"_blank"),children:[e.jsx(xe,{className:"w-3 h-3"}),s?"בקר":"Visit"]})]})]})},`${n.domain}-${g}`)})})]}),!v&&f.length===0&&e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ce,{className:"w-10 h-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm",children:s?"הכנס נושא כדי לגלות אתרי מדיה שמצוטטים על ידי AI":"Enter a topic to discover AI-cited media outlets"})]})]})}function ms(){const{language:l}=W(),{selectedClient:a}
10=H(),s=l==="he",[m,r]=d.useState(""),[p,N]=d.useState([]),[f,P]=d.useState(!1),[v,L]=d.useState([]),[y,w]=d.useState([]),[M,k]=d.useState(""),[S,n]=d.useState("search"),[g,j]=d.useState(new Set);d.useEffect(()=>{a&&($(),I())},[a==null?void 0:a.id]);const $=async()=>{if(!a)return;const{data:t}=await _.from("pr_journalists").select("*").eq("client_id",a.id).order("created_at",{ascending:!1}).limit(100);L(t||[])},I=async()=>{if(!a)return;const{data:t}=await _.from("pr_media_lists").select("*").eq("client_id",a.id).order("created_at",{ascending:!1});w(t||[])},K=async()=>{var t;if(m.trim()){P(!0);try{const{data:h,error:b}=await _.functions.invoke("pr-journalist-search",{body:{query:m,language:l}});if(b)throw b;if(h!=null&&h.error)throw new Error(h.error);N(h.journalists||[]),(t=h.journalists)!=null&&t.length||x.info(s?"לא נמצאו תוצאות":"No results found")}catch(h){x.error(h.message)}finally{P(!1)}}},T=async t=>{var h,b;if(a){j(C=>new Set(C).add(t.full_name));try{const{error:C}=await _.from("pr_journalists").insert({client_id:a.id,full_name:t.full_name,email:t.email,job_title:t.job_title,beat:t.beat,bio:t.bio,linkedin_url:t.linkedin_url,twitter_handle:t.twitter_handle,recent_articles:((h=t.recent_topics)==null?void 0:h.map(q=>({topic:q})))||[],tags:((b=t.recent_topics)==null?void 0:b.slice(0,3))||[]});if(C)throw C;x.success(s?`${t.full_name} נשמר`:`${t.full_name} saved`),$()}catch(C){x.error(C.message)}finally{j(C=>{const q=new Set(C);return q.delete(t.full_name),q})}}},B=async()=>{if(!(!M.trim()||!a))try{const{error:t}=await _.from("pr_media_lists").insert({client_id:a.id,name:M});if(t)throw t;x.success(s?"רשימה נוצרה":"List created"),k(""),I()}catch(t){x.error(t.message)}},Q=async(t,h)=>{try{const{error:b}=await _.from("pr_media_list_members").insert({list_id:t,journalist_id:h});if(b){if(b.code==="23505"){x.info(s?"כבר ברשימה":"Already in list");return}throw b}x.success(s?"נוסף לרשימה":"Added to list")}catch(b){x.error(b.message)}},i=async t=>{try{const{error:h}=await _.from("pr_journalists").delete().eq("id",t);if(h)throw h;L(b=>b.filter(C=>C.id!==t)),x.success(s?"נמחק":"Deleted")}catch(h){x.error(h.message)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex gap-2 border-b border-border pb-2",children:[{key:"search",icon:J,label:s?"חיפוש AI":"AI Search"},{key:"saved",icon:de,label:s?`שמורים (${v.length})`:`Saved (${v.length})`},{key:"lists",icon:ne,label:s?`רשימות (${y.length})`:`Lists (${y.length})`}].map(t=>e.jsxs(A,{variant:S===t.key?"default":"ghost",size:"sm",className:"gap-1.5 text-xs",onClick:()=>n(t.key),children:[e.jsx(t.icon,{className:"w-3.5 h-3.5"}),t.label]},t.key))}),S==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(E,{className:"border-border bg-card/50",children:e.jsx(D,{className:"p-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(J,{className:"absolute start-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(V,{placeholder:s?"חפש עיתונאים לפי נושא, מדיה או שם...":"Search journalists by topic, outlet, or name...",value:m,onChange:t=>r(t.target.value),onKeyDown:t=>t.key==="Enter"&&K(),className:"ps-9"})]}),e.jsxs(A,{onClick:K,disabled:f||!m.trim(),className:"gap-2",children:[f?e.jsx(R,{className:"w-4 h-4 animate-spin"}):e.jsx(J,{className:"w-4 h-4"}),s?"חפש":"Search"]})]})})}),p.length>0&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:p.map((t,h)=>e.jsx(xs,{journalist:t,isHe:s,onSave:()=>T(t),saving:g.has(t.full_name)},`${t.full_name}-${h}`))}),!f&&p.length===0&&e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(J,{className:"w-10 h-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm",children:s?"חפש עיתונאים עם AI":"Search for journalists with AI"})]})]}),S==="saved"&&e.jsx("div",{className:"space-y-3",children:v.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(de,{className:"w-10 h-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm",children:s?"אין עיתונאים שמורים עדיין":"No saved journalists yet"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:v.map(t=>{var h;return e.jsx(E,{className:"border-border bg-card/50",children:e.jsxs(D,{className:"p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(we,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:t.full_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.job_title})]})]}),e.jsxs("div",{className:"flex gap-1",children:[y.length>0&&e.jsxs(Be,{children:[e.jsx(Qe,{asChild:!0,children:e.jsx(A,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",children:e.jsx(Ye,{className:"w-3.5 h-3.5"})})}),e.jsxs(Ue,{className:"max-w-sm",children:[e.jsx(qe,{children:e.jsx(Ge,{children:s?"הוסף לרשימה":"Add to List"})}),e.jsx("div",{className:"space-y-2",children:y.map(b=>e.jsx(A,{variant:"outline",className:"w-full justify-start text-sm",onClick:()=>Q(b.id,t.id),children:b.name},b.id))})]})]}),e.jsx(A,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive",onClick:()=>i(t.id),children:"×"})]})]}),t.beat&&e.jsx("p",{className:"text-xs text-muted-foreground",children:t.beat}),t.email&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ue,{className:"w-3 h-3"})," ",t.email]}),((h=t.tags)==null?void 0:h.length)>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:t.tags.map((b,C)=>e.jsx(U,{variant:"secondary",className:"text-[10px]",children:b},C))})]})},t.id)})})}),S==="lists"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(E,{className:"border-border bg-card/50",children:e.jsx(D,{className:"p-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(V,{placeholder:s?"שם רשימה חדשה...":"New list name...",value:M,onChange:t=>k(t.target.value),onKeyDown:t=>t.key==="Enter"&&B()}),e.jsxs(A,{onClick:B,disabled:!M.trim(),className:"gap-1",children:[e.jsx(te,{className:"w-4 h-4"}),s?"צור":"Create"]})]})})}),y.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ne,{className:"w-10 h-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm",children:s?"אין רשימות עדיין":"No lists yet"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:y.map(t=>e.jsx(E,{className:"border-border bg-card/50 hover:bg-card/80 transition-colors",children:e.jsxs(D,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4 text-primary"}),e.jsx("p",{className:"text-sm font-semibold",children:t.name})]}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.description})]})},t.id))})]})]})}function xs({journalist:l,isHe:a,onSave:s,saving:m}){var r;return e.jsx(E,{className:"border-border bg-card/50 hover:bg-card/80 transition-colors",children:e.jsxs(D,{className:"p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(we,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold truncate",children:l.full_name}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[l.job_title," @ ",l.outlet_name]})]})]}),l.relevance_score&&e.jsxs(U,{variant:"outline",className:"text-[10px] flex-shrink-0",children:[l.relevance_score,"%"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.beat}),l.bio&&e.jsx("p",{className:"text-[11px] text-muted-foreground line-clamp-2",children:l.bio}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[l.email&&e.jsxs("a",{href:`mailto:${l.email}`,className:"flex items-center gap-1 hover:text-foreground",children:[e.jsx(ue,{className:"w-3 h-3"})," ",l.email]}),l.linkedin_url&&e.jsx("a",{href:l.linkedin_url,target:"_blank",className:"flex items-center gap-1 hover:text-foreground",children:e.jsx(Ve,{className:"w-3 h-3"})}
10),l.twitter_handle&&e.jsxs("a",{href:`https://x.com/${l.twitter_handle}`,target:"_blank",className:"flex items-center gap-1 hover:text-foreground",children:[e.jsx(is,{className:"w-3 h-3"})," ",l.twitter_handle]})]}),((r=l.recent_topics)==null?void 0:r.length)>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:l.recent_topics.slice(0,4).map((p,N)=>e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-muted/50 rounded text-muted-foreground",children:p},N))}),e.jsx("div",{className:"pt-1",children:e.jsxs(A,{size:"sm",variant:"outline",className:"text-xs gap-1 h-7",onClick:s,disabled:m,children:[m?e.jsx(R,{className:"w-3 h-3 animate-spin"}):e.jsx(X,{className:"w-3 h-3"}),a?"שמור ל-CRM":"Save to CRM"]})})]})})}function us(){const{language:l,t:a,isRTL:s}=W(),{selectedClient:m}=H(),[r,p]=d.useState("list"),[N,f]=d.useState([]),[P,v]=d.useState(!1),[L,y]=d.useState(null),[w,M]=d.useState(""),[k,S]=d.useState(""),[n,g]=d.useState(""),[j,$]=d.useState("professional"),[I,K]=d.useState(!1),[T,B]=d.useState(!1);d.useEffect(()=>{m&&Q()},[m==null?void 0:m.id]);const Q=async()=>{if(!m)return;const{data:o}=await _.from("pr_press_releases").select("*").eq("client_id",m.id).order("created_at",{ascending:!1});f(o||[])},i=async()=>{if(!w.trim()){x.error(a("pr.enterTitle"));return}K(!0);try{const{data:o,error:z}=await _.functions.invoke("pr-write-press-release",{body:{topic:w,key_points:n,tone:j,language:l,company_name:m==null?void 0:m.name,existing_content:k||void 0}});if(z)throw z;if(o!=null&&o.error)throw new Error(o.error);S(o.content||""),x.success(a("pr.generated"))}catch(o){x.error(o.message)}finally{K(!1)}},t=async()=>{if(!(!m||!w.trim())){B(!0);try{if(L){const{error:o}=await _.from("pr_press_releases").update({title:w,content:k,language:l,updated_at:new Date().toISOString()}).eq("id",L);if(o)throw o}else{const{error:o}=await _.from("pr_press_releases").insert({client_id:m.id,title:w,content:k,language:l,status:"draft"});if(o)throw o}x.success(a("pr.saved")),Q(),p("list"),C()}catch(o){x.error(o.message)}finally{B(!1)}}},h=o=>{y(o.id),M(o.title),S(o.content),p("editor")},b=async o=>{try{const{error:z}=await _.from("pr_press_releases").delete().eq("id",o);if(z)throw z;f(ae=>ae.filter(Z=>Z.id!==o)),x.success(a("pr.deleted"))}catch(z){x.error(z.message)}},C=()=>{y(null),M(""),S(""),g(""),$("professional")},q=o=>o==="sent"?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":o==="draft"?"bg-amber-500/10 text-amber-400 border-amber-500/20":"bg-muted/50 text-muted-foreground";return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(A,{variant:r==="list"?"default":"ghost",size:"sm",className:"gap-1.5 text-xs",onClick:()=>{p("list"),C()},children:[e.jsx(Ne,{className:"w-3.5 h-3.5"}),a("pr.pressReleases")]}),e.jsxs(A,{variant:r==="editor"?"default":"ghost",size:"sm",className:"gap-1.5 text-xs",onClick:()=>{p("editor"),C()},children:[e.jsx(Je,{className:"w-3.5 h-3.5"}),a("pr.newRelease")]})]})}),r==="editor"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(E,{className:"border-border bg-card/50",children:e.jsxs(D,{className:"p-4 space-y-4",children:[e.jsx(V,{placeholder:a("pr.titlePlaceholder"),value:w,onChange:o=>M(o.target.value),className:"text-base font-medium"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx(V,{placeholder:a("pr.keyPoints"),value:n,onChange:o=>g(o.target.value),className:"flex-1"}),e.jsxs(es,{value:j,onValueChange:$,children:[e.jsx(ss,{className:"w-full sm:w-40",children:e.jsx(ts,{})}),e.jsxs(as,{children:[e.jsx(Y,{value:"professional",children:a("pr.professional")}),e.jsx(Y,{value:"casual",children:a("pr.casual")}),e.jsx(Y,{value:"urgent",children:a("pr.urgent")}),e.jsx(Y,{value:"storytelling",children:a("pr.storytelling")})]})]}),e.jsxs(A,{onClick:i,disabled:I||!w.trim(),className:"gap-2",children:[I?e.jsx(R,{className:"w-4 h-4 animate-spin"}):e.jsx(ie,{className:"w-4 h-4"}),a("pr.generateAI")]})]}),e.jsx(We,{placeholder:a("pr.contentPlaceholder"),value:k,onChange:o=>S(o.target.value),rows:16,className:"font-mono text-sm"}),e.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[e.jsx(A,{variant:"outline",onClick:()=>{p("list"),C()},children:a("pr.cancel")}),e.jsxs(A,{onClick:t,disabled:T||!w.trim(),className:"gap-2",children:[T?e.jsx(R,{className:"w-4 h-4 animate-spin"}):e.jsx(X,{className:"w-4 h-4"}),a("pr.save")]})]})]})}),k&&e.jsx(E,{className:"border-border bg-card/50",children:e.jsxs(D,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(le,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:a("pr.preview")})]}),e.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",dir:s?"rtl":"ltr",dangerouslySetInnerHTML:{__html:rs.sanitize(k)}})]})})]}),r==="list"&&e.jsx("div",{className:"space-y-3",children:N.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Ne,{className:"w-10 h-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm",children:a("pr.noReleases")}),e.jsxs(A,{variant:"outline",size:"sm",className:"mt-3 gap-1",onClick:()=>{p("editor"),C()},children:[e.jsx(te,{className:"w-3.5 h-3.5"}),a("pr.createNew")]})]}):N.map(o=>e.jsx(E,{className:"border-border bg-card/50 hover:bg-card/80 transition-colors cursor-pointer",onClick:()=>h(o),children:e.jsx(D,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-sm font-semibold truncate",children:o.title}),e.jsx(U,{variant:"outline",className:`text-[10px] ${q(o.status)}`,children:o.status==="draft"?a("pr.draft"):o.status==="sent"?a("pr.sent"):o.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(o.created_at).toLocaleDateString(s?"he-IL":"en-US")}),o.sent_count>0&&e.jsxs("div",{className:"flex gap-3 mt-1 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[e.jsx(ye,{className:"w-3 h-3 inline me-1"}),o.sent_count]}),e.jsxs("span",{children:[e.jsx(le,{className:"w-3 h-3 inline me-1"}),o.opened_count]})]})]}),e.jsx(A,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive flex-shrink-0",onClick:z=>{z.stopPropagation(),b(o.id)},children:e.jsx(_e,{className:"w-3.5 h-3.5"})})]})})},o.id))})]})}function hs(){const{language:l}=W(),{selectedClient:a}
10=H(),s=l==="he",[m,r]=d.useState([]),[p,N]=d.useState(""),[f,P]=d.useState(""),[v,L]=d.useState(null),[y,w]=d.useState([]),[M,k]=d.useState(""),[S,n]=d.useState(!1),[g,j]=d.useState(!1);d.useEffect(()=>{a&&$()},[a==null?void 0:a.id]);const $=async()=>{if(!a)return;const{data:i}=await _.from("pr_monitoring_queries").select("*").eq("client_id",a.id).order("created_at",{ascending:!1});r(i||[])},I=async()=>{if(!(!p.trim()||!a)){j(!0);try{const{error:i}=await _.from("pr_monitoring_queries").insert({client_id:a.id,query_text:p,alert_email:f||null});if(i)throw i;x.success(s?"שאילתה נוצרה":"Query created"),N(""),P(""),$()}catch(i){x.error(i.message)}finally{j(!1)}}},K=async i=>{try{const{error:t}=await _.from("pr_monitoring_queries").delete().eq("id",i);if(t)throw t;r(h=>h.filter(b=>b.id!==i)),(v==null?void 0:v.id)===i&&(L(null),w([])),x.success(s?"נמחק":"Deleted")}catch(t){x.error(t.message)}},T=async i=>{if(a){L(i),n(!0),w([]),k("");try{const{data:t,error:h}=await _.functions.invoke("pr-monitor-mentions",{body:{query_text:i.query_text,client_id:a.id,language:l}});if(h)throw h;if(t!=null&&t.error)throw new Error(t.error);w(t.mentions||[]),k(t.overall_summary||""),await _.from("pr_monitoring_queries").update({last_run_at:new Date().toISOString(),results_count:(t.mentions||[]).length}).eq("id",i.id),$()}catch(t){x.error(t.message)}finally{n(!1)}}},B=i=>i==="positive"?e.jsx(se,{className:"w-3.5 h-3.5 text-emerald-400"}):i==="negative"?e.jsx(me,{className:"w-3.5 h-3.5 text-red-400"}):e.jsx(ns,{className:"w-3.5 h-3.5 text-muted-foreground"}),Q=i=>i==="positive"?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":i==="negative"?"bg-red-500/10 text-red-400 border-red-500/20":"bg-muted/50 text-muted-foreground border-border";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(E,{className:"border-border bg-card/50",children:e.jsx(D,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx(V,{placeholder:s?"מה לנטר? (שם חברה, מותג, מוצר...)":"What to monitor? (company, brand, product...)",value:p,onChange:i=>N(i.target.value),onKeyDown:i=>i.key==="Enter"&&I(),className:"flex-1"}),e.jsx(V,{placeholder:s?"אימייל להתראות (אופציונלי)":"Alert email (optional)",value:f,onChange:i=>P(i.target.value),className:"w-full sm:w-56"}),e.jsxs(A,{onClick:I,disabled:g||!p.trim(),className:"gap-2",children:[g?e.jsx(R,{className:"w-4 h-4 animate-spin"}):e.jsx(te,{className:"w-4 h-4"}),s?"צור שאילתה":"Create Query"]})]})})}),m.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s?"שאילתות מעקב":"Monitoring Queries"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:m.map(i=>e.jsx(E,{className:`border-border cursor-pointer transition-colors ${(v==null?void 0:v.id)===i.id?"bg-primary/5 border-primary/30":"bg-card/50 hover:bg-card/80"}`,onClick:()=>T(i),children:e.jsx(D,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:i.query_text}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[i.last_run_at&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[s?"סריקה אחרונה":"Last scan",": ",new Date(i.last_run_at).toLocaleDateString(s?"he-IL":"en-US")]}),i.results_count>0&&e.jsx(U,{variant:"secondary",className:"text-[10px]",children:i.results_count}),i.alert_email&&e.jsx(Fe,{className:"w-3 h-3 text-amber-400"})]})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(A,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:t=>{t.stopPropagation(),T(i)},children:e.jsx(ve,{className:`w-3.5 h-3.5 ${S&&(v==null?void 0:v.id)===i.id?"animate-spin":""}`})}),e.jsx(A,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive",onClick:t=>{t.stopPropagation(),K(i.id)},children:e.jsx(_e,{className:"w-3.5 h-3.5"})})]})]})})},i.id))})]}),S&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(R,{className:"w-8 h-8 animate-spin mx-auto mb-3 text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?"סורק אזכורים...":"Scanning mentions..."})]}),M&&!S&&e.jsx(E,{className:"border-primary/20 bg-primary/5",children:e.jsxs(D,{className:"p-4",children:[e.jsx("p",{className:"text-xs font-medium text-primary mb-1",children:s?"סיכום AI":"AI Summary"}),e.jsx("p",{className:"text-sm text-foreground",children:M})]})}),y.length>0&&!S&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s?`${y.length} אזכורים נמצאו`:`${y.length}
10 mentions found`}),y.map((i,t)=>e.jsx(E,{className:"border-border bg-card/50",children:e.jsxs(D,{className:"p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:i.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.outlet_name})]}),e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:e.jsxs(U,{variant:"outline",className:`text-[10px] gap-1 ${Q(i.sentiment)}`,children:[B(i.sentiment),i.sentiment==="positive"?s?"חיובי":"Positive":i.sentiment==="negative"?s?"שלילי":"Negative":s?"ניטרלי":"Neutral"]})})]}),i.snippet&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:i.snippet}),i.ai_summary&&e.jsx("p",{className:"text-[11px] text-muted-foreground italic border-s-2 border-primary/30 ps-2",children:i.ai_summary}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[i.published_at&&e.jsx("span",{children:new Date(i.published_at).toLocaleDateString(s?"he-IL":"en-US")}),i.url&&e.jsxs("a",{href:i.url,target:"_blank",className:"flex items-center gap-1 hover:text-foreground",children:[e.jsx(xe,{className:"w-3 h-3"}),s?"קרא":"Read"]})]})]})},t))]}),!S&&y.length===0&&m.length===0&&e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Ae,{className:"w-10 h-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm",children:s?"צור שאילתת מעקב כדי לנטר אזכורי מדיה":"Create a monitoring query to track media mentions"})]})]})}const ps=[{key:"cited",icon:ce,tKey:"pr.citedMedia"},{key:"crm",icon:de,tKey:"pr.mediaCRM"},{key:"emails",icon:ue,tKey:"pr.emailsPR"},{key:"monitoring",icon:Ae,tKey:"pr.monitoring"}];function gs(){const{t:l,language:a}=W();return e.jsxs(Se,{defaultValue:"cited",dir:a==="he"?"rtl":"ltr",children:[e.jsx(ke,{className:"mb-4 flex-wrap h-auto gap-1 p-1",children:ps.map(s=>{const m=s.icon;return e.jsxs(oe,{value:s.key,className:"gap-1.5 text-xs",children:[e.jsx(m,{className:"w-3.5 h-3.5"}),l(s.tKey)]},s.key)})}),e.jsx(F,{value:"cited",children:e.jsx(os,{})}),e.jsx(F,{value:"crm",children:e.jsx(ms,{})}),e.jsx(F,{value:"emails",children:e.jsx(us,{})}),e.jsx(F,{value:"monitoring",children:e.jsx(hs,{})})]})}function Rs(){const{selectedClient:l}=H(),{t:a,dir:s}=W();return e.jsxs("div",{className:"space-y-5",dir:s,children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold",children:a("pr.title")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:l?`${a("pr.brandAnalysis")} — ${l.name}`:a("pr.selectClient")})]}),e.jsx(Ze,{sectionKey:"pr",departmentKey:"campaigns"}),e.jsxs(Se,{defaultValue:"sentiment",dir:s,children:[e.jsxs(ke,{className:"mb-4",children:[e.jsx(oe,{value:"sentiment",children:a("pr.sentimentAnalysis")}),e.jsx(oe,{value:"toolkit",children:a("pr.aiToolkit")})]}),e.jsx(F,{value:"sentiment",children:e.jsx(ds,{})}),e.jsx(F,{value:"toolkit",children:e.jsx(gs,{})})]})]})}export{Rs 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.