1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PriceChart-CyNfnKJM.js","assets/main-B8eWcItW.js"])))=>i.map(i=>d[i]); 2import{r as n,j as e,_ as pe}from"./main-B8eWcItW.js";import{c as G,f,a as fe,b as be,d as X,S as w,E as D,e as ee,u as je,g as ye}from"./use-iframe-auto-height-CcbV6K_b.js";const ve=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ne=G("arrow-down",ve);const we=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],De=G("arrow-up",we);const _e=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]],Se=G("calculator",_e),ke=n.lazy(()=>pe(()=>import("./PriceChart-CyNfnKJM.js"),__vite__mapDeps([0,1]))),Me={"1M":30,"3M":90,"6M":180,"1Y":365},Le=["1M","3M","6M","1Y","ALL"];function m(s){if(s==null)return 0;const a=typeof s=="number"?s:parseFloat(s);return Number.isFinite(a)?a:0}function l(s,a=2){return s.toLocaleString("en-GB",{minimumFractionDigits:a,maximumFractionDigits:a})}function Pe(s){const a=typeof s=="string"?parseInt(s,10)||0:s,g=Math.floor(a/1e4),p=Math.floor(a%1e4/100),j=a%100;return`${String(g).padStart(2,"0")}:${String(p).padStart(2,"0")}:${String(j).padStart(2,"0")}`}function Te(s){const a=typeof s=="string"?parseInt(s,10)||0:s,g=Math.floor(a/1e4),p=Math.floor(a%1e4/100),j=a%100;return new Date(g,p-1,j).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})}function Be(){const[s,a]=n.useState(null),[g,p]=n.useState([]),[j,te]=n.useState([]),[_,se]=n.useState("3M"),[v,R]=n.useState("amount"),[T,ae]=n.useState(""),[B,re]=n.useState(""),V=new Date,F=new Date;F.setFullYear(V.getFullYear()-1);const Z=new Date(D+"T00:00:00Z"),ne=F<Z?Z:F,[h,oe]=n.useState(f(ne)),[b,ie]=n.useState(f(V)),[Y,A]=n.useState([]),[le,H]=n.useState(!0),[O,de]=n.useState(null);n.useEffect(()=>{let t=!1;return H(!0),fe(w).then(async r=>{if(t)return;a(r);const c=new Date(r.Date.slice(0,10)+"T00:00:00Z"),o=[];for(let i=0;i<14;i++){const u=new Date(c);u.setDate(u.getDate()-i);const L=f(u),P=await be(w,L).catch(()=>[]);if(o.push(...P),o.length>=10)break}o.sort((i,u)=>{const L=typeof i.trade_date=="string"?parseInt(i.trade_date,10):i.trade_date,P=typeof u.trade_date=="string"?parseInt(u.trade_date,10):u.trade_date;if(P!==L)return P-L;const ge=typeof i.trade_time=="string"?parseInt(i.trade_time,10):i.trade_time;return(typeof u.trade_time=="string"?parseInt(u.trade_time,10):u.trade_time)-ge}),t||te(o)}).catch(r=>!t&&de(r.message)).finally(()=>!t&&H(!1)),()=>{t=!0}},[]),n.useEffect(()=>{let t=!1;const r=new Date,c=new Date(D+"T00:00:00Z");let o;return _==="ALL"?o=c:(o=new Date,o.setDate(o.getDate()-Me[_]),o<c&&(o=c)),X(w,f(o),f(r)).then(i=>!t&&p(i)).catch(()=>!t&&p([])),()=>{t=!0}},[_]);const E=n.useMemo(()=>g.map(t=>{const r=t.price_date*1e3,c=m(t.close_price);return{dateTs:r,dateLabel:new Date(r).toLocaleDateString("en-GB",{timeZone:"UTC",day:"2-digit",month:"short",year:"numeric"}),price:c}}).filter(t=>Number.isFinite(t.price)&&t.price>0).sort((t,r)=>t.dateTs-r.dateTs),[g]),d=s?.price_format_decimals??2,q=m(s?.Change),ce=m(s?.ChangePercent),S=q>=0,me=m(s?.mid_price);n.useEffect(()=>{let t=!1;if(!h||!b||h>b){A([]);return}const r=new Date(h+"T00:00:00Z");r.setDate(r.getDate()-14);const c=new Date(b+"T00:00:00Z");return c.setDate(c.getDate()+1),X(w,f(r),f(c)).then(o=>!t&&A(o)).catch(()=>!t&&A([])),()=>{t=!0}},[h,b]);function U(t){if(!t||Y.length===0)return 0;const r=Math.floor(new Date(t+"T23:59:59Z").getTime()/1e3),c=[...Y].sort((i,u)=>i.price_date-u.price_date);let o=0;for(const i of c)if(i.price_date<=r)o=m(i.close_price);else break;return o}const z=U(h),J=U(b),I=z/100,ue=J/100,$=v==="shares"?parseFloat(T)||0:I>0?(parseFloat(B)||0)/I:0,k=$*I,K=$*ue,N=K-k,xe=k>0?N/k*100:0,M=E.map(t=>t.price),Q=M.length?Math.min(...M):0,C=M.length?Math.max(...M):0,W=Math.max((C-Q)*.12,C*.03,.5),he
2=[Math.max(0,Q-W),C+W];return O?e.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive",children:O}):le||!s?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"h-[280px] animate-pulse rounded-lg bg-muted"}),e.jsx("div",{className:"h-[420px] animate-pulse rounded-lg bg-muted"}),e.jsx("div",{className:"h-[520px] animate-pulse rounded-lg bg-muted"})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-card p-5 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:[s.MarketName," : ",s.Symbol]}),e.jsx("h2",{className:"mt-1 text-xl font-semibold text-foreground",children:s.Share}),e.jsxs("div",{className:"mt-3 flex items-baseline gap-3",children:[e.jsx("span",{className:"brand-text text-5xl font-bold tabular-nums",children:l(me,d)}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:s.Currency})]}),e.jsxs("div",{className:`mt-1 inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-sm font-semibold ${S?"bg-[color-mix(in_oklab,var(--gain)_15%,transparent)] text-[var(--gain)]":"bg-[color-mix(in_oklab,var(--loss)_15%,transparent)] text-[var(--loss)]"}`,children:[S?e.jsx(De,{className:"h-3.5 w-3.5"}):e.jsx(Ne,{className:"h-3.5 w-3.5"}),S?"+":"",l(q,d)," (",S?"+":"",l(ce,2),"%)"]})]}),e.jsxs("div",{className:"text-right text-xs text-muted-foreground",children:[e.jsx("div",{children:"As of"}),e.jsx("div",{className:"font-medium text-foreground",children:new Date(s.Date).toLocaleString("en-GB",{timeZone:"Europe/London"})}),e.jsx("div",{className:"mt-2",children:"Delayed at least 15 minutes"})]})]}),e.jsxs("div",{className:"mt-5 grid grid-cols-2 gap-x-6 border-t-2 border-foreground pt-0 text-sm sm:grid-cols-4",children:[e.jsx(x,{label:"Open",value:l(m(s.Open),d)}),e.jsx(x,{label:"Prev close",value:l(m(s.PreviousClose),d)}),e.jsx(x,{label:"Bid",value:l(m(s.Bid),d)}),e.jsx(x,{label:"Ask",value:l(m(s.Ask),d)}),e.jsx(x,{label:"Day high",value:l(m(s.High),d)}),e.jsx(x,{label:"Day low",value:l(m(s.Low),d)}),e.jsx(x,{label:"52w high",value:l(m(s.fifty_two_week_high),d)}),e.jsx(x,{label:"52w low",value:l(m(s.fifty_two_week_low),d)}),e.jsx(x,{label:"Volume",value:s.Volume.toLocaleString("en-GB")}),e.jsx(x,{label:"Market cap",value:`£${s.MarketCap}m`}),e.jsx(x,{label:"Shares (m)",value:s.NoShares}),e.jsx(x,{label:"ISIN",value:s.ISIN})]})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-card p-5 shadow-sm",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Price history"}),e.jsx("div",{className:"flex gap-1",children:Le.map(t=>e.jsx("button",{onClick:()=>se(t),className:`rounded-md px-2.5 py-1 text-xs font-semibold transition-colors ${_===t?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:t},t))})]}),e.jsx("div",{className:"h-64 w-full",children:E.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"No data"}):e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"h-full w-full animate-pulse rounded-md bg-muted/40"}),children:e.jsx(ke,{data:E,yAxisDomain:he,decimals:d,formatPrice:l})})})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2 lg:items-start",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-card p-5 shadow-sm",children:[e.jsx("h3",{className:"mb-3 text-sm font-semibold text-foreground",children:"Latest trades"}),j.length===0?e.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No trades available for the latest session."}):e.jsx("div",{className:"border-t-2 border-foreground",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border",children:[e.jsx("th",{className:"px-1 py-3 text-left text-xs font-semibold text-foreground",children:"Date / Time"}),e.jsx("th",{className:"px-1 py-3 text-right text-xs font-semibold text-foreground",children:"Price"}),e.jsx("th",{className:"px-1 py-3 text-right text-xs font-semibold text-foreground",children:"Volume"}),e.jsx("th",{className:"px-1 py-3 text-right text-xs font-semibold text-foreground",children:"Value"})]})}),e.jsx("tbody",{children:j.slice(0,10).map((t,r)=>e.jsxs("tr",{className:"border-b border-border tabular-nums",children:[e.jsxs("td",{className:"px-1 py-3 text-foreground",children:[Te(t.trade_date),", ",Pe(t.trade_time)]}),e.jsx("td",{className:"px-1 py-3 text-right text-foreground",children:l(parseFloat(t.trade_price),d)}),e.jsx("td",{className:"px-1 py-3 text-right text-muted-foreground",children:t.trade_amount.toLocaleStr
2ing("en-GB")}),e.jsx("td",{className:"px-1 py-3 text-right text-muted-foreground",children:parseFloat(t.trade_value).toLocaleString("en-GB",{maximumFractionDigits:2})})]},r))})]})})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-card p-5 shadow-sm",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(Se,{className:"h-4 w-4 text-primary"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Investment calculator"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground",children:"Investment date"}),e.jsx("input",{type:"date",value:h,min:D,max:b,onChange:t=>oe(t.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none ring-primary/30 transition focus:ring-2"}),h<D&&e.jsxs("p",{className:"mt-1 text-xs text-destructive",children:[w," began trading on ",ee,". Please pick a date on or after ",ee,"."]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground",children:"End date"}),e.jsx("input",{type:"date",value:b,min:h,max:f(new Date),onChange:t=>ie(t.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none ring-primary/30 transition focus:ring-2"})]})]}),e.jsxs("div",{className:"mt-3 inline-flex rounded-md border border-border bg-muted/40 p-0.5 text-xs",children:[e.jsx("button",{onClick:()=>R("amount"),className:`rounded px-3 py-1 font-semibold transition-colors ${v==="amount"?"bg-primary text-primary-foreground":"text-muted-foreground"}`,children:"By value invested"}),e.jsx("button",{onClick:()=>R("shares"),className:`rounded px-3 py-1 font-semibold transition-colors ${v==="shares"?"bg-primary text-primary-foreground":"text-muted-foreground"}`,children:"By shares held"})]}),v==="shares"?e.jsx("input",{type:"number",min:"0",value:T,onChange:t=>ae(t.target.value),placeholder:"Number of shares",className:"mt-2 w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none ring-primary/30 transition focus:ring-2"}):e.jsx("input",{type:"number",min:"0",value:B,onChange:t=>re(t.target.value),placeholder:"Amount in £",className:"mt-2 w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none ring-primary/30 transition focus:ring-2"}),h>=D&&(v==="shares"?parseFloat(T)>0:parseFloat(B)>0)&&e.jsxs("div",{className:"mt-4 space-y-3 rounded-md bg-muted/50 p-4",children:[e.jsx(y,{label:"Buy price",value:`${l(z,d)}p`}),e.jsx(y,{label:"Sell price",value:`${l(J,d)}p`}),e.jsx(y,{label:"Shares held",value:$.toLocaleString("en-GB",{maximumFractionDigits:0})}),e.jsx(y,{label:"Initial value",value:`£${k.toLocaleString("en-GB",{minimumFractionDigits:2,maximumFractionDigits:2})}`}),e.jsx(y,{label:"Final value",value:`£${K.toLocaleString("en-GB",{minimumFractionDigits:2,maximumFractionDigits:2})}`,strong:!0}),e.jsx(y,{label:"Profit / loss",value:`${N>=0?"+":""}£${N.toLocaleString("en-GB",{minimumFractionDigits:2,maximumFractionDigits:2})} (${N>=0?"+":""}${l(xe,2)}%)`,valueClass:N>=0?"text-[var(--gain)]":"text-[var(--loss)]"})]}),e.jsx("p",{className:"mt-3 text-[11px] leading-relaxed text-muted-foreground",children:"For illustrative purposes only. Based on closing prices and excludes dealing costs, taxes and dividends."})]})]})]})}function x({label:s,value:a}){return e.jsxs("div",{className:"border-b border-border py-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:s}),e.jsx("div",{className:"font-medium tabular-nums text-foreground",children:a})]})}function y({label:s,value:a,strong:g,valueClass:p}){return e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),e.jsx("span",{className:`tabular-nums ${g?"text-base font-semibold text-foreground":"font-medium text-foreground"} ${p??""}`,children:a})]})}function Ie(){return je(),e.jsx("div",{className:"bg-background",children:e.jsxs("div",{className:"mx-auto w-full max-w-[1280px] px-4 py-6 sm:px-6 sm:py-8",children:[e.jsx(Be,{}),e.jsx(ye,{})]})})}export{Ie as component};
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.