1!function(){try{var e="u">typeof window?window:"u">typeof global?global:"u">typeof globalThis?globalThis:"u">typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a3062e2c-f8c4-4ee2-948d-cc34f83e58ef",e._sentryDebugIdIdentifier="sentry-dbid-a3062e2c-f8c4-4ee2-948d-cc34f83e58ef")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3071],{9872:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/suggestions",function(){return a(78512)}])},74252:(e,t,a)=>{"use strict";a.d(t,{h:()=>i});var s=a(14232),r=a(4033);function i(){let[e,t]=(0,s.useState)(null),[a,i]=(0,s.useState)(!0);return(0,s.useEffect)(()=>{let e=!0;return(async()=>{try{let{data:a}=await r.N.auth.getSession(),s=a.session?.access_token;if(!s){e&&(t(null),i(!1));return}let n=await fetch("/api/profile/user-org",{headers:{Authorization:`Bearer ${s}`}});if(!n.ok){e&&(t(null),i(!1));return}let l=await n.json(),o=l?.orgUser?.role||null;e&&(t(o),i(!1))}catch(a){e&&(t(null),i(!1))}})(),()=>{e=!1}},[]),{role:e,loading:a,canEdit:"owner"===e||"member"===e,canManageTeam:"owner"===e,isViewer:"viewer"===e}}},78512:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>f});var s=a(37876),r=a(48230),i=a.n(r),n=a(89099),l=a(14232),o=a(99584),d=a(4033),c=a(74252),u=a(3961),m=a(11316),x=a(56848);function g(e){return"number"==typeof e&&Number.isFinite(e)?`${e.toFixed(1)}/5`:"â"}function p(e){return"prospects"===e?"bg-brand/10 text-brand border-brand/20":"leads"===e?"bg-brand-taupe/20 text-brand-darkGrey border-brand-taupe/30":"signals"===e?"bg-brand-magenta/10 text-brand-magenta border-brand-magenta/20":"bg-surface-muted text-fg-secondary border-border"}function f(){let{user:e,loading:t}=(0,o.A)(),a=(0,n.useRouter)(),r=(0,x.Z)(),{canEdit:f}=(0,c.h)(),[h,b]=(0,l.useState)(null),[y,j]=(0,l.useState)(null),[v,N]=(0,l.useState)([]),[w,k]=(0,l.useState)(null),[A,S]=(0,l.useState)(!0),[_,$]=(0,l.useState)(null),[E,F]=(0,l.useState)(!1),[C,T]=(0,l.useState)(null),[B,I]=(0,l.useState)(""),[O,P]=(0,l.useState)(!1),[z,R]=(0,l.useState)(null),[D,q]=(0,l.useState)(null),[J,L]=(0,l.useState)(null),[U,G]=(0,l.useState)(null);(0,l.useEffect)(()=>{let e=!0;(async()=>{let{data:t}=await d.N.auth.getSession();e&&b(t.session?.access_token||null)})();let{data:t}=d.N.auth.onAuthStateChange((e,t)=>{b(t?.access_token||null)});return()=>{e=!1,t.subscription.unsubscribe()}},[]);let K=async(e,t)=>{if(h&&!U){G(t);try{let t=await fetch("/api/profile/suggestions-assistant",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`},body:JSON.stringify({message:"Fix this suggestion now by applying the necessary profile changes. Return an apply_profile_patch action.",suggestion:e})}),a=await t.json().catch(()=>({}));if(!t.ok)throw Error(a?.error||"Fix failed");let i=a?.action&&"apply_profile_patch"===a.action.kind?{kind:"apply_profile_patch",summary:String(a.action.summary||""),patch:a.action.patch&&"object"==typeof a.action.patch?a.action.patch:{}}:null;if(!i||!Object.keys(i.patch||{}).length)return void await r.alert({title:"No automatic fix",message:(0,s.jsx)("div",{className:"text-sm text-fg-secondary",children:"The assistant didn't return an automatic fix for this suggestion."})});let n=await fetch("/api/profile/org-profile/state",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`},body:JSON.stringify(i.patch)}),l=await n.json().catch(()=>({}));if(!n.ok)throw Error(l?.error||"Failed to apply fix");await r.alert({title:"Fixed",tone:"success",message:(0,s.jsx)("div",{className:"text-sm text-fg-secondary",children:i.summary||"Applied the fix to your profile."})}),S(!0),$(null);try{let[e,t]=await Promise.all([fetch("/api/profile/org-profile",{headers:{Authorization:`Bearer ${h}`}}),fetch("/api/profile/suggestions?limit=500",{headers:{Authorization:`Bearer ${h}`}})]),a=await e.json().catch(()=>({}));if(!e.ok)throw Error(a?.error||"Failed to reload profile");let s=await t.json().catch(()=>({}));if(!t.ok)throw Error(s?.error||"Failed to reload metrics");j(a.profile||null);let r=Array.isArray(a.state?.profileSuggestionInbox)?a.state.profileSuggestionInbox:[];N(r),k(s?.metrics&&"object"==typeof s.metrics?s.metrics:null)}finally{S(!1)}}catch(e){await r.alert({title:"Fix failed",tone:"danger",message:(0,s.jsx)("div",{className:"text-sm text-fg-secondary",children:e?.message||"Fix failed"})})}finally{G(null)}}};(0,l.useEffect)(()=>{t||e||a.replace(`/login?redirectedFrom=${encodeURIComponent(a.asPath||"/suggestions")}`)},[t,e,a]),(0,l.useEffect)(()=>{h&&(async()=>{S(!0),$(null);try{let[e,t]=await Promise.all([fetch("/api/profile/org-profile",{headers:{Authorization:`Bearer ${h}`}}),fetch("/api/profile/suggestions?limit=500",{headers:{Authorization:`Bearer ${h}`}})]),a=await e.json().catch(()=>({}));if(!e.ok)throw Error(a?.error||"Failed to load profile");let s=await t.json().catch(()=>({}));if(!t.ok)throw Error(s?.error||"Failed to load metrics");j(a.profile||null);let r=Array.isArray(a.state?.profileSuggestionInbox)?a.state.profileSuggestionInbox:[];N(r),k(s?.metrics&&"object"==typeof s.metrics?s.metrics:null)}catch(e){$(e?.message||"Failed to load suggestions"),j(null),N([]),k(null)}finally{S(!1)}})()},[h]),(0,l.useEffect)(()=>
1{if(e?.id&&!A)try{let t=`suggestions_last_seen_at_v1:${e.id}`;window.localStorage.setItem(t,String(Date.now()))}catch{}},[A,e?.id]);let X=async()=>{if(!h||!C)return;let e=B.trim();if(e&&!O){P(!0),R(null),q(null),L(null);try{let t=await fetch("/api/profile/suggestions-assistant",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`},body:JSON.stringify({message:e,suggestion:C})}),a=await t.json().catch(()=>({}));if(!t.ok)throw Error(a?.error||"Assistant failed");q("string"==typeof a?.answer?a.answer:""),L(a?.action&&"apply_profile_patch"===a.action.kind?{kind:"apply_profile_patch",summary:String(a.action.summary||""),patch:a.action.patch&&"object"==typeof a.action.patch?a.action.patch:{}}:null)}catch(e){R(e?.message||"Assistant failed")}finally{P(!1)}}},Y=async()=>{if(h&&J&&"apply_profile_patch"===J.kind&&await r.confirm({title:"Apply suggested change",message:(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("div",{className:"text-sm text-fg-secondary",children:"This will update your profile."}),(0,s.jsx)("div",{className:"text-sm font-medium text-fg-primary",children:J.summary})]}),confirmText:"Apply",cancelText:"Cancel"}))try{let e=await fetch("/api/profile/org-profile/state",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`},body:JSON.stringify(J.patch)}
1),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t?.error||"Failed to apply change");await r.alert({title:"Applied",tone:"success",message:(0,s.jsx)("div",{className:"text-sm text-fg-secondary",children:"Your profile was updated."})}),F(!1),T(null),I(""),q(null),L(null),R(null),S(!0),$(null);try{let e=await fetch("/api/profile/org-profile",{headers:{Authorization:`Bearer ${h}`}}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t?.error||"Failed to reload profile");j(t.profile||null);let a=Array.isArray(t.state?.profileSuggestionInbox)?t.state.profileSuggestionInbox:[];N(a)}finally{S(!1)}}catch(e){await r.alert({title:"Failed",tone:"danger",message:(0,s.jsx)("div",{className:"text-sm text-fg-secondary",children:e?.message||"Failed to apply change"})})}};return t||A?(0,s.jsx)("div",{className:"fixed inset-0 flex items-center justify-center bg-surface",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-brand"})}):(0,s.jsxs)("div",{className:"w-full h-full flex bg-surface text-fg-primary",children:[(0,s.jsx)(u.A,{}),(0,s.jsxs)("div",{className:"flex-1 min-h-screen bg-surface overflow-auto",children:[(0,s.jsxs)("div",{className:"max-w-6xl mx-auto px-6 py-10",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-6 flex-wrap",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-sm text-fg-secondary",children:"Dashboard"}),(0,s.jsx)("h1",{className:"text-3xl font-semibold tracking-tight text-fg-primary",children:"Suggestions"}),(0,s.jsxs)("div",{className:"text-fg-secondary mt-2 max-w-2xl",children:[y?.name?`For ${y.name}. `:"","Ask quick questions or fix recommendations instantly."]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(i(),{href:"/home",className:"px-4 py-2 rounded-xl border border-border bg-surface-muted hover:bg-surface transition",children:"Back to Leads"}),(0,s.jsx)(i(),{href:"/my-profile",className:"px-4 py-2 rounded-xl bg-brand text-fg-onBrand hover:opacity-90 transition",children:"Edit Profile"})]})]}),_&&(0,s.jsx)("div",{className:"mt-6 border border-brand-magenta/20 bg-brand-magenta/10 text-brand-magenta rounded-xl p-3 text-sm",children:_}),(0,s.jsx)("div",{className:"mt-8",children:(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,s.jsxs)("div",{className:"rounded-3xl border border-brand/20 bg-brand/5 p-5 shadow-2xl hover:border-brand/30 transition-colors",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsx)("div",{className:"text-sm text-fg-secondary",children:"Prospects"}),(0,s.jsx)("div",{className:`text-xs px-2 py-1 rounded-full border ${p("prospects")}`,children:"Avg"})]}),(0,s.jsx)("div",{className:"mt-2 text-2xl font-semibold tracking-tight text-fg-primary",children:g(w?.prospectAvg)}),(0,s.jsx)("div",{className:"mt-1 text-xs text-fg-secondary",children:"number"==typeof w?.prospectRatedCount?`${w.prospectRatedCount} ratings`:"No ratings yet"})]}),(0,s.jsxs)("div",{className:"rounded-3xl border border-brand-taupe/25 bg-brand-taupe/10 p-5 shadow-2xl hover:border-brand-taupe/35 transition-colors",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsx)("div",{className:"text-sm text-fg-secondary",children:"Leads"}),(0,s.jsx)("div",{className:`text-xs px-2 py-1 rounded-full border ${p("leads")}`,children:"Avg"})]}),(0,s.jsx)("div",{className:"mt-2 text-2xl font-semibold tracking-tight text-fg-primary",children:g(w?.leadsAvg)}),(0,s.jsx)("div",{className:"mt-1 text-xs text-fg-secondary",children:"number"==typeof w?.leadsRatedCount?`${w.leadsRatedCount} ratings`:"No ratings yet"})]}),(0,s.jsxs)("div",{className:"rounded-3xl border border-brand-magenta/20 bg-brand-magenta/5 p-5 shadow-2xl hover:border-brand-magenta/30 transition-colors",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsx)("div",{className:"text-sm text-fg-secondary",children:"Signals"}),(0,s.jsx)("div",{className:`text-xs px-2 py-1 rounded-full border ${p("signals")}`,children:"Avg"})]}),(0,s.jsx)("div",{className:"mt-2 text-2xl font-semibold tracking-tight text-fg-primary",children:g(w?.signalsAvg)}),(0,s.jsx)("div",{className:"mt-1 text-xs text-fg-secondary",children:"number"==typeof w?.signalsRatedCount?`${w.signalsRatedCount} ratings`:"No ratings yet"})]}),(0,s.jsxs)("div",{className:"rounded-3xl border border-brand-dark/20 bg-brand-dark/5 p-5 shadow-2xl hover:border-brand-dark/30 transition-colors",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsx)("div",{className:"text-sm text-fg-secondary",children:"Ranking"}),(0,s.jsx)("div",{className:`text-xs px-2 py-1 rounded-full border ${p("ranking")}`,children:"Overall"})]}),(0,s.jsx)("div",{className:"mt-2 text-2xl font-semibold tracking-tight text-fg-primary",children:g(w?.overallAvg)}),(0,s.jsx)("div",{className:"mt-1 text-xs text-fg-secondary",children:"number"==typeof w?.totalFeedback&&w.totalFeedback?`${w.totalFeedback} total ratings`:"Rate a few results to improve this"})]})]})}),(0,s.jsxs)("div",{className:"mt-8",children:[(0,s.jsx)("div",{className:"text-sm text-fg-secondary",children:v.length?`${v.length} suggestion${1===v.length?"":"s"}`:"No suggestions"}),(0,s.jsxs)("div",{className:"mt-3 grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(v||[]).map((e,t)=>{var a;let r=`${e.id}:${e.sentAt||""}:${t}`,i="high"===e.priority?"border-l-brand-magenta":"medium"===e.priority?"border-l-brand-taupe":"border-l-brand";return(0,s.jsxs)("div",{className:`rounded-3xl border border-border border-l-4 ${i} bg-surface-alt p-5 shadow-2xl hover:bg-surface-muted/60 transition-colors`,children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"font-semibold leading-snug text-fg-primary",children:e.title}),(0,s.jsx)("div",{className:"text-sm text-fg-secondary mt-1",children:e.impact}),e.sentAt&&(0,s.jsxs)("div",{className:"text-xs text-fg-secondary mt-1",children:["Sent ",new Date(e.sentAt).toLocaleStr
1ing()]})]}),(0,s.jsx)("div",{className:`shrink-0 text-xs px-2 py-1 rounded-full border ${"high"===(a=e.priority)?"bg-brand-magenta/10 text-brand-magenta border-brand-magenta/20":"medium"===a?"bg-brand-taupe/15 text-brand-darkGrey border-brand-taupe/30":"bg-surface-muted text-fg-secondary border-border"}`,children:e.priority.toUpperCase()})]}),Array.isArray(e.steps)&&e.steps.length>0&&(0,s.jsx)("div",{className:"mt-3 space-y-1",children:e.steps.map((e,t)=>(0,s.jsxs)("div",{className:"text-sm text-fg-secondary",children:[t+1,". ",e]},t))}),(0,s.jsxs)("div",{className:"mt-4 flex items-center gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:()=>{T(e),I(""),q(null),L(null),R(null),F(!0)},className:"text-sm px-3 py-2 rounded-xl border border-border bg-surface-alt hover:bg-surface-muted transition",children:"Ask"}),(0,s.jsx)("button",{type:"button",onClick:()=>void K(e,r),disabled:!f||!!U,className:"text-sm px-3 py-2 rounded-xl bg-brand hover:bg-brand-dark text-fg-onBrand transition-colors disabled:opacity-50",children:U===r?"Fixingâ¦":"Fix"})]})]},r)}),!v?.length&&(0,s.jsx)("div",{className:"border border-border rounded-2xl bg-surface-alt p-6 text-fg-secondary",children:"No suggestions from your admin yet."})]})]})]}),(0,s.jsx)(m.a,{isOpen:E,onClose:()=>{F(!1),T(null),I(""),q(null),L(null),R(null)},title:C?"Ask about this suggestion":"Ask",size:"md",children:(0,s.jsxs)("div",{className:"space-y-4",children:[C&&(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-surface-muted p-3",children:[(0,s.jsx)("div",{className:"text-sm font-semibold text-fg-primary",children:C.title}),(0,s.jsx)("div",{className:"text-sm text-fg-secondary mt-1",children:C.impact})]}),z&&(0,s.jsx)("div",{className:"rounded-xl border border-brand-magenta/20 bg-brand-magenta/10 text-brand-magenta p-3 text-sm",children:z}),D&&(0,s.jsx)("div",{className:"rounded-xl border border-border bg-surface-alt p-3 text-sm text-fg-secondary whitespace-pre-wrap",children:D}),J&&"apply_profile_patch"===J.kind&&(0,s.jsxs)("div",{className:"rounded-xl border border-brand/20 bg-brand/10 p-3",children:[(0,s.jsx)("div",{className:"text-sm font-medium text-fg-primary",children:"Proposed change"}),(0,s.jsx)("div",{className:"text-sm text-fg-secondary mt-1",children:J.summary}),(0,s.jsx)("div",{className:"mt-3",children:(0,s.jsx)("button",{type:"button",onClick:()=>void Y(),disabled:!f,className:"inline-flex items-center justify-center px-3 py-2 rounded-xl bg-brand text-fg-onBrand hover:opacity-90 transition disabled:opacity-50",children:"Apply"})})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("div",{className:"text-sm font-medium text-fg-primary",children:"Your question"}),(0,s.jsx)("textarea",{className:"w-full rounded-xl border border-border bg-surface px-3 py-2 text-sm",rows:3,value:B,onChange:e=>I(e.target.value),placeholder:"Ask a quick question...",disabled:O,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),X())}}),(0,s.jsx)("div",{className:"flex items-center justify-end gap-2",children:(0,s.jsx)("button",{type:"button",onClick:()=>void X(),disabled:O||!B.trim()||!C,className:"inline-flex items-center justify-center px-3 py-2 rounded-xl border border-border bg-surface hover:bg-surface-muted transition disabled:opacity-50",children:O?"Askingâ¦":"Ask"})}),(0,s.jsx)("div",{className:"text-xs text-fg-secondary",children:"Enter to ask. Shift+Enter for a newline."})]})]})})]})]})}}},e=>{e.O(0,[636,6593,8792],()=>e(e.s=9872)),_N_E=e.O()}]);
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.