PageSourceSearch

https://ai-energy-planning.netlify.app/assets/Timeline-FzdYx3uT.js

js ai-energy-planning.netlify.app collected 2026-10-03 10:25:49 UTC 12,835 bytes, 31 lines download raw bytes

1import{R as o,j as e}from"./vendor-react-DVrBU6_x.js";import{c as y,I as _,d as q,a as J,e as Q,f as ee}from"./index-DM7KUgsE.js";import{g as te,a as ae,y as se}from"./deploymentYears-CPD6el1W.js";import"./vendor-d3-CGnuPtl4.js";import"./vendor-sweetalert-CRdFYMG-.js";import"./vendor-duckdb-DncbAeEm.js";/**
2 * @license lucide-react v0.344.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 ne=y("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
7 * @license lucide-react v0.344.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const re=y("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]);/**
12 * @license lucide-react v0.344.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const oe=y("Pause",[["rect",{width:"4",height:"16",x:"6",y:"4",key:"iffhe4"}],["rect",{width:"4",height:"16",x:"14",y:"4",key:"sjin7j"}]]);/**
17 * @license lucide-react v0.344.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const le=y("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
22 * @license lucide-react v0.344.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const G=y("Thermometer",[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]]);/**
27 * @license lucide-react v0.344.0 - ISC
28 *
29 * This source code is licensed under the ISC license.
30 * See the LICENSE file in the root directory of this source tree.
31 */const K=y("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),ie={Insulation:e.jsx(re,{className:"w-4 h-4"}),ASHP:e.jsx(G,{className:"w-4 h-4"}),PV:e.jsx(le,{className:"w-4 h-4"}),GSHP:e.jsx(G,{className:"w-4 h-4"}),Hydrogen:e.jsx(K,{className:"w-4 h-4"}),Mixed:e.jsx(K,{className:"w-4 h-4"}),"District Heating":e.jsx(K,{className:"w-4 h-4"})},ce=({item:n,isSelected:x,currentYear:l,onClick:b,onEdit:D,onUpdate:R,onMoveUp:I,onMoveDown:A,yearsRange:d,laneWidth:E=0,metricSeries:z=null})=>{const[h,j]=o.useState(null),m=o.useRef(null),p=o.useRef(null),N=o.useRef(!1),P=h?.startYear??n.startYear,S=h?.duration??n.duration,v=d[0],i=d[d.length-1],g=P+S-1,f=Math.max(P,v),H=Math.min(g,i),k=Math.max(0,H-f+1),V=f-v,M=k/d.length*100,B=V/d.length*100,$=E>0?E/d.length:1,Y=(s,a)=>{a.stopPropagation(),a.button===0&&(p.current={mode:s,x0:a.clientX,startYear0:n.startYear,duration0:n.duration,moved:!1},window.addEventListener("mousemove",t),window.addEventListener("mouseup",r))},t=s=>{const a=p.current;if(!a)return;const U=(s.clientX-a.x0)/$,w=Math.round(U),T=d[0],O=d[d.length-1],W=a.startYear0+a.duration0-1;let L=a.startYear0,Z=a.duration0;if((Math.abs(s.clientX-a.x0)>3||w!==0)&&(a.moved=!0),a.mode==="move"){const F=O-a.duration0+1;L=Math.max(T,Math.min(F,a.startYear0+w))}else a.mode==="resize-left"?(L=Math.max(T,Math.min(W,a.startYear0+w)),Z=W-L+1):a.mode==="resize-right"&&(Z=Math.max(a.startYear0,Math.min(O,W+w))-a.startYear0+1);const X={startYear:L,duration:Math.max(1,Z)};m.current=X,j(X)},r=()=>{const s=p.current;if(window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",r),p.current=null,!s)return;const a=m.current;s.moved&&a?(N.current=!0,R?.({startYear:a.startYear,duration:a.duration})):(m.current=null,j(null))};o.useEffect(()=>{h&&n.startYear===h.startYear&&n.duration===h.duration&&(m.current=null,j(null))},[n.startYear,n.duration,h]);const c=Array.isArray(z)?z:[],C=c.reduce((s,a)=>Math.max(s,Number(a)||0),0),u=_[n.tech]||"#64748b";return k<=0?null:e.jsxs("div",{onClick:s=>{if(N.current){N.current=!1;return}b?.(s)},onMouseDown:s=>{x&&Y("move",s)}
31,className:`group relative h-14 rounded-md border cursor-pointer transition-all duration-200 ${x?"ring-2 ring-offset-1 scale-[1.01]":"hover:brightness-95"}`,style:{width:`${M}%`,marginLeft:`${B}%`,backgroundColor:`${u}12`,borderColor:u,ringColor:u},children:[e.jsxs("div",{className:"absolute inset-0 p-2 flex flex-col justify-between overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between z-10",children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden whitespace-nowrap",children:[e.jsx("span",{className:"scale-90 origin-left",style:{color:u},children:ie[n.tech]}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-tight truncate",style:{color:u},children:n.label})]}),e.jsxs("span",{className:"text-[10px] opacity-60 font-mono",style:{color:u},children:["£",(n.budget/1e6).toFixed(1),"M"]})]}),x&&e.jsxs("div",{className:"absolute top-1.5 right-1.5 z-20 opacity-0 group-hover:opacity-100 transition-opacity flex bg-[var(--laep-surface-panel)]/95 border border-[var(--laep-border-subtle)] rounded shadow-sm",children:[e.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),D?.()},"aria-label":`Edit ${n.label||n.tech||"intervention"}`,className:"min-h-10 min-w-10 xl:min-h-6 xl:min-w-6 p-1 border-r border-[var(--laep-border-subtle)] hover:bg-[var(--laep-surface-muted)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--laep-focus)]",title:"Edit intervention",children:e.jsx(q,{className:"w-3 h-3"})}),e.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),I?.()},"aria-label":`Move ${n.label||n.tech||"intervention"} up`,className:"min-h-10 min-w-10 xl:min-h-6 xl:min-w-6 p-1 border-r border-[var(--laep-border-subtle)] hover:bg-[var(--laep-surface-muted)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--laep-focus)]",title:"Move intervention up",children:e.jsx(ne,{className:"w-3 h-3"})}),e.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),A?.()},"aria-label":`Move ${n.label||n.tech||"intervention"} down`,className:"min-h-10 min-w-10 xl:min-h-6 xl:min-w-6 p-1 hover:bg-[var(--laep-surface-muted)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--laep-focus)]",title:"Move intervention down",children:e.jsx(J,{className:"w-3 h-3"})})]}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-7 px-1 flex items-end gap-1 opacity-35 group-hover:opacity-80 transition-opacity",children:c.length>0?c.map((s,a)=>{const U=d[a]===l,w=Number(s)||0,T=C>0?w/C*100:0;return e.jsx("div",{className:`flex-1 rounded-t-sm transition-all duration-500 ease-out ${U?"opacity-100 scale-y-110 brightness-125":"opacity-50"}`,style:{height:`${T}%`,backgroundColor:u}},a)}):e.jsx("div",{className:"w-full h-1 bg-[var(--laep-border-strong)] mb-1 rounded-full opacity-50"})}),e.jsxs("div",{className:"text-[8px] font-medium self-end opacity-80 z-10",children:[n.strategy?.toUpperCase()||"STANDARD"," STRATEGY"]})]}),x&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute left-0 top-1/4 bottom-1/4 w-1 bg-[var(--laep-action)]/40 rounded-full cursor-ew-resize",onMouseDown:s=>Y("resize-left",s)}),e.jsx("div",{className:"absolute right-0 top-1/4 bottom-1/4 w-1 bg-[var(--laep-action)]/40 rounded-full cursor-ew-resize",onMouseDown:s=>Y("resize-right",s)})]})]})},xe=({interventions:n,simulationOutput:x,currentYear:l,setCurrentYear:b,selectedId:D,onSelectIntervention:R,onEditIntervention:I,onUpdateIntervention:A,onAddIntervention:d,onMoveSelectedUp:E,onMoveSelectedDown:z,metricMode:h="carbon",onMetricModeChange:j})=>{const[m,p]=o.useState(!1),[N,P]=o.useState(60),S=o.useRef(null),v=o.useMemo(()=>{const t=te(n);return ae(t,{bufferYears:1,minSpanYears:6,fallbackYear:l,includeYears:[l]})},[n,l]),i=o.useMemo(()=>se(v.startYear,v.endYear),[v]),g=i[0],f=i[i.length-1];o.useEffect(()=>{const t=S.current;if(!t)return;const r=c=>{if(c.shiftKey){c.preventDefault();const C=c.deltaY>0?-5:5;P(u=>
31Math.max(25,Math.min(250,u+C)))}};return t.addEventListener("wheel",r,{passive:!1}),()=>t.removeEventListener("wheel",r)},[]),o.useEffect(()=>{if(!m)return;if(l>=f){p(!1);return}const t=setTimeout(()=>{b(l+1)},700);return()=>clearTimeout(t)},[m,l,f,b]);const H=()=>{if(l>=f){b(g),p(!0);return}p(t=>!t)},k=t=>{p(!1),b(t)},V=(t,r)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(t.key))return;t.preventDefault();const c=t.key==="Home"?g:t.key==="End"?f:t.key==="ArrowLeft"?Math.max(g,r-1):Math.min(f,r+1);k(c)},M=o.useRef(null),[B,$]=o.useState(0);o.useEffect(()=>{if(!M.current)return;const t=M.current,r=new ResizeObserver(()=>{$(t.clientWidth||0)});return r.observe(t),$(t.clientWidth||0),()=>r.disconnect()},[]);const Y=o.useCallback(t=>{const r=x?.rawResults?.find(c=>c?.name===t?.label)?.result?.metrics||{};return i.map(c=>{const u=(r[String(c)]||[]).reduce((s,a)=>(s.cost+=Number(a?.stats?.cost||0),s.carbon+=Number(a?.stats?.carbonSaved||0),s.demand+=Math.abs(Number(a?.stats?.demandChange||0)),s.count+=1,s),{cost:0,carbon:0,demand:0,count:0});return Number(u[h]||0)})},[x,h,i]);return e.jsx("div",{className:"laep-panel border rounded-lg overflow-hidden relative h-full min-h-0 flex flex-col",children:e.jsxs("div",{className:"p-3 flex flex-col h-full min-h-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2 shrink-0",children:[e.jsxs("h2",{className:"text-base font-semibold flex min-w-0 items-center gap-1.5 text-[var(--laep-text)]",children:[e.jsx(Q,{className:"w-4 h-4 shrink-0 laep-muted"})," Scenario Composition"]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider laep-label font-semibold",children:"Block chart"}),e.jsxs("select",{value:h,onChange:t=>j?.(t.target.value),"aria-label":"Timeline block metric",className:"text-[10px] uppercase tracking-wider font-semibold laep-control border rounded px-2 py-1",children:[e.jsx("option",{value:"carbon",children:"Carbon"}),e.jsx("option",{value:"cost",children:"Cost"}),e.jsx("option",{value:"demand",children:"Demand"}),e.jsx("option",{value:"count",children:"Count"})]})]})]}),e.jsxs("div",{className:"relative mt-1 min-h-0 flex-1",children:[e.jsx("button",{onClick:H,type:"button","aria-label":m?"Pause year playback":"Play year playback",className:"absolute bottom-3 left-2 z-40 inline-flex h-8 w-8 items-center justify-center rounded-md bg-[var(--laep-action)] text-[var(--laep-action-contrast)] shadow-sm transition-colors hover:bg-[var(--laep-action-hover)] focus:outline-none focus:ring-2 focus:ring-[var(--laep-focus)]",title:m?"Pause year playback":"Play year playback",children:m?e.jsx(oe,{className:"w-4 h-4"}):e.jsx(ee,{className:"w-4 h-4 fill-current"})}),e.jsx("div",{ref:S,className:"h-full min-h-0 overflow-x-auto overflow-y-hidden custom-scrollbar",children:e.jsxs("div",{style:{minWidth:`${Math.max(520,i.length*N)}px`,position:"relative",height:"100%",paddingBottom:"12px"},children:[e.jsx("div",{className:"mb-2 border-b border-[var(--laep-border-subtle)] pb-1 relative z-10",style:{display:"grid",gridTemplateColumns:`repeat(${i.length}, 1fr)`},children:i.map(t=>e.jsx("button",{type:"button",onClick:()=>k(t),onKeyDown:r=>V(r,t),"aria-pressed":t===l,"aria-label":`Set scenario year to ${t}`,className:`mx-0.5 rounded px-1 py-1 text-center transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--laep-focus)] ${t===l?"bg-[var(--laep-action)] text-[var(--laep-action-contrast)] text-[11px] font-bold shadow-sm":"text-[var(--laep-text-soft)] text-xs hover:bg-[var(--laep-surface-muted)] hover:text-[var(--laep-text)]"}`,children:t},t))}),e.jsx("div",{className:"absolute inset-0 pointer-events-none opacity-30 z-0 pt-8",style:{display:"grid",gridTemplateColumns:`repeat(${i.length}, 1fr)`},children:i.map(t=>e.jsx("div",{className:`border-l border-[var(--laep-border-subtle)] h-full ${t===l?"border-[var(--laep-border-strong)] border-l-2":""}`},`line-${t}`))}),e.jsx("div",{className:"absolute top-8 bottom-0 w-px bg-[var(--laep-action)] z-30 pointer-events-none",style:{left:`${(l
31-g+.5)/i.length*100}%`,transition:"left 0.3s cubic-bezier(0.4, 0, 0.2, 1)"}}),e.jsx("div",{ref:M,className:"space-y-2 py-1 relative z-10 h-[calc(100%-40px)] overflow-hidden pr-1",children:n.map(t=>e.jsx(ce,{item:t,isSelected:D===t.id,currentYear:l,onClick:()=>R(D===t.id?null:t.id),onEdit:()=>I?.(t.id),onUpdate:r=>A?.(t.id,r),onMoveUp:()=>E?.(),onMoveDown:()=>z?.(),yearsRange:i,laneWidth:B,metricSeries:Y(t)},t.id))})]})})]})]})})};export{xe 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.