PageSourceSearch

https://aivatarconsulting.com/assets/RiskSnapshot-C517iMD4.js

js aivatarconsulting.com collected 2026-10-06 16:17:30 UTC 15,236 bytes, 1 lines download raw bytes

1import{r as u,u as P,j as e,d as F}from"./query-fyEnlpnq.js";import{f as M,a as $,L as E}from"./vendor-Dfppvpp-.js";import{i as B,z as S,B as b,ah as L,Q as _,aG as D,T as R,v as A,a as v,k as j,s as w,l as I}from"./main-fPD8r1f5.js";import{I as g}from"./input-DUR0onGU.js";import{L as k}from"./label-LcIBBB7d.js";import{C as m,c as x}from"./card-CLPmDBmE.js";import{B as y}from"./badge-6XLFaS8J.js";import{S as T}from"./skeleton-DG_ZxSHs.js";import{u as N}from"./builder-CKyCCeo_.js";import{B as G}from"./building-2-B_GDZkw8.js";import{S as q}from"./share-2-CCesb5cR.js";import{S as z}from"./shield-alert-DQDrLPYo.js";import{T as W}from"./triangle-alert-CCkSeLAm.js";import"./ui-bwY9AN7d.js";function Q(r){return r==="high"?"bg-rose-500/10 text-rose-700 border-rose-500/30":r==="medium"?"bg-amber-500/10 text-amber-700 border-amber-500/30":"bg-emerald-500/10 text-emerald-700 border-emerald-500/30"}function U(r){return r>=70?{ring:"stroke-rose-500",text:"text-rose-600",track:"stroke-rose-500/15"}:r>=40?{ring:"stroke-amber-500",text:"text-amber-600",track:"stroke-amber-500/15"}:{ring:"stroke-emerald-500",text:"text-emerald-600",track:"stroke-emerald-500/15"}}function H({score:r}){const s=U(r),i=56,t=2*Math.PI*i,c=t-r/100*t;return e.jsxs("div",{className:"relative w-32 h-32",children:[e.jsxs("svg",{className:"w-32 h-32 -rotate-90",viewBox:"0 0 128 128",children:[e.jsx("circle",{cx:"64",cy:"64",r:i,className:`fill-none ${s.track}`,strokeWidth:"10"}),e.jsx("circle",{cx:"64",cy:"64",r:i,className:`fill-none ${s.ring} transition-all duration-700`,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:t,strokeDashoffset:c})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:`text-3xl font-black tabular-nums ${s.text}`,children:r}),e.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:"/ 100"})]})})]})}function K({onComplete:r}){const{t:s}=N("publicMarketing"),{toast:i}=_(),[t,c]=u.useState(""),[n,p]=u.useState(""),[d,a]=u.useState(""),[l,h]=u.useState(""),f=F({mutationFn:async()=>{j("risk_snapshot_started",{company:t.trim(),has_country:!!n.trim(),has_industry:!!d.trim()});const{data:o,error:C}=await w.functions.invoke("risk-snapshot-public",{body:{company_name:t.trim(),country:n.trim(),industry:d.trim(),website:l.trim()}});if(C)throw new Error(C.message??s("riskSnapshot.form.errorGenerationFailed"));if(o?.error)throw new Error(o.error);return o},onSuccess:o=>{j("risk_snapshot_generated",{company:t.trim(),risk_score:o.risk_score??null}),r(o.share_token)},onError:o=>{j("risk_snapshot_failed",{company:t.trim(),error:o.message}),i({title:o.message,variant:"destructive"})}});return e.jsx(m,{className:"rounded-2xl border-border/50 bg-card/70 backdrop-blur",children:e.jsxs(x,{className:"p-5 md:p-7 space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-lg md:text-xl font-black tracking-tight text-foreground",children:s("riskSnapshot.form.title")}),e.jsx("p",{className:"text-sm text-muted-foreground font-medium",children:s("riskSnapshot.form.subtitle")})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs(k,{htmlFor:"company",className:"text-xs font-bold",children:[s("riskSnapshot.form.companyLabel")," ",e.jsx("span",{className:"text-rose-500",children:"*"})]}),e.jsx(g,{id:"company",value:t,onChange:o=>c(o.target.value),placeholder:s("riskSnapshot.form.companyPlaceholder"),className:"rounded-lg mt-1"})]}),e.jsxs("div",{children:[e.jsx(k,{htmlFor:"country",className:"text-xs font-bold",children:s("riskSnapshot.form.countryLabel")}),e.jsx(g,{id:"country",value:n,onChange:o=>p(o.target.value),placeholder:s("riskSnapshot.form.countryPlaceholder"),className:"rounded-lg mt-1"})]}),e.jsxs("div",{children:[e.jsx(k,{htmlFor:"industry",className:"text-xs font-bold",children:s("riskSnapshot.form.industryLabel")}),e.jsx(g,{id:"industry",value:d,onChange:o=>a(o.target.value),placeholder:s("riskSnapshot.form.industryPlaceholder"),className:"rounded-lg mt-1"})]}),e.jsxs("div",{children:[e.jsx(k,{htmlFor:"website",className:"text-xs font-bold",children:s("riskSnapshot.form.websiteLabel")}
1),e.jsx(g,{id:"website",value:l,onChange:o=>h(o.target.value),placeholder:s("riskSnapshot.form.websitePlaceholder"),className:"rounded-lg mt-1"})]})]}),e.jsx(b,{size:"lg",className:"w-full rounded-lg font-bold gap-2",disabled:f.isPending||t.trim().length<2,onClick:()=>f.mutate(),children:f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"w-4 h-4 animate-pulse"}),s("riskSnapshot.form.researching")]}):e.jsxs(e.Fragment,{children:[s("riskSnapshot.form.submit"),e.jsx(L,{className:"w-4 h-4"})]})}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70 text-center",children:s("riskSnapshot.form.footnote")})]})})}function O({shareToken:r}){const{t:s}=N("publicMarketing"),{toast:i}=_(),[t,c]=u.useState(""),[n,p]=u.useState(!1),d=F({mutationFn:async()=>{const{data:a,error:l}=await w.functions.invoke("risk-snapshot-public",{body:{action:"capture_email",share_token:r,email:t.trim()}});if(l)throw new Error(l.message??s("riskSnapshot.email.errorFailed"));if(a?.error)throw new Error(a.error);return a},onSuccess:()=>{j("risk_snapshot_email_captured",{share_token:r}),p(!0),i({title:s("riskSnapshot.email.toastSuccess")})},onError:a=>i({title:a.message,variant:"destructive"})});return n?e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-emerald-700",children:[e.jsx(v,{className:"w-4 h-4"}),s("riskSnapshot.email.submittedNote",{email:t})]}):e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(g,{type:"email",value:t,onChange:a=>c(a.target.value),placeholder:s("riskSnapshot.email.placeholder"),className:"rounded-lg"}),e.jsxs(b,{onClick:()=>d.mutate(),disabled:d.isPending||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t),className:"rounded-lg font-bold gap-2 shrink-0",children:[e.jsx(I,{className:"w-4 h-4"}),d.isPending?s("riskSnapshot.email.sending"):s("riskSnapshot.email.submit")]})]})}function J({row:r}){const{t:s}=N("publicMarketing"),{toast:i}=_(),t=r.snapshot,c=r.risk_score??t.risk_score??0,n=r.exposure_summary??t.exposure_summary??"",p=u.useMemo(()=>`${window.location.origin}/risk-snapshot/${r.share_token}`,[r.share_token]),d=async()=>{try{await navigator.clipboard.writeText(p),i({title:s("riskSnapshot.result.copyToastSuccess")})}catch{i({title:s("riskSnapshot.result.copyToastFailed",{url:p}),variant:"destructive"})}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(m,{className:"rounded-2xl border-border/50 bg-card/70 backdrop-blur overflow-hidden",children:e.jsx(x,{className:"p-5 md:p-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center gap-5",children:[e.jsx(H,{score:c}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(G,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("h1",{className:"text-xl md:text-2xl font-black tracking-tight text-foreground truncate",children:t.company?.name??r.company_name}),t.company?.country&&e.jsxs(y,{variant:"outline",className:"font-bold rounded-full",children:[e.jsx(D,{className:"w-3 h-3 mr-1"}),t.company.country]}),t.company?.industry&&e.jsx(y,{variant:"outline",className:"font-bold rounded-full",children:t.company.industry})]}),e.jsx("p",{className:"text-sm md:text-base font-semibold text-foreground/90 leading-snug",children:n||s("riskSnapshot.result.generatingSummary")}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsxs(b,{size:"sm",variant:"outline",onClick:d,className:"rounded-lg gap-2 h-8 font-bold",children:[e.jsx(q,{className:"w-3.5 h-3.5"}),s("riskSnapshot.result.copyLink")]}),e.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:s("riskSnapshot.result.generatedAt",{date:new Date(r.generated_at).toLocaleString()})})]})]})]})})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:(t.top_risks??[]).map((a,l)=>e.jsx(m,{className:"rounded-xl border-border/50 bg-card/60",children:e.jsxs(x,{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-1.5",children:[e.jsx(z,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-[10px] font-black uppercase tracking-wider text-muted-foreground",children:a.category})]}),e.jsx(y,{className:`text-[10px] font-bold rounded-full uppercase ${Q(a.severity)}`,children:a.severity})]}),e.jsx("h3",{className:"text-sm font-black tracking-tight text-foreground leading-snug",children:a.title}),e.jsx("p",{className:"text-xs text-muted-foreground font-medium leading-relaxed",children:a.rationale}),e.jsxs("div",{className:"flex items-center gap-3 pt-1 text-[10px] font-bold text-muted-foreground
1/80",children:[a.date_anchor&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(R,{className:"w-3 h-3"})," ",a.date_anchor]}),a.source_hint&&e.jsx("span",{className:"truncate",children:s("riskSnapshot.result.verifyPrefix",{source:a.source_hint})})]})]})},l))}),t.named_regulations?.length>0&&e.jsx(m,{className:"rounded-xl border-border/50 bg-card/60",children:e.jsxs(x,{className:"p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(A,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-[10px] font-black uppercase tracking-wider text-muted-foreground",children:s("riskSnapshot.result.namedRegulations")})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.named_regulations.map((a,l)=>e.jsxs("span",{title:a.relevance,className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-lg bg-foreground/[0.04] border border-border/40 text-xs font-bold",children:[a.name,e.jsx("span",{className:"text-[10px] font-medium text-muted-foreground",children:a.jurisdiction})]},l))})]})}),t.recent_event_impact&&e.jsx(m,{className:"rounded-xl border-amber-500/30 bg-amber-500/[0.03]",children:e.jsxs(x,{className:"p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(W,{className:"w-3.5 h-3.5 text-amber-600"}),e.jsx("span",{className:"text-[10px] font-black uppercase tracking-wider text-amber-700",children:s("riskSnapshot.result.recentEventImpact",{date:t.recent_event_impact.date_anchor})})]}),e.jsx("h3",{className:"text-sm font-black text-foreground",children:t.recent_event_impact.event}),e.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:t.recent_event_impact.impact})]})}),e.jsx(m,{className:"rounded-2xl border-primary/30 bg-gradient-to-br from-primary/5 to-primary/[0.02]",children:e.jsxs(x,{className:"p-5 md:p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(S,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-[10px] font-black uppercase tracking-wider text-primary",children:s("riskSnapshot.result.fullDossierEyebrow")})]}),e.jsx("h2",{className:"text-lg md:text-xl font-black tracking-tight text-foreground",children:s("riskSnapshot.result.fullDossierTitle")})]}),e.jsx("ul",{className:"space-y-1.5",children:(t.what_full_dossier_adds??[]).map((a,l)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm font-medium text-foreground/90",children:[e.jsx(v,{className:"w-4 h-4 text-primary shrink-0 mt-0.5"}),e.jsx("span",{children:a})]},l))}),r.email_captured?e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-emerald-700",children:[e.jsx(v,{className:"w-4 h-4"}),s("riskSnapshot.result.alreadyRequested")]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(k,{className:"text-xs font-bold",children:s("riskSnapshot.email.label")}),e.jsx(O,{shareToken:r.share_token})]}),e.jsx("div",{className:"text-[11px] text-muted-foreground/70 pt-1 border-t border-border/30",children:s("riskSnapshot.result.privacyNote")})]})})]})}function de(){const{t:r}=N("publicMarketing"),{token:s}=M(),i=$(),[t,c]=u.useState(s??null);u.useEffect(()=>{s&&s!==t&&c(s)},[s,t]);const{data:n,isLoading:p}=P({queryKey:["public_risk_snapshot",t],queryFn:async()=>{if(!t)return null;const{data:h,error:f}=await w.rpc("get_public_risk_snapshot",{p_share_token:t});return f?null:(h??[])[0]??null},enabled:!!t,refetchInterval:h=>h.state.data?.status==="generating"?3e3:!1,staleTime:3e4}),d=h=>{c(h),i(`/risk-snapshot/${h}`)},a=n?r("riskSnapshot.seo.titleResult",{company:n.company_name}):r("riskSnapshot.seo.titleDefault"),l=n?.exposure_summary?n.exposure_summary:r("riskSnapshot.seo.descriptionDefault");return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-background via-background to-background/95",children:[e.jsx(B,{title:a,description:l,path:n?`/risk-snapshot/${n.share_token}`:"/risk-snapshot"}),e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-8 md:py-12 space-y-6",children:[e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsxs(E,{to:"/",className:"inline-flex items-center gap-1.5 text-xs font-bold text-muted-foreground hover:text-foreground transition",children:["← ",r("riskSnapshot.header.backToConsulting")]}),e.jsx("h1",{className:"text-2xl md:text-4xl font-black tracking-tight text-foreground leading-tight",children:r("riskSnapshot.header.title")}),e.jsx("p",{className:"text-sm md:text-base text-muted-foreground font-medium max-w-xl mx-auto",children:r("riskSnapshot.header.subtitle")})]}),!t&&e.jsx(K,{onComplete:d}),t&&p&&e.jsx(m,{className:"rounded-2xl border-border/50",children:e.jsxs(x,{className:"p-5 space-y-3",children:[e.jsx(T,{className:"h-32 w-full rounded-xl"}),e.jsx(T,{className:"h-24 w-full rounded-xl"})]})}),t&&n?.status==="generating"&&e.jsx(m,{className:"rounded-2xl border-border/50",children:e.jsxs(x,{className:"p-5 flex flex-col items-center text-center gap-3",children:[e.jsx(S,{className:"w-6 h-6 text-primary animate-pulse"}),e.jsx("p",{className:"text-sm font-bold text-foreground",children:r("riskSnapshot.states.researchingExposures",{company:n.company_name})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("riskSnapshot.states.researchingNote")})]})}),t&&n?.status==="failed"&&e.jsx(m,{className:"rounded-2xl border-rose-500/30 bg-rose-500/[0.03]",children:e.jsxs(x,{className:"p-5 space-y-3",children:[e.jsx("p",{className:"text-sm font-bold text-rose-700",children:r("riskSnapshot.states.failedTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("riskSnapshot.states.failedNote")}),e.jsx(b,{onClick:()=>{c(null),i("/risk-snapshot")},variant:"outline",className:"rounded-lg font-bold",children:r("riskSnapshot.states.tryAnother")})]})}),t&&n?.status==="ready"&&e.jsx(J,{row:n}),e.jsxs("div",{className:"text-center space-y-1 pt-4",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground font-medium",children:r("riskSnapshot.footer.poweredBy")}),e.jsxs(E,{to:"/ai/risk-intelligence",className:"inline-flex items-center gap-1 text-[11px] font-bold text-primary hover:underline",children:[r("riskSnapshot.footer.seeModule")," ",e.jsx(L,{className:"w-3 h-3"})]})]})]})]})}export{de 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.