1import{j as e}from"./state-DKBP_IF5.js";import{r as f}from"./react-vendor-Unhn4PzF.js";import M from"./PVPlantOptimizationDashboard-DInIefdh.js";import{A as $,u as P}from"./VistaArtifact-gyiM6fL1.js";import{c as E,l as L,a6 as N,a8 as G}from"./index-Br3_ARw7.js";import{R as O,L as X,C as Y,X as H,Y as q,T as J,k as Q,e as Z,f as R}from"./charts-D5dg506X.js";import{T as ee,G as te}from"./trending-down-6OIStIMv.js";import{A as ne}from"./activity-BM_sYnFs.js";import{S as ie}from"./sun-DOUPKHL9.js";import{C as re}from"./ChatPage-CfpyKI6o.js";import{B as Xe}from"./ChatPage-CfpyKI6o.js";import{C as He}from"./cpu-BteiylvZ.js";import"./building-2-CaI-KLWC.js";import"./map-pin-WJOwG4Ma.js";import"./file-spreadsheet-AVyU16rM.js";import"./layout-grid-De8JllvD.js";import"./ui-Dw3dkPmY.js";/* empty css */import"./forms-GD8l5aEM.js";import"./useAccessibleAgents-e8A-ferf.js";import"./agentService-CPyDPIkE.js";import"./AgentDetailsModal-CbEfF627.js";import"./user-plus-DCW8OCSS.js";import"./sparkles-D7NTekMs.js";import"./markdown-DHncH_pN.js";window.CESIUM_BASE_URL="/cesium/";const oe=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],D=E("arrow-left",oe);const ae=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Ke=E("file-text",ae),se={runA:"#3B82F6",runB:"#F59E0B"},le={positive:"#0F8A5F",danger:"#B42318"};function B(){const t=P();return f.useMemo(()=>({...t,...se,...le}),[t])}const ce={fixed_tilt:"Fixed tilt",tracker:"Single-axis tracker",backtracker:"Backtracker"},_=(t,n=2)=>typeof t!="number"||!isFinite(t)?"â":t.toLocaleString("en-US",{maximumFractionDigits:n}),de=[{key:"system_type",label:"Mounting system",pick:t=>t.optimal_design.system_type,format:t=>ce[String(t)]??String(t)},{key:"tilt",label:"Tilt",unit:"°",pick:t=>t.optimal_design.tilt,format:t=>_(t,1)},{key:"row_spacing",label:"Row spacing",unit:"m",pick:t=>t.optimal_design.row_spacing,format:t=>_(t,2)},{key:"installed_power_kwp",label:"Installed power",unit:"kWp",pick:t=>t.optimal_design.installed_power_kwp,format:t=>_(t,0)},{key:"num_panels",label:"Panels",pick:t=>t.optimal_design.num_panels,format:t=>_(t,0)},{key:"dc_ac_ratio",label:"DC/AC ratio",pick:t=>t.optimal_design.dc_ac_ratio,format:t=>_(t,2)},{key:"area_ha",label:"Site area",unit:"ha",pick:t=>t.site_info.area_ha,format:t=>_(t,2)}],pe=[{key:"irr",label:"IRR",unit:"%",digits:2,higherIsBetter:!0,pick:t=>t.financial_metrics.irr},{key:"npv",label:"NPV",unit:"â¬",digits:0,higherIsBetter:!0,pick:t=>t.financial_metrics.npv},{key:"lcoe",label:"LCOE",unit:"â¬/MWh",digits:1,higherIsBetter:!1,pick:t=>t.financial_metrics.lcoe},{key:"payback_years",label:"Payback",unit:"yr",digits:1,higherIsBetter:!1,pick:t=>t.financial_metrics.payback_years}],ue=[{key:"annual_energy_mwh",label:"Annual energy",unit:"MWh",digits:0,higherIsBetter:!0,pick:t=>t.energy_metrics.annual_energy_mwh},{key:"specific_yield",label:"Specific yield",unit:"kWh/kWp",digits:0,higherIsBetter:!0,pick:t=>t.energy_metrics.specific_yield},{key:"capacity_factor",label:"Capacity factor",unit:"%",digits:1,higherIsBetter:!0,pick:t=>t.energy_metrics.capacity_factor},{key:"performance_ratio",label:"Performance ratio",unit:"%",digits:1,higherIsBetter:!0,pick:t=>t.energy_metrics.performance_ratio}];function T({label:t,value:n,onChange:l,runs:o,exclude:i}){const r=B();return e.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:8,fontSize:12,color:r.text2},children:[e.jsx("span",{style:{fontWeight:500,color:t==="Baseline"?r.runA:r.runB},children:t}),e.jsx("select",{value:n,onChange:p=>l(Number(p.target.value)),style:{padding:"6px 10px",border:`1px solid ${r.outline}`,borderRadius:6,fontSize:13,fontFamily:"inherit",color:r.text1,background:r.card,outline:"none",minWidth:180},children:o.map((p,y)=>e.jsxs("option",{value:y,disabled:y===i,children:["#",y+1," â ",p.label]},y))})]})}function xe(t){return e.jsx($,{children:e.jsx(ge,{...t})})}function ge({runs:t,initialA:n,initialB:l,onClose:o}){const i=B(),r=t.length,p=n!=null&&n>=0&&n<r?n:Math.max(0,r-2),y=l!=null&&l>=0&&l<r?l:Math.max(0,r-1),[s,u]=f.useState(p),[x,w]=f.useState(y);f.useEffect(()=>{n!=null&&n!==s&&u(n),l!=null&&l!==x&&w(l)},[n,l]);const k=s===x,c=t[s],g=t[x],S=f.useMemo(()=>!c||!g||k?[]:de.map(a=>{const m=a.pick(c.data),d=a.pick(g.data);
1return m===d||m==null&&d==null?null:{...a,a:m,b:d}}).filter(Boolean),[c,g,k]),v=f.useCallback(a=>!c||!g||k?[]:a.map(m=>{const d=m.pick(c.data),j=m.pick(g.data);if(d==null||j==null||!isFinite(d)||!isFinite(j))return null;const b=j-d,W=Math.abs(d)>1e-9?b/d*100:null;return{...m,va:d,vb:j,delta:b,pct:W}}).filter(Boolean),[c,g,k]),h=f.useMemo(()=>v(pe),[v]),K=f.useMemo(()=>v(ue),[v]),F=f.useMemo(()=>{if(!c||!g||k)return[];const a=c.data.cash_flows??[],m=g.data.cash_flows??[],d=Math.max(a.length,m.length),j=[];for(let b=0;b<d;b++)j.push({year:a[b]?.year??m[b]?.year??b,a:a[b]?.cumulative_npv??null,b:m[b]?.cumulative_npv??null});return j},[c,g,k]);if(!c||!g)return e.jsxs("div",{style:{padding:24,background:i.body,height:"100%",display:"flex",flexDirection:"column",gap:12,alignItems:"center",justifyContent:"center",color:i.text2,fontFamily:"'Inter', system-ui, sans-serif"},children:[r<2?"Need at least two runs to compare. Run another optimisation and come back.":"Couldnât resolve the requested runs. Try picking them manually.",o&&e.jsx("button",{onClick:o,style:{padding:"6px 14px",border:`1px solid ${i.outline}`,background:i.card,borderRadius:8,cursor:"pointer",fontFamily:"inherit",color:i.text1,fontSize:13},children:"Back to runs"})]});const z={fontSize:11,fill:i.text2},I=a=>Math.abs(a)>=1e6?`â¬${(a/1e6).toFixed(1)}M`:Math.abs(a)>=1e3?`â¬${(a/1e3).toFixed(0)}k`:`â¬${a.toFixed(0)}`;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minWidth:0,background:i.body,fontFamily:"'Inter', system-ui, -apple-system, sans-serif",color:i.text1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"14px 20px",background:i.card,borderBottom:`1px solid ${i.outline}`,flexWrap:"wrap"},children:[o&&e.jsxs("button",{onClick:o,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 12px",border:`1px solid ${i.outline}`,background:i.card,borderRadius:8,cursor:"pointer",fontSize:12,color:i.text2,fontFamily:"inherit"},children:[e.jsx(D,{size:13,strokeWidth:2})," Back to runs"]}),e.jsx(T,{label:"Baseline",value:s,onChange:u,runs:t,exclude:x}),e.jsx(T,{label:"Compare",value:x,onChange:w,runs:t,exclude:s}),k&&e.jsx("span",{style:{fontSize:12,color:i.danger,marginLeft:"auto"},children:"Pick two different runs to see the diff."})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",minWidth:0,padding:"20px 24px",display:"flex",flexDirection:"column",gap:18},children:[e.jsxs("section",{style:{background:i.card,border:`1px solid ${i.outline}`,borderRadius:12,padding:"14px 20px",minWidth:0},children:[e.jsx("h3",{style:{margin:"0 0 10px",fontSize:13,fontWeight:500,color:i.text1},children:"Inputs that differ"}),S.length===0?e.jsx("p",{style:{margin:0,fontSize:12,color:i.text3},children:"The two runs have identical design parameters â any KPI deltas below come from configuration changes (CAPEX, OPEX, losses) or re-runs with different cached weather data."}):e.jsx("div",{style:{overflowX:"auto",minWidth:0},children:e.jsx("table",{style:{width:"100%",minWidth:420,tableLayout:"auto",borderCollapse:"collapse",fontSize:13},children:e.jsx("tbody",{children:S.map((a,m)=>{const d=a.format??(U=>String(U)),j=d(a.a),b=d(a.b),W=a.unit?` ${a.unit}`:"";return e.jsxs("tr",{style:{borderBottom:m<S.length-1?`1px solid ${i.divider}`:"none"},children:[e.jsx("td",{style:{color:i.text2,padding:"6px 12px 6px 0",whiteSpace:"nowrap"},children:a.label}),e.jsxs("td",{style:{color:i.runA,textAlign:"right",fontVariantNumeric:"tabular-nums",padding:"6px 8px"},children:[j,W]}),e.jsx("td",{style:{padding:"6px 4px",width:24},children:e.jsx(L,{size:12,strokeWidth:2,style:{color:i.text3}})}),e.jsxs("td",{style:{color:i.runB,fontWeight:500,fontVariantNumeric:"tabular-nums",padding:"6px 0 6px 8px"},children:[b,W]})]},a.key)})})})})]}),e.jsx(A,{title:"Financial KPIs",deltas:h,formatVal:I}),e.jsx(A,{title:"Energy KPIs",deltas:K,formatVal:I}),F.length>0&&e.jsxs("section",{style:{background:i.card,border:`1px solid ${i.outline}`,borderRadius:12,padding:"14px 20px",minWidth:0},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:16},children:[e.jsx("h3",{style:{margin:0,fontSize:13,fontWeight:500,color:i.text1},children:"Cumulative NPV â A vs B"}),e.jsx("span",{style:{fontSize:12,color:i.text3},children:"year-by-year running total"})]}),e.jsx(O,{width:"100%",height:300,children:e.jsxs(X,{data:F,margin:{top:8,right:12,left:8,bottom:0},children:[e.jsx(Y,{strokeDasharray:"3 3",stroke:i.divider,vertical:!1}
1),e.jsx(H,{dataKey:"year",tick:z,axisLine:!1,tickLine:!1,tickFormatter:a=>`Y${a}`}),e.jsx(q,{tick:z,axisLine:!1,tickLine:!1,tickFormatter:I}),e.jsx(J,{formatter:a=>I(a),labelFormatter:a=>`Year ${a}`,contentStyle:{background:i.card,border:`1px solid ${i.outline}`,borderRadius:8,fontSize:12,color:i.text1}}),e.jsx(Q,{y:0,stroke:i.text3,strokeDasharray:"3 3"}),e.jsx(Z,{wrapperStyle:{fontSize:12,color:i.text2,paddingTop:8}}),e.jsx(R,{type:"monotone",dataKey:"a",name:`#${s+1} â ${c.label}`,stroke:i.runA,strokeWidth:2,dot:!1,connectNulls:!0}),e.jsx(R,{type:"monotone",dataKey:"b",name:`#${x+1} â ${g.label}`,stroke:i.runB,strokeWidth:2,dot:!1,connectNulls:!0})]})})]})]})]})}function A({title:t,deltas:n,formatVal:l}){const o=B();if(n.length===0)return null;const i=(r,p)=>r.unit==="â¬"?l(p):`${p.toLocaleString("en-US",{maximumFractionDigits:r.digits})}${r.unit?` ${r.unit}`:""}`;return e.jsxs("section",{style:{background:o.card,border:`1px solid ${o.outline}`,borderRadius:12,padding:"14px 20px",minWidth:0},children:[e.jsx("h3",{style:{margin:"0 0 10px",fontSize:13,fontWeight:500,color:o.text1},children:t}),e.jsx("div",{style:{overflowX:"auto",minWidth:0},children:e.jsxs("table",{style:{width:"100%",minWidth:520,tableLayout:"auto",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:`1px solid ${o.divider}`,fontSize:10,color:o.text3,textTransform:"uppercase",letterSpacing:"0.04em"},children:[e.jsx("th",{style:{textAlign:"left",fontWeight:500,padding:"4px 8px 6px 0"},children:"Metric"}),e.jsx("th",{style:{textAlign:"right",fontWeight:500,color:o.runA,padding:"4px 8px 6px"},children:"Baseline"}),e.jsx("th",{style:{width:16,padding:"4px 0 6px"}}),e.jsx("th",{style:{textAlign:"right",fontWeight:500,color:o.runB,padding:"4px 8px 6px"},children:"Compare"}),e.jsx("th",{style:{textAlign:"right",fontWeight:500,padding:"4px 0 6px 8px"},children:"Î"})]})}),e.jsx("tbody",{children:n.map((r,p)=>{const y=r.higherIsBetter?r.delta>0:r.delta<0,s=r.higherIsBetter?r.delta<0:r.delta>0,u=Math.abs(r.delta)<1e-9?o.text3:y?o.positive:o.danger,x=y&&r.higherIsBetter||s&&!r.higherIsBetter?N:ee;return e.jsxs("tr",{style:{borderBottom:p<n.length-1?`1px solid ${o.divider}`:"none"},children:[e.jsx("td",{style:{color:o.text2,padding:"8px 8px 8px 0",whiteSpace:"nowrap"},children:r.label}),e.jsx("td",{style:{color:o.text1,textAlign:"right",fontVariantNumeric:"tabular-nums",padding:"8px"},children:i(r,r.va)}),e.jsx("td",{style:{padding:"8px 0",textAlign:"center"},children:e.jsx(L,{size:11,strokeWidth:2,style:{color:o.text3}})}),e.jsx("td",{style:{color:o.text1,fontWeight:500,textAlign:"right",fontVariantNumeric:"tabular-nums",padding:"8px"},children:i(r,r.vb)}),e.jsx("td",{style:{padding:"8px 0 8px 8px",textAlign:"right",color:u,fontVariantNumeric:"tabular-nums",fontWeight:500},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"flex-end",gap:4},children:[e.jsx(x,{size:12,strokeWidth:2.2}),r.delta>=0?"+":"",i(r,r.delta).replace(/^â¬/,"â¬"),r.pct!=null&&e.jsxs("span",{style:{color:o.text3,fontWeight:400},children:["(",r.pct>=0?"+":"",r.pct.toFixed(1),"%)"]})]})})]},r.key)})})]})})]})}const he={positive:"#0F8A5F",danger:"#B42318"},me={fixed_tilt:{bg:"rgba(99,102,241,0.12)",fg:"#6366F1",label:"FIXED"},tracker:{bg:"rgba(16,185,129,0.12)",fg:"#10B981",label:"TRACK"},backtracker:{bg:"rgba(245,158,11,0.12)",fg:"#F59E0B",label:"BTRK"}};function V(){const t=P();return f.useMemo(()=>({...t,...he,badge:me}),[t])}function fe(t){return t>=1e3?`${(t/1e3).toFixed(1)} MWp`:`${t.toLocaleString("en-US",{maximumFractionDigits:0})} kWp`}function ye(t){return Math.abs(t)>=1e6?`â¬${(t/1e6).toFixed(1)}M`:Math.abs(t)>=1e3?`â¬${(t/1e3).toFixed(0)}k`:`â¬${t.toFixed(0)}`}function Ue({results:t}){return e.jsx($,{children:e.jsx(be,{results:t})})}function be({results:t}){const n=V(),[l,o]=f.useState("list"),[i,r]=f.useState(null),[p,y]=f.useState(null);if(t.length===1)return e.jsx(M,{data:t[0].data});if(l==="single"&&i!==null){const s=t[i];return e.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",background:n.body},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 20px",background:n.card,borderBottom:`1px solid ${n.outline}`,fontFamily:"'Inter', system-ui, sans-serif"},children:[e.jsxs("button",{onClick:()=>{o("list"),r(null)},style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 12px",border:`1px solid ${n.outline}`,background:n.card,borderRadius:8,cursor:"pointer",fontSize:12,color:n.text2,fontFamily:"inherit",transition:"background 120ms linear"},onMouseEnter:u=>{u.currentTarget.style.background=n.divider},onMouseLeave:u=>{u.currentTarget.style.background=n.card},children:[e.jsx(D,{size:13,strokeWidth:2})," Back to runs"]}),e.jsxs("span",{style:{color:n.text2,fontSize:13},children:["#",i+1," â ",s.label]})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsx(M,{data:s.data})})]})}return l==="compare"&&p?e.jsx(xe,{runs:t,initialA:p.a,initialB:p.b,onClose:()=>{o("list"),y(null)}}):e.jsxs("div",{style:{padding:24,background:n.body,minHeight:"100%",minWidth:0,fontFamily:"'Inter', system-ui, -apple-system, sans-serif",color:n.text1},children:[e.jsxs("div",{style:{background:n.card,border:`1px solid ${n.outline}`,borderRadius:12,padding:"14px 20px",marginBottom:16,display:"flex",alignItems:"center",gap:14,flexWrap:"wrap"},children:[e.jsx("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:8,background:n.primaryContainer,color:n.primary},children:e.jsx(ne,{size:16,strokeWidth:2.2})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:n.text1,letterSpacing:"-0.01em"},children:"PV plant optimisation runs"}),e.jsxs("div",{style:{fontSize:12,color:n.text2,marginTop:2},children:[t.length," scenarios in this conversation"]})]}),t.length>=2&&e.jsxs("button",{onClick:()=>{y({a:t.length-2,b:t.length-1}),o("compare")},style:{display:"inline-flex",alignItems:"center",gap:6,padding:"8px 14px",background:n.primaryContainer,color:n.primary,border:"none",borderRadius:999,fontSize:13,fontWeight:500,cursor:"pointer",fontFamily:"inherit",transition:"background 120ms linear, color 120ms linear"},onMouseEnter:s=>{s.currentTarget.style.background=n.primary,s.currentTarget.style.color=n.ctaFg},onMouseLeave:s=>{s.currentTarget.style.background=n.primaryContainer,s.currentTarget.style.color=n.primary},children:[e.jsx(te,{size:14,strokeWidth:2.2})," Compare runs"]})]}),e.jsx("div",{style:{background:n.card,borderRadius:12,border:`1px solid ${n.outline}`,overflow:"hidden"},children:t.map((s,u)=>{const x=s.data.optimal_design,w=s.data.financial_metrics,k=x?.system_type||"unknown",c=n.badge[k]||{bg:n.divider,fg:n.text2,label:"PV"},g=x?.installed_power_kwp||0,S=w?.irr||0,v=w?.npv||0;return e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{r(u),o("single")},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),r(u),o("single"))},style:{display:"flex",alignItems:"center",gap:14,padding:"14px 18px",borderBottom:u<t.length-1?`1px solid ${n.divider}`:"none",cursor:"pointer",transition:"background 120ms linear",outline:"none"},onMouseEnter:h=>{h.currentTarget.style.background=n.surface2},onMouseLeave:h=>{h.currentTarget.style.background="transparent"},onFocus:h=>{h.currentTarget.style.background=n.surface2},onBlur:h=>{h.currentTarget.style.background="transparent"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4,width:56,flexShrink:0},children:[e.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:n.primaryContainer,color:n.primary,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:500},children:u+1}),e.jsx("div",{style:{padding:"2px 6px",background:c.bg,color:c.fg,fontSize:9,fontWeight:600,borderRadius:4,letterSpacing:"0.04em"},children:c.label})]}),e.jsxs("div",{style:{flex:"1 1 200px",minWidth:0},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,color:n.text1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.label}),e.jsxs("div",{style:{fontSize:11,color:n.text3,marginTop:2}
1,children:["Tilt ",x?.tilt??"â","° · spacing ",x?.row_spacing??"â"," m"]})]}),e.jsx(C,{icon:e.jsx(ie,{size:12,strokeWidth:2}),label:"Power",value:fe(g)}),e.jsx(C,{icon:e.jsx(N,{size:12,strokeWidth:2}),label:"IRR",value:`${S.toFixed(1)}%`,valueColor:S>=0?n.positive:n.danger}),e.jsx(C,{icon:e.jsx(re,{size:12,strokeWidth:2}),label:"NPV",value:ye(v),valueColor:v>=0?n.positive:n.danger}),e.jsx(G,{size:16,strokeWidth:2,style:{color:n.text3,flexShrink:0}})]},u)})})]})}function C({icon:t,label:n,value:l,valueColor:o}){const i=V();return e.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",alignItems:"flex-end",gap:2,minWidth:92,flexShrink:0},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:i.text3,textTransform:"uppercase",letterSpacing:"0.04em"},children:[t,n]}),e.jsx("span",{style:{fontSize:13,fontWeight:500,color:o??i.text1,fontVariantNumeric:"tabular-nums"},children:l})]})}export{Xe as _BatteryCharging,He as _Cpu,Ke as _FileText,Ue 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.