@gearbox-protocol/permissionless-ui 1.17.6 → 1.17.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),l=require("../tooltip/tooltip.cjs"),p=require("../../utils/cn.cjs"),N=1e3*60*10;function w({blockByChain:n,explorerAddresses:g,networkById:S}){const[i,v]=u.useState(Date.now());u.useEffect(()=>{const s=()=>{v(Date.now())},t=window.setInterval(s,1e3);return()=>{clearInterval(t)}},[]);const x=u.useMemo(()=>{if(!n)return 0;const s=Object.values(n).reduce((t,a)=>{const o=a.lastSyncBlock.localTimestamp;return t===0||t!==0&&o<t?o:t},0);return s?i-s:0},[n,i])>N,m=()=>e.jsxs("div",{className:"flex h-[30px] items-center gap-1.5",children:[e.jsx("span",{className:p.cn("text-sm leading-[17px]",x?"text-destructive":"text-success"),children:"Status"}),e.jsx("div",{className:p.cn("w-2 h-2 rounded-full",x?"bg-destructive":"bg-success")})]}),h=()=>{if(!n)return null;const s=Object.entries(n);return e.jsx("div",{className:"flex flex-col text-left text-xs",children:s.map(([t,a],o)=>{const d=a.lastSyncBlock,c=d?.block||0n,T=d?.localTimestamp?i-d.localTimestamp:0,r=g[Number(t)],f=typeof r=="string"?r:r&&typeof r=="object"&&"url"in r?r.url:void 0,b=S[Number(t)]||"Unknown",j=`[${c.toString()}]`,k=o===s.length-1;return e.jsxs("div",{className:p.cn(!k&&"mb-2"),children:[e.jsxs("span",{children:[b," "]}),f&&c>0?e.jsx("a",{href:`${f}/block/${c}`,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground",children:j}):e.jsx("span",{children:j}),c>0&&e.jsxs("span",{children:[", updated ",(T/1e3).toFixed(0)," seconds ago"]})]},t)})})};return n?e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx("div",{className:"cursor-help",children:m()})}),e.jsx(l.TooltipContent,{side:"top",collisionPadding:8,children:h()})]})}):m()}exports.BlockSync=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),l=require("../tooltip/tooltip.cjs"),p=require("../../utils/cn.cjs"),k=1e3*60*10;function w({blockByChain:n,explorerAddresses:g,networkById:v}){const[i,S]=u.useState(Date.now());u.useEffect(()=>{const s=()=>{S(Date.now())},t=window.setInterval(s,1e3);return()=>{clearInterval(t)}},[]);const x=u.useMemo(()=>{if(!n)return 0;const s=Object.values(n).reduce((t,a)=>{const o=a.lastSyncBlock.localTimestamp;return t===0||t!==0&&o<t?o:t},0);return s?i-s:0},[n,i])>k,m=()=>e.jsxs("div",{className:"flex h-[30px] items-center gap-1.5",children:[e.jsx("span",{className:p.cn("text-sm leading-[17px]",x?"text-destructive":"text-success"),children:"Status"}),e.jsx("div",{className:p.cn("w-2 h-2 rounded-full",x?"bg-destructive":"bg-success")})]}),h=()=>{if(!n)return null;const s=Object.entries(n);return e.jsx("div",{className:"flex flex-col text-left text-xs",children:s.map(([t,a],o)=>{const d=a.lastSyncBlock,c=d?.block||0n,T=d?.localTimestamp?i-d.localTimestamp:0,r=g[Number(t)],j=typeof r=="string"?r:r&&typeof r=="object"&&"url"in r?r.url:void 0,N=v[Number(t)]||"Unknown",f=`[${c.toString()}]`,b=o===s.length-1;return e.jsxs("div",{className:p.cn(!b&&"mb-2"),children:[e.jsxs("span",{children:[N," "]}),j&&c>0?e.jsx("a",{href:`${j}/block/${c}`,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground",children:f}):e.jsx("span",{children:f}),c>0&&e.jsxs("span",{children:[", updated ",(T/1e3).toFixed(0)," seconds ago"]})]},t)})})};return n?e.jsx(l.TooltipProvider,{delayDuration:200,children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx("div",{className:"cursor-auto select-none",children:m()})}),e.jsx(l.TooltipContent,{side:"top",collisionPadding:8,children:h()})]})}):e.jsx("div",{className:"select-none",children:m()})}exports.BlockSync=w;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("luxon"),o=require("../../utils/format-number.cjs"),{MIN_DISPLAY_THRESHOLD:i,MAX_EXPONENTIAL_THRESHOLD:h}=o.FORMAT_CONSTANTS,$=(t,r,e="full")=>{if(o.isBelowDisplayThreshold(t))return r?`<${i}${r}`:`<${i}`;if(t===0)return r?`0${r}`:"0";const n=o.formatNumberWithSuffix(t,{maxExponentialThreshold:h,minimumFractionDigits:0,maximumFractionDigits:e==="short"?1:0,format:e,adaptiveDecimals:e==="short"});return r?`${n}${r}`:n},S=2,D=(t,r)=>{if(o.isBelowDisplayThreshold(t))return r?`<${i}${r}`:`<${i}`;if(t===0)return r?`0${r}`:"0";const e=o.toSignificantDigits(t,S);return r?`${e}${r}`:e},F=4,g=t=>{if(o.isBelowDisplayThreshold(t))return`<${i}`;if(t===0)return"0";const r=Math.round(t),e=Math.abs(t-r);return e>0&&e<.01?t.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):o.toSignificantDigits(t,F)},M=(t,r)=>{if(o.isBelowDisplayThreshold(t))return r?`<${i} ${r}`:`<${i}`;if(t===0)return r?`0 ${r}`:"0";const e=Number.isInteger(t),n=Math.abs(t),a=e&&n>=1e3,T=Math.round(t),m=Math.abs(t-T);if(m>0&&m<.01&&!a){const f=t.toFixed(12).replace(/0+$/,"").replace(/\.$/,"");return r?`${f} ${r}`:f}const c=o.formatNumberWithSuffix(t,{maxExponentialThreshold:h,minimumFractionDigits:e?0:2,maximumFractionDigits:a?1:e?0:2,format:a?"short":"full",adaptiveDecimals:a});return r?`${c} ${r}`:c},u={"%":D,$,token:M,none:g},N=t=>u[t]||u.token,E=t=>s.DateTime.fromSeconds(Number(t)).toFormat("dd/LL/yyyy HH:mm"),l=t=>s.DateTime.fromSeconds(Number(t)).toFormat("HH:mm"),p=()=>{let t=null;return r=>{const e=s.DateTime.fromSeconds(Number(r)),n=e.toFormat("yyyy-MM-dd");return n!==t?(t=n,e.toFormat("dd MMM")):e.toFormat("HH:mm")}},I=(t,r)=>D(Number(t),r),d={time:E,"%":I},x=(t,r)=>{if(t==="time"&&r&&r.length>0){const e=s.DateTime.fromSeconds(Number(r[0].time)),n=s.DateTime.fromSeconds(Number(r[r.length-1].time));return e.hasSame(n,"day")?l:p()}return d[t]||d.time};exports.getXFormatter=x;exports.getYFormatter=N;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("luxon"),s=require("../../utils/format-number.cjs"),{MIN_DISPLAY_THRESHOLD:u,MAX_EXPONENTIAL_THRESHOLD:T}=s.FORMAT_CONSTANTS,E=(t,e,r="full")=>{if(s.isBelowDisplayThreshold(t))return e?`<${u}${e}`:`<${u}`;if(t===0)return e?`0${e}`:"0";const n=s.formatNumberWithSuffix(t,{maxExponentialThreshold:T,minimumFractionDigits:0,maximumFractionDigits:r==="short"?1:0,format:r,adaptiveDecimals:r==="short"});return e?`${n}${e}`:n},A=2,x=(t,e)=>{if(s.isBelowDisplayThreshold(t))return e?`<${u}${e}`:`<${u}`;if(t===0)return e?`0${e}`:"0";const r=s.toSignificantDigits(t,A);return e?`${r}${e}`:r},I=4,_=t=>{if(s.isBelowDisplayThreshold(t))return`<${u}`;if(t===0)return"0";const e=Math.round(t),r=Math.abs(t-e);return r>0&&r<.01?t.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):s.toSignificantDigits(t,I)},H=(t,e)=>{if(s.isBelowDisplayThreshold(t))return e?`<${u} ${e}`:`<${u}`;if(t===0)return e?`0 ${e}`:"0";const r=Number.isInteger(t),n=Math.abs(t),m=r&&n>=1e3,l=Math.round(t),h=Math.abs(t-l);if(h>0&&h<.01&&!m){const S=t.toFixed(12).replace(/0+$/,"").replace(/\.$/,"");return e?`${S} ${e}`:S}const D=s.formatNumberWithSuffix(t,{maxExponentialThreshold:T,minimumFractionDigits:r?0:2,maximumFractionDigits:m?1:r?0:2,format:m?"short":"full",adaptiveDecimals:m});return e?`${D} ${e}`:D},M={"%":x,$:E,token:H,none:_},R=t=>M[t]||M.token;function O(t,e,r=8){if(t===0)return e?`0 ${e}`:"0";const n=t.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:r});return e?`${n} ${e}`:n}function X(t,e){let r=t.length>0?Math.min(...t):0,n=t.length>0?Math.max(...t):0,m=[];const l=()=>{const a=n-r,i=(r+n)/2;let o=1,c="";i>=1e9?(o=1e9,c="B"):i>=1e6?(o=1e6,c="M"):i>=1e3&&(o=1e3,c="K");const f=a/10/o;let d=1;if(f>0){const N=Math.floor(Math.log10(f));d=Math.max(1,-N),d=Math.min(d,4)}return{scale:o,suffix:c,decimals:d}},h=(a,i,o)=>i>1?`${(a/i).toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:4,useGrouping:!1})}${o}`:a.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:4,useGrouping:!1});return{formatter:a=>{if(a===0)return"0";const{scale:i,suffix:o,decimals:c}=l(),F=Math.abs(a)*1e-10||1e-10;return m.some(f=>Math.abs(f-a)<F)?h(a,i,o):i>1?`${(a/i).toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:c,useGrouping:!1})}${o}`:a.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:c,useGrouping:!1})},updateVisibleRange:a=>{a.length>0&&(r=Math.min(...a),n=Math.max(...a))},updateLastValues:a=>{m=[...a]}}}const G=t=>g.DateTime.fromSeconds(Number(t)).toFormat("dd/LL/yyyy HH:mm"),P=t=>g.DateTime.fromSeconds(Number(t)).toFormat("HH:mm"),U=()=>{let t=null;return e=>{const r=g.DateTime.fromSeconds(Number(e)),n=r.toFormat("yyyy-MM-dd");return n!==t?(t=n,r.toFormat("dd MMM")):r.toFormat("HH:mm")}},C=(t,e)=>x(Number(t),e),$={time:G,"%":C},Y=(t,e)=>{if(t==="time"&&e&&e.length>0){const r=g.DateTime.fromSeconds(Number(e[0].time)),n=g.DateTime.fromSeconds(Number(e[e.length-1].time));return r.hasSame(n,"day")?P:U()}return $[t]||$.time};exports.createAdaptiveYAxisFormatter=X;exports.formatExactValue=O;exports.getXFormatter=Y;exports.getYFormatter=R;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("../../utils/cn.cjs"),s=require("./formatters.cjs");function d({point:t,xMeasureUnit:r,yMeasureUnit:o,className:n}){const i=s.getXFormatter(r),a=s.getYFormatter(o),l=i(t.time,r),m=a(t.value,o);return e.jsxs("div",{className:c.cn("absolute top-2 left-2 right-2 z-[100] pointer-events-none",n),children:[e.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:m}),e.jsx("div",{className:"text-xs sm:text-sm font-medium text-muted-foreground whitespace-nowrap overflow-hidden text-ellipsis mt-0.5",children:l})]})}exports.GraphCurrentValue=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),c=require("../../utils/cn.cjs"),o=require("./formatters.cjs");function d({point:e,xMeasureUnit:s,yMeasureUnit:t,className:a}){const l=o.getXFormatter(s)(e.time,s),n=t!=="%"&&t!=="$"&&t!=="none"?t:void 0,m=t==="$"?`$${o.formatExactValue(e.value)}`:t==="%"?`${o.formatExactValue(e.value)}%`:o.formatExactValue(e.value,n);return r.jsxs("div",{className:c.cn("absolute top-2 left-2 right-2 z-[100] pointer-events-none",a),children:[r.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:m}),r.jsx("div",{className:"text-xs sm:text-sm font-medium text-muted-foreground whitespace-nowrap overflow-hidden text-ellipsis mt-0.5",children:l})]})}exports.GraphCurrentValue=d;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),f=require("react"),N=require("../../utils/cn.cjs"),w=require("./formatters.cjs"),y=require("./graph.cjs");function C({points:m,series:j,xMeasureUnit:h,yMeasureUnit:R,className:v,position:e,containerRef:x}){const g=f.useRef(null),[p,i]=f.useState(e),S=w.getXFormatter(h);f.useEffect(()=>{if(!e){i(e);return}const t=x?.current;if(!t){i(e);return}const u=g.current;if(!u){i(e);return}const a=t.getBoundingClientRect(),d=u.getBoundingClientRect();let s=e.x,r=e.y;const c=d.width,o=d.height,l=8;s-c/2<l?s=c/2+l:s+c/2>a.width-l&&(s=a.width-c/2-l);const b=o+8;r-b<l?r=e.y+20:r=e.y-b,i({x:s,y:r})},[e,x]);const F=p?{left:`${p.x}px`,top:`${p.y}px`,transform:"translate(-50%, 0)"}:{};if(m.size===0)return null;const _=Array.from(m.values())[0],E=S(_.time,h);return n.jsx("div",{ref:g,className:N.cn("absolute z-[100] pointer-events-none whitespace-nowrap",v),style:F,children:n.jsxs("div",{className:"bg-background/90 backdrop-blur-sm rounded border border-border p-1.5 sm:p-2 space-y-1 sm:space-y-1.5",children:[n.jsx("div",{className:"text-xs sm:text-sm font-medium text-muted-foreground mb-0.5 sm:mb-1 whitespace-nowrap",children:E}),j.map((t,u)=>{const a=m.get(t.label);if(!a)return null;const d=y.DEFAULT_SERIES_COLORS[u%y.DEFAULT_SERIES_COLORS.length],s=t.color||d.line,r=t.yMeasureUnit||R;let o=w.getYFormatter(r)(a.value,r==="none"?void 0:r);return o.endsWith(" none")&&(o=o.slice(0,-5)),n.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm whitespace-nowrap",children:[n.jsx("div",{className:"w-1.5 h-1.5 sm:w-2 sm:h-2 rounded-full flex-shrink-0",style:{backgroundColor:s}}),n.jsxs("span",{className:"text-muted-foreground whitespace-nowrap",children:[t.label,":"]}),n.jsx("span",{className:"font-medium text-foreground whitespace-nowrap",children:o})]},t.label)})]})})}exports.GraphTooltip=C;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),x=require("react"),$=require("../../utils/cn.cjs"),d=require("./formatters.cjs"),w=require("./graph.cjs");function C({points:m,series:v,xMeasureUnit:h,yMeasureUnit:j,className:R,position:t,containerRef:g}){const b=x.useRef(null),[f,l]=x.useState(t),E=d.getXFormatter(h);x.useEffect(()=>{if(!t){l(t);return}const r=g?.current;if(!r){l(t);return}const i=b.current;if(!i){l(t);return}const s=r.getBoundingClientRect(),u=i.getBoundingClientRect();let n=t.x,e=t.y;const a=u.width,p=u.height,c=8;n-a/2<c?n=a/2+c:n+a/2>s.width-c&&(n=s.width-a/2-c);const y=p+8;e-y<c?e=t.y+20:e=t.y-y,l({x:n,y:e})},[t,g]);const S=f?{left:`${f.x}px`,top:`${f.y}px`,transform:"translate(-50%, 0)"}:{};if(m.size===0)return null;const _=Array.from(m.values())[0],N=E(_.time,h);return o.jsx("div",{ref:b,className:$.cn("absolute z-[100] pointer-events-none whitespace-nowrap",R),style:S,children:o.jsxs("div",{className:"bg-background/90 backdrop-blur-sm rounded border border-border p-1.5 sm:p-2 space-y-1 sm:space-y-1.5",children:[o.jsx("div",{className:"text-xs sm:text-sm font-medium text-muted-foreground mb-0.5 sm:mb-1 whitespace-nowrap",children:N}),v.map((r,i)=>{const s=m.get(r.label);if(!s)return null;const u=w.DEFAULT_SERIES_COLORS[i%w.DEFAULT_SERIES_COLORS.length],n=r.color||u.line,e=r.yMeasureUnit||j,a=e!=="%"&&e!=="$"&&e!=="none"?e:void 0,p=e==="$"?`$${d.formatExactValue(s.value)}`:e==="%"?`${d.formatExactValue(s.value)}%`:d.formatExactValue(s.value,a);return o.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm whitespace-nowrap",children:[o.jsx("div",{className:"w-1.5 h-1.5 sm:w-2 sm:h-2 rounded-full flex-shrink-0",style:{backgroundColor:n}}),o.jsxs("span",{className:"text-muted-foreground whitespace-nowrap",children:[r.label,":"]}),o.jsx("span",{className:"font-medium text-foreground whitespace-nowrap",children:p})]},r.label)})]})})}exports.GraphTooltip=C;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),fe=require("lightweight-charts"),s=require("react"),ge=require("../../hooks/use-media-query.cjs"),le=require("../../utils/cn.cjs"),B=require("../../utils/colors.cjs"),H=require("./default-config.cjs"),U=require("./formatters.cjs"),de=require("./graph-current-value.cjs"),he=require("./graph-tooltip.cjs"),me=require("./plugins/vertical-line.cjs");function pe(e){const w=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const m in e)if(m!=="default"){const T=Object.getOwnPropertyDescriptor(e,m);Object.defineProperty(w,m,T.get?T:{enumerable:!0,get:()=>e[m]})}}return w.default=e,Object.freeze(w)}const ee=pe(s),G=[{line:"#02c39a",top:"rgba(2, 195, 154, 0.56)",bottom:"rgba(2, 195, 154, 0.04)"},{line:"#3b82f6",top:"rgba(59, 130, 246, 0.56)",bottom:"rgba(59, 130, 246, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 0.04)"},{line:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#8b5cf6",top:"rgba(139, 92, 246, 0.56)",bottom:"rgba(139, 92, 246, 0.04)"},{line:"#ec4899",top:"rgba(236, 72, 153, 0.56)",bottom:"rgba(236, 72, 153, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"}];function be({series:e,className:w,showLegend:m=!1,onUnselectSeries:T,xMeasureUnit:P="time",yMeasureUnit:k="token",optionsOverrides:A,verticalLineOptions:D}){const y=s.useRef(null),v=s.useRef(new Map),$=s.useRef(!1),X=s.useRef(new Set),te=s.useRef(0),oe=s.useRef(!0),V=s.useRef(null),W=s.useRef(null),E=ge.useIsMobile(),M=ee.useMemo(()=>e.flatMap(t=>t.data),[e]),se=ee.useMemo(()=>{if(e.length>0){const t=e[e.length-1];if(t.data.length>0)return t.data[t.data.length-1]}},[e]),[re,Y]=s.useState(()=>{if(!se)return;const t=new Map;for(const r of e)r.data.length>0&&t.set(r.label,r.data[r.data.length-1]);return t}),[ne,L]=s.useState(null);s.useEffect(()=>{const t=()=>{if(y.current&&V.current){const u=V.current.clientWidth,a=V.current.clientHeight;y.current.resize(u,a),y.current.timeScale().fitContent()}},r=V.current,l=r?new ResizeObserver(t):null;return r&&l?.observe(r),()=>{r&&l?.unobserve(r)}},[]),s.useEffect(()=>{if(!W.current||$.current)return;const t=H.getDefaultOptions(),r=B.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=fe.createChart(W.current,{...t,rightPriceScale:{...t.rightPriceScale||{},visible:!E,textColor:r},...A});return y.current=l,$.current=!0,()=>{l.remove(),y.current=null,$.current=!1,v.current.clear()}},[E,A]),s.useEffect(()=>{const t=y.current;if(!t||e.length===0)return;const r=P==="time"?U.getXFormatter(P,M):U.getXFormatter(P),l=U.getYFormatter(k),u=H.getDefaultOptions();t.applyOptions({localization:{...u.localization||{},timeFormatter:r?(o=>r(parseFloat(o),void 0)):void 0},timeScale:{...u.timeScale||{},tickMarkFormatter:r?(o=>r(parseFloat(o),void 0)):void 0,minBarSpacing:0}});const g=(M.length>0?Math.min(...M.map(o=>o.value)):0)<0,S=M.some(o=>o.value===0),F=!g&&S,i=e.length>1,j=i||E,R=B.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");t.applyOptions({rightPriceScale:{...u.rightPriceScale||{},visible:!E,textColor:R,...F&&{scaleMargins:{top:.3,bottom:0}}}});const p=new Set(v.current.keys()),c=new Set(e.map(o=>o.label));for(const o of p)if(!c.has(o)){const n=v.current.get(o);n&&(t.removeSeries(n),v.current.delete(o))}const b=H.getDefaultSeries(),f=[];let C=0;for(let o=0;o<e.length;o++){const n=e[o],J=G[o%G.length],I=n.color||J.line;let _,N;if(n.color)if(n.topColor&&n.bottomColor)_=n.topColor,N=n.bottomColor;else if(n.topColor){const d=B.generateColorsFromBase(I);_=n.topColor,N=d.bottomColor}else if(n.bottomColor)_=B.generateColorsFromBase(I).topColor,N=n.bottomColor;else{const d=B.generateColorsFromBase(I);_=d.topColor,N=d.bottomColor}else _=n.topColor||J.top,N=n.bottomColor||J.bottom;if(n.data.length===0){const d=v.current.get(n.label);d&&(t.removeSeries(d),v.current.delete(n.label));continue}const ie=(n.data.length>0?Math.min(...n.data.map(d=>d.value)):0)<0,ce=n.data.some(d=>d.value===0),ue=!ie&&ce,K=i?C===0?void 0:`scale-${C}`:void 0;i&&f.push({priceScaleId:K||"right",shouldPreventNegativeAxis:ue,seriesIndex:C});let q=v.current.get(n.label);q?(q.applyOptions({lineColor:I,topColor:_,bottomColor:N,priceScaleId:K}),q.setData(n.data)):(q=t.addAreaSeries({...b,lineColor:I,topColor:_,bottomColor:N,priceScaleId:K,priceFormat:{type:"custom",formatter:d=>l(parseFloat(d.toString()),void 0,"short")}}),q.setData(n.data),v.current.set(n.label,q)),C++}if(i&&f.length>0)for(const o of f)try{const n=t.priceScale(o.priceScaleId);n&&n.applyOptions({visible:!j,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...o.shouldPreventNegativeAxis&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:R})}catch(n){console.warn(`Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,n)}const x=new Set(e.map(o=>o.label)),O=x.size!==X.current.size||[...x].some(o=>!X.current.has(o)),Q=M.length!==te.current;(oe.current||O||Q||E)&&(t.timeScale().fitContent(),oe.current=!1),X.current=x,te.current=M.length;const z=new Map;for(const o of e)o.data.length>0&&z.set(o.label,o.data[o.data.length-1]);Y(z.size>0?z:void 0)},[e,M,P,k,E]),s.useEffect(()=>{const t=y.current;if(!t||e.length===0)return;const r=e.length===1;let l;for(const a of e)if(a.data.length>0){l=a.data[a.data.length-1].time;break}if(!l)return;const u=a=>{const{time:g=l,seriesData:S,point:F}=a||{},i=Array.from(v.current.values());if(!F||!g){const p=new Map;for(const c of e)c.data.length>0&&p.set(c.label,c.data[c.data.length-1]);if(Y(p.size>0?p:void 0),r)L(null);else if(i[0]&&l){const b=t.timeScale().timeToCoordinate(l),f=e[0];if(f.data.length>0){const C=f.data[f.data.length-1].value,x=i[0].priceToCoordinate(C);b!==null&&x!==null&&L({x:b,y:x})}}return}const j=new Map;let R;for(let p=0;p<e.length;p++){const c=e[p],b=i[p];if(!b)continue;const f=S?.get(b),C=f&&"value"in f?f.value:void 0,x=c.data[c.data.length-1],O=C!==void 0?C:x?.value??0;p===0&&(R=O),j.set(c.label,{value:O,time:g})}if(Y(j),R!==void 0&&i[0]){const c=t.timeScale().timeToCoordinate(g),b=i[0].priceToCoordinate(R);if(c!==null&&b!==null){const f=V.current;if(f){const C=f.querySelector(".LightweightChart");if(C){const x=C.getBoundingClientRect(),O=f.getBoundingClientRect(),Q=c+(x.left-O.left),z=b+(x.top-O.top);L({x:Q,y:z})}else L({x:c,y:b})}else L({x:c,y:b})}else L(null)}else L(null)};return t.subscribeCrosshairMove(u),r||requestAnimationFrame(()=>{const a=Array.from(v.current.values());if(a[0]&&l&&e[0]?.data.length>0){const S=t.timeScale().timeToCoordinate(l),F=e[0].data[e[0].data.length-1].value,i=a[0].priceToCoordinate(F);S!==null&&i!==null&&L({x:S,y:i})}}),()=>{t.unsubscribeCrosshairMove(u)}},[e]),s.useEffect(()=>{const t=y.current;if(!t||e.length===0)return;const r=t.timeScale(),l=Math.max(...e.map(a=>a.data.length)),u=()=>{if(l===0)return;const a=r.getVisibleLogicalRange();if(!a)return;const g={from:0,to:l-1},S=typeof a.from=="number"?a.from:0,F=typeof a.to=="number"?a.to:l-1,i=.01;let j=!1;const R={...a};S<g.from-i&&(R.from=g.from,j=!0),F>g.to+i&&(R.to=g.to,j=!0),j&&r.setVisibleLogicalRange(R)};return r.subscribeVisibleLogicalRangeChange(u),()=>{r.unsubscribeVisibleLogicalRangeChange(u)}},[e]),s.useEffect(()=>{const t=y.current,r=Array.from(v.current.values()),l=[];if(t&&r.length>0&&D){const u=H.getDefaultVerticalLine(),a=r[0];for(const g of D){const S=new me.VertLine(t,a,g.xCoordinate,{...u,...g.options||{}});a.attachPrimitive(S),l.push(S)}}return()=>{if(r.length>0){const u=r[0];for(const a of l)u.detachPrimitive(a)}}},[D]);const Z=e.length===1,ae=ee.useMemo(()=>{if(Z&&e.length>0){const t=e[0];if(t.data.length>0)return t.data[t.data.length-1]}},[Z,e]);return h.jsxs("div",{ref:V,className:le.cn("relative z-[1] w-full h-full overflow-hidden p-0",w),children:[Z&&ae&&h.jsx(de.GraphCurrentValue,{point:ae,xMeasureUnit:P,yMeasureUnit:k}),re&&ne&&h.jsx(he.GraphTooltip,{points:re,xMeasureUnit:P,yMeasureUnit:k,series:e,position:ne,containerRef:V}),m&&h.jsx(Ce,{series:e,onUnselect:T}),h.jsx("div",{ref:W,className:"LightweightChart w-full h-full overflow-hidden"})]})}function Ce({series:e,onUnselect:w}){return h.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((m,T)=>{const P=G[T%G.length],k=m.color||P.line,A=m.data.length===0;return h.jsxs("div",{className:le.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",A&&"opacity-50"),children:[h.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:k}}),h.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[m.label,A&&" (no data)"]}),w&&h.jsx("button",{type:"button",onClick:D=>{D.stopPropagation(),w(m.label)},className:"ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer","aria-label":`Remove ${m.label}`,children:h.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-muted-foreground hover:text-foreground","aria-hidden":"true",children:[h.jsx("title",{children:"Close"}),h.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},m.label)})})}exports.DEFAULT_SERIES_COLORS=G;exports.Graph=be;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),be=require("lightweight-charts"),i=require("react"),ve=require("../../hooks/use-media-query.cjs"),ce=require("../../utils/cn.cjs"),G=require("../../utils/colors.cjs"),$=require("./default-config.cjs"),oe=require("./formatters.cjs"),Ce=require("./graph-current-value.cjs"),Se=require("./graph-tooltip.cjs"),xe=require("./plugins/vertical-line.cjs");function Re(e){const V=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const p in e)if(p!=="default"){const T=Object.getOwnPropertyDescriptor(e,p);Object.defineProperty(V,p,T.get?T:{enumerable:!0,get:()=>e[p]})}}return V.default=e,Object.freeze(V)}const ne=Re(i),H=[{line:"#02c39a",top:"rgba(2, 195, 154, 0.56)",bottom:"rgba(2, 195, 154, 0.04)"},{line:"#3b82f6",top:"rgba(59, 130, 246, 0.56)",bottom:"rgba(59, 130, 246, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 0.04)"},{line:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#8b5cf6",top:"rgba(139, 92, 246, 0.56)",bottom:"rgba(139, 92, 246, 0.04)"},{line:"#ec4899",top:"rgba(236, 72, 153, 0.56)",bottom:"rgba(236, 72, 153, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"}];function ye({series:e,className:V,showLegend:p=!1,onUnselectSeries:T,xMeasureUnit:L="time",yMeasureUnit:q="token",optionsOverrides:D,verticalLineOptions:I}){const R=i.useRef(null),S=i.useRef(new Map),X=i.useRef(!1),Y=i.useRef(new Set),re=i.useRef(0),ae=i.useRef(!0),W=i.useRef(null),ue=i.useRef(null),F=i.useRef(null),Z=i.useRef(null),A=ve.useIsMobile(),P=ne.useMemo(()=>e.flatMap(t=>t.data),[e]),fe=ne.useMemo(()=>{if(e.length>0){const t=e[e.length-1];if(t.data.length>0)return t.data[t.data.length-1]}},[e]),[le,Q]=i.useState(()=>{if(!fe)return;const t=new Map;for(const n of e)n.data.length>0&&t.set(n.label,n.data[n.data.length-1]);return t}),[se,M]=i.useState(null);i.useEffect(()=>{const t=()=>{if(R.current&&F.current){const d=F.current.clientWidth,a=F.current.clientHeight;R.current.resize(d,a),R.current.timeScale().fitContent()}},n=F.current,l=n?new ResizeObserver(t):null;return n&&l?.observe(n),()=>{n&&l?.unobserve(n)}},[]),i.useEffect(()=>{if(!Z.current||X.current)return;const t=$.getDefaultOptions(),n=G.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=be.createChart(Z.current,{...t,rightPriceScale:{...t.rightPriceScale||{},visible:!A,textColor:n},...D});return R.current=l,X.current=!0,()=>{l.remove(),R.current=null,X.current=!1,S.current.clear()}},[A,D]),i.useEffect(()=>{const t=R.current;if(!t||e.length===0)return;const n=L==="time"?oe.getXFormatter(L,P):oe.getXFormatter(L),l=P.map(o=>o.value),{formatter:d,updateVisibleRange:a,updateLastValues:f}=oe.createAdaptiveYAxisFormatter(l);W.current=a,ue.current=f;const b=e.filter(o=>o.data.length>0).map(o=>o.data[o.data.length-1].value);f(b);const x=$.getDefaultOptions();t.applyOptions({localization:{...x.localization||{},timeFormatter:n?(o=>n(parseFloat(o),void 0)):void 0},timeScale:{...x.timeScale||{},tickMarkFormatter:n?(o=>n(parseFloat(o),void 0)):void 0,minBarSpacing:0}});const j=(P.length>0?Math.min(...P.map(o=>o.value)):0)<0,y=P.some(o=>o.value===0),g=!j&&y,s=e.length>1,u=s||A,c=G.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");t.applyOptions({rightPriceScale:{...x.rightPriceScale||{},visible:!A,textColor:c,...g&&{scaleMargins:{top:.3,bottom:0}}}});const h=new Set(S.current.keys()),w=new Set(e.map(o=>o.label));for(const o of h)if(!w.has(o)){const r=S.current.get(o);r&&(t.removeSeries(r),S.current.delete(o))}const O=$.getDefaultSeries(),z=[];let k=0;for(let o=0;o<e.length;o++){const r=e[o],ee=H[o%H.length],B=r.color||ee.line;let _,N;if(r.color)if(r.topColor&&r.bottomColor)_=r.topColor,N=r.bottomColor;else if(r.topColor){const C=G.generateColorsFromBase(B);_=r.topColor,N=C.bottomColor}else if(r.bottomColor)_=G.generateColorsFromBase(B).topColor,N=r.bottomColor;else{const C=G.generateColorsFromBase(B);_=C.topColor,N=C.bottomColor}else _=r.topColor||ee.top,N=r.bottomColor||ee.bottom;if(r.data.length===0){const C=S.current.get(r.label);C&&(t.removeSeries(C),S.current.delete(r.label));continue}const he=(r.data.length>0?Math.min(...r.data.map(C=>C.value)):0)<0,me=r.data.some(C=>C.value===0),pe=!he&&me,te=s?k===0?void 0:`scale-${k}`:void 0;s&&z.push({priceScaleId:te||"right",shouldPreventNegativeAxis:pe,seriesIndex:k});let E=S.current.get(r.label);E?(E.applyOptions({lineColor:B,topColor:_,bottomColor:N,priceScaleId:te,priceFormat:{type:"custom",formatter:d}}),E.setData(r.data)):(E=t.addAreaSeries({...O,lineColor:B,topColor:_,bottomColor:N,priceScaleId:te,priceFormat:{type:"custom",formatter:d}}),E.setData(r.data),S.current.set(r.label,E)),k++}if(s&&z.length>0)for(const o of z)try{const r=t.priceScale(o.priceScaleId);r&&r.applyOptions({visible:!u,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...o.shouldPreventNegativeAxis&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:c})}catch(r){console.warn(`Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,r)}const K=new Set(e.map(o=>o.label)),de=K.size!==Y.current.size||[...K].some(o=>!Y.current.has(o)),ge=P.length!==re.current;(ae.current||de||ge||A)&&(t.timeScale().fitContent(),ae.current=!1),Y.current=K,re.current=P.length;const U=new Map;for(const o of e)o.data.length>0&&U.set(o.label,o.data[o.data.length-1]);Q(U.size>0?U:void 0)},[e,P,L,q,A]),i.useEffect(()=>{const t=R.current;if(!t||e.length===0)return;const n=e.length===1;let l;for(const a of e)if(a.data.length>0){l=a.data[a.data.length-1].time;break}if(!l)return;const d=a=>{const{time:f=l,seriesData:b,point:x}=a||{},v=Array.from(S.current.values());if(!x||!f){const g=new Map;for(const s of e)s.data.length>0&&g.set(s.label,s.data[s.data.length-1]);if(Q(g.size>0?g:void 0),n)M(null);else if(v[0]&&l){const u=t.timeScale().timeToCoordinate(l),c=e[0];if(c.data.length>0){const h=c.data[c.data.length-1].value,w=v[0].priceToCoordinate(h);u!==null&&w!==null&&M({x:u,y:w})}}return}const j=new Map;let y;for(let g=0;g<e.length;g++){const s=e[g],u=v[g];if(!u)continue;const c=b?.get(u),h=c&&"value"in c?c.value:void 0,w=s.data[s.data.length-1],O=h!==void 0?h:w?.value??0;g===0&&(y=O),j.set(s.label,{value:O,time:f})}if(Q(j),y!==void 0&&v[0]){const s=t.timeScale().timeToCoordinate(f),u=v[0].priceToCoordinate(y);if(s!==null&&u!==null){const c=F.current;if(c){const h=c.querySelector(".LightweightChart");if(h){const w=h.getBoundingClientRect(),O=c.getBoundingClientRect(),z=s+(w.left-O.left),k=u+(w.top-O.top);M({x:z,y:k})}else M({x:s,y:u})}else M({x:s,y:u})}else M(null)}else M(null)};return t.subscribeCrosshairMove(d),n||requestAnimationFrame(()=>{const a=Array.from(S.current.values());if(a[0]&&l&&e[0]?.data.length>0){const b=t.timeScale().timeToCoordinate(l),x=e[0].data[e[0].data.length-1].value,v=a[0].priceToCoordinate(x);b!==null&&v!==null&&M({x:b,y:v})}}),()=>{t.unsubscribeCrosshairMove(d)}},[e]),i.useEffect(()=>{const t=R.current;if(!t||e.length===0)return;const n=t.timeScale(),l=Math.max(...e.map(a=>a.data.length)),d=()=>{if(l===0)return;const a=n.getVisibleLogicalRange();if(!a)return;const f={from:0,to:l-1},b=typeof a.from=="number"?a.from:0,x=typeof a.to=="number"?a.to:l-1;if(W.current){const g=Math.max(0,Math.floor(b)),s=Math.min(l-1,Math.ceil(x)),u=[];for(const c of e)for(let h=g;h<=s&&h<c.data.length;h++)u.push(c.data[h].value);u.length>0&&W.current(u)}const v=.01;let j=!1;const y={...a};b<f.from-v&&(y.from=f.from,j=!0),x>f.to+v&&(y.to=f.to,j=!0),j&&n.setVisibleLogicalRange(y)};return n.subscribeVisibleLogicalRangeChange(d),()=>{n.unsubscribeVisibleLogicalRangeChange(d)}},[e]),i.useEffect(()=>{const t=R.current,n=Array.from(S.current.values()),l=[];if(t&&n.length>0&&I){const d=$.getDefaultVerticalLine(),a=n[0];for(const f of I){const b=new xe.VertLine(t,a,f.xCoordinate,{...d,...f.options||{}});a.attachPrimitive(b),l.push(b)}}return()=>{if(n.length>0){const d=n[0];for(const a of l)d.detachPrimitive(a)}}},[I]);const J=e.length===1,ie=ne.useMemo(()=>{if(J&&e.length>0){const t=e[0];if(t.data.length>0)return t.data[t.data.length-1]}},[J,e]);return m.jsxs("div",{ref:F,className:ce.cn("relative z-[1] w-full h-full overflow-hidden p-0",V),children:[J&&ie&&m.jsx(Ce.GraphCurrentValue,{point:ie,xMeasureUnit:L,yMeasureUnit:q}),le&&se&&m.jsx(Se.GraphTooltip,{points:le,xMeasureUnit:L,yMeasureUnit:q,series:e,position:se,containerRef:F}),p&&m.jsx(we,{series:e,onUnselect:T}),m.jsx("div",{ref:Z,className:"LightweightChart w-full h-full overflow-hidden"})]})}function we({series:e,onUnselect:V}){return m.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((p,T)=>{const L=H[T%H.length],q=p.color||L.line,D=p.data.length===0;return m.jsxs("div",{className:ce.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",D&&"opacity-50"),children:[m.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:q}}),m.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[p.label,D&&" (no data)"]}),V&&m.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),V(p.label)},className:"ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer","aria-label":`Remove ${p.label}`,children:m.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-muted-foreground hover:text-foreground","aria-hidden":"true",children:[m.jsx("title",{children:"Close"}),m.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),m.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},p.label)})})}exports.DEFAULT_SERIES_COLORS=H;exports.Graph=ye;
@@ -1,30 +1,30 @@
1
- import { jsxs as c, jsx as t } from "react/jsx-runtime";
1
+ import { jsx as t, jsxs as c } from "react/jsx-runtime";
2
2
  import { useState as b, useEffect as w, useMemo as E } from "react";
3
- import { TooltipProvider as j, Tooltip as U, TooltipTrigger as D, TooltipContent as L } from "../tooltip/tooltip.js";
3
+ import { TooltipProvider as j, Tooltip as U, TooltipTrigger as D, TooltipContent as y } from "../tooltip/tooltip.js";
4
4
  import { cn as u } from "../../utils/cn.js";
5
- const $ = 1e3 * 60 * 10;
5
+ const L = 1e3 * 60 * 10;
6
6
  function B({
7
- blockByChain: s,
7
+ blockByChain: n,
8
8
  explorerAddresses: g,
9
- networkById: h
9
+ networkById: v
10
10
  }) {
11
- const [i, v] = b(Date.now());
11
+ const [i, h] = b(Date.now());
12
12
  w(() => {
13
13
  const r = () => {
14
- v(Date.now());
14
+ h(Date.now());
15
15
  }, e = window.setInterval(r, 1e3);
16
16
  return () => {
17
17
  clearInterval(e);
18
18
  };
19
19
  }, []);
20
20
  const p = E(() => {
21
- if (!s) return 0;
22
- const r = Object.values(s).reduce((e, a) => {
21
+ if (!n) return 0;
22
+ const r = Object.values(n).reduce((e, a) => {
23
23
  const o = a.lastSyncBlock.localTimestamp;
24
24
  return e === 0 || e !== 0 && o < e ? o : e;
25
25
  }, 0);
26
26
  return r ? i - r : 0;
27
- }, [s, i]) > $, m = () => /* @__PURE__ */ c("div", { className: "flex h-[30px] items-center gap-1.5", children: [
27
+ }, [n, i]) > L, m = () => /* @__PURE__ */ c("div", { className: "flex h-[30px] items-center gap-1.5", children: [
28
28
  /* @__PURE__ */ t(
29
29
  "span",
30
30
  {
@@ -44,14 +44,14 @@ function B({
44
44
  )
45
45
  }
46
46
  )
47
- ] }), S = () => {
48
- if (!s) return null;
49
- const r = Object.entries(s);
47
+ ] }), N = () => {
48
+ if (!n) return null;
49
+ const r = Object.entries(n);
50
50
  return /* @__PURE__ */ t("div", { className: "flex flex-col text-left text-xs", children: r.map(([e, a], o) => {
51
- const d = a.lastSyncBlock, l = d?.block || 0n, T = d?.localTimestamp ? i - d.localTimestamp : 0, n = g[Number(e)], f = typeof n == "string" ? n : n && typeof n == "object" && "url" in n ? n.url : void 0, N = h[Number(e)] || "Unknown", x = `[${l.toString()}]`, k = o === r.length - 1;
51
+ const d = a.lastSyncBlock, l = d?.block || 0n, S = d?.localTimestamp ? i - d.localTimestamp : 0, s = g[Number(e)], f = typeof s == "string" ? s : s && typeof s == "object" && "url" in s ? s.url : void 0, T = v[Number(e)] || "Unknown", x = `[${l.toString()}]`, k = o === r.length - 1;
52
52
  return /* @__PURE__ */ c("div", { className: u(!k && "mb-2"), children: [
53
53
  /* @__PURE__ */ c("span", { children: [
54
- N,
54
+ T,
55
55
  " "
56
56
  ] }),
57
57
  f && l > 0 ? /* @__PURE__ */ t(
@@ -66,16 +66,16 @@ function B({
66
66
  ) : /* @__PURE__ */ t("span", { children: x }),
67
67
  l > 0 && /* @__PURE__ */ c("span", { children: [
68
68
  ", updated ",
69
- (T / 1e3).toFixed(0),
69
+ (S / 1e3).toFixed(0),
70
70
  " seconds ago"
71
71
  ] })
72
72
  ] }, e);
73
73
  }) });
74
74
  };
75
- return s ? /* @__PURE__ */ t(j, { children: /* @__PURE__ */ c(U, { children: [
76
- /* @__PURE__ */ t(D, { asChild: !0, children: /* @__PURE__ */ t("div", { className: "cursor-help", children: m() }) }),
77
- /* @__PURE__ */ t(L, { side: "top", collisionPadding: 8, children: S() })
78
- ] }) }) : m();
75
+ return n ? /* @__PURE__ */ t(j, { delayDuration: 200, children: /* @__PURE__ */ c(U, { children: [
76
+ /* @__PURE__ */ t(D, { asChild: !0, children: /* @__PURE__ */ t("div", { className: "cursor-auto select-none", children: m() }) }),
77
+ /* @__PURE__ */ t(y, { side: "top", collisionPadding: 8, children: N() })
78
+ ] }) }) : /* @__PURE__ */ t("div", { className: "select-none", children: m() });
79
79
  }
80
80
  export {
81
81
  B as BlockSync
@@ -1,74 +1,126 @@
1
- import { DateTime as a } from "luxon";
2
- import { isBelowDisplayThreshold as m, FORMAT_CONSTANTS as S, toSignificantDigits as $, formatNumberWithSuffix as h } from "../../utils/format-number.js";
3
- const { MIN_DISPLAY_THRESHOLD: o, MAX_EXPONENTIAL_THRESHOLD: D } = S, M = (t, r, e = "full") => {
4
- if (m(t))
5
- return r ? `<${o}${r}` : `<${o}`;
1
+ import { DateTime as d } from "luxon";
2
+ import { isBelowDisplayThreshold as h, FORMAT_CONSTANTS as I, toSignificantDigits as x, formatNumberWithSuffix as T } from "../../utils/format-number.js";
3
+ const { MIN_DISPLAY_THRESHOLD: c, MAX_EXPONENTIAL_THRESHOLD: L } = I, H = (t, e, r = "full") => {
4
+ if (h(t))
5
+ return e ? `<${c}${e}` : `<${c}`;
6
6
  if (t === 0)
7
- return r ? `0${r}` : "0";
8
- const n = h(t, {
9
- maxExponentialThreshold: D,
7
+ return e ? `0${e}` : "0";
8
+ const n = T(t, {
9
+ maxExponentialThreshold: L,
10
10
  minimumFractionDigits: 0,
11
- maximumFractionDigits: e === "short" ? 1 : 0,
12
- format: e,
13
- adaptiveDecimals: e === "short"
11
+ maximumFractionDigits: r === "short" ? 1 : 0,
12
+ format: r,
13
+ adaptiveDecimals: r === "short"
14
14
  });
15
- return r ? `${n}${r}` : n;
16
- }, g = 2, F = (t, r) => {
17
- if (m(t))
18
- return r ? `<${o}${r}` : `<${o}`;
15
+ return e ? `${n}${e}` : n;
16
+ }, R = 2, p = (t, e) => {
17
+ if (h(t))
18
+ return e ? `<${c}${e}` : `<${c}`;
19
19
  if (t === 0)
20
- return r ? `0${r}` : "0";
21
- const e = $(t, g);
22
- return r ? `${e}${r}` : e;
23
- }, N = 4, E = (t) => {
24
- if (m(t))
25
- return `<${o}`;
20
+ return e ? `0${e}` : "0";
21
+ const r = x(t, R);
22
+ return e ? `${r}${e}` : r;
23
+ }, _ = 4, O = (t) => {
24
+ if (h(t))
25
+ return `<${c}`;
26
26
  if (t === 0)
27
27
  return "0";
28
- const r = Math.round(t), e = Math.abs(t - r);
29
- return e > 0 && e < 0.01 ? t.toFixed(12).replace(/0+$/, "").replace(/\.$/, "") : $(t, N);
30
- }, I = (t, r) => {
31
- if (m(t))
32
- return r ? `<${o} ${r}` : `<${o}`;
28
+ const e = Math.round(t), r = Math.abs(t - e);
29
+ return r > 0 && r < 0.01 ? t.toFixed(12).replace(/0+$/, "").replace(/\.$/, "") : x(t, _);
30
+ }, G = (t, e) => {
31
+ if (h(t))
32
+ return e ? `<${c} ${e}` : `<${c}`;
33
33
  if (t === 0)
34
- return r ? `0 ${r}` : "0";
35
- const e = Number.isInteger(t), n = Math.abs(t), i = e && n >= 1e3, T = Math.round(t), c = Math.abs(t - T);
36
- if (c > 0 && c < 0.01 && !i) {
37
- const f = t.toFixed(12).replace(/0+$/, "").replace(/\.$/, "");
38
- return r ? `${f} ${r}` : f;
34
+ return e ? `0 ${e}` : "0";
35
+ const r = Number.isInteger(t), n = Math.abs(t), s = r && n >= 1e3, S = Math.round(t), g = Math.abs(t - S);
36
+ if (g > 0 && g < 0.01 && !s) {
37
+ const M = t.toFixed(12).replace(/0+$/, "").replace(/\.$/, "");
38
+ return e ? `${M} ${e}` : M;
39
39
  }
40
- const s = h(t, {
41
- maxExponentialThreshold: D,
42
- minimumFractionDigits: e ? 0 : 2,
43
- maximumFractionDigits: i ? 1 : e ? 0 : 2,
44
- format: i ? "short" : "full",
45
- adaptiveDecimals: i
40
+ const F = T(t, {
41
+ maxExponentialThreshold: L,
42
+ minimumFractionDigits: r ? 0 : 2,
43
+ maximumFractionDigits: s ? 1 : r ? 0 : 2,
44
+ format: s ? "short" : "full",
45
+ adaptiveDecimals: s
46
46
  });
47
- return r ? `${s} ${r}` : s;
48
- }, u = {
49
- "%": F,
50
- $: M,
51
- token: I,
52
- none: E
53
- }, R = (t) => u[t] || u.token, p = (t) => a.fromSeconds(Number(t)).toFormat("dd/LL/yyyy HH:mm"), A = (t) => a.fromSeconds(Number(t)).toFormat("HH:mm"), x = () => {
47
+ return e ? `${F} ${e}` : F;
48
+ }, D = {
49
+ "%": p,
50
+ $: H,
51
+ token: G,
52
+ none: O
53
+ }, k = (t) => D[t] || D.token;
54
+ function w(t, e, r = 8) {
55
+ if (t === 0)
56
+ return e ? `0 ${e}` : "0";
57
+ const n = t.toLocaleString("en-US", {
58
+ minimumFractionDigits: 0,
59
+ maximumFractionDigits: r
60
+ });
61
+ return e ? `${n} ${e}` : n;
62
+ }
63
+ function z(t, e) {
64
+ let r = t.length > 0 ? Math.min(...t) : 0, n = t.length > 0 ? Math.max(...t) : 0, s = [];
65
+ const S = () => {
66
+ const o = n - r, a = (r + n) / 2;
67
+ let i = 1, m = "";
68
+ a >= 1e9 ? (i = 1e9, m = "B") : a >= 1e6 ? (i = 1e6, m = "M") : a >= 1e3 && (i = 1e3, m = "K");
69
+ const f = o / 10 / i;
70
+ let u = 1;
71
+ if (f > 0) {
72
+ const A = Math.floor(Math.log10(f));
73
+ u = Math.max(1, -A), u = Math.min(u, 4);
74
+ }
75
+ return { scale: i, suffix: m, decimals: u };
76
+ }, g = (o, a, i) => a > 1 ? `${(o / a).toLocaleString("en-US", {
77
+ minimumFractionDigits: 0,
78
+ maximumFractionDigits: 4,
79
+ useGrouping: !1
80
+ })}${i}` : o.toLocaleString("en-US", {
81
+ minimumFractionDigits: 0,
82
+ maximumFractionDigits: 4,
83
+ useGrouping: !1
84
+ });
85
+ return { formatter: (o) => {
86
+ if (o === 0) return "0";
87
+ const { scale: a, suffix: i, decimals: m } = S(), $ = Math.abs(o) * 1e-10 || 1e-10;
88
+ return s.some((f) => Math.abs(f - o) < $) ? g(o, a, i) : a > 1 ? `${(o / a).toLocaleString("en-US", {
89
+ minimumFractionDigits: 0,
90
+ maximumFractionDigits: m,
91
+ useGrouping: !1
92
+ })}${i}` : o.toLocaleString("en-US", {
93
+ minimumFractionDigits: 0,
94
+ maximumFractionDigits: m,
95
+ useGrouping: !1
96
+ });
97
+ }, updateVisibleRange: (o) => {
98
+ o.length > 0 && (r = Math.min(...o), n = Math.max(...o));
99
+ }, updateLastValues: (o) => {
100
+ s = [...o];
101
+ } };
102
+ }
103
+ const U = (t) => d.fromSeconds(Number(t)).toFormat("dd/LL/yyyy HH:mm"), X = (t) => d.fromSeconds(Number(t)).toFormat("HH:mm"), C = () => {
54
104
  let t = null;
55
- return (r) => {
56
- const e = a.fromSeconds(Number(r)), n = e.toFormat("yyyy-MM-dd");
57
- return n !== t ? (t = n, e.toFormat("dd MMM")) : e.toFormat("HH:mm");
105
+ return (e) => {
106
+ const r = d.fromSeconds(Number(e)), n = r.toFormat("yyyy-MM-dd");
107
+ return n !== t ? (t = n, r.toFormat("dd MMM")) : r.toFormat("HH:mm");
58
108
  };
59
- }, H = (t, r) => F(Number(t), r), d = {
60
- time: p,
61
- "%": H
62
- }, X = (t, r) => {
63
- if (t === "time" && r && r.length > 0) {
64
- const e = a.fromSeconds(Number(r[0].time)), n = a.fromSeconds(
65
- Number(r[r.length - 1].time)
109
+ }, P = (t, e) => p(Number(t), e), l = {
110
+ time: U,
111
+ "%": P
112
+ }, B = (t, e) => {
113
+ if (t === "time" && e && e.length > 0) {
114
+ const r = d.fromSeconds(Number(e[0].time)), n = d.fromSeconds(
115
+ Number(e[e.length - 1].time)
66
116
  );
67
- return e.hasSame(n, "day") ? A : x();
117
+ return r.hasSame(n, "day") ? X : C();
68
118
  }
69
- return d[t] || d.time;
119
+ return l[t] || l.time;
70
120
  };
71
121
  export {
72
- X as getXFormatter,
73
- R as getYFormatter
122
+ z as createAdaptiveYAxisFormatter,
123
+ w as formatExactValue,
124
+ B as getXFormatter,
125
+ k as getYFormatter
74
126
  };
@@ -1,27 +1,27 @@
1
- import { jsxs as a, jsx as r } from "react/jsx-runtime";
2
- import { cn as d } from "../../utils/cn.js";
3
- import { getXFormatter as x, getYFormatter as c } from "./formatters.js";
4
- function u({
5
- point: t,
6
- xMeasureUnit: e,
7
- yMeasureUnit: o,
8
- className: m
1
+ import { jsxs as n, jsx as m } from "react/jsx-runtime";
2
+ import { cn as x } from "../../utils/cn.js";
3
+ import { getXFormatter as c, formatExactValue as o } from "./formatters.js";
4
+ function h({
5
+ point: e,
6
+ xMeasureUnit: r,
7
+ yMeasureUnit: t,
8
+ className: l
9
9
  }) {
10
- const s = x(e), n = c(o), i = s(t.time, e), l = n(t.value, o);
11
- return /* @__PURE__ */ a(
10
+ const s = c(r)(e.time, r), a = t !== "%" && t !== "$" && t !== "none" ? t : void 0, d = t === "$" ? `$${o(e.value)}` : t === "%" ? `${o(e.value)}%` : o(e.value, a);
11
+ return /* @__PURE__ */ n(
12
12
  "div",
13
13
  {
14
- className: d(
14
+ className: x(
15
15
  "absolute top-2 left-2 right-2 z-[100] pointer-events-none",
16
- m
16
+ l
17
17
  ),
18
18
  children: [
19
- /* @__PURE__ */ r("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: l }),
20
- /* @__PURE__ */ r("div", { className: "text-xs sm:text-sm font-medium text-muted-foreground whitespace-nowrap overflow-hidden text-ellipsis mt-0.5", children: i })
19
+ /* @__PURE__ */ m("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: d }),
20
+ /* @__PURE__ */ m("div", { className: "text-xs sm:text-sm font-medium text-muted-foreground whitespace-nowrap overflow-hidden text-ellipsis mt-0.5", children: s })
21
21
  ]
22
22
  }
23
23
  );
24
24
  }
25
25
  export {
26
- u as GraphCurrentValue
26
+ h as GraphCurrentValue
27
27
  };
@@ -1,88 +1,84 @@
1
- import { jsx as d, jsxs as p } from "react/jsx-runtime";
2
- import { useRef as Y, useState as j, useEffect as k } from "react";
3
- import { cn as E } from "../../utils/cn.js";
4
- import { getXFormatter as P, getYFormatter as A } from "./formatters.js";
5
- import { DEFAULT_SERIES_COLORS as b } from "./graph.js";
1
+ import { jsx as m, jsxs as p } from "react/jsx-runtime";
2
+ import { useRef as S, useState as j, useEffect as k } from "react";
3
+ import { cn as P } from "../../utils/cn.js";
4
+ import { getXFormatter as A, formatExactValue as h } from "./formatters.js";
5
+ import { DEFAULT_SERIES_COLORS as y } from "./graph.js";
6
6
  function T({
7
- points: u,
8
- series: y,
9
- xMeasureUnit: h,
10
- yMeasureUnit: v,
11
- className: F,
12
- position: e,
13
- containerRef: x
7
+ points: d,
8
+ series: v,
9
+ xMeasureUnit: x,
10
+ yMeasureUnit: N,
11
+ className: R,
12
+ position: t,
13
+ containerRef: g
14
14
  }) {
15
- const g = Y(null), [f, c] = j(e), N = P(h);
15
+ const b = S(null), [u, l] = j(t), $ = A(x);
16
16
  k(() => {
17
- if (!e) {
18
- c(e);
17
+ if (!t) {
18
+ l(t);
19
19
  return;
20
20
  }
21
- const t = x?.current;
22
- if (!t) {
23
- c(e);
21
+ const r = g?.current;
22
+ if (!r) {
23
+ l(t);
24
24
  return;
25
25
  }
26
- const i = g.current;
27
- if (!i) {
28
- c(e);
26
+ const c = b.current;
27
+ if (!c) {
28
+ l(t);
29
29
  return;
30
30
  }
31
- const s = t.getBoundingClientRect(), m = i.getBoundingClientRect();
32
- let o = e.x, r = e.y;
33
- const a = m.width, n = m.height, l = 8;
34
- o - a / 2 < l ? o = a / 2 + l : o + a / 2 > s.width - l && (o = s.width - a / 2 - l);
35
- const w = n + 8;
36
- r - w < l ? r = e.y + 20 : r = e.y - w, c({ x: o, y: r });
37
- }, [e, x]);
38
- const R = f ? {
39
- left: `${f.x}px`,
40
- top: `${f.y}px`,
31
+ const o = r.getBoundingClientRect(), i = c.getBoundingClientRect();
32
+ let n = t.x, e = t.y;
33
+ const s = i.width, f = i.height, a = 8;
34
+ n - s / 2 < a ? n = s / 2 + a : n + s / 2 > o.width - a && (n = o.width - s / 2 - a);
35
+ const w = f + 8;
36
+ e - w < a ? e = t.y + 20 : e = t.y - w, l({ x: n, y: e });
37
+ }, [t, g]);
38
+ const C = u ? {
39
+ left: `${u.x}px`,
40
+ top: `${u.y}px`,
41
41
  transform: "translate(-50%, 0)"
42
42
  // Center horizontally
43
43
  } : {};
44
- if (u.size === 0)
44
+ if (d.size === 0)
45
45
  return null;
46
- const C = Array.from(u.values())[0], S = N(C.time, h);
47
- return /* @__PURE__ */ d(
46
+ const E = Array.from(d.values())[0], F = $(E.time, x);
47
+ return /* @__PURE__ */ m(
48
48
  "div",
49
49
  {
50
- ref: g,
51
- className: E(
50
+ ref: b,
51
+ className: P(
52
52
  "absolute z-[100] pointer-events-none whitespace-nowrap",
53
- F
53
+ R
54
54
  ),
55
- style: R,
55
+ style: C,
56
56
  children: /* @__PURE__ */ p("div", { className: "bg-background/90 backdrop-blur-sm rounded border border-border p-1.5 sm:p-2 space-y-1 sm:space-y-1.5", children: [
57
- /* @__PURE__ */ d("div", { className: "text-xs sm:text-sm font-medium text-muted-foreground mb-0.5 sm:mb-1 whitespace-nowrap", children: S }),
58
- y.map((t, i) => {
59
- const s = u.get(t.label);
60
- if (!s) return null;
61
- const m = b[i % b.length], o = t.color || m.line, r = t.yMeasureUnit || v;
62
- let n = A(r)(
63
- s.value,
64
- r === "none" ? void 0 : r
65
- );
66
- return n.endsWith(" none") && (n = n.slice(0, -5)), /* @__PURE__ */ p(
57
+ /* @__PURE__ */ m("div", { className: "text-xs sm:text-sm font-medium text-muted-foreground mb-0.5 sm:mb-1 whitespace-nowrap", children: F }),
58
+ v.map((r, c) => {
59
+ const o = d.get(r.label);
60
+ if (!o) return null;
61
+ const i = y[c % y.length], n = r.color || i.line, e = r.yMeasureUnit || N, s = e !== "%" && e !== "$" && e !== "none" ? e : void 0, f = e === "$" ? `$${h(o.value)}` : e === "%" ? `${h(o.value)}%` : h(o.value, s);
62
+ return /* @__PURE__ */ p(
67
63
  "div",
68
64
  {
69
65
  className: "flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm whitespace-nowrap",
70
66
  children: [
71
- /* @__PURE__ */ d(
67
+ /* @__PURE__ */ m(
72
68
  "div",
73
69
  {
74
70
  className: "w-1.5 h-1.5 sm:w-2 sm:h-2 rounded-full flex-shrink-0",
75
- style: { backgroundColor: o }
71
+ style: { backgroundColor: n }
76
72
  }
77
73
  ),
78
74
  /* @__PURE__ */ p("span", { className: "text-muted-foreground whitespace-nowrap", children: [
79
- t.label,
75
+ r.label,
80
76
  ":"
81
77
  ] }),
82
- /* @__PURE__ */ d("span", { className: "font-medium text-foreground whitespace-nowrap", children: n })
78
+ /* @__PURE__ */ m("span", { className: "font-medium text-foreground whitespace-nowrap", children: f })
83
79
  ]
84
80
  },
85
- t.label
81
+ r.label
86
82
  );
87
83
  })
88
84
  ] })