(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,143,e=>{"use strict";async function s(e,t={}){let a=localStorage.getItem("amos_token"),l=await fetch(`/api/v1${e}`,{...t,headers:{"Content-Type":"application/json",...a?{Authorization:`Bearer ${a}`}:{},...t.headers}});if(!l.ok)throw Error((await l.json().catch(()=>({}))).error||`HTTP ${l.status}`);return l.json()}e.s(["api",0,{auth:{login:(e,t)=>s("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})}),me:()=>s("/auth/me")},crm:{customers:()=>s("/crm/customers")},sales:{deals:()=>s("/sales/deals")},finance:{balance:()=>s("/finance/balance"),accounts:()=>s("/finance/accounts")},hr:{employees:()=>s("/hr/employees")},legal:{contracts:()=>s("/legal/contracts")}}])},93370,e=>{"use strict";var s=e.i(1624),t=e.i(30573);e.s(["Skeleton",0,function({className:e,...a}){return(0,s.jsx)("div",{"data-slot":"skeleton",className:(0,t.cn)("animate-pulse rounded-md bg-muted",e),...a})}])},35683,e=>{"use strict";let s=(0,e.i(64828).default)("dollar-sign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);e.s(["DollarSign",0,s],35683)},18110,e=>{"use strict";var s=e.i(1624),t=e.i(62714),a=e.i(34772),l=e.i(143),r=e.i(43673),i=e.i(80063),d=e.i(93370),c=e.i(53743),x=e.i(35683),n=e.i(64828);let o=(0,n.default)("target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),h=(0,n.default)("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);var m=e.i(91054),p=e.i(3562),u=e.i(33902),j=e.i(59658),b=e.i(20307),g=e.i(2188),N=e.i(45178),f=e.i(60681);let y={discovery:"bg-blue-50 text-blue-700 border-blue-200",proposal:"bg-amber-50 text-amber-700 border-amber-200",negotiation:"bg-violet-50 text-violet-700 border-violet-200","closed-won":"bg-emerald-50 text-emerald-700 border-emerald-200","closed-lost":"bg-red-50 text-red-700 border-red-200"},v=["discovery","proposal","negotiation","closed-won"];e.s(["default",0,function(){let[e,n]=(0,t.useState)([]),[w,E]=(0,t.useState)(!0),[k,B]=(0,t.useState)("");(0,t.useEffect)(()=>{l.api.sales.deals().then(e=>{n(e.deals),E(!1)}).catch(e=>{B(e.message),E(!1)})},[]);let S=e.reduce((e,s)=>e+s.value,0),C=e.reduce((e,s)=>e+s.value*(s.probability/100),0),_=e.filter(e=>"closed-won"===e.stage).reduce((e,s)=>e+s.value,0),D=v.map(s=>({stage:s.charAt(0).toUpperCase()+s.slice(1),value:e.filter(e=>e.stage===s).reduce((e,s)=>e+s.value,0),count:e.filter(e=>e.stage===s).length})),K=["#93C5FD","#FCD34D","#C4B5FD","#6EE7B7"];return(0,s.jsx)(a.DashboardShell,{children:(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-xl font-bold text-[#111827]",children:"Sales"}),(0,s.jsx)("p",{className:"text-sm text-[#6B7280] mt-0.5",children:"Pipeline and deal management"})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-4",children:[(0,s.jsx)(r.Card,{className:"p-5 bg-white rounded-2xl border border-[#E5E7EB] shadow-[0_2px_8px_rgba(0,0,0,0.04)]",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-xl bg-blue-50 flex items-center justify-center",children:(0,s.jsx)(x.DollarSign,{className:"w-5 h-5 text-blue-600"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs text-[#6B7280] uppercase tracking-wider",children:"Total Pipeline"}),(0,s.jsxs)("p",{className:"text-xl font-bold text-[#111827]",children:["SEK ",(S/1e3).toFixed(0),"K"]})]})]})}),(0,s.jsx)(r.Card,{className:"p-5 bg-white rounded-2xl border border-[#E5E7EB] shadow-[0_2px_8px_rgba(0,0,0,0.04)]",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-xl bg-violet-50 flex items-center justify-center",children:(0,s.jsx)(o,{className:"w-5 h-5 text-violet-600"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs text-[#6B7280] uppercase tracking-wider",children:"Weighted"}),(0,s.jsxs)("p",{className:"text-xl font-bold text-[#111827]",children:["SEK ",(C/1e3).toFixed(0),"K"]})]})]})}),(0,s.jsx)(r.Card,{className:"p-5 bg-white rounded-2xl border border-[#E5E7EB] shadow-[0_2px_8px_rgba(0,0,0,0.04)]",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-xl bg-emerald-50 flex items-center justify-center",children:(0,s.jsx)(c.TrendingUp,{className:"w-5 h-5 text-emerald-600"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs text-[#6B7280] uppercase tracking-wider",children:"Closed Won"}),(0,s.jsxs)("p",{className:"text-xl font-bold text-[#111827]",children:["SEK ",(_/1e3).toFixed(0),"K"]})]})]})}),(0,s.jsx)(r.Card,{className:"p-5 bg-white rounded-2xl border border-[#E5E7EB] shadow-[0_2px_8px_rgba(0,0,0,0.04)]",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-xl bg-amber-50 flex items-center justify-center",children:(0,s.jsx)(h,{className:"w-5 h-5 text-amber-600"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs text-[#6B7280] uppercase tracking-wider",children:"Active Deals"}),(0,s.jsx)("p",{className:"text-xl font-bold text-[#111827]",children:e.filter(e=>"closed-won"!==e.stage&&"closed-lost"!==e.stage).length})]})]})})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsxs)(r.Card,{className:"bg-white rounded-2xl border border-[#E5E7EB] shadow-[0_2px_8px_rgba(0,0,0,0.04)] overflow-hidden",children:[(0,s.jsx)("div",{className:"p-5 border-b border-[#E5E7EB]",children:(0,s.jsx)("h3",{className:"text-sm font-semibold text-[#111827]",children:"Deals"})}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b border-[#E5E7EB]",children:[(0,s.jsx)("th",{className:"text-left text-xs font-semibold text-[#6B7280] uppercase tracking-wider px-5 py-3",children:"Deal"}),(0,s.jsx)("th",{className:"text-left text-xs font-semibold text-[#6B7280] uppercase tracking-wider px-5 py-3",children:"Customer"}),(0,s.jsx)("th",{className:"text-left text-xs font-semibold text-[#6B7280] uppercase tracking-wider px-5 py-3",children:"Stage"}),(0,s.jsx)("th",{className:"text-right text-xs font-semibold text-[#6B7280] uppercase tracking-wider px-5 py-3",children:"Value"}),(0,s.jsx)("th",{className:"text-right text-xs font-semibold text-[#6B7280] uppercase tracking-wider px-5 py-3",children:"Probability"}),(0,s.jsx)("th",{className:"text-left text-xs font-semibold text-[#6B7280] uppercase tracking-wider px-5 py-3",children:"Close Date"})]})}),(0,s.jsx)("tbody",{children:w?Array.from({length:5}).map((e,t)=>(0,s.jsxs)("tr",{className:"border-b border-[#E5E7EB]/50",children:[(0,s.jsx)("td",{className:"px-5 py-4",children:(0,s.jsx)(d.Skeleton,{className:"h-4 w-32"})}),(0,s.jsx)("td",{className:"px-5 py-4",children:(0,s.jsx)(d.Skeleton,{className:"h-4 w-28"})}),(0,s.jsx)("td",{className:"px-5 py-4",children:(0,s.jsx)(d.Skeleton,{className:"h-5 w-20"})}),(0,s.jsx)("td",{className:"px-5 py-4",children:(0,s.jsx)(d.Skeleton,{className:"h-4 w-16 ml-auto"})}),(0,s.jsx)("td",{className:"px-5 py-4",children:(0,s.jsx)(d.Skeleton,{className:"h-4 w-12 ml-auto"})}),(0,s.jsx)("td",{className:"px-5 py-4",children:(0,s.jsx)(d.Skeleton,{className:"h-4 w-20"})})]},t)):k?(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:6,className:"px-5 py-8 text-center text-sm text-[#DC2626]",children:k})}):e.map((e,t)=>(0,s.jsxs)(m.motion.tr,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.2,delay:.03*t},className:"border-b border-[#E5E7EB]/50 hover:bg-[#F7F9FC] transition-colors",children:[(0,s.jsx)("td",{className:"px-5 py-4",children:(0,s.jsx)("span",{className:"text-sm font-medium text-[#111827]",children:e.title})}),(0,s.jsx)("td",{className:"px-5 py-4",children:(0,s.jsx)("span",{className:"text-sm text-[#6B7280]",children:e.customer})}),(0,s.jsx)("td",{className:"px-5 py-4",children:(0,s.jsx)(i.Badge,{variant:"outline",className:`${y[e.stage]} text-[10px] font-semibold uppercase rounded-full`,children:e.stage})}),(0,s.jsx)("td",{className:"px-5 py-4 text-right",children:(0,s.jsxs)("span",{className:"text-sm font-medium text-[#111827]",children:["SEK ",(e.value/1e3).toFixed(0),"K"]})}),(0,s.jsx)("td",{className:"px-5 py-4 text-right",children:(0,s.jsxs)("span",{className:"text-sm text-[#6B7280]",children:[e.probability,"%"]})}),(0,s.jsx)("td",{className:"px-5 py-4",children:(0,s.jsx)("span",{className:"text-xs text-[#6B7280]",children:e.expectedClose})})]},e.id))})]})})]})}),(0,s.jsx)("div",{children:(0,s.jsxs)(r.Card,{className:"p-5 bg-white rounded-2xl border border-[#E5E7EB] shadow-[0_2px_8px_rgba(0,0,0,0.04)]",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-[#111827] mb-4",children:"Sales Funnel"}),(0,s.jsx)("div",{className:"h-64",children:(0,s.jsx)(N.ResponsiveContainer,{width:"100%",height:"100%",children:(0,s.jsxs)(p.BarChart,{data:D,layout:"vertical",margin:{top:5,right:30,left:20,bottom:5},children:[(0,s.jsx)(j.XAxis,{type:"number",hide:!0}),(0,s.jsx)(b.YAxis,{dataKey:"stage",type:"category",axisLine:!1,tickLine:!1,tick:{fontSize:11,fill:"#6B7280"},width:80}),(0,s.jsx)(g.Tooltip,{contentStyle:{backgroundColor:"#111827",border:"none",borderRadius:"12px",padding:"10px 14px",fontSize:"12px",color:"#fff"},formatter:(e,s)=>"value"===s?[`SEK ${(Number(e)/1e3).toFixed(0)}K`,"Value"]:[String(e),"Deals"]}),(0,s.jsx)(u.Bar,{dataKey:"value",radius:[0,6,6,0],animationDuration:1200,children:D.map((e,t)=>(0,s.jsx)(f.Cell,{fill:K[t%K.length]},`cell-${t}`))})]})})}),(0,s.jsx)("div",{className:"mt-3 space-y-1.5",children:D.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:K[t]}}),(0,s.jsx)("span",{className:"text-[#6B7280]",children:e.stage})]}),(0,s.jsxs)("span",{className:"font-medium text-[#111827]",children:[e.count," deals"]})]},e.stage))})]})})]})]})})}],18110)}]);