1import{c as Ct,u as Ke,r as j,s as Ce,d as We,j as e,L as fe,B as R,aD as mt,aE as ht,aF as xt,I as K,F as Ve,U as ut,T as qe,aI as wt,z as kt,a as ve,C as St,i as Tt,v as It}from"./index-CH1aB7Jc.js";import{u as Ft,a as Et}from"./useWorkshop-BpyCVwoq.js";import{useAssessmentCompletions as Qe}from"./useAssessmentCompletions-DzbBVNf_.js";import{C as Ae}from"./circle-check-DVaFY8ze.js";import{E as Pe}from"./external-link-BIwwqjxv.js";import{C as Pt}from"./circle-help-3_uWO8Q2.js";import{T as je}from"./textarea-BJgTVKoS.js";import{D as Ne}from"./dollar-sign-dtLDiWKu.js";import{T as At}from"./target-6k95tBj6.js";import{C as Rt}from"./crown-D35lWNog.js";import{C as Mt}from"./calculator-BZpddF3t.js";import{f,a as Ge,b as Ye}from"./format-BlPxwB3c.js";import{c as gt,d as Dt}from"./calculations-DTdj0jRo.js";import{E as _t}from"./jspdf.es.min-C6yFD8bK.js";import{l as $t,d as Ot,a as Gt}from"./pdfBranding-BtOlkCy-.js";import{C as Wt}from"./circle-alert-C-uC9ooY.js";import{C as Bt}from"./chevron-up-gwQ9Mctt.js";import{C as Lt}from"./clock-Clbki1cK.js";import{T as zt}from"./triangle-alert-BxUguvpS.js";import{C as Yt}from"./circle-check-big-CSttohIq.js";import{D as pt}from"./download-B2VD89TQ.js";import{M as Ht}from"./message-square-SVtHgNeX.js";import{A as Ut}from"./arrow-right-BAcpXN4R.js";import{R as st}from"./refresh-cw-DQglWjpR.js";import{C as Vt}from"./chevron-left-BAi7PJB3.js";import{G as qt}from"./gift-Cnm0O8LU.js";import{f as Me}from"./format-DBLa_ekD.js";import"./useActingClient-DckhvK3Q.js";import"./assessmentType-D2tLyYie.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 Jt=Ct("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]),at=7;function Kt(){const{user:r}=Ke(),[c,d]=j.useState([]),[t,a]=j.useState(!0),i=j.useCallback(async()=>{if(r){a(!0);try{const{data:h}=await Ce.from("workshop_step_data").select("*").eq("user_id",r.id).order("step_number",{ascending:!0}),x=new Map;(h||[]).forEach(N=>{x.set(N.step_number,{step_number:N.step_number,status:N.status,data:N.data||{}})});const T=[];for(let N=1;N<=at;N++)T.push(x.get(N)||{step_number:N,status:"not_started",data:{}});d(T)}catch(h){console.error("Error fetching workshop steps:",h)}finally{a(!1)}}},[r]);j.useEffect(()=>{i()},[i]);const l=j.useCallback(async(h,x,T="in_progress")=>{if(r)try{const{error:N}=await Ce.from("workshop_step_data").upsert({user_id:r.id,step_number:h,status:T,data:x},{onConflict:"user_id,step_number"});if(N)throw N;d(n=>n.map(v=>v.step_number===h?{...v,status:T,data:x}:v))}catch(N){console.error("Error saving workshop step:",N)}},[r]),m=j.useCallback(async(h,x)=>{await l(h,x,"complete")},[l]),s=j.useCallback(h=>c.find(x=>x.step_number===h)||{step_number:h,status:"not_started",data:{}},[c]),p=j.useCallback(h=>{if(h===1)return!0;const x=c.find(T=>T.step_number===h-1);return(x==null?void 0:x.status)==="complete"},[c]),C=c.filter(h=>h.status==="complete").length;return{steps:c,loading:t,saveStep:l,completeStep:m,getStep:s,isStepUnlocked:p,completedCount:C,totalSteps:at,refetch:i}}const De=[{id:"ceo-score",label:"CEO Score",desc:"Rate yourself across 8 dimensions of CEO effectiveness",route:"/ceoscore",icon:"ð¯"},{id:"profit-leak",label:"Profit Leaks Assessment",desc:"Identify where money is bleeding from your business",route:"/profit",icon:"ð°"},{id:"constraint-finder",label:"Constraint Finder",desc:"Discover the #1 bottleneck limiting your growth",route:"/assessments/constraint",icon:"ð"}];function Qt(){const r=We(),{completedIds:c,completions:d,loading:t}=Qe(),a=De.filter(l=>c.includes(l.id)).length,i=a===De.length;return t?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(fe,{className:"h-5 w-5 animate-spin text-emerald-500"})}):e.jsxs("div",{className:`rounded-2xl border p-6 mb-6 ${i?"bg-emerald-900/20 border-emerald-500/30":"bg-amber-900/20 border-amber-500/30"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-bold text-white flex items-center gap-2",children:["ð Pre-Work Homework",i&&e.jsx(Ae,{className:"w-5 h-5 text-emerald-400"})]}),e.jsx("p",{className:"text-slate-400 text-sm mt-0.5",children:i?"All assessments complete â your results are loaded into the workshop.":"C
6omplete these assessments before the workshop for the richest experience."})]}),e.jsxs("span",{className:`text-sm font-bold px-3 py-1 rounded-full ${i?"bg-emerald-500/20 text-emerald-400":"bg-amber-500/20 text-amber-400"}`,children:[a,"/",De.length]})]}),e.jsx("div",{className:"space-y-2",children:De.map(l=>{const m=c.includes(l.id);return e.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg border transition-all ${m?"border-emerald-500/30 bg-emerald-500/5":"border-slate-700 bg-slate-800/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xl",children:l.icon}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-white font-medium text-sm flex items-center gap-2",children:[l.label,m&&e.jsx(Ae,{className:"w-4 h-4 text-emerald-400"})]}),e.jsx("p",{className:"text-slate-400 text-xs",children:l.desc})]})]}),e.jsxs(R,{variant:m?"outline":"default",size:"sm",onClick:()=>{if(m){const s=d.find(p=>p.assessmentType===l.id);r(s?`${l.route}?results=${s.id}`:l.route)}else r(l.route)},className:m?"border-emerald-500/40 text-emerald-600 hover:bg-emerald-500/10 bg-white":"bg-emerald-600 hover:bg-emerald-700 text-white",children:[m?"Review":"Take Now",e.jsx(Pe,{className:"w-3 h-3 ml-1.5"})]})]},l.id)})})]})}const _e=[{id:"profit_illusion",title:"The Profit Illusion",desc:"Your P&L says profitable. Your bank account disagrees."},{id:"revenue_vanish",title:"The Revenue Vanish",desc:"Revenue grows, profit doesn't. Complexity is the thief."},{id:"hiring_roulette",title:"The Hiring Roulette",desc:"You hire for tasks, not outcomes. Every bad hire costs $50Kâ$150K."},{id:"strategy_mirage",title:"The Strategy Mirage",desc:"Your team can't connect their work to revenue."},{id:"pricing_paradox",title:"The Pricing Paradox",desc:"You're undercharging. You know it. Your clients would pay more."},{id:"growth_gamble",title:"The Growth Gamble",desc:"You're making marketing bets without knowing your LTV or CAC."},{id:"founders_trap",title:"The Founder's Trap",desc:"The business can't run without you. That's a job, not a business."}];function z(r){const c=parseFloat(r);return isNaN(c)?0:c}function bt(r,c){switch(r){case"profit_illusion":{const d=z(c.a),t=z(c.b),a=z(c.c);if(!d)return null;const i=d*t/100-a;return{monthlyCost:i,annualCost:i*12}}case"revenue_vanish":{const d=z(c.a),t=z(c.b),a=z(c.c);if(!d)return null;if(t>=a)return{monthlyCost:0,annualCost:0,note:"Your margin held or improved â your Revenue Vanish may be in volume mix rather than efficiency. Estimate your hidden cost manually."};const i=a-t,l=d*i/100;return{monthlyCost:l/12,annualCost:l}}case"hiring_roulette":{const d=z(c.a),t=z(c.b);if(!d)return null;const i=Math.max(0,d-t)*75e3;return{monthlyCost:i/12,annualCost:i}}case"strategy_mirage":{const d=z(c.a),t=z(c.b);if(!d)return null;const a=d*t*.4;return{monthlyCost:a/12,annualCost:a}}case"pricing_paradox":{const d=z(c.a),t=z(c.b),a=z(c.c)||10;if(!d)return null;const l=d*(a/100)*(t/100);return{monthlyCost:l/12,annualCost:l}}case"growth_gamble":{const d=z(c.a),t=z(c.b),a=z(c.c),i=z(c.d);if(!t||!d)return null;const l=d/t,m=a*i,s=m/l,p=m/3,C=s<3?(l-p)*t:0;let h="text-emerald-400",x="Healthy";return s<3?(h="text-red-400",x="Gambling"):s<=5&&(h="text-amber-400",x="Improving"),{monthlyCost:C,annualCost:C*12,extraDisplay:{label:`LTV:CAC Ratio â ${s.toFixed(1)}:1`,value:x,color:h}}}case"founders_trap":{const d=z(c.a),t=z(c.b),a=z(c.c)||50;if(!d||!t)return null;const i=t*50*(d-a);return i<=0?{monthlyCost:0,annualCost:0,note:"Your operational hours may be appropriate for your current stage. This gap grows significantly as you scale."}:{monthlyCost:i/12,annualCost:i}}default:return null}}function Zt(r,c){const d=a=>{const i=parseFloat(a);return isNaN(i)?0:i},t=a=>"$"+Math.round(Math.abs(a)).toLocaleString();switch(r){case"profit_illusion":{const a=d(c.a),i=d(c.b),l=d(c.c);return a?{formula:"Monthly Cost = (Revenue à Margin%) â Actual Cash",substituted:`= (${t(a)} à ${i}%) â ${t(l)} = ${t(a*i/100-l)}/mo`}:null}case"revenue_vanish":{const a=d(c.a),i=d(c.b),l=d(c.c);if(!a||i>=l)return null;const m=l-i;
6return{formula:"Annual Cost = (Prior Margin% â Current Margin%) à Annual Revenue",substituted:`= (${l}% â ${i}%) à ${t(a)} = ${t(a*m/100)}/yr ÷ 12`}}case"hiring_roulette":{const a=d(c.a),i=d(c.b);if(!a)return null;const l=Math.max(0,a-i);return{formula:"Annual Cost = Missed Hires à $75,000",substituted:`= (${a} â ${i}) missed à $75,000 = ${t(l*75e3)}/yr ÷ 12`}}case"strategy_mirage":{const a=d(c.a),i=d(c.b);return a?{formula:"Annual Cost = Employees à Avg Salary à 40% efficiency gap",substituted:`= ${a} à ${t(i)} à 0.40 = ${t(a*i*.4)}/yr ÷ 12`}:null}case"pricing_paradox":{const a=d(c.a),i=d(c.b),l=d(c.c)||10;return a?{formula:"Annual Cost = Revenue à Price Increase% à Gross Margin%",substituted:`= ${t(a)} à ${l}% à ${i}% = ${t(a*(l/100)*(i/100))}/yr ÷ 12`}:null}case"growth_gamble":{const a=d(c.a),i=d(c.b),l=d(c.c),m=d(c.d);if(!i||!a)return null;const s=a/i,p=l*m;return{formula:"CAC = Spend ÷ Clients | LTV = Contract Value à Retention | Ratio = LTV ÷ CAC",substituted:`CAC = ${t(a)} ÷ ${i} = ${t(s)} | LTV = ${t(l)} à ${m}mo = ${t(p)} | Ratio = ${(p/s).toFixed(1)}:1`}}case"founders_trap":{const a=d(c.a),i=d(c.b),l=d(c.c)||50;if(!a||!i)return null;const m=i*50*(a-l);return{formula:"Annual Cost = Hours/wk à 50 weeks à (Your Rate â Delegate Rate)",substituted:`= ${i} à 50 à (${t(a)} â ${t(l)}) = ${t(m)}/yr ÷ 12`}}default:return null}}function Xt(r){switch(r){case"profit_illusion":return{fields:[{key:"a",label:"Monthly Revenue",prefix:"$",hint:"Your total top-line revenue for the most recent month. Found on your P&L or income statement."},{key:"b",label:"Estimated Profit Margin",suffix:"%",hint:"Net profit ÷ revenue à 100. If your P&L shows $20K profit on $100K revenue, enter 20."},{key:"c",label:"Actual cash increase in your bank last month",prefix:"$",hint:"Check your bank balance: ending balance minus starting balance for the month. This is what actually landed."}],helper:"The gap between what your P&L says you made and what actually landed in your bank. This is your Profit Illusion."};case"revenue_vanish":return{fields:[{key:"a",label:"Annual Revenue this year",prefix:"$",hint:"Total revenue for the current year (or trailing 12 months). Use your P&L or accounting software."},{key:"b",label:"Gross Margin % this year",suffix:"%",hint:"(Revenue â COGS) ÷ Revenue à 100. Measures how much you keep after direct costs."},{key:"c",label:"Gross Margin % last year",suffix:"%",hint:"Same calculation as above, but for the prior year. The difference reveals your complexity tax."}],helper:"Every point your margin dropped while revenue grew is a complexity tax. Here's what yours costs annually."};case"hiring_roulette":return{fields:[{key:"a",label:"Number of hires in the last 12 months",hint:"Count every new hire â full-time, part-time, or contractor â in the past 12 months."},{key:"b",label:"Hires who hit their 90-day performance target",hint:"How many of those hires were fully productive and met expectations within 90 days?"}],helper:"Industry benchmark for a bad hire â salary, rework, re-recruiting, opportunity cost â is $50K to $150K. We use $75K as the conservative midpoint."};case"strategy_mirage":return{fields:[{key:"a",label:"Number of employees (not including founder)",hint:"Total headcount excluding yourself. Include full-time and key part-time team members."},{key:"b",label:"Average annual salary per employee",prefix:"$",hint:"Total payroll ÷ number of employees. Include base salary and benefits if possible."}],helper:"Teams without financial line-of-sight operate at 50â60% of their potential. We use a conservative 40% efficiency gap."};case"pricing_paradox":return{fields:[{key:"a",label:"Annual Revenue",prefix:"$",hint:"Your total annual revenue. A price increase applies across your entire revenue base."},{key:"b",label:"Your Gross Margin",suffix:"%",hint:"(Revenue â COGS) ÷ Revenue à 100. The higher your margin, the more a price increase drops to profit."},{key:"c",label:"Price increase you could make",type:"toggle",hint:"Be honest â what increase would your best clients accept without blinking?",options:[{label:"5%",value:5},{label:"10%",value:10},{label:"15%",value:15},{label:"20%",value:20},{label:"25%",value:25}]}],helper:"A price increase goes straight to profit â no new clients, no new costs. Every percentage point you raise prices is pure margin improvement."};case"growth_gamble":return{fields:[{key:"a",label:"Monthly marketing spend",prefix:"$",hint:"Total spend on ads, content, SEO, events, sponsorships â everything aimed at acquiring clients."},{key:"b",label:"New clients acquired per month",hint:"Average number of new paying clients you close each month from all marketing efforts."},{key:"c",label:"Average contract value per client/month",prefix:"$",hint:"Monthly recurring revenue per client. Annual contracts: divide by 12."},{key:"d",label:"Average client retention (months)",hint:"How many months does a typical client stay? LTV = contract value à retention months."}],helper:"A healthy LTV:CAC ratio is 3:1 or better. Below that, every marketing dollar you spend is subsidizing growth that doesn't compound."};
6case"founders_trap":return{fields:[{key:"a",label:"What is your time worth per hour?",prefix:"$",hint:"What should your hourly rate be as CEO? A $1M business = $500/hr, $2M = $1,000/hr. Think about what you could generate in revenue-producing activities."},{key:"b",label:"Hours/week you spend in operations (not strategy or sales)",hint:"Hours doing tasks someone at $25â50/hr could do: email, admin, fulfillment, fixing things."},{key:"c",label:"Cost to delegate those hours ($/hr)",prefix:"$",hint:"What would you pay someone to do those tasks? Typically $25â75/hr depending on complexity."}],helper:"Every hour you spend doing low-value work costs you the difference between your true hourly worth and the cost to delegate."};default:return{fields:[],helper:""}}}const lt=r=>r<0?"-$"+Math.abs(Math.round(r)).toLocaleString():"$"+Math.round(r).toLocaleString();function es({killer:r,inputs:c,onInputsChange:d}){if(!r)return null;const{fields:t,helper:a}=Xt(r.id),i=bt(r.id,c),l=Zt(r.id,c),m=(s,p)=>{d({...c,[s]:p})};return e.jsxs("div",{className:"bg-slate-800/60 border border-amber-500/30 rounded-xl p-5 space-y-4",children:[e.jsxs("h4",{className:"text-amber-400 font-semibold text-sm",children:["What is ",r.title," costing you?"]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:t.map(s=>e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs text-slate-400 mb-1 flex items-center gap-1.5",children:[s.label,s.hint&&e.jsxs(mt,{children:[e.jsx(ht,{asChild:!0,children:e.jsx(Pt,{className:"w-3.5 h-3.5 text-slate-500 hover:text-amber-400 transition-colors cursor-help shrink-0"})}),e.jsx(xt,{side:"top",className:"max-w-xs bg-slate-900 border-slate-700 text-slate-200 text-xs",children:s.hint})]})]}),s.type==="toggle"?e.jsx("div",{className:"flex gap-2",children:s.options.map(p=>e.jsx("button",{onClick:()=>m(s.key,String(p.value)),className:`px-3 py-1.5 rounded text-xs font-medium transition-all ${String(c[s.key]||"10")===String(p.value)?"bg-amber-500 text-slate-900":"bg-slate-700 text-slate-300 hover:bg-slate-600"}`,children:p.label},p.value))}):e.jsxs("div",{className:"relative",children:[s.prefix&&e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500 text-sm",children:s.prefix}),e.jsx(K,{type:"number",value:c[s.key]??"",onChange:p=>m(s.key,p.target.value),className:`bg-slate-900 border-slate-700 text-white ${s.prefix?"pl-7":""} ${s.suffix?"pr-8":""}`}),s.suffix&&e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-500 text-sm",children:s.suffix})]})]},s.key))}),e.jsx("p",{className:"text-xs text-slate-300 italic",children:a}),i&&e.jsx("div",{className:"bg-slate-900/60 rounded-lg p-4 space-y-2",children:i.note?e.jsx("p",{className:"text-amber-400/80 text-sm italic",children:i.note}):e.jsxs(e.Fragment,{children:[l&&e.jsxs("div",{className:"border-b border-slate-700/50 pb-2 mb-2",children:[e.jsx("p",{className:"text-[11px] text-slate-500 uppercase tracking-wider mb-1",children:"How we calculated this"}),e.jsx("p",{className:"text-xs text-slate-300 font-mono",children:l.formula}),e.jsx("p",{className:"text-xs text-amber-400/80 font-mono mt-0.5",children:l.substituted})]}),i.extraDisplay&&e.jsxs("p",{className:`text-sm font-semibold ${i.extraDisplay.color}`,children:[i.extraDisplay.label," â ",i.extraDisplay.value]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-400",children:"Monthly Cost"}),e.jsx("span",{className:"text-white font-semibold",children:lt(i.monthlyCost)})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-400",children:"Annual Cost"}),e.jsx("span",{className:"text-amber-400 font-bold",children:lt(i.annualCost)})]})]})})]})}const Se=r=>r<0?"-$"+Math.abs(Math.round(r)).toLocaleString():"$"+Math.round(r).toLocaleString();function ts({data:r,onSave:c,onComplete:d}){var v,I;const[t,a]=j.useState(()=>(r.selected||[]).filter(u=>_e.some(S=>S.id===u)).slice(0,2)),[i,l]=j.useState(r.calcInputs||{}),[m,s]=j.useState(r.context||"");j.useEffect(()=>{const b=setTimeout(()=>{c(n())},1500);return()=>clearTimeout(b)},[t,i,m]);const p=b=>{a(u=>u.includes(b)?u.filter(S=>S!==b):u.length>=2?u:[...u,b])},C=t.map(b=>{const u=_e.find(S=>S.id===b);return u?{id:b,killer:u,result:bt(b,i[b]||{})}:null}).filter(b=>b!==null),h=C.filter(b=>b.result&&(b.result.monthlyCost!==0||b.result.note)),x=C.reduce((b,u)=>{var S;return b+(((S=u.result)==null?void 0:S.monthlyCost)||0)},0),T=x*12,N=t.length===2&&h.length===2;function n(){const b=C.map(u=>{var S,g;return{id:u.id,name:u.killer.title,monthlyCost:((S=u.result)==null?void 0:S.monthlyCost)||0,annualCost:((g=u.result)==null?void 0:g.annualCost)||0}});return{selected:t,calcInputs:i,context:m,killers:b,combinedMonthlyLeak:x,combinedAnnualLeak:T}}return e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-slate-400 text-sm",children:"Select your top 2 â the ones that hit closest to home. Then calculate what each one is costing you every month."}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:_e.map((b,u)=>{const S=t.includes(b.id),g=!S&&t.length>=2;return e.jsxs("button",{onClick:()=>!g&&p(b.id),disabled:g,className:`p-4 rounded-lg border text-left transition-all ${u===_e.length-1?"sm:col-span-2 lg:col-span-1 lg:col-start-2":""} ${S?"border-amber-500 bg-amber-500/10 ring-1 ring-amber-500/40":g?"border-slate-800 bg-slate-800/30 opacity-40 cursor-not-allowed":"border-slate-700 bg-slate-800/50 hover:border-slate-600"}`,children:[e.jsx("h4",{className:"text-white font-medium text-sm mb-1",children:b.title}),e.jsx("p",{className:"text-slate-400 text-xs",children:b.desc})]},b.id)})}),C.map(b=>
6e.jsx(es,{killer:b.killer,inputs:i[b.id]||{},onInputsChange:u=>l(S=>({...S,[b.id]:u}))},b.id)),N&&e.jsxs("div",{className:"bg-slate-900 border border-amber-500/40 rounded-xl p-6 text-center space-y-3",children:[e.jsx("h3",{className:"text-amber-400 font-bold text-sm uppercase tracking-wider",children:"Your Combined Monthly Blindspot Cost"}),e.jsxs("div",{className:"flex items-center justify-center gap-3 text-white text-lg font-semibold flex-wrap",children:[e.jsx("span",{children:Se(((v=C[0].result)==null?void 0:v.monthlyCost)||0)}),e.jsx("span",{className:"text-slate-500",children:"+"}),e.jsx("span",{children:Se(((I=C[1].result)==null?void 0:I.monthlyCost)||0)}),e.jsx("span",{className:"text-slate-500",children:"="}),e.jsx("span",{className:"text-amber-400 text-2xl font-bold",children:Se(x)})]}),e.jsx("p",{className:"text-slate-400 text-sm",children:"This is what your Financial Operating System is missing every month."}),e.jsxs("p",{className:"text-amber-400/70 text-lg font-semibold",children:["Annual impact: ",Se(T)]}),e.jsxs("p",{className:"text-amber-400/80 italic text-sm mt-2",children:["Drop this number in the chat: ",e.jsxs("span",{className:"font-semibold",children:[Se(x),"/month"]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-white mb-2 block",children:"Any additional context on your top 2 blindspots? (Optional)"}),e.jsx(K,{value:m,onChange:b=>s(b.target.value),placeholder:"What's the business situation behind these numbers?",className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"})]}),e.jsx(R,{onClick:()=>d(n()),className:"w-full bg-emerald-600 hover:bg-emerald-700 text-white",disabled:t.length===0,children:"Save + Continue"})]})}const $e=[{id:"vision",label:"Vision & Strategy",desc:"Clarity of long-term direction"},{id:"financial",label:"Financial Mastery",desc:"Understanding of margins, cash, P&L"},{id:"sales",label:"Sales & Revenue",desc:"Pipeline, conversion, pricing power"},{id:"operations",label:"Operations",desc:"Delivery efficiency and scalability"},{id:"team",label:"Team & Leadership",desc:"Hiring, delegation, accountability"},{id:"cash",label:"Cash Management",desc:"Cash flow, runway, reserves"},{id:"systems",label:"Systems & Processes",desc:"Automation, documentation, repeatability"},{id:"customer",label:"Customer Experience",desc:"Retention, satisfaction, referrals"},{id:"growth",label:"Growth Mindset",desc:"Willingness to change, learn, invest"}];function ss({data:r,onSave:c,onComplete:d}){const t=We(),{completions:a,completedIds:i}=Qe(),l=i.includes("ceo-score"),m=a.find(o=>o.assessmentType==="ceo-score"),[s,p]=j.useState(r.scores||{}),[C,h]=j.useState(r.reflection||""),[x,T]=j.useState(r.submitted||!1),[N,n]=j.useState(!1);j.useEffect(()=>{const o=setTimeout(()=>{c({scores:s,reflection:C,submitted:x})},1500);return()=>clearTimeout(o)},[s,C,x]);const v=(o,w)=>{p(A=>({...A,[o]:w}))},I=Object.values(s).reduce((o,w)=>o+w,0),b=$e.length*10,u=Math.round(I/b*100),S=$e.every(o=>s[o.id]!==void 0),g=()=>{T(!0)};if(l&&!N)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-emerald-900/20 border border-emerald-500/30 rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx(Ae,{className:"w-6 h-6 text-emerald-400"}),e.jsx("h3",{className:"text-white font-bold text-lg",children:"CEO Score Complete"})]}),e.jsxs("div",{className:"flex items-center gap-6 mb-4",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-20 h-20 transform -rotate-90",children:[e.jsx("circle",{cx:"40",cy:"40",r:"34",stroke:"currentColor",strokeWidth:"6",fill:"none",className:"text-slate-700"}),e.jsx("circle",{cx:"40",cy:"40",r:"34",stroke:"currentColor",strokeWidth:"6",fill:"none",strokeDasharray:`${((m==null?void 0:m.percentage)||0)/100*214} 214`,className:m&&m.percentage>=70?"text-emerald-500":"text-amber-500"})]}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-2xl font-bold text-white",children:(m==null?void 0:m.percentage)||0})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-300 text-sm",children:"Your score from the full CEO Score assessment"}),e.jsxs("p",{className:"text-slate-400 text-xs mt-1",children:["Grade: ",m==null?void 0:m.grade]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>t("/ceoscore"),className:"border-emerald-500/40 bg-emerald-500/10 text-white hover:bg-emerald-500/20",children:["Review Full Results ",e.jsx(Pe,{className:"w-3 h-3 ml-1.5"})]}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>n(!0),className:"text-slate-400 hover:text-white",children:"Do inline self-rating instead"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-white mb-2 block",children:"What did you discover? What surprised you?"}),e.jsx(je,{value:C,onChange:o=>h(o.target.value),placeholder:"Note your honest reactions. These become your baseline.",className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500 min-h-[100px]"})]}),e.jsx(R,{onClick:()=>d({scores:r.scores||{},reflection:C,submitted:!0,fromAssessment:!0,assessmentScore:m==null?void 0:m.percentage}),className:"w-full bg-emerald-600 hover:bg-emerald-700 text-white",children:"Save + Continue"})]});const y="Before your money runs through the Efficiency Filter, the Timing Filter, or the Capital Filter â it runs through you. Your CEO Score reveals which leadership dimensions are creating your financial gaps. Identity & Mindset. Financial Intelligence. Vision & Strategy. Execution. People. Pricing & Profit. Operations. Leadership. The Financial Blindspots you're about to find almost always trace back to one of these eight dimensions.",B="Which of the 8 dimensions surprised you most? Which one do you suspect is connected to your biggest Financial Blindspot?";return l&&!N?e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm italic text-muted-foreground",children:y}),e.jsxs("div",{className:"bg-emerald-900/20 border border-emerald-500/30 rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx(Ae,{className:"w-6 h-6 text-emerald-400"}),e.jsx("h3",{className:"text-white font-bold text-lg",children:"CEO Score Complete"})]}),e.jsxs("div",{className:"flex items-center gap-6 mb-4",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-20 h-20 transform -rotate-90",children:[e.jsx("circle",{cx:"40",cy:"40",r:"34",stroke:"currentColor",strokeWidth:"6",fill:"none",className:"text-slate-700"}),e.jsx("circle",{cx:"40",cy:"40",r:"34",stroke:"currentColor",strokeWidth:"6",fill:"none",strokeDasharray:`${((m==null?void 0:m.percentage)||0)/100*214} 214`,className:m&&m.percentage>
6=70?"text-emerald-500":"text-amber-500"})]}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-2xl font-bold text-white",children:(m==null?void 0:m.percentage)||0})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-300 text-sm",children:"Your score from the full CEO Score assessment"}),e.jsxs("p",{className:"text-slate-400 text-xs mt-1",children:["Grade: ",m==null?void 0:m.grade]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>t("/ceoscore"),className:"border-emerald-500/40 bg-emerald-500/10 text-white hover:bg-emerald-500/20",children:["Review Full Results ",e.jsx(Pe,{className:"w-3 h-3 ml-1.5"})]}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>n(!0),className:"text-slate-400 hover:text-white",children:"Do inline self-rating instead"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-white mb-2 block",children:B}),e.jsx(je,{value:C,onChange:o=>h(o.target.value),placeholder:"Note your honest reactions. These become your baseline.",className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500 min-h-[100px]"})]}),e.jsx(R,{onClick:()=>d({scores:r.scores||{},reflection:C,submitted:!0,fromAssessment:!0,assessmentScore:m==null?void 0:m.percentage}),className:"w-full bg-emerald-600 hover:bg-emerald-700 text-white",children:"Save + Continue"})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm italic text-muted-foreground",children:y}),!l&&!x&&e.jsxs("div",{className:"bg-amber-900/20 border border-amber-500/30 rounded-lg p-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-white text-sm font-medium",children:"Want deeper insights?"}),e.jsx("p",{className:"text-slate-400 text-xs",children:"Take the full CEO Score assessment for a detailed breakdown."})]}),e.jsxs(R,{size:"sm",onClick:()=>t("/ceoscore"),className:"bg-emerald-600 hover:bg-emerald-700 text-white",children:["Take Full Assessment ",e.jsx(Pe,{className:"w-3 h-3 ml-1.5"})]})]}),x?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm italic text-muted-foreground",children:y}),e.jsxs("div",{className:"bg-slate-800/50 rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-6 mb-6",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-20 h-20 transform -rotate-90",children:[e.jsx("circle",{cx:"40",cy:"40",r:"34",stroke:"currentColor",strokeWidth:"6",fill:"none",className:"text-slate-700"}),e.jsx("circle",{cx:"40",cy:"40",r:"34",stroke:"currentColor",strokeWidth:"6",fill:"none",strokeDasharray:`${u/100*214} 214`,className:u>=70?"text-emerald-500":"text-amber-500"})]}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-2xl font-bold text-white",children:u})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-white font-bold text-lg",children:"Your CEO Score"}),e.jsx("p",{className:`text-sm font-medium ${u>=70?"text-emerald-400":"text-amber-400"}`,children:u>=80?"Scaling Ready":u>=60?"Growth Opportunity":"Foundation Building"}),e.jsxs("p",{className:"text-slate-400 text-xs mt-1",children:[I," / ",b," points"]})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:$e.map(o=>e.jsxs("div",{className:"bg-slate-700/40 rounded p-2 text-center",children:[e.jsx("p",{className:"text-[10px] text-slate-400 truncate",children:o.label}),e.jsxs("p",{className:`font-bold text-sm ${(s[o.id]||0)>=7?"text-emerald-400":(s[o.id]||0)>=5?"text-amber-400":"text-red-400"}`,children:[s[o.id],"/10"]})]},o.id))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-white mb-2 block",children:B}),e.jsx(je,{value:C,onChange:o=>h(o.target.value),placeholder:"Note your honest reactions. These become your baseline.",className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500 min-h-[100px]"})]}),e.jsx(R,{onClick:()=>d({scores:s,reflection:C,submitted:!0}),className:"w-full bg-emerald-600 hover:bg-emerald-700 text-white",children:"Save + Continue"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-slate-400 text-sm",children:"Rate yourself 1â10 on each dimension. Be honest â this is your baseline."}),e.jsx("div",{className:"space-y-3",children:$e.map(o=>e.jsxs("div",{className:"bg-slate-800/50 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-medium text-sm",children:o.label}),e.jsx("p",{className:"text-slate-500 text-xs",children:o.desc})]}),e.jsx("span",{className:"text-emerald-400 font-bold text-lg min-w-[2rem] text-right",children:s[o.id]||"â"})]}),e.jsx("div",{className:"flex gap-1.5",children:[1,2,3,4,5,6,7,8,9,10].map(w=>e.jsx("button",{onClick:()=>v(o.id,w),className:`flex-1 h-8 rounded text-xs font-medium transition-all ${s[o.id]===w?"bg-emerald-500 text-white":s[o.id]&&w<=s[o.id]?"bg-emerald-500/30 text-emerald-400":"bg-slate-700 text-slate-400 hover:bg-slate-600"}`,children:w}
6,w))})]},o.id))}),e.jsx(R,{onClick:g,className:"w-full bg-emerald-600 hover:bg-emerald-700 text-white",disabled:!S,children:"Submit CEO Score"})]})]})}const as=[{id:"market",label:"Market & Demand",desc:"Not enough qualified leads or market positioning"},{id:"sales",label:"Sales & Conversion",desc:"Pipeline leaks, pricing issues, low close rates"},{id:"delivery",label:"Delivery & Fulfillment",desc:"Quality drops, bottlenecks, capacity limits"},{id:"team",label:"People & Talent",desc:"Wrong hires, role confusion, skill gaps"},{id:"cash",label:"Cash & Capital",desc:"Cash flow gaps, underfunded growth, margins too thin"},{id:"systems",label:"Systems & Ops",desc:"Manual processes, no SOPs, tech debt"}],ls=[{id:"pricing",label:"Underpricing",desc:"Not charging what you're worth or discounting too much"},{id:"scope_creep",label:"Scope Creep",desc:"Delivering more than contracted without charge"},{id:"overhead",label:"Hidden Overhead",desc:"Costs buried in subscriptions, tools, or processes"},{id:"collections",label:"Slow Collections",desc:"Money owed but not collected on time"},{id:"waste",label:"Operational Waste",desc:"Time and resources spent on non-revenue activities"},{id:"bad_clients",label:"Wrong Clients",desc:"Low-margin clients consuming premium resources"}];function rs({data:r,onSave:c,onComplete:d}){const t=We(),{completions:a,completedIds:i}=Qe(),l=i.includes("profit-leak"),m=i.includes("constraint-finder"),s=a.find(u=>u.assessmentType==="profit-leak"),p=a.find(u=>u.assessmentType==="constraint-finder"),[C,h]=j.useState(r.constraints||[]),[x,T]=j.useState(r.profitLeaks||[]),[N,n]=j.useState(r.takeaways||"");j.useEffect(()=>{const u=setTimeout(()=>{c({constraints:C,profitLeaks:x,takeaways:N})},1500);return()=>clearTimeout(u)},[C,x,N]);const v=u=>{h(S=>S.includes(u)?S.filter(g=>g!==u):[...S,u])},I=u=>{T(S=>S.includes(u)?S.filter(g=>g!==u):[...S,u])},b=({done:u,label:S,score:g,grade:y,route:B,completionId:o})=>e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border mb-3 ${u?"border-emerald-500/30 bg-emerald-900/20":"border-amber-500/30 bg-amber-900/20"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[u?e.jsx(Ae,{className:"w-4 h-4 text-emerald-400"}):e.jsx("span",{className:"text-amber-400 text-sm",children:"â ï¸"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-white text-sm font-medium",children:S}),u&&y&&e.jsxs("span",{className:"text-slate-400 text-xs ml-2",children:["Grade: ",y," · Score: ",g,"%"]})]})]}),e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>t(u&&o?`${B}?results=${o}`:B),className:u?"border-emerald-500/40 text-emerald-600 bg-white hover:bg-emerald-500/10 text-xs":"border-slate-600 text-slate-300 text-xs",children:[u?"Review":"Take Now"," ",e.jsx(Pe,{className:"w-3 h-3 ml-1"})]})]});return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-semibold text-sm mb-3",children:"Your Assessment Results"}),e.jsx(b,{done:l,label:"Profit Leaks Assessment",score:s==null?void 0:s.percentage,grade:s==null?void 0:s.grade,route:"/profit",completionId:s==null?void 0:s.id}),e.jsx(b,{done:m,label:"Constraint Finder",score:p==null?void 0:p.percentage,grade:p==null?void 0:p.grade,route:"/assessments/constraint",completionId:p==null?void 0:p.id})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-semibold text-sm mb-3",children:"Where is your business constrained?"}),e.jsx("p",{className:"text-slate-400 text-xs mb-3",children:m?"Based on your Constraint Finder results, confirm or adjust your top constraints:":"Select the areas where you feel most stuck:"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:as.map(u=>e.jsxs("button",{onClick:()=>v(u.id),className:`p-4 rounded-lg border text-left transition-all ${C.includes(u.id)?"border-emerald-500 bg-emerald-500/10":"border-slate-700 bg-slate-800/50 hover:border-slate-600"}`,children:[e.jsx("h5",{className:"text-white font-medium text-sm mb-1",children:u.label}),e.jsx("p",{className:"text-slate-400 text-xs",children:u.desc})]},u.id))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-semibold text-sm mb-3",children:"Where is profit leaking?"}),e.jsx("p",{className:"text-slate-400 text-xs mb-3",children:l?"Your Profit Leak asse
6ssment flagged key areas. Confirm or add more:":"Select the areas where money is slipping through:"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:ls.map(u=>e.jsxs("button",{onClick:()=>I(u.id),className:`p-4 rounded-lg border text-left transition-all ${x.includes(u.id)?"border-amber-500 bg-amber-500/10":"border-slate-700 bg-slate-800/50 hover:border-slate-600"}`,children:[e.jsx("h5",{className:"text-white font-medium text-sm mb-1",children:u.label}),e.jsx("p",{className:"text-slate-400 text-xs",children:u.desc})]},u.id))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-white mb-2 block",children:"What are your key takeaways? What will you do differently?"}),e.jsx(je,{value:N,onChange:u=>n(u.target.value),placeholder:"Write this as if you are briefing yourself before the session.",className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500 min-h-[100px]"})]}),e.jsx(R,{onClick:()=>d({constraints:C,profitLeaks:x,takeaways:N}),className:"w-full bg-emerald-600 hover:bg-emerald-700 text-white",disabled:C.length===0&&x.length===0,children:"Save + Continue"})]})}const ns=[{id:"revenue",label:"Revenue",subtitle:"The top line, what is the number?",type:"currency",icon:Ne},{id:"profit",label:"Profit",subtitle:"The bottom line, what do you actually keep?",type:"currency",icon:Ne},{id:"cash",label:"Cash",subtitle:"How much in reserves?",type:"currency",icon:Ne},{id:"key_hires",label:"Key Hires",subtitle:"Who do you need on the team?",type:"text",icon:ut},{id:"priority",label:"#1 Priority",subtitle:"The main thing this year",type:"text",icon:At},{id:"role",label:"Your Role",subtitle:"How does it change?",type:"text",icon:Rt}];function os({data:r,onSave:c,onComplete:d}){const[t,a]=j.useState(r.fields||{}),[i,l]=j.useState(r.visionNarrative||"");j.useEffect(()=>{const p=setTimeout(()=>{c({fields:t,visionNarrative:i})},1500);return()=>clearTimeout(p)},[t,i]);const m=(p,C)=>{a(h=>({...h,[p]:C}))},s=Object.values(t).some(p=>p&&p.trim())||i.trim().length>0;return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("p",{className:"text-slate-400 text-sm",children:"Define Your Commitments â 8 Minutes"})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:ns.map(p=>{const C=p.icon;return e.jsxs("div",{className:"bg-slate-800/50 border border-slate-700/50 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(C,{className:"w-4 h-4 text-emerald-400"}),e.jsx("h4",{className:"text-white font-medium text-sm",children:p.label})]}),e.jsx("p",{className:"text-slate-500 text-xs mb-3",children:p.subtitle}),e.jsx(K,{value:t[p.id]||"",onChange:h=>m(p.id,h.target.value),placeholder:p.type==="currency"?"$0":"Type here...",className:"bg-slate-700/50 border-slate-600 text-white placeholder:text-slate-500"})]},p.id)})}),e.jsxs("div",{className:"bg-slate-800/50 border border-slate-700/50 rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ve,{className:"w-4 h-4 text-emerald-400"}),e.jsx("h4",{className:"text-white font-medium text-sm",children:"Your 1-Year Vision Statement"})]}),e.jsx("p",{className:"text-slate-500 text-xs mb-3",children:"In your own words â what does your business look like one year from today? Describe the transformation: revenue, team, clients, lifestyle, the way the business operates. Be specific."}),e.jsx(je,{value:i,onChange:p=>l(p.target.value),placeholder:"One year from now, my business will...",className:"bg-slate-700/50 border-slate-600 text-white placeholder:text-slate-500 min-h-[120px] resize-none"})]}),e.jsx(R,{onClick:()=>d({fields:t,visionNarrative:i}),className:"w-full bg-emerald-600 hover:bg-emerald-700 text-white",disabled:!s,children:"Save + Continue"})]})}const Te=(r,c="",d="")=>r===null||isNaN(r)?"â":c==="$"?`$${r.toLocaleString("en-US",{maximumFractionDigits:0})}${d}`:`${r.toLocaleString("en-US",{maximumFractionDigits:1})}${d}`;function is({data:r,onSave:c,onComplete:d}){const[t,a]=j.useState(r.inputs||{}),[i,l]=j.useState(r.overrides||{});j.useEffect(()=>{const n=setTimeout(()=>{c({inputs:t,overrides:i,numbers:p})},1500);return()=>clearTimeout(n)},[t,i]);const m=(n,v)=>{v!==""&&!/^-?\d*\.?\d*$/.test(v)||a(I=>({...I,[n]:v}))},s=n=>{const v=t[n];if(!v||v.trim()==="")return null;const I=parseFloat(v);return isNaN(I)?null:I},p=j.useMemo(()=>{const n=s("revenue"),v=s("cogs"),I=s("opex"),b=s("cash_on_hand"),u=s("monthly_burn"),S=s("marketing_spend"),g=s("new_clients"),y=s("avg_contract_value"),B=s("avg_retention_months"),o=n!==null&&v!==null?n-v:null,w=n&&o!==null?o/n*100:null,A=o!==null&&I!==null?o-I:null,M=n&&A!==null?A/n*100:null,Y=A,J=S!==null&&g?S/g:null,U=y!==null&&B!==null?y*B:null,V=b!==null&&u?b/u:null,D=s("dso"),L=s("dio"),G=s("dpo"),ee=D!==null&&G!==null?D+(L??0)-G:null;return{gross_margin:w,cac:J,ltv:U,net_profit:M,ebitda:Y,ccc:ee,cash_runway:V}},[t,i]),C=[{id:"revenue",label:"Annual Revenue",prefix:"$",placeholder:"e.g. 2000000"},{id:"cogs",label:"Cost of Goods Sold (COGS)",prefix:"$",placeholder:"Direct costs of delivery"},{id:"opex",label:"Operating Expenses",prefix:"$",placeholder:"Payroll, rent, tools, etc."},{id:"marketing_spend",label:"Annual Marketing Spend",prefix:"$",placeholder:"Total marketing budget"},{id:"new_clients",label:"New Clients Acquired (per year)",prefix:"",placeholder:"e.g. 24"},{id:"avg_contract_value",label:"Avg Contract Value (monthly)",prefix:"$",placeholder:"Monthly revenue per client"},{id:"avg_retention_months",label:"Avg Client Retention (months)",prefix:"",placeholder:"e.g. 12"},{id:"cash_on_hand",label:"Cash on Hand",prefix:"$",placeholder:"Current bank balance"},{id:"monthly_burn",label:"Monthly Burn Rate",prefix:"$",placeholder:"Monthly expenses if no revenue"}
6,{id:"dso",label:"Days Sales Outstanding (DSO)",prefix:"",placeholder:"Avg days to collect payment"},{id:"dio",label:"Days Inventory Outstanding (DIO)",prefix:"",placeholder:"0 if service business"},{id:"dpo",label:"Days Payable Outstanding (DPO)",prefix:"",placeholder:"Avg days you take to pay vendors"}],h=[{id:"gross_margin",label:"Gross Margin",value:p.gross_margin,format:n=>Te(n,"","%"),benchmark:"50%+ services, 30%+ products",health:n=>n>=50?"good":n>=30?"ok":"bad"},{id:"cac",label:"CAC",value:p.cac,format:n=>Te(n,"$"),benchmark:"Should be < 1/3 of LTV",health:n=>p.ltv?n<p.ltv/3?"good":n<p.ltv?"ok":"bad":"ok"},{id:"ltv",label:"LTVGP",value:p.ltv,format:n=>Te(n,"$"),benchmark:"Should be 3x+ CAC",health:n=>p.cac?n>=p.cac*3?"good":n>=p.cac?"ok":"bad":"ok"},{id:"ccc",label:"Cash Conversion Cycle",value:p.ccc,format:n=>`${n.toFixed(0)} days`,benchmark:"Lower is better; <30 days strong",health:n=>n<=30?"good":n<=60?"ok":"bad"},{id:"net_profit",label:"Net Profit %",value:p.net_profit,format:n=>Te(n,"","%"),benchmark:"10%+ healthy, 20%+ strong",health:n=>n>=20?"good":n>=10?"ok":"bad"},{id:"ebitda",label:"EBITDA",value:p.ebitda,format:n=>Te(n,"$"),benchmark:"Profit before interest, taxes, depreciation & amortization",health:n=>n>0?"good":"bad"},{id:"cash_runway",label:"Cash Runway",value:p.cash_runway,format:n=>`${n.toFixed(1)} months`,benchmark:"3 months min, 6 months strong",health:n=>n>=6?"good":n>=3?"ok":"bad"}],x=n=>n==="good"?"text-emerald-400":n==="ok"?"text-amber-400":"text-red-400",T=n=>n==="good"?"bg-emerald-500/10 border-emerald-500/30":n==="ok"?"bg-amber-500/10 border-amber-500/30":"bg-red-500/10 border-red-500/30",N=Object.values(t).some(n=>n&&n.trim());return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Mt,{className:"w-4 h-4 text-emerald-400"}),e.jsx("h4",{className:"text-white font-semibold text-sm",children:"Your Financial Data"})]}),e.jsx("p",{className:"text-slate-400 text-xs mb-4",children:"Enter your real numbers. The 7 metrics will calculate automatically."}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:C.map(n=>e.jsxs("div",{className:"bg-slate-800/50 border border-slate-700/50 rounded-lg p-3",children:[e.jsx("label",{className:"text-white text-xs font-medium block mb-1.5",children:n.label}),e.jsxs("div",{className:"relative",children:[n.prefix&&e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 text-sm",children:n.prefix}),e.jsx(K,{value:t[n.id]||"",onChange:v=>m(n.id,v.target.value),placeholder:n.placeholder,className:`bg-slate-700/50 border-slate-600 text-white placeholder:text-slate-500 ${n.prefix?"pl-7":""}`})]})]},n.id))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(qe,{className:"w-4 h-4 text-emerald-400"}),e.jsx("h4",{className:"text-white font-semibold text-sm",children:"Your 7 Numbers"})]}),e.jsx("div",{className:"space-y-2",children:h.map(n=>{const v=n.value!==null?n.health(n.value):"ok";return e.jsx("div",{className:`rounded-lg border p-4 transition-all ${n.value!==null?T(v):"bg-slate-800/50 border-slate-700/50"}`,children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h5",{className:"text-white font-medium text-sm",children:n.label}),e.jsx("p",{className:"text-slate-500 text-xs",children:n.benchmark})]}),e.jsx("div",{className:`text-right ${n.value!==null?x(v):"text-slate-500"}`,children:e.jsx("span",{className:"text-lg font-bold",children:n.value!==null?n.format(n.value):"â"})})]})},n.id)})})]}),e.jsx(R,{onClick:()=>d({inputs:t,overrides:i,numbers:p}),className:"w-full bg-emerald-600 hover:bg-emerald-700 text-white",disabled:!N,children:"Save + Continue"})]})}const Ie=[74,96,130],X=[26,26,46],Oe=[51,51,64],ce=[136,136,153],ue=[246,247,250],He=[212,237,218],Ee=[60,118,61],Ue=[255,243,205],Je=[138,109,59],rt=[169,68,66],nt=[255,255,255],cs=r=>new Promise((c,d)=>{const t=new Image;t.crossOrigin="anonymous",t.onload=()=>c(t),t.onerror=d,t.src=r});function ds(r){return r?Ee:Je}async function ms(r,c){const d=gt(r),t=new _t("p","mm","a4"),a=t.internal.pageSize.getWidth(),i=t.internal.pageSize.getHeight(),l=20,m=a-l*2;let s=0,p=null;try{p=await cs($t)}catch{}const C=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),h=k=>{t.setFontSize(7),t.setFont("helvetica","normal"),t.setTextColor(...ce),t.text("ScalingCFO | Financial Scaling Analysis",l,i-8),t.text(`Page ${k}`,a-l,i-8,{align:"right"})},x=k=>s+k>i-20?(h(t.getNumberOfPages()),t.addPage(),s=l,!0):!1;if(t.setFillColor(...Ie),t.rect(0,0,a,55,"F"),p){const P=p.height/p.width*28;t.addImage(p,"PNG",a-l-28,5,28,P)}t.setTextColor(255,255,255),t.setFontSize(7),t.setFont("helvetica","bold"),t.text("FINANCIAL ANALYSIS",l,22),t.setFontSize(22),t.text("Capital Bridge & Scaling Analysis",l,31),t.setFontSize(9),t.setFont("helvetica","normal"),t.text("A complete financial scaling analysis showing your path from current revenue to your goal.",l,38),t.setDrawColor(255,255,255),t.setLineWidth(.2),t.line(l,43,a-l,43);const T=[{label:"PREPARED FOR",value:"Founder"},{label:"DATE",value:C},{label:"CURRENT REVENUE",value:f(d.currentAnnualRevenue)},{label:"REVENUE GOAL",value:f(r.annualRevenueGoal)}],N=m/T.length;T.forEach((k,P)=>{const $=l+N*P+N/2;t.setFontSize(6),t.setFont("helvetica","bold"),t.text(k.label,$,47,{align:"center"}),t.setFontSize(8),t.setFont("helvetica","normal"),t.text(k.value,$,52,{align:"center"})}),s=65,t.setTextColor(...X),t.setFontSize(14),t.setFont("helvetica","bold"),t.text("Your Financial Inputs",l,s),s+=8;const n=m/2-3;t.setFillColor(...Ie),t.roundedRect(l,s,n,8,1,1,"F"),t.roundedRect(l+n+6,s,n,8,1,1,"F"),t.setTextColor(255,255,255),t.setFontSize(8),t.setFont("helvetica","bold"),t.text("AS-IS (CURRENT)",l+4,s+5.5),t.text("TARGET (GOAL)",l+n+10,s+5.5),s+=11;const v=[["Monthly Revenue",f(r.monthlyRevenue)],["# of Clients",r.numClients.toString()],["Gross Margin",`${r.grossMargin}%`],["Total Monthly Expenses",f(r.monthlyExpenses)],["Marketing Spend",f(r.marketingSpend)],["Current Cash",f(r.currentCash)],["AR Days",`${r.arDays}`],["AP Days",`${r.apDays}`],["Inventory Days",`${r.inventoryDays}`]],I=[["1-Year Revenue Goal",f(r.annualRevenueGoal)],["New Clients / Month",r.newClientsPerMonth.toString()],["Target Gross Margin",r.targetGrossMargin>0?`${r.targetGrossMargin}%`:"-"],["Target OpEx %",r.targetOpExpensePercent>0?`${r.targetOpExpensePercent}%`:"-"],["Months to Target",`${r.monthsToTarget||12}`],["Debt Service",f(r.debtService||0)],["AR Days (Target)",`${r.targetArDays||r.arDays}`],["AP Days (Target)",`${r.targetApDays||r.apDays}`],["Inventory Days (Target)",`${r.targetInventoryDays||r.inventoryDays}`]],b=Math.max(v.length,I.length);for(let k=0;k<b;k++){const P=v[k],$=I[k];P&&(t.setFillColor(...ue),t.roundedRect(l,s,n,10,1,1,"F"),t.setFontSize(7),t.setFont("helvetica","normal"),t.setTextColor(...ce),t.text(P[0],l+4,s+4),t.setFontSize(9),t.setFont("helvetica","bold"),t.setTextColor(...X),t.text(P[1],l+4,s+8.5)),$&&(t.setFillColor(...ue),t.roundedRect(l+n+6,s,n,10,1,1,"F"),t.setFontSize(7),t.setFont("helvetica","normal"),t.setTextColor(...ce),t.text($[0],l+n+10,s+4),t.setFontSize(9),t.setFont("helvetica","bold"),t.setTextColor(...X),t.text($[1],l+n+10,s+8.5)),s+=13}s+=5,x(80),t.setTextColor(...X),t.setFontSize(14),t.setFont("helvetica","bold"),t.text("Income Statement (Monthly) - As-Is vs Target",l,s),s+=8;const u=r.monthlyRevenue,S=u*(r.grossMargin/100),g=u-S,y=r.marketingSpend,B=r.monthlyExpenses,o=S-B,w=r.annualRevenueGoal/12,A=r.targetGrossMargin>0?r.targetGrossMargin:r.grossMargin,M=w*(A/100),Y=w-M,J=u>0?w/u:1,U=y*J,V=r.targetOpExpensePercent>0?w*(r.targetOpExpensePercent/100):r.monthlyExpenses*J,D=M-V,L=u/30,G=g/30,ee=L*r.arDays+G*r.inventoryDays-G*r.apDays,q=0,re=r.targetArDays||r.arDays,de=r.targetApDays||r.apDays,E=r.targetInventoryDays||r.inventoryDays,F=w/30,_=Y/30,H=F*re+_*E-_*de-ee,te=r.monthlyCapex||
60,me=r.targetMonthlyCapex||te,ne=r.debtService||0,ie=o-q-te,xe=D-H-me,he=ie-ne,ye=xe-ne,Q=(k,P)=>P>0?`${(k/P*100).toFixed(1)}%`:"0.0%",oe=[{label:"Revenue",asIs:f(u),target:f(w),delta:f(w-u),isBold:!0},{label:"COGS",asIs:f(g),target:f(Y),delta:f(Y-g)},{label:"Gross Profit",asIs:f(S),target:f(M),delta:f(M-S),isBold:!0},{label:" Gross Margin %",asIs:Q(S,u),target:Q(M,w),delta:"",isPct:!0},{label:"Marketing Expenses",asIs:f(y),target:f(U),delta:f(U-y)},{label:" Marketing % of Sales",asIs:Q(y,u),target:Q(U,w),delta:"",isPct:!0},{label:"Total Operating Expenses",asIs:f(B),target:f(V),delta:f(V-B)},{label:" OpEx % of Sales",asIs:Q(B,u),target:Q(V,w),delta:"",isPct:!0},{label:"EBITDA",asIs:f(o),target:f(D),delta:f(D-o),isBold:!0},{label:" EBITDA % of Sales",asIs:Q(o,u),target:Q(D,w),delta:"",isPct:!0},{label:"Working Capital Change",asIs:f(q),target:f(H),delta:f(H-q)},{label:"CapEx",asIs:f(te),target:f(me),delta:f(me-te)},{label:"Free Cash Flow",asIs:f(ie),target:f(xe),delta:f(xe-ie),isBold:!0},{label:" FCF % of Sales",asIs:Q(ie,u),target:Q(xe,w),delta:"",isPct:!0},{label:"Debt Service",asIs:f(ne),target:f(ne),delta:f(0)},{label:"Cash Flow After Debt Service (CADS)",asIs:f(he),target:f(ye),delta:f(ye-he),isBold:!0},{label:" CADS % of Sales",asIs:Q(he,u),target:Q(ye,w),delta:"",isPct:!0}],Z=[m*.34,m*.22,m*.22,m*.22];t.setFillColor(...Ie),t.roundedRect(l,s,m,7,1,1,"F"),t.setTextColor(255,255,255),t.setFontSize(7),t.setFont("helvetica","bold");let O=l;["","As-Is","Target","Delta"].forEach((k,P)=>{t.text(k,P===0?O+4:O+Z[P]-4,s+5,P===0?{}:{align:"right"}),O+=Z[P]}),s+=7,oe.forEach((k,P)=>{if(x(7),k.isBold?(t.setFillColor(...ue),t.rect(l,s,m,7,"F")):P%2===0&&(t.setFillColor(...nt),t.rect(l,s,m,7,"F")),t.setFontSize(k.isPct?6.5:7.5),t.setFont("helvetica",k.isBold?"bold":"normal"),t.setTextColor(...k.isPct?ce:k.isBold?X:Oe),O=l,t.text(k.label,O+4,s+5),O+=Z[0],t.text(k.asIs,O+Z[1]-4,s+5,{align:"right"}),O+=Z[1],t.text(k.target,O+Z[2]-4,s+5,{align:"right"}),O+=Z[2],k.delta){const $=parseFloat(k.delta.replace(/[^0-9.-]/g,""));t.setTextColor(...$>=0?Ee:rt),t.text(k.delta.startsWith("-")?k.delta:`+${k.delta}`,O+Z[3]-4,s+5,{align:"right"})}s+=7}),s+=8,x(40),t.setTextColor(...X),t.setFontSize(14),t.setFont("helvetica","bold"),t.text("Capital Bridge",l,s),s+=8;const ge=Math.max(0,d.revenueGap)/12,pe=d.cashConversionCycle,we=ge*(pe/30)+0+0,Xe=we>0,yt=Xe?Ue:He,vt=Xe?Je:Ee;t.setFillColor(...yt),t.roundedRect(l,s,m,22,2,2,"F"),t.setFontSize(8),t.setFont("helvetica","bold"),t.setTextColor(...vt),t.text("MONTHLY CAPITAL BRIDGE",l+6,s+6),t.setFontSize(16),t.text(f(Math.abs(we)),l+6,s+14),t.setFontSize(7),t.setFont("helvetica","normal"),t.setTextColor(...ce);const jt=`Monthly Revenue Gap (${f(ge)}) x (CCC ${Ge(pe)} days / 30)`;t.text(jt,l+6,s+19),s+=30,x(80);const Re=m/3;t.setTextColor(...X),t.setFontSize(14),t.setFont("helvetica","bold"),t.text("Unit Economics",l,s),s+=8;const Le=d.ltvCacRatio>=3;[{label:"Lifetime Value (LTV)",value:f(d.ltv),sub:`${r.customerLifespanYears||3}-year value`},{label:"Customer Acquisition Cost",value:f(d.cac),sub:"Marketing / New Clients"},{label:"LTV:CAC Ratio",value:`${Ge(d.ltvCacRatio)}:1`,sub:Le?"Healthy (>=3:1)":"Below target (<3:1)"}].forEach((k,P)=>{const $=l+P*Re,ze=P===2?Le?He:Ue:ue;t.setFillColor(...ze),t.roundedRect($+1,s,Re-3,18,1,1,"F"),t.setFontSize(7),t.setFont("helvetica","normal"),t.setTextColor(...ce),t.text(k.label,$+5,s+5),t.setFontSize(12),t.setFont("helvetica","bold"),t.setTextColor(...P===2?ds(Le):X),t.text(k.value,$+5,s+12),t.setFontSize(6),t.setFont("helvetica","normal"),t.setTextColor(...ce),t.text(k.sub,$+5,s+16)}),s+=25,x(40),t.setTextColor(...X),t.setFontSize(14),t.setFont("helvetica","bold"),t.text("Employee Efficiency",l,s),s+=8,[{label:"Revenue / Employee",value:f(d.revenuePerEmployee)},{label:"Employees at Goal",value:d.employeesNeededAtGoal.toString()},{label:"Additional Hires Needed",value:d.additionalEmployeesNeeded.toString()}].forEach((k,P)=>{const $=l+P*Re;t.setFillColor(...ue),t.roundedRect($+1,s,Re-3,15,1,1,"F"),t.setFontSize(7),t.setFont("helvetica","normal"),t.setTextColor(...ce),t.text(k.label,$+5,s+5),t.setFontSize(11),t.setFont("helvetica","bold"),t.setTextColor(...X),t.text(k.value,$+5,s+11)}),s+=22,x(45),t.setTextColor(...X),t.setFontSize(14),t.setFont("helvetica","bold"),t.text("Borrowing Capacity",l,s),s+=8,[["","Current","At Goal"],["Cash Flow Method",f(d.currentBorrowingCapacityCash),f(d.futureBorrowingCapacityCash)],["EBITDA Method (2.5x)",f(d.currentBorrowingCapacityEbitda),f(d.futureBorrowingCapacityEbitda)]].forEac
6h((k,P)=>{const $=P===0;$?(t.setFillColor(...Ie),t.roundedRect(l,s,m,8,1,1,"F"),t.setTextColor(255,255,255)):(t.setFillColor(...P%2===0?ue:nt),t.rect(l,s,m,8,"F"),t.setTextColor(...Oe)),t.setFontSize(8),t.setFont("helvetica",$?"bold":"normal"),t.text(k[0],l+4,s+5.5),t.text(k[1],l+m/2,s+5.5,{align:"center"}),t.text(k[2],a-l-4,s+5.5,{align:"right"}),s+=8}),s+=8,x(25),t.setTextColor(...X),t.setFontSize(14),t.setFont("helvetica","bold"),t.text("Working Capital",l,s),s+=8,[{label:"Cash Conversion Cycle",value:`${d.cashConversionCycle} days`},{label:"Working Capital Needed",value:f(d.workingCapitalNeeded)}].forEach((k,P)=>{const $=l+P*(m/2);t.setFillColor(...ue),t.roundedRect($+1,s,m/2-3,15,1,1,"F"),t.setFontSize(7),t.setFont("helvetica","normal"),t.setTextColor(...ce),t.text(k.label,$+5,s+5),t.setFontSize(11),t.setFont("helvetica","bold"),t.setTextColor(...X),t.text(k.value,$+5,s+11)}),s+=22,x(30),t.setTextColor(...X),t.setFontSize(14),t.setFont("helvetica","bold"),t.text("12-Month Cash Projection",l,s),s+=3,t.setFontSize(7),t.setFont("helvetica","normal"),t.setTextColor(...ce),t.text("As-is scenario (flat revenue, no growth investment)",l,s+4),s+=8;const Nt=["Month","Revenue","Gross Profit","Expenses","Net Cash","End Cash"],et=[15,m*.17,m*.17,m*.17,m*.17,m*.17];let ke=l;t.setFillColor(...Ie),t.roundedRect(l,s,m,7,1,1,"F"),t.setTextColor(255,255,255),t.setFontSize(6.5),t.setFont("helvetica","bold"),Nt.forEach((k,P)=>{t.text(k,ke+2,s+5),ke+=et[P]}),s+=7,d.projectionTable.forEach((k,P)=>{x(7),P%2===0&&(t.setFillColor(...ue),t.rect(l,s,m,6.5,"F")),t.setFontSize(6.5),t.setFont("helvetica","normal"),t.setTextColor(...Oe),ke=l,[k.month,f(k.revenue),f(k.grossProfit),f(k.expenses),f(k.netCash),f(k.endCash)].forEach((ze,tt)=>{tt===5&&(t.setTextColor(...k.endCash<0?rt:Ee),t.setFont("helvetica","bold")),t.text(ze,ke+2,s+4.5),ke+=et[tt],t.setTextColor(...Oe),t.setFont("helvetica","normal")}),s+=6.5}),s+=8,x(15),d.runwayMonth>=0?(t.setFillColor(...Ue),t.roundedRect(l,s,m,10,1,1,"F"),t.setFontSize(8),t.setFont("helvetica","bold"),t.setTextColor(...Je),t.text(`Warning: Cash runs out at Month ${d.runwayMonth+1}`,l+6,s+6.5)):(t.setFillColor(...He),t.roundedRect(l,s,m,10,1,1,"F"),t.setFontSize(8),t.setFont("helvetica","bold"),t.setTextColor(...Ee),t.text("Cash remains positive through the full 12-month projection.",l+6,s+6.5)),s+=15,x(70),s=Ot({pdf:t,y:s+6,margin:l,pageWidth:a,contentWidth:m}),s+=8,await Gt(t,l,a,i),t.save(`Capital-Bridge-Analysis-${C.replace(/\s/g,"-")}.pdf`)}const ot=[{asIs:{id:"monthlyRevenue",label:"Monthly Revenue",placeholder:"e.g. 250000"},target:{id:"annualRevenueGoal",label:"1-Year Revenue Goal",placeholder:"e.g. 5000000"}},{asIs:{id:"numClients",label:"Current # of Clients",placeholder:"e.g. 50"},target:{id:"newClientsPerMonth",label:"New Clients / Month",placeholder:"e.g. 4"}}],it=[{asIs:{id:"grossMargin",label:"Gross Margin %",placeholder:"e.g. 60",suffix:"%"},target:{id:"targetGrossMargin",label:"Target Gross Margin %",placeholder:"e.g. 65",suffix:"%"}},{asIs:{id:"monthlyExpenses",label:"Total Monthly Expenses",placeholder:"e.g. 180000"},target:{id:"targetOpExpensePercent",label:"Target OpEx %",placeholder:"e.g. 40",suffix:"%"}},{asIs:{id:"marketingSpend",label:"Monthly Marketing Spend",placeholder:"e.g. 15000"},target:{id:"monthsToTarget",label:"Months to Target",placeholder:"e.g. 12"}},{asIs:{id:"currentCash",label:"Current Cash on Hand",placeholder:"e.g. 100000"},target:{id:"debtService",label:"Monthly Debt Service",placeholder:"e.g. 0"}},{asIs:{id:"monthlyCapex",label:"Monthly CapEx",placeholder:"e.g. 5000"},target:{id:"targetMonthlyCapex",label:"Monthly CapEx (Target)",placeholder:"e.g. 8000"}},{asIs:{id:"numEmployees",label:"# of Employees",placeholder:"e.g. 10"},target:{id:"targetEmployees",label:"# of Employees (Target)",placeholder:"e.g. 15"}},{asIs:{id:"costPerEmployee",label:"Fully Loaded Cost/Employee",placeholder:"e.g. 6000"},target:{id:"targetCostPerEmployee",label:"Cost/Employee (Target)",placeholder:"e.g. 6000"}}],ct=[{asIs:{id:"arDays",label:"AR Days",placeholder:"e.g. 30"},target:{id:"targetArDays",label:"AR Days (Target)",placeholder:"e.g. 25"}},{asIs:{id:"apDays",label:"AP Days",placeholder:"e.g. 15"},target:{id:"targetApDays",label:"AP Days (Target)",placeholder:"e.g. 20"}},{asIs:{id:"inventoryDays",label:"Inventory Days",placeholder:"e.g. 0"},target:{id:"targetInventoryDays",label:"Inventory Days (Target)",placeholder:"e.g. 0"}}],hs=[{id:"avgTransaction",label:"Avg Transaction",placeholder:"e.g. 5000"},{id:"purchasesPerYear",label:"Purchases / Year",placeholder:"e.g. 1",step:"0.1"},{id:"customerLifespanYears",label:"Customer Lifespan (yrs)",placeholder:"e.g. 3",step:"0.5"}],xs=[{id:"closeRate",label:"Close Rate %",placeholder:"e.g. 25",
6suffix:"%"},{id:"bookingRate",label:"Booking Rate %",placeholder:"e.g. 33",suffix:"%"},{id:"debtService",label:"Monthly Debt Service",placeholder:"e.g. 0"}];function Ze({formula:r,children:c}){return r?e.jsxs(mt,{children:[e.jsx(ht,{asChild:!0,children:c}),e.jsx(xt,{side:"top",className:"max-w-xs bg-slate-900 border-slate-700 text-slate-200 text-xs font-mono",children:r})]}):e.jsx(e.Fragment,{children:c})}function be({icon:r,label:c,value:d,subtitle:t,highlight:a,formula:i}){return e.jsx(Ze,{formula:i,children:e.jsxs("div",{className:`p-3 rounded-lg bg-slate-800/60 ${a?"ring-1 ring-amber-500/40":""} ${i?"cursor-help":""}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(r,{className:"h-3.5 w-3.5 text-slate-500"}),e.jsx("span",{className:"text-xs text-slate-500",children:c})]}),e.jsx("p",{className:"text-lg font-semibold text-white",children:d}),t&&e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:t})]})})}function dt({title:r,fields:c,values:d,onChange:t}){return e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider mb-3",children:r}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:c.map(a=>e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-slate-400 mb-1 block",children:a.label}),e.jsx(K,{type:"number",step:a.step||"1",value:d[a.id]||"",onChange:i=>t(a.id,i.target.value),placeholder:a.placeholder,className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500 h-8 text-sm"})]},a.id))})]})}function W({label:r,asIs:c,target:d,isBold:t,isNeg:a,formula:i}){const l=d-c,m=t?"font-semibold text-white":"text-slate-300";return e.jsx(Ze,{formula:i,children:e.jsxs("div",{className:`grid grid-cols-4 gap-2 py-1.5 px-3 ${t?"bg-slate-700/40 rounded":""} ${i?"cursor-help":""}`,children:[e.jsx("span",{className:`text-sm ${m}`,children:r}),e.jsx("span",{className:`text-sm text-right ${m}`,children:f(c)}),e.jsx("span",{className:`text-sm text-right ${m}`,children:f(d)}),e.jsxs("span",{className:`text-sm text-right ${l>0&&!a?"text-emerald-400":l<0&&!a?"text-red-400":l<0&&a?"text-emerald-400":"text-slate-400"}`,children:[l>=0?"+":"",f(l)]})]})})}function le({label:r,asIsPct:c,targetPct:d,formula:t}){const a=d-c;return e.jsx(Ze,{formula:t,children:e.jsxs("div",{className:`grid grid-cols-4 gap-2 py-1 px-3 bg-slate-800/20 ${t?"cursor-help":""}`,children:[e.jsx("span",{className:"text-xs italic text-slate-500",children:r}),e.jsx("span",{className:"text-xs text-right text-slate-500",children:Ye(c)}),e.jsx("span",{className:"text-xs text-right text-slate-500",children:Ye(d)}),e.jsxs("span",{className:`text-xs text-right ${a>0?"text-emerald-400/70":a<0?"text-red-400/70":"text-slate-600"}`,children:[a>=0?"+":"",Ye(a)]})]})})}function us({data:r,onSave:c,onComplete:d,sevenNumbersData:t}){const[a,i]=j.useState(r.fields||{}),[l,m]=j.useState(!1),[s,p]=j.useState(!!r._autoFilled);j.useEffect(()=>{if(s||!(t!=null&&t.inputs))return;const o=t.inputs;if(a.monthlyRevenue&&parseFloat(a.monthlyRevenue)>0){p(!0);return}const A=parseFloat(o.revenue||"0"),M=parseFloat(o.cogs||"0"),Y=parseFloat(o.opex||"0"),J=parseFloat(o.marketing_spend||"0"),U=parseFloat(o.cash_on_hand||"0"),V=parseFloat(o.avg_contract_value||"0"),D=parseFloat(o.avg_retention_months||"0"),L=parseFloat(o.new_clients||"0");if(A<=0)return;const G=Math.round(A/12),ee=A>0&&M>=0?Math.round((A-M)/A*100):0,q=Math.round(Y/12),re=Math.round(J/12),de=L>0?Math.round(L/12*10)/10:0,E=D>0?Math.round(D/12*10)/10:0,F={};G>0&&(F.monthlyRevenue=String(G)),ee>0&&(F.grossMargin=String(ee)),q>0&&(F.monthlyExpenses=String(q)),re>0&&(F.marketingSpend=String(re)),U>0&&(F.currentCash=String(U)),V>0&&(F.avgTransaction=String(V)),E>0&&(F.customerLifespanYears=String(E)),de>0&&(F.newClientsPerMonth=String(de)),Object.keys(F).length>0&&(i(_=>({...F,..._})),p(!0))},[t,s]);const C=(o,w)=>{i(A=>({...A,[o]:w}))},h=o=>parseFloat((o||"0").replace(/[^0-9.-]/g,""))||0,x=j.useMemo(()=>({...Dt,monthlyRevenue:h(a.monthlyRevenue),annualRevenueGoal:h(a.annualRevenueGoal),numClients:h(a.numClients),newClientsPerMonth:h(a.newClientsPerMonth),grossMargin:h(a.grossMargin),monthlyExpenses:h(a.monthlyExpenses),marketingSpend:h(a.marketingSpend),currentCash:h(a.currentCash),avgTransaction:h(a.avgTransaction),purchasesPerYear:h(a.purchasesPerYear)||1,customerLifespanYears:h(a.customerLifespanYears)||3,targetGrossMargin:h(a.targetGrossMargin),targetOpExpensePercent:h(a.targetOpExpensePercent),monthsToTarget:h(a.monthsToTarget)||12,closeRate:h(a.closeRate)||25,bookingRate:h(a.bookingRate)||33,numEmployees:h(a.numEmployees),debtService:h(a.debtService),arDays:h(a.arDays),apDays:h(a.apDays),inventoryDays:h(a.inventoryDays)}
6),[a]),T=j.useMemo(()=>gt(x),[x]),N=h(a.monthlyRevenue)>0&&h(a.annualRevenueGoal)>0,n=h(a.monthlyCapex),v=h(a.targetMonthlyCapex)||n,I=h(a.targetArDays)||x.arDays,b=h(a.targetApDays)||x.apDays,u=h(a.targetInventoryDays)||x.inventoryDays,S=(o,w,A,M,Y,J,U,V,D)=>{const L=o*(w/100),G=o-L,ee=Math.max(0,A-M),q=L-A,re=q-x.debtService,de=o/30,E=G/30,F=de*J,_=E*V,se=E*U,H=F+_-se,te=q-Y-D,me=te-x.debtService,ne=q*12-D-Y*12,ie=ne-x.debtService*12;return{rev:o,gp:L,cogs:G,opex:A,mktg:M,otherOpex:ee,net:q,netDebt:re,capex:Y,wc:H,deltaWc:D,fcf:te,fcfe:me,gmPct:w,opexPct:o>0?A/o*100:0,netPct:o>0?q/o*100:0,fcfPct:o>0?te/o*100:0,fcfePct:o>0?me/o*100:0,mktgPct:o>0?M/o*100:0,otherOpexPct:o>0?ee/o*100:0,annual:{rev:o*12,gp:L*12,cogs:G*12,opex:A*12,mktg:M*12,otherOpex:ee*12,net:q*12,netDebt:re*12,capex:Y*12,wc:H,deltaWc:D,fcf:ne,fcfe:ie,gmPct:w,opexPct:o>0?A/o*100:0,netPct:o>0?q/o*100:0,fcfPct:o>0?ne/(o*12)*100:0,fcfePct:o>0?ie/(o*12)*100:0,mktgPct:o>0?M/o*100:0,otherOpexPct:o>0?ee/o*100:0}}},g=j.useMemo(()=>S(x.monthlyRevenue,x.grossMargin,x.monthlyExpenses,x.marketingSpend,n,x.arDays,x.apDays,x.inventoryDays,0),[x,n]),y=j.useMemo(()=>{const o=x.annualRevenueGoal/12,w=x.targetGrossMargin>0?x.targetGrossMargin:x.grossMargin,A=x.monthlyRevenue>0?o/x.monthlyRevenue:1,M=x.targetOpExpensePercent>0?o*(x.targetOpExpensePercent/100):x.monthlyExpenses*A,Y=x.marketingSpend*A,J=o*(w/100),U=o-J,V=o/30,D=U/30,G=V*I+D*u-D*b-g.wc;return S(o,w,M,Y,v,I,b,u,G)},[x,v,I,b,u,g.wc]),B=j.useMemo(()=>({fields:a,computed:{asIs:{monthlyRevenue:g.rev,annualRevenue:g.annual.rev,grossProfit:g.gp,grossMarginPct:g.gmPct,cogs:g.cogs,marketingSpend:g.mktg,marketingPct:g.mktgPct,otherOpex:g.otherOpex,totalOpex:g.opex,opexPct:g.opexPct,netProfit:g.net,netProfitPct:g.netPct,workingCapital:g.wc,capex:g.capex,fcf:g.fcf,fcfPct:g.fcfPct},target:{monthlyRevenue:y.rev,annualRevenue:y.annual.rev,grossProfit:y.gp,grossMarginPct:y.gmPct,cogs:y.cogs,marketingSpend:y.mktg,marketingPct:y.mktgPct,otherOpex:y.otherOpex,totalOpex:y.opex,opexPct:y.opexPct,netProfit:y.net,netProfitPct:y.netPct,workingCapital:y.wc,capex:y.capex,fcf:y.fcf,fcfPct:y.fcfPct},metrics:{cac:T.cac,ltv:T.ltv,ltvCacRatio:T.ltvCacRatio,cashGap:T.cashGap,growthCost:T.growthCost,clientsNeeded:T.clientsNeeded,revenuePerEmployee:T.revenuePerEmployee,monthsToPayback:T.monthsToPayback,cashConversionCycle:T.cashConversionCycle,workingCapitalNeeded:T.workingCapitalNeeded},currentCash:x.currentCash}}),[a,g,y,T,x.currentCash]);return j.useEffect(()=>{const o=setTimeout(()=>{c(B)},1500);return()=>clearTimeout(o)},[B]),e.jsx(wt,{delayDuration:200,children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(Wt,{className:"w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-slate-300 text-sm",children:"This uses the same model as the Financial Scaling Calculator. Cruz will walk you through it live â complete what you can now."})]}),e.jsxs("section",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-7 w-7 rounded-full border-2 border-amber-500 bg-slate-800 text-amber-500 text-xs font-bold",children:"A"}),e.jsx("h2",{className:"text-base font-semibold text-white",children:"Financial Inputs"})]}),e.jsxs("div",{className:"border border-slate-700/50 rounded-lg p-4 bg-slate-900/30 space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-amber-400 uppercase tracking-wider",children:"Client"}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"As-Is"}),ot.map(o=>e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-white mb-1.5 block",children:o.asIs.label}),e.jsx(K,{type:"number",value:a[o.asIs.id]||"",onChange:w=>C(o.asIs.id,w.target.value),placeholder:o.asIs.placeholder,className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"})]},o.asIs.id))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Target"}),ot.map(o=>e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-white mb-1.5 block",children:o.target.label}),e.jsx(K,{type:"number",value:a[o.target.id]||"",onChange:w=>C(o.target.id,w.target.value),placeholder:o.target.placeholder,className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"})]},o.target.id))]})]})]}),e.jsxs("div",{className:"border border-slate-700/50 rounded-lg p-4 bg-slate-900/30 space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-emerald-400 uppercase tracking-wider",children:"Income Statement"}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"As-Is"}),it.map(o=>e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-white mb-1.5 block",children:o.asIs.label}),e.jsx(K,{type:"number",value:a[o.asIs.id]||"",onChange:w=>C(o.asIs.id,w.target.value),placeholder:o.asIs.placeholder,className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"})]},o.asIs.id))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Target"}),it.map(o=>e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-white mb-1.5 block",children:o.target.label}),e.jsx(K,{type:"number",value:a[o.target.id]||"",onChange:w=>C(o.target.id,w.target.value),placeholder:o.target.placeholder,className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"})]},o.target.id))]})]})]}),e.jsxs("div",{className:"border border-slate-700/50 rounded-lg p-4 bg-slate-900/30 space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-sky-400 uppercase tracking-wider",children:"Working Capital"}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"As-Is"}),ct.map(o=>e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-white mb-1.5 block",children:o.asIs.label}),e.jsx(K,{type:"number",value:a[o.asIs.id]||"",onChange:w=>C(o.asIs.id,w.target.value),placeholder:o.asIs.placeholder,className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"})]},o.asIs.id))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Target"}),ct.map(o=>e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-white mb-1.5 block",children:o.target.label}),e.jsx(K,{type:"number",value:a[o.target.id]||"",onChange:w=>C(o.target.id,w.target.value),placeholder:o.target.placeholder,className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"})]},o.target.id))]})]})]}),e.jsxs("button",{onClick:()=>m(!l),className:"flex items-center gap-2 text-sm text-slate-400 hover:text-white transition-colors w-full justify-center py-2",children:[l?e.jsx(Bt,{className:"h-4 w-4"}):e.jsx(kt,{className:"h-4 w-4"}),l?"Hide":"Show"," Advanced Inputs (Customer, Activity)"]}),l&&e.jsxs("div",{className:"space-y-5 border border-slate-700/50 rounded-lg p-4 bg-slate-900/50",children:[e.jsx(dt,{title:"Customer Metrics",fields:hs,values:a,onChange:C}),e.jsx(dt,{title:"Activity & Overhead",fields:xs,values:a,onChange:C})]})]}),N&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-7 w-7 rounded-full border-2 border-amber-500 bg-slate-800 text-amber-500 text-xs font-bold",children:"B"}),e.jsx("h2",{className:"text-base font-semibold text-white",children:"Key KPIs"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(be,{icon:qe,label:"Current Annual",value:f(T.currentAnnualRevenue),formula:"Monthly Revenue
6à 12"}),e.jsx(be,{icon:qe,label:"Revenue Gap",value:f(Math.max(0,T.revenueGap)),highlight:T.revenueGap>0,formula:"Revenue Goal â Current Annual Revenue"}),e.jsx(be,{icon:ut,label:"Clients Needed",value:T.clientsNeeded.toString(),formula:"Revenue Gap ÷ Avg Client Value"}),e.jsx(be,{icon:Ne,label:"Avg Client Value",value:f(T.avgClientValue),formula:"Avg Transaction à Purchases/Year"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:[e.jsx(be,{icon:Ne,label:"CAC",value:f(T.cac),subtitle:"Cost per client",formula:"Marketing Spend ÷ New Clients/Month"}),e.jsx(be,{icon:Ne,label:"Growth Cost",value:f(T.growthCost),subtitle:"Total to acquire new clients",formula:"Clients Needed à CAC"}),e.jsx(be,{icon:Lt,label:"Payback",value:`${Ge(T.monthsToPayback)} mo`,subtitle:"Time to recoup CAC",formula:"CAC ÷ (Avg Client Value ÷ 12)"})]})]}),e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-7 w-7 rounded-full border-2 border-amber-500 bg-slate-800 text-amber-500 text-xs font-bold",children:"C"}),e.jsx("h2",{className:"text-base font-semibold text-white",children:"Income Statement"})]}),e.jsxs("div",{className:"border border-slate-700/50 rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-slate-800/80 px-4 py-3",children:e.jsx("h3",{className:"text-sm font-semibold text-white",children:"Monthly Income Statement â As-Is vs Target"})}),e.jsxs("div",{className:"bg-slate-800/30 grid grid-cols-4 gap-2 py-2 px-3 border-b border-slate-700/50",children:[e.jsx("span",{className:"text-xs font-semibold text-slate-500"}),e.jsx("span",{className:"text-xs font-semibold text-slate-500 text-right",children:"As-Is"}),e.jsx("span",{className:"text-xs font-semibold text-slate-500 text-right",children:"Target"}),e.jsx("span",{className:"text-xs font-semibold text-slate-500 text-right",children:"Delta"})]}),e.jsxs("div",{className:"divide-y divide-slate-800/30",children:[e.jsx(W,{label:"Revenue",asIs:g.rev,target:y.rev,isBold:!0,formula:"Monthly Revenue (input)"}),e.jsx(W,{label:"COGS",asIs:g.cogs,target:y.cogs,isNeg:!0,formula:"Revenue à (1 â Gross Margin %)"}),e.jsx(W,{label:"Gross Profit",asIs:g.gp,target:y.gp,isBold:!0,formula:"Revenue â COGS"}),e.jsx(le,{label:" Gross Margin %",asIsPct:g.gmPct,targetPct:y.gmPct,formula:"Gross Profit ÷ Revenue à 100"}),e.jsx(W,{label:"Marketing Expenses",asIs:g.mktg,target:y.mktg,isNeg:!0,formula:"Monthly Marketing Spend (input)"}),e.jsx(le,{label:" Marketing % of Sales",asIsPct:g.mktgPct,targetPct:y.mktgPct,formula:"Marketing Expenses ÷ Revenue à 100"}),e.jsx(W,{label:"Total Operating Expenses",asIs:g.opex,target:y.opex,isNeg:!0,formula:"Marketing + Other Operating Expenses"}),e.jsx(le,{label:" OpEx % of Sales",asIsPct:g.opexPct,targetPct:y.opexPct,formula:"Operating Expenses ÷ Revenue à 100"}),e.jsx(W,{label:"EBITDA",asIs:g.net,target:y.net,isBold:!0,formula:"Gross Profit â Operating Expenses"}),e.jsx(le,{label:" EBITDA % of Sales",asIsPct:g.netPct,targetPct:y.netPct,formula:"EBITDA ÷ Revenue à 100"}),e.jsx(W,{label:"ÎWorking Capital",asIs:g.deltaWc,target:y.deltaWc,isNeg:!0,formula:"Change in WC (As-Is = 0 steady state; Target = Target WC â As-Is WC)"}),e.jsx(W,{label:"CapEx",asIs:g.capex,target:y.capex,isNeg:!0,formula:"Monthly CapEx (input)"}),e.jsx(W,{label:"Free Cash Flow",asIs:g.fcf,target:y.fcf,isBold:!0,formula:"EBITDA â ÎWorking Capital â CapEx"}),e.jsx(le,{label:" FCF % of Sales",asIsPct:g.fcfPct,targetPct:y.fcfPct,formula:"Free Cash Flow ÷ Revenue à 100"}),e.jsx(W,{label:"Debt Service",asIs:x.debtService,target:x.debtService,isNeg:!0,formula:"Monthly Debt Service (input)"}),e.jsx(W,{label:"Free Cash Flow After Debt Service (CADS)",asIs:g.fcfe,target:y.fcfe,isBold:!0,formula:"FCF â Debt Service"}),e.jsx(le,{label:" CADS % of Sales",asIsPct:g.fcfePct,targetPct:y.fcfePct,formula:"CADS ÷ Revenue à 100"})]}),h(a.numEmployees)>0&&e.jsxs("div",{className:"bg-slate-800/30 grid grid-cols-4 gap-2 py-2.5 px-3 border-t border-slate-700/50",children:[e.jsx("span",{className:"text-xs font-semibold text-slate-400",children:"Rev / Employee"}),e.jsx("span",{className:"text-xs text-right text-slate-300",children:f(h(a.numEmployees)>0?g.rev/h(a.numEmployees):0)}),e.jsx("span",{className:"text-xs text-right text-slate-300",children:f(h(a.targetEmployees)>0?y.rev/h(a.targetEmployees):h(a.numEmployees)>0?y.rev/h(a.numEmployees):0)}),e.jsx("span",{className:"text-xs text-right text-slate-400",children:"per month"})]})]}),e.jsxs("div",{className:"border border-slate-700/50 rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-slate-800/80 px-4 py-3",children:e.jsx("h3",{className:"text-sm font-semibold text-white",children:"Annual Income Statement â As-Is vs Target"})}),e.jsxs("div",{className:"bg-slate-800/30 grid grid-cols-4 gap-2 py-2 px-3 border-b border-slate-700/50",children:[e.jsx("span",{className:"text-xs font-semibold text-slate-500"}),e.jsx("span",{className:"text-xs font-semibold text-slate-500 text-right",children:"As-Is"}),e.jsx("span",{className:"text-xs font-semibold text-slate-500 text-right",children:"Target"}),e.jsx("span",{className:"text-xs font-semibold text-slate-500 text-right",children:"Delta"})]}),e.jsxs("div",{className:"divide-y divide-slate-800/30",children:[e.jsx(W,{label:"Revenue",asIs:g.annual.rev,target:y.annual.rev,isBold:!0,formula:"Monthly Revenue
6à 12"}),e.jsx(W,{label:"COGS",asIs:g.annual.cogs,target:y.annual.cogs,isNeg:!0,formula:"Monthly COGS à 12"}),e.jsx(W,{label:"Gross Profit",asIs:g.annual.gp,target:y.annual.gp,isBold:!0,formula:"Annual Revenue â Annual COGS"}),e.jsx(le,{label:" Gross Margin %",asIsPct:g.annual.gmPct,targetPct:y.annual.gmPct,formula:"Gross Profit ÷ Revenue à 100"}),e.jsx(W,{label:"Marketing Expenses",asIs:g.annual.mktg,target:y.annual.mktg,isNeg:!0,formula:"Monthly Marketing à 12"}),e.jsx(le,{label:" Marketing % of Sales",asIsPct:g.annual.mktgPct,targetPct:y.annual.mktgPct,formula:"Marketing ÷ Revenue à 100"}),e.jsx(W,{label:"Total Operating Expenses",asIs:g.annual.opex,target:y.annual.opex,isNeg:!0,formula:"Monthly OpEx à 12"}),e.jsx(le,{label:" OpEx % of Sales",asIsPct:g.annual.opexPct,targetPct:y.annual.opexPct,formula:"Operating Expenses ÷ Revenue à 100"}),e.jsx(W,{label:"EBITDA",asIs:g.annual.net,target:y.annual.net,isBold:!0,formula:"Gross Profit â Operating Expenses"}),e.jsx(le,{label:" EBITDA % of Sales",asIsPct:g.annual.netPct,targetPct:y.annual.netPct,formula:"EBITDA ÷ Revenue à 100"}),e.jsx(W,{label:"ÎWorking Capital",asIs:g.annual.deltaWc,target:y.annual.deltaWc,isNeg:!0,formula:"Change in WC (As-Is = 0; Target = Target WC â As-Is WC)"}),e.jsx(W,{label:"CapEx",asIs:g.annual.capex,target:y.annual.capex,isNeg:!0,formula:"Monthly CapEx à 12"}),e.jsx(W,{label:"Free Cash Flow",asIs:g.annual.fcf,target:y.annual.fcf,isBold:!0,formula:"EBITDA â ÎWorking Capital â CapEx"}),e.jsx(le,{label:" FCF % of Sales",asIsPct:g.annual.fcfPct,targetPct:y.annual.fcfPct,formula:"Free Cash Flow ÷ Revenue à 100"}),e.jsx(W,{label:"Debt Service",asIs:x.debtService*12,target:x.debtService*12,isNeg:!0,formula:"Monthly Debt Service à 12"}),e.jsx(W,{label:"Free Cash Flow After Debt Service (CADS)",asIs:g.annual.fcfe,target:y.annual.fcfe,isBold:!0,formula:"FCF â Debt Service"}),e.jsx(le,{label:" CADS % of Sales",asIsPct:g.annual.fcfePct,targetPct:y.annual.fcfePct,formula:"CADS ÷ Revenue à 100"})]}),h(a.numEmployees)>0&&e.jsxs("div",{className:"bg-slate-800/30 grid grid-cols-4 gap-2 py-2.5 px-3 border-t border-slate-700/50",children:[e.jsx("span",{className:"text-xs font-semibold text-slate-400",children:"Rev / Employee"}),e.jsx("span",{className:"text-xs text-right text-slate-300",children:f(h(a.numEmployees)>0?g.annual.rev/h(a.numEmployees):0)}),e.jsx("span",{className:"text-xs text-right text-slate-300",children:f(h(a.targetEmployees)>0?y.annual.rev/h(a.targetEmployees):h(a.numEmployees)>0?y.annual.rev/h(a.numEmployees):0)}),e.jsx("span",{className:"text-xs text-right text-slate-400",children:"per year"})]})]})]}),e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-7 w-7 rounded-full border-2 border-amber-500 bg-slate-800 text-amber-500 text-xs font-bold",children:"D"}),e.jsx("h2",{className:"text-base font-semibold text-white",children:"Capital Bridge"})]}),(()=>{const o=Math.max(0,T.revenueGap)/12,w=T.cashConversionCycle,A=o*(w/30),M=n,Y=h(a.numEmployees),J=h(a.targetEmployees)||Y,U=Math.max(0,J-Y),V=h(a.targetCostPerEmployee)||h(a.costPerEmployee),D=U*V,L=A+M+D,G=L>0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"border border-slate-700/50 rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-slate-800/80 px-4 py-3",children:e.jsx("h3",{className:"text-sm font-semibold text-white",children:"Capital Bridge = (Î Revenue à CCC) + CapEx + Additional Hiring Cost"})}),e.jsxs("div",{className:"divide-y divide-slate-800/30",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 py-2.5 px-4",children:[e.jsx("span",{className:"text-sm text-slate-400",children:"Î Revenue
6à CCC ÷ 30"}),e.jsxs("span",{className:"text-xs text-slate-500 self-center",children:[f(o)," à (",Ge(w)," ÷ 30)"]}),e.jsx("span",{className:"text-sm font-semibold text-white text-right",children:f(A)})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 py-2.5 px-4",children:[e.jsx("span",{className:"text-sm text-slate-400",children:"CapEx"}),e.jsx("span",{className:"text-xs text-slate-500 self-center",children:"Monthly capital expenditure"}),e.jsx("span",{className:"text-sm font-semibold text-white text-right",children:f(M)})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 py-2.5 px-4",children:[e.jsx("span",{className:"text-sm text-slate-400",children:"Additional Hiring Cost"}),e.jsxs("span",{className:"text-xs text-slate-500 self-center",children:[U," hires à ",f(V),"/mo each"]}),e.jsx("span",{className:"text-sm font-semibold text-white text-right",children:f(D)})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 py-3 px-4 bg-slate-700/30",children:[e.jsx("span",{className:"text-sm font-bold text-white",children:"Capital Bridge"}),e.jsx("span",{className:"text-xs text-slate-500 self-center",children:"Cash needed to fund your growth"}),e.jsx("span",{className:`text-lg font-bold text-right ${G?"text-amber-400":"text-emerald-400"}`,children:f(L)})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:`p-5 rounded-lg border ${G?"bg-amber-500/10 border-amber-500/30":"bg-emerald-500/10 border-emerald-500/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[G?e.jsx(zt,{className:"h-4 w-4 text-amber-400"}):e.jsx(Yt,{className:"h-4 w-4 text-emerald-400"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Monthly Capital Bridge"})]}),e.jsx("p",{className:`text-3xl font-bold ${G?"text-amber-400":"text-emerald-400"}`,children:f(L)}),e.jsx("p",{className:"text-xs text-slate-500 mt-2",children:"Cash needed each month to fund your growth"})]}),e.jsxs("div",{className:`p-5 rounded-lg border ${G?"bg-amber-500/10 border-amber-500/30":"bg-emerald-500/10 border-emerald-500/30"}`,children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"What This Means"})}),G?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-amber-300 font-medium",children:"You need to bridge this gap."}),e.jsxs("p",{className:"text-xs text-slate-400 leading-relaxed",children:["Your business needs ",e.jsxs("span",{className:"text-amber-400 font-semibold",children:[f(L),"/mo"]})," in capital to fund the growth from where you are to your revenue goal. This includes working capital tied up in the cash conversion cycle, capital expenditures, and the cost of ",U," additional hires. You'll need to bridge this through retained earnings, a line of credit, or other financing â otherwise growth will stall."]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-emerald-300 font-medium",children:"Your growth is self-funding."}),e.jsx("p",{className:"text-xs text-slate-400 leading-relaxed",children:"Your cash conversion cycle, CapEx, and operating margins are all working in your favor. Your growth is self-funding â no external capital bridge is needed."})]})]})]})]})})()]})]}),N&&e.jsxs(R,{onClick:()=>ms(x),className:"w-full bg-emerald-600 hover:bg-emerald-700 text-white",children:[e.jsx(pt,{className:"h-4 w-4 mr-2"}),"Download Full Scaling Analysis (PDF)"]}),e.jsx(R,{onClick:()=>d(B),className:"w-full bg-emerald-600 hover:bg-emerald-700 text-white",children:"Save + Continue"})]})})}const gs=[{id:"acquisition",title:"Client Acquisition",desc:"Not enough of the right clients coming in"},{id:"fulfillment",title:"Fulfillment",desc:"Delivery breaks down as volume grows"},{id:"team",title:"Team",desc:"The wrong people in the wrong seats"},{id:"cash",title:"Cash",desc:"Not enough runway to fund the next move"}];function ps({data:r,onSave:c,onComplete:d,allStepsData:t}){const[a,i]=j.useState(r.selectedConstraint||""),[l,m]=j.useState(r.specificConstraint||""),[s,p]=j.useState(r.actions||[{action:"",owner:"",deadline:""},{action:"",owner:"",deadline:""},{action:"",owner:"",deadline:""}]),[C,h]=j.useState(!1);j.useEffect(()=>{const N=setTimeout(()=>{c({selectedConstraint:a,specificConstraint:l,actions:s})},1500);return()=>clearTimeout(N)},[a,l,s]);const x=(N,n,v)=>{p(I=>I.map((b,u)=>u===N?{...b,[n]:v}:b))},T=()=>{h(!0),d({selectedConstraint:a,specificConstraint:l,actions:s})};return{...t},e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-semibold mb-1",children:"Your #1 Constraint"}),e.jsx("p",{className:"text-slate-400 text-sm mb-4",children:"What is holding everything else back?"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mb-4",children:gs.map(N=>e.jsxs("button",{onClick:()=>i(N.id),className:`p-4 rounded-lg border text-left transition-all ${a===N.id?"border-emerald-500 bg-emerald-500/10":"border-slate-700 bg-slate-800/50 hover:border-slate-600"}`,children:[e.jsx("h5",{className:"text-white font-medium text-sm mb-1",children:N.title}),e.jsx("p",{className:"text-slate-400 text-xs",children:N.desc})]},N.id))}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-white mb-1.5 block",children:"Name it specifically"}
6),e.jsx(K,{value:l,onChange:N=>m(N.target.value),placeholder:"Do not stay generic. What exactly is the constraint in your business?",className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-semibold mb-1",children:"Your 90-Day Plan (Rocks)"}),e.jsx("p",{className:"text-slate-400 text-sm mb-4",children:"Three moves to eliminate it this quarter"}),e.jsx("div",{className:"space-y-3",children:s.map((N,n)=>e.jsxs("div",{className:"bg-slate-800/50 border border-slate-700/50 rounded-lg p-4",children:[e.jsxs("p",{className:"text-emerald-400 text-xs font-semibold mb-3",children:["Move ",n+1]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-slate-400 mb-1 block",children:"Action"}),e.jsx(K,{value:N.action,onChange:v=>x(n,"action",v.target.value),placeholder:"What will you do?",className:"bg-slate-700/50 border-slate-600 text-white placeholder:text-slate-500"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-slate-400 mb-1 block",children:"Owner"}),e.jsx(K,{value:N.owner,onChange:v=>x(n,"owner",v.target.value),placeholder:"Who is responsible?",className:"bg-slate-700/50 border-slate-600 text-white placeholder:text-slate-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-slate-400 mb-1 block",children:"Deadline"}),e.jsx(K,{type:"date",value:N.deadline,onChange:v=>x(n,"deadline",v.target.value),className:"bg-slate-700/50 border-slate-600 text-white"})]})]})]})]},n))})]}),e.jsx(R,{onClick:T,className:"w-full bg-emerald-600 hover:bg-emerald-700 text-white",disabled:!a,children:"Save + Continue to Debrief Report"})]})}function bs({allStepsData:r}){var de;const{session:c,user:d}=Ke(),[t,a]=j.useState(""),[i,l]=j.useState(!1),[m,s]=j.useState(null),[p,C]=j.useState(!1),[h,x]=j.useState([]),[T,N]=j.useState(!0),[n,v]=j.useState(null),[I,b]=j.useState(!1),u=j.useRef(null),[S,g]=j.useState("idle"),[y,B]=j.useState([]),[o,w]=j.useState(["","",""]),[A,M]=j.useState([]);j.useEffect(()=>{if(!d)return;(async()=>{const{data:F}=await Ce.from("workshop_debrief_reports").select("*").eq("user_id",d.id).order("created_at",{ascending:!1}).limit(7);F&&F.length>0&&(x(F),a(F[0].report_text),v(F[0].id)),N(!1)})()},[d]);const Y=async E=>{if(!(!d||!E))try{const{data:F}=await Ce.from("workshop_debrief_reports").insert({user_id:d.id,report_text:E,steps_data:r,company_name:(r==null?void 0:r.companyName)||null}).select().single();C(!0),F&&(x(_=>[F,..._].slice(0,7)),v(F.id))}catch(F){console.error("Failed to save debrief report:",F)}},J=async()=>{g("loading_questions"),B([]),w(["","",""]);try{const F=await fetch("https://kfdrhgktbtzmfrotgvhv.supabase.co/functions/v1/workshop-debrief-questions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${(c==null?void 0:c.access_token)||"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImtmZHJoZ2t0YnR6bWZyb3Rndmh2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njg5MzE1MDIsImV4cCI6MjA4NDUwNzUwMn0.gQ5FJC93zwqpFoiPJ11PRisgYaNWUdJE33ak1YhxGTQ"}`},body:JSON.stringify({stepsData:r})});if(!F.ok)throw new Error("Failed to load questions");const _=await F.json();_.questions&&_.questions.length>0?(B(_.questions),w(_.questions.map(()=>"")),g("answering")):(g("done"),M([]),D([]))}catch(E){console.error("Failed to fetch questions:",E),g("done"),M([]),D([])}},U=()=>{const E=y.map((F,_)=>({question:F,answer:o[_]||""}));M(E),g("done"),D(E)},V=()=>{g("done"),M([]),D([])},D=async E=>{var _,se,H,te,me,ne,ie;a(""),l(!0),s(null),C(!1),b(!0),v(null);const F=E??A;try{const he=await fetch("https://kfdrhgktbtzmfrotgvhv.supabase.co/functions/v1/workshop-summary",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${(c==null?void 0:c.access_token)||"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImtmZHJoZ2t0YnR6bWZyb3Rndmh2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njg5MzE1MDIsImV4cCI6MjA4NDUwNzUwMn0.gQ5FJC93zwqpFoiPJ11PRisgYaNWUdJE33ak1YhxGTQ"}`},body:JSON.stringify({stepsData:r,clarifyingQA:F})});if(!he.ok){if(he.status===429){s("Rate limit exceeded. Please wait a moment and try again."),l(!1);return}if(he.status===402){s("AI credits exhausted. Please add credits to continue."),l(!1);return}const O=await he.json().catch(()=>({}));throw new Error(O.error||"Failed to generate report")}const ye=(_=he.body)==null?void 0:_.getReader();if(!ye)throw new Error("No response stream");const Q=new TextDecoder;let oe="",Z="";for(;;){const{done:O,value:ge}=await ye.read();if(O)break;oe+=Q.decode(ge,{stream:!0});let pe;for(;(pe=oe.indexOf(` 7`))!==-1;){let ae=oe.slice(0,pe);if(oe=oe.slice(pe+1),ae.endsWith("\r")&&(ae=ae.slice(0,-1)),ae.startsWith(":")||ae.trim()===""||!ae.startsWith("data: "))continue;const Be=ae.slice(6).trim();if(Be==="[DONE]")break;try{const we=(te=(H=(se=JSON.parse(Be).choices)==null?void 0:se[0])==null?void 0:H.delta)==null?void 0:te.content;we&&(Z+=we,a(Z))}catch{oe=ae+` 8`+oe;break}}}if(oe.trim())for(let O of oe.split(` 9`)){if(!O||(O.endsWith("\r")&&(O=O.slice(0,-1)),O.startsWith(":")||O.trim()==="")||!O.startsWith("data: "))continue;const ge=O.slice(6).trim();if(ge!=="[DONE]")try{const ae=(ie=(ne=(me=JSON.parse(ge).choices)==null?void 0:me[0])==null?void 0:ne.delta)==null?void 0:ie.content;ae&&(Z+=ae,a(Z))}catch{}}l(!1),b(!1),await Y(Z)}catch(xe){console.error("Workshop summary error:",xe),s(xe.message||"Failed to generate report"),l(!1),b(!1),ve.error("Failed to generate report")}},L=()=>
9{g("idle"),B([]),w(["","",""]),M([]),J()},G=E=>{a(E.report_text),v(E.id),b(!1),s(null),g("done")},ee=E=>E.split(` 10`).map((_,se)=>{const H=_.trim();return/^(\d+\.\s+)?[A-Z][A-Z\s&:()]+$/.test(H)&&H.length>5?e.jsxs("div",{className:"mt-8 mb-3 first:mt-0",children:[e.jsx("h3",{className:"text-emerald-400 font-bold text-sm tracking-widest uppercase",children:H}),e.jsx("div",{className:"h-px bg-emerald-500/30 mt-1"})]},se):H.startsWith("- ")?e.jsxs("div",{className:"flex gap-2 ml-2 my-1",children:[e.jsx("span",{className:"text-emerald-500 mt-0.5 flex-shrink-0",children:"-"}),e.jsx("span",{className:"text-slate-300 text-sm leading-relaxed",children:H.slice(2)})]},se):H===""?e.jsx("div",{className:"h-3"},se):e.jsx("p",{className:"text-slate-300 text-sm leading-relaxed my-1",children:H},se)}),q=t.length>0,re=h.length>0;return T?e.jsxs("div",{className:"border border-slate-700/50 rounded-xl p-6 flex items-center justify-center gap-3",children:[e.jsx(fe,{className:"h-4 w-4 animate-spin text-slate-500"}),e.jsx("p",{className:"text-slate-500 text-sm",children:"Loading saved reports..."})]}):S==="loading_questions"?e.jsxs("div",{className:"border border-emerald-500/20 rounded-xl p-8 text-center space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx(fe,{className:"h-5 w-5 animate-spin text-emerald-500"}),e.jsx("p",{className:"text-slate-300 text-sm",children:"Alex is reviewing your workshop data..."})]}),e.jsx("p",{className:"text-slate-500 text-xs",children:"Preparing clarifying questions to make your report more insightful"})]}):S==="answering"&&y.length>0?e.jsxs("div",{className:"border border-emerald-500/20 rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"bg-slate-900 border-b border-emerald-500/20 px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ht,{className:"w-4 h-4 text-emerald-400"}),e.jsx("p",{className:"text-emerald-500 text-[10px] font-bold tracking-[0.3em] uppercase",children:"Before Your Report"})]}),e.jsx("h3",{className:"text-white font-bold text-lg",children:"Alex Has a Few Questions"}),e.jsx("p",{className:"text-slate-400 text-sm mt-1",children:"Your answers will make the debrief report significantly more targeted and actionable."})]}),e.jsx("div",{className:"bg-slate-900/60 px-6 py-5 space-y-5",children:y.map((E,F)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-white text-sm font-medium flex items-start gap-2",children:[e.jsxs("span",{className:"text-emerald-400 font-bold text-xs mt-0.5 flex-shrink-0",children:["Q",F+1]}),E]}),e.jsx(je,{value:o[F],onChange:_=>w(se=>se.map((H,te)=>te===F?_.target.value:H)),placeholder:"Type your answer...",className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-500 min-h-[80px] resize-none",rows:3})]},F))}),e.jsxs("div",{className:"bg-slate-900 border-t border-emerald-500/20 px-6 py-4 flex items-center justify-between gap-3",children:[e.jsxs(R,{variant:"ghost",size:"sm",onClick:V,className:"text-slate-400 hover:text-white text-xs",children:[e.jsx(Jt,{className:"w-3 h-3 mr-1"}),"Skip & Generate"]}),e.jsxs(R,{onClick:U,className:"bg-emerald-600 hover:bg-emerald-700 text-white",children:["Generate Report",e.jsx(Ut,{className:"w-4 h-4 ml-2"})]})]})]}):!q&&!re&&S==="idle"?e.jsxs("div",{className:"text-center py-8 space-y-4",children:[e.jsx(Ve,{className:"w-12 h-12 text-slate-600 mx-auto"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-white font-semibold mb-1",children:"Generate Your Strategic Debrief"}),e.jsx("p",{className:"text-slate-400 text-sm max-w-md mx-auto",children:"Alex will analyze all your workshop data and create a personalized strategic report with actionable recommendations."})]}),e.jsxs(R,{onClick:()=>J(),className:"bg-emerald-600 hover:bg-emerald-700 text-white",children:[e.jsx(Ve,{className:"w-4 h-4 mr-2"}),"Generate Strategic Debrief Report"]})]}):e.jsxs("div",{className:"space-y-4",children:[re&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs text-slate-500 font-medium",children:"Reports:"}),h.map((E,F)=>e.jsx("button",{onClick:()=>G(E),className:`text-xs px-3 py-1.5 rounded-full border transition-colors ${n===E.id?"bg-emerald-600/20 border-emerald-500/50 text-emerald-400":"bg-slate-800/50 border-slate-700/50 text-slate-400 hover:border-slate-600"}`,children:F===0?"Latest":new Date(E.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric"})},E.id)),e.jsxs(R,{variant:"ghost",size:"sm",onClick:L,className:"text-emerald-400 hover:text-emerald-300 text-xs h-7",disabled:i||S!=="done"&&S!=="idle",children:[e.jsx(st,{className:`w-3 h-3 mr-1 ${i?"animate-spin":""}`}),"Generate New"]})]}),e.jsxs("div",{className:"border border-emerald-500/20 rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"bg-slate-900 border-b border-emerald-500/20 px-6 py-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-emerald-500 text-[10px] font-bold tracking-[0.3em] uppercase",children:"Strategic Analysis"}),e.jsx("h3",{className:"text-white font-bold text-lg mt-0.5",children:"Workshop Debrief Report"}),n&&!I&&e.jsxs("p",{className:"text-slate-500 text-[10px] mt-1",children:["Generated ",new Date(((de=h.find(E=>E.id===n))==null?void 0:de.created_at)||"").toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t&&!i&&e.jsxs(R,{variant:"ghost",size:"sm",onClick:()=>{const E=new Blob([t],{type:"text/plain;charset=utf-8"}),F=URL.createObjectURL(E),_=document.createElement("a");_.href=F,_.download=`Workshop-Debrief-Report-${new Date().toISOString().slice(0,10)}.txt`,_.click(),URL.revokeObjectURL(F),ve.success("Report downloaded")},className:"text-slate-400 hover:text-white",children:[e.jsx(pt,{className:"w-4 h-4 mr-1"}),"Download"]}),!re&&e.jsxs(R,{variant:"ghost",size:"sm",onClick:L,className:"text-slate-400 hover:text-white",disabled:i,children:[e.jsx(st,{className:`w-4 h-4 mr-1 ${i?"animate-spin":""}`}),"Regenerate"]})]})]}),e.jsx("div",{ref:u,className:"bg-slate-900/60 px-6 py-5 max-h-[600px] overflow-y-auto",children:m?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-red-400 text-sm mb-4",children:m}),e.jsx(R,{onClick:()=>D(),variant:"outline",size:"sm",className:"border-slate-600 text-slate-300",children:"Try Again"})]}):t?e.jsxs("div",{className:"space-y-0",children:[ee(t),i&&e.jsx("span",{className:"inline-block w-2 h-4 bg-emerald-500 animate-pulse ml-1"})]}):e.jsxs("div",{className:"flex items-center justify-center py-12 gap-3",children:[e.jsx(fe,{className:"h-5 w-5 animate-spin text-emerald-500"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"Analyzing your workshop data and generating strategic report..."})]})}),e.jsx("div",{className:"bg-slate-900 border-t border-emerald-500/20 px-6 py-3",children:e.jsx("p",{className:"text-slate-600 text-[10px] tracking-wider up
10percase",children:"ScalingCFO Workshop · Strategic Debrief Report"})})]})]})}const Fe=[{number:0,title:"Pre-Work",subtitle:"Complete your homework assessments"},{number:1,title:"Your CEO Score",subtitle:"The first filter is you."},{number:2,title:"Financial Blindspots",subtitle:"Which blindspot is bleeding your business dry?"},{number:3,title:"Constraints + Profit Leaks",subtitle:"Identify what's bleeding your business"},{number:4,title:"Your 1-Year Vision",subtitle:"Build a numbered commitment with real targets"},{number:5,title:"The 7 Numbers",subtitle:"The metrics that predict scale or stall"},{number:6,title:"The Capital Bridge",subtitle:"Calculate the capital needed to fund your growth"},{number:7,title:"Your #1 Constraint + 90-Day Plan",subtitle:"Name the constraint and build your plan"},{number:8,title:"Debrief Report",subtitle:"Your AI-generated strategic analysis"}];function fs(){const{steps:r,loading:c,saveStep:d,completeStep:t,getStep:a,isStepUnlocked:i}=Kt(),[l,m]=j.useState(0);if(c)return e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(fe,{className:"h-8 w-8 animate-spin text-emerald-500"})});const s=async(n,v)=>{await t(n,v),l<Fe.length-1&&m(l+1)},p=async(n,v)=>{await d(n,v,a(n).status==="not_started"?"in_progress":a(n).status)},C={};r.forEach(n=>{C[n.step_number]=n.data});const h=n=>{if(n===0)return e.jsx(Qt,{});const I={data:a(n).data,onSave:b=>p(n,b),onComplete:b=>s(n,b)};switch(n){case 1:return e.jsx(ss,{...I});case 2:return e.jsx(ts,{...I});case 3:return e.jsx(rs,{...I});case 4:return e.jsx(os,{...I});case 5:return e.jsx(is,{...I});case 6:return e.jsx(us,{...I,sevenNumbersData:C[5]});case 7:return e.jsx(ps,{...I,allStepsData:C});case 8:return e.jsx(bs,{allStepsData:C});default:return null}},x=Fe[l],T=l>0,N=l<Fe.length-1;return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center gap-1 w-full overflow-x-auto pb-1",children:Fe.map((n,v)=>{const I=l===v,u=(n.number===0?null:a(n.number).status)==="complete",S=n.number===0||i(n.number);return e.jsx("button",{onClick:()=>S&&m(v),disabled:!S,className:`flex-1 min-w-0 px-2 py-2.5 rounded-lg text-center transition-all border ${I?"border-emerald-500/50 bg-emerald-500/10 text-white":u?"border-emerald-500/20 bg-emerald-500/5 text-emerald-400":S?"border-slate-700/50 bg-slate-800/30 text-slate-400 hover:text-white hover:border-slate-600":"border-slate-800/30 bg-slate-900/30 text-slate-600 opacity-50 cursor-not-allowed"}`,children:e.jsx("span",{className:"text-[10px] md:text-xs font-medium truncate block",children:n.title})},n.number)})}),e.jsxs("div",{className:"border border-slate-700/50 rounded-xl bg-slate-900/60 p-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:x.title}),x.subtitle&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:x.subtitle})]}),h(x.number)]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>m(l-1),disabled:!T,className:"border-slate-700 text-slate-300 hover:text-white hover:bg-slate-800",children:[e.jsx(Vt,{className:"w-4 h-4 mr-1"})," Previous"]}),e.jsxs("span",{className:"text-xs text-slate-500",children:[l+1," of ",Fe.length]}),e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>m(l+1),disabled:!N,className:"border-slate-700 text-slate-300 hover:text-white hover:bg-slate-800",children:["Next ",e.jsx(St,{className:"w-4 h-4 ml-1"})]})]})]})}function Zs(){const r=We(),{user:c,userRole:d}=Ke(),t=d==="super_admin",{sessions:a,registration:i,engagementInfo:l,loading:m,price:s,discountPercent:p,refetch:C}=Ft(),[h,x]=j.useState(null),[T,N]=j.useState(!1);j.useEffect(()=>{a.length>0&&!h&&x(a[0].id)},[a,h]);const n=async()=>{var v,I;if(!h){ve.error("Please select a workshop date");return}if(l.isServiceClient){try{N(!0);const{error:b}=await Ce.from("workshop_registrations").insert({user_id:c==null?void 0:c.id,session_id:h,email:(c==null?void 0:c.email)||"",first_name:((I=(v=c==null?void 0:c.user_metadata)==null?void 0:v.full_name)==null?void 0:I.split(" ")[0])||"",discount_percent:100,discount_source:"service_client",registration_status:"confirmed",amount_paid:0});if(b)throw b;ve.success("You're registered for the workshop!"),C()}catch(b){console.error("Registration error:",b),ve.error("Failed to register. Please try again.")}finally{N(!1)}return}try{N(!0);const{data:b,error:u}=await Ce.functions.invoke("workshop-checkout",{body:{session_id:h,discount_percent:p}});if(u)throw u;b!=null&&b.url&&window.open(b.url,"_blank")}catch(b){console.error("Checkout error:",b),ve.error("Failed to start checkout. Please try again.")}finally{N(!1)}};if(m)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(fe,{className:"h-8 w-8 animate-spin text-emerald-500"})});if(i&&(i.registration_status==="confirmed"||i.registration_status==="attended")){const v=a.find(S=>S.id===i.session_id),I=v?new Date(v.session_date):null,b=new Date,u=t||(I?b.toDateString()===I.toDateString()||b>=I:!1);return e.jsxs("div",{className:"p-6 md:p-10 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold text-white mb-1",children:"Cash Flow Accelerator"}),e.jsx("p",{className:"text-slate-400 text-sm",children:v?`${Me(new Date(v.session_date),"MMMM d")} · 2-Hour Working Session`:"Your pre-work and session exercises"})]}),u?e.jsx(fs,{}):e.jsxs("div",{className:"bg-slate-800/40 border border-slate-700/50 rounded-2xl p-8 text-center",children:[e.jsx("div",{className:"text-4xl mb-4",children:"ð"}),e.jsx("h2",{className:"text-white font-bold text-lg mb-2",children:"Workshop Steps Unlock on Session Day"}),e.jsxs("p",{className:"text-slate-400 text-sm max-w-md mx-auto mb-2",children:["The 7-step working session will be available on"," ",e.jsx("span",{className:"text-white font-medium",children:I?Me(I,"MMMM d, yyyy"):"your workshop date"}),"."]}),e.jsx("p",{className:"text-slate-500 text-xs",children:"In the meantime, complete your pre-work homework above to get the most out of the session."})]})]})}return e.jsxs("div",{className:"p-6 md:p-10 max-w-3xl mx-auto",children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold text-white mb-2",children:"Cash Flow Accelerator"}),e.jsx("p",{className:"text-slate-400 mb-8",children:"A 2-hour live virtual workshop to build your scaling vision, identify constraints, and create your 90-day plan."}),e.jsxs("div",{className:"bg-slate-800/40 border border-slate-700/50 rounded-2xl p-6 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-white",children:"Reserve Your Seat"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"Select a date and register"})]}),e.jsx("div",{className:"text-right",children:l.isServiceClient?e.jsx("span",{className:"text-emerald-400 font-bold text-xl",children:"Included"}):p>0?e.jsxs("div",{children:[e.jsx("span",{className:"line-through text-slate-500 text-sm",children:"$497"})," ",e.jsxs("span",{className:"text-emerald-400 font-bold text-xl",children:["$",s]})]}):e.jsxs("span",{className:"text-emerald-400 font-bold text-xl",children:["$",s]})})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"text-sm font-medium text-white mb-3 block",children:"Choose your workshop date:"}),a.length===0?e.jsx("p",{className:"text-slate-500 text-sm py-4 text-center",children:"No upcoming sessions available right now."}):e.jsx("div",{className:"space-y-2",children:a.map(v=>e.jsx("button",{onClick:()=>x(v.id),className:`w-full p-4 rounded-lg border text-left transition-all ${h===v.id?"border-emerald-500 bg-emerald-500/10":"border-slate-600 bg-slate-800/50 hover:border-slate-500"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Tt,{className:"w-4 h-4 text-emerald-400"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-white font-medium",children:Me(new Date(v.session_date),"MMMM d, yyyy")}),e.jsxs("span",{className:"text-slate-400 ml-2 text-sm",children:[Me(new Date(v.session_date),"h:mm a")," ET"]})]})]}),e.jsxs("span",{className:"text-sm text-emerald-400",children:[v.spots_remaining," spots left"]})]})},v.id))})]}),e.jsx(R,{onClick:n,className:"w-full bg-emerald-600 hover:bg-emerald-700 text-white py-3 text-base",disabled:!h||T,children:T?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 mr-2 animate-spin"})," Processing..."]}):l.isServiceClient?"Register â Included with Engagement":e.jsxs(e.Fragment,{children:["Reserve My Seat â $",s]})})]}),e.jsxs("div",{className:"bg-slate-800/40 border border-slate-700/50 rounded-2xl p-6 mb-6",children:[e.jsx("h3",{className:"text-lg font-bold text-white mb-4",children:"What's Included"}),e.jsx("ul",{className:"space-y-2",children:Et.map((v,I)=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(It,{className:"w-4 h-4 text-emerald-400 mt-0.5 flex-shrink-0"}),e.jsx("span",{className:"text-slate-300 text-sm",children:v})]},I))})]}),!l.isServiceClient&&p===0&&e.jsx("div",{className:"bg-gradient-to-r from-emerald-900/30 to-teal-900/30 border border-emerald-500/20 rounded-xl p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qt,{className:"w-5 h-5 text-emerald-400 flex-shrink-0"}),e.jsxs("p",{className:"text-slate-300 text-sm",children:[e.jsx("span",{className:"font-medium text-white",children:"Get Up to 50% Off:"})," ","Take free assessments and refer founders to earn discounts."," ",e.jsx("button",{onClick:()=>r("/founder/assessments"),className:"text-emerald-400 hover:underline",children:"Start Here â"})]})]})})]})}export{Zs 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.