PageSourceSearch

https://valuethropy.ai/assets/OperatingLeversToolPage-CDAK49Rb.js

js valuethropy.ai collected 2026-10-05 15:01:46 UTC 12,773 bytes, 1 lines download raw bytes

1import{r as h,a as J,j as e}from"./vendor-query-CVWBAYQN.js";import{E as Y}from"./ErrorState-De3uL_pY.js";import{P as ee}from"./PageShell-DDy5DWJ7.js";import{D as te}from"./DrawerEditorialHero-B4tszzQA.js";import{T as G}from"./ToolEmptyState-DVqvBD_X.js";import{T as re}from"./ToolLoadingState-B6nB0p0M.js";import{l as ae,a1 as oe,G as se,h as ne,C as w,f as N,B as M,c as F,I as ie,s as $}from"./index-DJLejKcN.js";import{a as ce}from"./AICta-CW9IvAIV.js";import{u as de}from"./useStrategyArtifact-JHpm8ckJ.js";import{p as le}from"./drawerChrome-IA-ZPunr.js";import{f as H}from"./ebitdaTypes-xTNTyCWL.js";import{m as me,u as fe}from"./vendor-icons-BJ-Rh-HN.js";import"./HeroBackdrop-CytUHOCH.js";import"./DrawerHero-CNs4a2F0.js";import"./HelpButton-C88-Kq3v.js";import"./HelpOverlayContext-vHZe9ebM.js";import"./vendor-supabase-DhFQUKws.js";import"./vendor-motion-8aOieDHp.js";import"./AiSparkIcon-CI_4QK7B.js";import"./aiPersonas-DRZibXAQ.js";import"./currency-BxZBgS5P.js";const S=d=>d>=66?2:d>=33?1:0;function pe(d){return d>=1?"var(--chart-emerald)":d===0?"var(--chart-amber)":"var(--chart-rose)"}const ue={"2-0":"Quick wins","2-2":"Big bets","0-0":"Fill-ins","0-2":"Money pit"};function he(d){const m=d instanceof Error?d.message:String(d);return/failed to send/i.test(m)?"The AI service isn't reachable - confirm the strategy-artifact-draft edge is deployed.":m.length>160?`${m.slice(0,157)}…`:m}function Pe(){const d=h.useMemo(()=>le("/toolbox/operating-levers"),[]),{toast:m}=ae(),{campaignId:I,campaigns:T,isLoading:Q}=oe(),x=I??void 0,{data:E}=se(x),{user:c}=ne(),g=!!(c!=null&&c.id)&&(E==null?void 0:E.sponsor_id)===c.id,{content:v,save:V,isLoading:U,isUnavailable:W,refetch:K}=de(x,"lever_matrix"),y=h.useMemo(()=>(v==null?void 0:v.effort)??{},[v]),b=J({queryKey:["lever-matrix-levers",x],queryFn:async()=>{const{data:t,error:a}=await $.from("vcp_levers").select("id,name,domain,ebitda_impact_mid").eq("campaign_id",x);if(a)throw a;return t??[]},enabled:!!x,staleTime:3e4}),l=h.useMemo(()=>b.data??[],[b.data]),[k,L]=h.useState(!1),[B,O]=h.useState({}),j=h.useMemo(()=>Math.max(0,...l.map(t=>Math.abs(t.ebitda_impact_mid??0))),[l]),p=h.useMemo(()=>l.map(t=>{const a=y[t.id],o=j>0?Math.round(Math.abs(t.ebitda_impact_mid??0)/j*100):0;return{lever:t,impactScore:o,effort:a??null}}).filter(t=>t.effort!==null),[l,y,j]),n=h.useMemo(()=>{const t=l.reduce((r,i)=>r+(i.ebitda_impact_mid??0),0),a=p.filter(r=>S(r.impactScore)===2&&S(r.effort.effortScore)===0).length,o=p.filter(r=>r.effort.scoredBy==="ai_proposed").length;return{totalImpactM:t,count:l.length,scored:p.length,unscored:l.length-p.length,quickWins:a,aiPending:o}},[l,p]),P=6;if(Q)return e.jsx(re,{});if(!T||T.length===0)return e.jsx(G,{toolTitle:"Lever Scorecard",variant:"noCampaignsExist"});if(!I)return e.jsx(G,{toolTitle:"Lever Scorecard",variant:"noCampaignSelected",description:"Choose a campaign to map its value-creation levers by impact and effort."});const _=async t=>{var r;const o=((r=(await K()).data)==null?void 0:r.content)??v??null;await V({effort:{...(o==null?void 0:o.effort)??{},...t}})},R=async t=>{if(!g||!x)return;const a=t?[...l]:l.filter(r=>!y[r.id]);if(a.length===0){m({title:"All levers scored",description:"Every lever already has an effort score. Use 'Re-estimate all' to refresh them, or edit any by hand."});return}const o=a.sort((r,i)=>Math.abs(i.ebitda_impact_mid??0)-Math.abs(r.ebitda_impact_mid??0));L(!0);try{let r=[],i=null;for(const u of[6,3,1]){const C=o.slice(0,Math.min(u,o.length)).map(f=>({id:f.id,name:f.name,note:f.domain??""}));try{const{data:f,error:D}=await $.functions.invoke("strategy-artifact-draft",{body:{campaignId:x,frameworkId:"lever_matrix",items:C}});if(D)throw new Error(D.message);r=(f==null?void 0:f.scores)??[],i=null;break}catch(f){i=f}}if(i)throw i;if(r.length===0){m({title:"No cited estimate yet",description:"The Truth Layer has no evidence to estimate effort for these levers - add documents, then try again."});return}const s={};for(const u of r)l.some(C=>C.id===u.id)&&(s[u.id]={effortScore:u.effortScore,scoredBy:"ai_proposed",evidenceRefs:u.evidenceRefs,rationale:u.rationale,confidence:u.confidence});await _(s);const A=Object.keys(s).length,q=t?n.count:Math.min(n.count,n.scored+A),z=Math.max(0,n.count-q);m({title:`AI estimated effort for ${A} lever${A===1?"":"s"}`,description:z>0?`${q}/${n.count} scored - run again to score ${Math.min(P,z)} more. Gold-ringed until you Accept.`:`All ${n.count} levers scored. Gold-ringed until you Accept.`})}catch(r){let i="";try{const{data:s}=await $.functions.invoke("strategy-artifact-draft",{body:{frameworkId:"ping"}});i=s!=null&&s.version?` · deployed engine: ${s.version}`:" · deployed engine: unknown (edge may not be deployed)"}catch{i=" · couldn't reach the edge to check its version"}m({title:"Couldn't estimate effort",description:he(r)+i,variant:"destructive"})}finally{L(!1)}},X=async()=>
1{if(!g)return;const t=(c==null?void 0:c.email)??(c==null?void 0:c.id)??"unknown",a=new Date().toISOString(),o={};for(const r of p)r.effort.scoredBy==="ai_proposed"&&(o[r.lever.id]={...r.effort,scoredBy:"human",author:t,at:a});Object.keys(o).length!==0&&(await _(o),m({title:"Accepted",description:"Recorded as your effort estimates, stamped with today's date."}))},Z=async t=>{if(!g)return;const a=B[t],o=Number(a);if(a===void 0||a.trim()===""||!Number.isFinite(o)||o<0||o>100){m({title:"Enter 0-100",description:"Effort is a 0-100 score (0 = trivial, 100 = very hard)."});return}const r=(c==null?void 0:c.email)??(c==null?void 0:c.id)??"unknown";await _({[t]:{...y[t]??{},effortScore:Math.round(o),scoredBy:"human",author:r,at:new Date().toISOString()}}),O(i=>{const s={...i};return delete s[t],s})};return e.jsx(ee,{icon:me,accent:d.accent,heroGradient:d.heroGradient,heroSlot:d.heroSlot,title:"Lever Scorecard",subtitle:"This deal's value-creation levers, placed by impact and effort - so the quick wins and the money pits are obvious.",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(te,{kicker:"TOOLBOX · LEVER SCORECARD",title:"Which levers are worth the effort?",tagline:"Every lever's EBITDA impact is real, from your value plan. Effort is AI-estimated and cited to your confirmed evidence, then you confirm it. High impact + low effort = quick wins; low impact + high effort = money pit."}),W?e.jsx(w,{className:"border-l-4 border-l-[var(--gold-dark)]",children:e.jsxs(N,{className:"py-3 text-sm text-muted-foreground",children:["Saving effort estimates turns on once the ",e.jsx("code",{className:"text-xs",children:"lever_matrix"})," store is enabled (a queued migration). The matrix still renders live below."]})}):null,b.isLoading||U?e.jsx(w,{children:e.jsx(N,{className:"py-8 text-center text-sm text-muted-foreground",children:"Loading levers…"})}):b.isError?e.jsx(Y,{noun:"levers",onRetry:()=>void b.refetch()}):l.length===0?e.jsx(w,{children:e.jsxs(N,{className:"py-8 text-center text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground",children:"No value-creation levers yet."}),e.jsx("p",{className:"mt-1",children:"This scorecard plots the levers in your value plan (VCP). Add levers there, then return to map them by impact and effort."})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-4",children:[{label:"Total plan impact",value:H(n.totalImpactM),tone:"var(--gold)"},{label:"Levers",value:String(n.count),tone:"var(--chart-sky)"},{label:"Effort scored",value:`${n.scored}/${n.count}`,tone:"var(--chart-slate)"},{label:"Quick wins",value:String(n.quickWins),tone:"var(--chart-emerald)"}].map(t=>e.jsxs("div",{className:"rounded-xl border p-3",style:{background:`color-mix(in srgb, ${t.tone} 7%, transparent)`,borderColor:`color-mix(in srgb, ${t.tone} 26%, transparent)`},children:[e.jsx("p",{className:"kicker text-muted-foreground",children:t.label}),e.jsx("p",{className:"mt-0.5 font-display text-xl font-bold text-foreground",style:{fontVariantNumeric:"tabular-nums"},children:t.value})]},t.label))}),g?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ce,{label:k?"Estimating…":n.unscored>0?`Estimate effort (${n.scored}/${n.count} scored)`:"All levers scored",persona:"atlas",size:"sm",loading:k,disabled:k||n.unscored===0,onClick:()=>void R(!1)}),n.scored>0?e.jsx(M,{size:"sm",variant:"ghost",className:"h-8 text-step-caption",disabled:k,onClick:()=>void R(!0),children:"Re-estimate all"}):null,n.aiPending>0?e.jsxs(M,{size:"sm",variant:"outline",className:"h-8 gap-1",onClick:()=>void X(),children:[e.jsx(fe,{className:"h-3.5 w-3.5","aria-hidden":!0})," Accept ",n.aiPending," AI estimate",n.aiPending===1?"":"s"]}):null]}),e.jsxs("p",{className:"text-step-caption text-muted-foreground",children:["AI scores ",P," levers per run, highest-impact first",n.unscored>0?` - ${n.unscored} not scored yet, click again to continue`:" - all scored",". Effort is an estimate; edit any by hand below."]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only the campaign sponsor can estimate and confirm effort. The matrix is read-only for you."}),e.jsx(w,{className:"shadow-card",children:e.jsx(N,{className:"py-5",children:e.jsxs("div",{className:"mx-auto w-full max-w-3xl",children:[e.jsx("div",{className:"kicker mb-2 text-center text-muted-foreground",children:"Value levers · EBITDA impact (vertical) × effort (horizontal)"}),p.length===0?e.jsxs("p",{className:"rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground",children:["No effort scored yet. ",g?"Estimate effort with AI (above), or enter it per lever below.":"Awaiting effort estimates."]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"kicker flex w-10 shrink-0 flex-col items-end justify-around py-0.5 text-right leading-tight text-muted-foreground",children:[e.jsxs("span",{children:["High",e.jsx("br",{}),"impact"]}),e.jsx("span",{children:"Med"}),e.jsx("span",{children:"Low"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"grid grid-cols-3 gap-1.5",role:"group","aria-label":"Impact by effort matrix",children:[2,1,0].map(t=>[0,1,2].map(a=>{const o=p.filter(s=>S(s.impactScore)===t&&S(s.effort.effortScore)===a),r=pe(t-a),i=ue[`${t}-${a}`];return e.jsxs("div",{className:"min-h-[92px] rounded-lg border p-1.5",style:{background:`color-mix(in srgb, ${r} 12%, transparent)`,borderColor:`color-mix(in srgb, ${r} 30%, transparent)`},children:[i?e.jsx("p",{className:"kicker mb-1 text-muted-foreground",children:i}):null,e.jsx("div",{className:"flex flex-wrap gap-1",children:o.map(s=>e.jsx("span",{title:`${s.lever.name} · impact ${s.impactScore} · effort ${s.effort.effortScore}${s.effort.scoredBy==="ai_proposed"?" · AI (unconfirmed)":""}`,className:F("max-w-full truncate rounded-full border bg-background px-2 py-0.5 text-step-caption",s.effort.scoredBy==="ai_proposed"?"border-[var(--gold-dark)] text-[var(--gold-dark)]":"border-border text-foreground"),children:s.lever.name},s.lever.id))})]},`${t}-${a}`)}))}),e.jsxs("div",{className:"kicker mt-1 grid grid-cols-3 text-center text-muted-foreground",children:[e.jsx("span",{children:"Low effort"}),e.jsx("span",{children:"Med effort"}),e.jsx("span",{children:"High effort"})]})]})]}),e.jsx("p",{className:"mt-1.5 text-step-caption text-muted-foreground",children:"Gold-ringed chips are AI estimates awaiting your confirmation. Impact is real (from the value plan); effort is the AI/your 0-100 estimate."})]})})}),e.jsx(w,{children:e.jsxs(N,{className:"space-y-2 py-5",children:[e.jsx("h3",{className:"font-display text-base font-bold text-foreground",children:"Levers & effort"}),l.map(t=>{const a=y[t.id],o=j>0?Math.round(Math.abs(t.ebitda_impact_mid??0)/j*100):0;return e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border bg-card/40 px-3 py-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:t.name}),e.jsxs("span",{className:"font-mono text-step-caption text-muted-foreground",children:["impact ",o,typeof t.ebitda_impact_mid=="number"?` · ${H(t.ebitda_impact_mid)}`:""]}),e.jsxs("span",{className:F("font-mono text-step-caption",a?a.scoredBy==="ai_proposed"?"text-[var(--gold-dark)]":"text-foreground":"text-muted-foreground"),children:["effort ",a?a.effortScore:"-",(a==null?void 0:a.scoredBy)==="ai_proposed"?" (AI)":""]}),g?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ie,{type:"number",value:B[t.id]??"",onChange:r=>O(i=>({...i,[t.id]:r.target.value})),placeholder:"0-100",className:"h-7 w-20 text-xs"}),e.jsx(M,{size:"sm",variant:"ghost",className:"h-7 px-2 text-step-caption",onClick:()=>void Z(t.id),children:"Set"})]}):null]},t.id)})]})})]})]})})}export{Pe 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.