@gearbox-protocol/permissionless-ui 1.17.7 → 1.17.9

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 r=require("../../utils/colors.cjs"),o={topColor:"rgba(76, 175, 80, 0.56)",bottomColor:"rgba(76, 175, 80, 0.04)",lineColor:"#02c39a",lineWidth:2},l={showLabel:!0,color:"#02c39a",labelBackgroundColor:"#02c39a",width:2};function t(){const e=r.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");return{timeScale:{borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",visible:!0},rightPriceScale:{autoScale:!0,alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:e},layout:{background:{color:"transparent"},textColor:e,fontSize:14},crosshair:{horzLine:{width:2,color:"rgba(224, 227, 235, 0.1)",style:0,labelVisible:!1},vertLine:{width:2,color:"rgba(224, 227, 235, 0.1)",style:0,labelVisible:!1}},grid:{vertLines:{visible:!1},horzLines:{visible:!1}}}}function i(){return{topColor:"rgba(76, 175, 80, 0.56)",bottomColor:"rgba(76, 175, 80, 0.04)",lineColor:o.lineColor,lineWidth:2}}function a(){const e=r.resolveCSSColor("hsl(var(--primary))","rgb(76, 175, 80)");return{showLabel:!0,color:e,labelBackgroundColor:e,width:2}}const s={timeScale:{borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",visible:!0},rightPriceScale:{autoScale:!0,alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1},layout:{background:{color:"transparent"},textColor:"rgb(0, 0, 0)",fontSize:14},crosshair:{horzLine:{width:2,color:"rgba(224, 227, 235, 0.1)",style:0,labelVisible:!1},vertLine:{width:2,color:"rgba(224, 227, 235, 0.1)",style:0,labelVisible:!1}},grid:{vertLines:{visible:!1},horzLines:{visible:!1}}};exports.DEFAULT_AREA_SERIES=o;exports.DEFAULT_OPTIONS=s;exports.DEFAULT_VERTICAL_LINE=l;exports.getDefaultOptions=t;exports.getDefaultSeries=i;exports.getDefaultVerticalLine=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../utils/colors.cjs"),o={topColor:"rgba(76, 175, 80, 0.56)",bottomColor:"rgba(76, 175, 80, 0.04)",lineColor:"#02c39a",lineWidth:2},l={showLabel:!0,color:"#02c39a",labelBackgroundColor:"#02c39a",width:2};function t(){const e=r.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");return{timeScale:{borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",visible:!0},rightPriceScale:{visible:!0,autoScale:!0,alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:e},layout:{background:{color:"transparent"},textColor:e,fontSize:14},crosshair:{horzLine:{width:2,color:"rgba(224, 227, 235, 0.1)",style:0,labelVisible:!1},vertLine:{width:2,color:"rgba(224, 227, 235, 0.1)",style:0,labelVisible:!1}},grid:{vertLines:{visible:!1},horzLines:{visible:!1}}}}function i(){return{topColor:"rgba(76, 175, 80, 0.56)",bottomColor:"rgba(76, 175, 80, 0.04)",lineColor:o.lineColor,lineWidth:2}}function a(){const e=r.resolveCSSColor("hsl(var(--primary))","rgb(76, 175, 80)");return{showLabel:!0,color:e,labelBackgroundColor:e,width:2}}const s={timeScale:{borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",visible:!0},rightPriceScale:{visible:!0,autoScale:!0,alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1},layout:{background:{color:"transparent"},textColor:"rgb(0, 0, 0)",fontSize:14},crosshair:{horzLine:{width:2,color:"rgba(224, 227, 235, 0.1)",style:0,labelVisible:!1},vertLine:{width:2,color:"rgba(224, 227, 235, 0.1)",style:0,labelVisible:!1}},grid:{vertLines:{visible:!1},horzLines:{visible:!1}}};exports.DEFAULT_AREA_SERIES=o;exports.DEFAULT_OPTIONS=s;exports.DEFAULT_VERTICAL_LINE=l;exports.getDefaultOptions=t;exports.getDefaultSeries=i;exports.getDefaultVerticalLine=a;
@@ -1 +1 @@
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
+ "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=4){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 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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),d=require("../../utils/cn.cjs"),o=require("./formatters.cjs");function i({point:e,xMeasureUnit:a,yMeasureUnit:t,className:l,decimals:r}){const n=o.getXFormatter(a)(e.time,a),m=t!=="%"&&t!=="$"&&t!=="none"?t:void 0,c=t==="$"?`$${o.formatExactValue(e.value,void 0,r)}`:t==="%"?`${o.formatExactValue(e.value,void 0,r)}%`:o.formatExactValue(e.value,m,r);return s.jsxs("div",{className:d.cn("absolute top-2 left-2 right-2 z-[100] pointer-events-none",l),children:[s.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:c}),s.jsx("div",{className:"text-xs sm:text-sm font-medium text-muted-foreground whitespace-nowrap overflow-hidden text-ellipsis mt-0.5",children:n})]})}exports.GraphCurrentValue=i;
@@ -1 +1 @@
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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),h=require("react"),C=require("../../utils/cn.cjs"),d=require("./formatters.cjs"),v=require("./graph.cjs");function F({points:m,series:j,xMeasureUnit:g,yMeasureUnit:R,className:E,position:t,containerRef:b,decimals:f}){const y=h.useRef(null),[p,l]=h.useState(t),S=d.getXFormatter(g);h.useEffect(()=>{if(!t){l(t);return}const r=b?.current;if(!r){l(t);return}const i=y.current;if(!i){l(t);return}const s=r.getBoundingClientRect(),u=i.getBoundingClientRect();let o=t.x,e=t.y;const a=u.width,x=u.height,c=8;o-a/2<c?o=a/2+c:o+a/2>s.width-c&&(o=s.width-a/2-c);const w=x+8;e-w<c?e=t.y+20:e=t.y-w,l({x:o,y:e})},[t,b]);const _=p?{left:`${p.x}px`,top:`${p.y}px`,transform:"translate(-50%, 0)"}:{};if(m.size===0)return null;const N=Array.from(m.values())[0],$=S(N.time,g);return n.jsx("div",{ref:y,className:C.cn("absolute z-[100] pointer-events-none whitespace-nowrap",E),style:_,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:$}),j.map((r,i)=>{const s=m.get(r.label);if(!s)return null;const u=v.DEFAULT_SERIES_COLORS[i%v.DEFAULT_SERIES_COLORS.length],o=r.color||u.line,e=r.yMeasureUnit||R,a=e!=="%"&&e!=="$"&&e!=="none"?e:void 0,x=e==="$"?`$${d.formatExactValue(s.value,void 0,f)}`:e==="%"?`${d.formatExactValue(s.value,void 0,f)}%`:d.formatExactValue(s.value,a,f);return 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:o}}),n.jsxs("span",{className:"text-muted-foreground whitespace-nowrap",children:[r.label,":"]}),n.jsx("span",{className:"font-medium text-foreground whitespace-nowrap",children:x})]},r.label)})]})})}exports.GraphTooltip=F;
@@ -1 +1 @@
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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),ve=require("lightweight-charts"),i=require("react"),Ce=require("../../hooks/use-media-query.cjs"),ue=require("../../utils/cn.cjs"),G=require("../../utils/colors.cjs"),Y=require("./default-config.cjs"),oe=require("./formatters.cjs"),Se=require("./graph-current-value.cjs"),xe=require("./graph-tooltip.cjs"),Re=require("./plugins/vertical-line.cjs");function ye(e){const V=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const p in e)if(p!=="default"){const A=Object.getOwnPropertyDescriptor(e,p);Object.defineProperty(V,p,A.get?A:{enumerable:!0,get:()=>e[p]})}}return V.default=e,Object.freeze(V)}const re=ye(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 we({series:e,className:V,showLegend:p=!1,onUnselectSeries:A,xMeasureUnit:L="time",yMeasureUnit:q="token",optionsOverrides:I,verticalLineOptions:z,currentValueDecimals:ne}){const R=i.useRef(null),S=i.useRef(new Map),$=i.useRef(!1),X=i.useRef(new Set),ae=i.useRef(0),le=i.useRef(!0),W=i.useRef(null),fe=i.useRef(null),F=i.useRef(null),Z=i.useRef(null),N=Ce.useIsMobile(),P=re.useMemo(()=>e.flatMap(o=>o.data),[e]),de=re.useMemo(()=>{if(e.length>0){const o=e[e.length-1];if(o.data.length>0)return o.data[o.data.length-1]}},[e]),[se,Q]=i.useState(()=>{if(!de)return;const o=new Map;for(const r of e)r.data.length>0&&o.set(r.label,r.data[r.data.length-1]);return o}),[ie,M]=i.useState(null);i.useEffect(()=>{const o=()=>{if(R.current&&F.current){const g=F.current.clientWidth,a=F.current.clientHeight;R.current.resize(g,a),R.current.timeScale().fitContent()}},r=F.current,l=r?new ResizeObserver(o):null;return r&&l?.observe(r),()=>{r&&l?.unobserve(r)}},[]),i.useEffect(()=>{if(!Z.current||$.current)return;const o=Y.getDefaultOptions(),r=G.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=ve.createChart(Z.current,{...o,rightPriceScale:{...o.rightPriceScale||{},visible:!N,textColor:r},...I});return R.current=l,$.current=!0,()=>{l.remove(),R.current=null,$.current=!1,S.current.clear()}},[N,I]),i.useEffect(()=>{const o=R.current;if(!o||e.length===0)return;const r=L==="time"?oe.getXFormatter(L,P):oe.getXFormatter(L),l=P.map(t=>t.value),{formatter:g,updateVisibleRange:a,updateLastValues:f}=oe.createAdaptiveYAxisFormatter(l);W.current=a,fe.current=f;const b=e.filter(t=>t.data.length>0).map(t=>t.data[t.data.length-1].value);f(b);const x=Y.getDefaultOptions();o.applyOptions({localization:{...x.localization||{},timeFormatter:r?(t=>r(parseFloat(t),void 0)):void 0},timeScale:{...x.timeScale||{},tickMarkFormatter:r?(t=>r(parseFloat(t),void 0)):void 0,minBarSpacing:0}});const j=(P.length>0?Math.min(...P.map(t=>t.value)):0)<0,y=P.some(t=>t.value===0),d=!j&&y,s=e.length>1,u=s||N,c=G.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");o.applyOptions({rightPriceScale:{...x.rightPriceScale||{},visible:!u,textColor:c,...d&&{scaleMargins:{top:.3,bottom:0}}}});const h=new Set(S.current.keys()),w=new Set(e.map(t=>t.label));for(const t of h)if(!w.has(t)){const n=S.current.get(t);n&&(o.removeSeries(n),S.current.delete(t))}const O=Y.getDefaultSeries(),D=[];let k=0;for(let t=0;t<e.length;t++){const n=e[t],ee=H[t%H.length],B=n.color||ee.line;let T,_;if(n.color)if(n.topColor&&n.bottomColor)T=n.topColor,_=n.bottomColor;else if(n.topColor){const C=G.generateColorsFromBase(B);T=n.topColor,_=C.bottomColor}else if(n.bottomColor)T=G.generateColorsFromBase(B).topColor,_=n.bottomColor;else{const C=G.generateColorsFromBase(B);T=C.topColor,_=C.bottomColor}else T=n.topColor||ee.top,_=n.bottomColor||ee.bottom;if(n.data.length===0){const C=S.current.get(n.label);C&&(o.removeSeries(C),S.current.delete(n.label));continue}const me=(n.data.length>0?Math.min(...n.data.map(C=>C.value)):0)<0,pe=n.data.some(C=>C.value===0),be=!me&&pe,te=s?k===0?"right":`scale-${k}`:"right";s&&D.push({priceScaleId:te||"right",shouldPreventNegativeAxis:be,seriesIndex:k});let E=S.current.get(n.label);E?(E.applyOptions({lineColor:B,topColor:T,bottomColor:_,priceScaleId:te,priceFormat:{type:"custom",formatter:g}}),E.setData(n.data)):(E=o.addAreaSeries({...O,lineColor:B,topColor:T,bottomColor:_,priceScaleId:te,priceFormat:{type:"custom",formatter:g}}),E.setData(n.data),S.current.set(n.label,E)),k++}if(s&&D.length>0)for(const t of D)try{const n=o.priceScale(t.priceScaleId);n&&n.applyOptions({visible:!1,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...t.shouldPreventNegativeAxis&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:c})}catch(n){console.warn(`Failed to configure price scale ${t.priceScaleId} for series ${t.seriesIndex}:`,n)}else if(!s)try{const t=o.priceScale("right");t&&t.applyOptions({visible:!N,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...d&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:c})}catch{}const K=new Set(e.map(t=>t.label)),ge=K.size!==X.current.size||[...K].some(t=>!X.current.has(t)),he=P.length!==ae.current;(le.current||ge||he||N)&&(o.timeScale().fitContent(),le.current=!1),X.current=K,ae.current=P.length;const U=new Map;for(const t of e)t.data.length>0&&U.set(t.label,t.data[t.data.length-1]);Q(U.size>0?U:void 0)},[e,P,L,q,N]),i.useEffect(()=>{const o=R.current;if(!o||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 g=a=>{const{time:f=l,seriesData:b,point:x}=a||{},v=Array.from(S.current.values());if(!x||!f){const d=new Map;for(const s of e)s.data.length>0&&d.set(s.label,s.data[s.data.length-1]);if(Q(d.size>0?d:void 0),r)M(null);else if(v[0]&&l){const u=o.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 d=0;d<e.length;d++){const s=e[d],u=v[d];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;d===0&&(y=O),j.set(s.label,{value:O,time:f})}if(Q(j),y!==void 0&&v[0]){const s=o.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(),D=s+(w.left-O.left),k=u+(w.top-O.top);M({x:D,y:k})}else M({x:s,y:u})}else M({x:s,y:u})}else M(null)}else M(null)};return o.subscribeCrosshairMove(g),r||requestAnimationFrame(()=>{const a=Array.from(S.current.values());if(a[0]&&l&&e[0]?.data.length>0){const b=o.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})}}),()=>{o.unsubscribeCrosshairMove(g)}},[e]),i.useEffect(()=>{const o=R.current;if(!o||e.length===0)return;const r=o.timeScale(),l=Math.max(...e.map(a=>a.data.length)),g=()=>{if(l===0)return;const a=r.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 d=Math.max(0,Math.floor(b)),s=Math.min(l-1,Math.ceil(x)),u=[];for(const c of e)for(let h=d;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&&r.setVisibleLogicalRange(y)};return r.subscribeVisibleLogicalRangeChange(g),()=>{r.unsubscribeVisibleLogicalRangeChange(g)}},[e]),i.useEffect(()=>{const o=R.current,r=Array.from(S.current.values()),l=[];if(o&&r.length>0&&z){const g=Y.getDefaultVerticalLine(),a=r[0];for(const f of z){const b=new Re.VertLine(o,a,f.xCoordinate,{...g,...f.options||{}});a.attachPrimitive(b),l.push(b)}}return()=>{if(r.length>0){const g=r[0];for(const a of l)g.detachPrimitive(a)}}},[z]);const J=e.length===1,ce=re.useMemo(()=>{if(J&&e.length>0){const o=e[0];if(o.data.length>0)return o.data[o.data.length-1]}},[J,e]);return m.jsxs("div",{ref:F,className:ue.cn("relative z-[1] w-full h-full overflow-hidden p-0",V),children:[J&&ce&&m.jsx(Se.GraphCurrentValue,{point:ce,xMeasureUnit:L,yMeasureUnit:q,decimals:ne}),se&&ie&&m.jsx(xe.GraphTooltip,{points:se,xMeasureUnit:L,yMeasureUnit:q,series:e,position:ie,containerRef:F,decimals:ne}),p&&m.jsx(Ve,{series:e,onUnselect:A}),m.jsx("div",{ref:Z,className:"LightweightChart w-full h-full overflow-hidden"})]})}function Ve({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,A)=>{const L=H[A%H.length],q=p.color||L.line,I=p.data.length===0;return m.jsxs("div",{className:ue.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",I&&"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,I&&" (no data)"]}),V&&m.jsx("button",{type:"button",onClick:z=>{z.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=we;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),F=require("sonner"),B=require("../../hooks/use-media-query.cjs"),W=require("../buttons/range-buttons/range-buttons.cjs"),l=require("../graph/graph.cjs"),z=require("../graph/graph-view.cjs"),H=require("./graph-dropdown.cjs"),P=({size:t=16})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Expand fullscreen",children:[e.jsx("title",{children:"Expand fullscreen"}),e.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})]}),$=({size:t=16})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Exit fullscreen",children:[e.jsx("title",{children:"Exit fullscreen"}),e.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"})]});function Q({data:t,yMeasureUnit:n,height:h=306,defaultGraph:g,onGraphSelected:v,graphs:b,isMultipleSelect:y,range:A,rangeList:E,setRange:L,onGraphExpanded:w,isGraphExpanded:R,onUnselectSeries:C,graphsWithNoData:D,loadingGraphs:I,noDataMessage:j="No data available for this graph"}){const a=i.useMemo(()=>Array.isArray(t)?t:t?[t]:[],[t]),S=i.useMemo(()=>Array.isArray(t)&&t.length>1,[t]),k=B.useIsMobile(),O=i.useCallback((c,f)=>{F.toast.error(j)},[j]),N=i.useMemo(()=>{if(n)return Array.isArray(n)?n[0]:n},[n]),M=e.jsxs("div",{className:"z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2",children:[e.jsx("div",{children:v&&b&&g&&e.jsx(H.GraphDropdown,{onSelected:v,items:b,defaultItem:g,multiple:y,graphsWithNoData:D,loadingGraphs:I,onNoDataSelected:O})}),e.jsxs("div",{className:"flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1",children:[e.jsx(W.RangeButtons,{range:A,rangeList:E,setRange:L}),!k&&w&&e.jsx("button",{type:"button",className:"px-2.5 py-1.5 flex min-w-[44px] min-h-[26px] justify-center items-center text-xs leading-[14px] font-medium text-center rounded-md border cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring bg-muted border-muted text-muted-foreground hover:border-secondary ml-1.5",onClick:w,children:R?e.jsx($,{size:16}):e.jsx(P,{size:16})})]})]}),u=i.useRef(new Map),x=i.useRef(0),T=i.useMemo(()=>{const c=Array.isArray(n)?n:void 0;return a.map((f,_)=>{const d=f?.title||`Series ${_+1}`;if(!u.current.has(d)){const r=new Set(Array.from(u.current.values()));let o=x.current;for(let s=0;s<l.DEFAULT_SERIES_COLORS.length;s++){const m=(x.current+s)%l.DEFAULT_SERIES_COLORS.length;if(!r.has(m)){o=m;break}}u.current.set(d,o),x.current=(o+1)%l.DEFAULT_SERIES_COLORS.length}const V=u.current.get(d)??0,p=l.DEFAULT_SERIES_COLORS[V%l.DEFAULT_SERIES_COLORS.length];return{data:[...f?.data||[]].sort((r,o)=>{const s=typeof r.time=="number"?r.time:Number(r.time),m=typeof o.time=="number"?o.time:Number(o.time);return s-m}).reduce((r,o)=>{const s=o.time;return r.length===0||r[r.length-1].time!==s?r.push({time:s,value:o.value}):r[r.length-1]={time:s,value:o.value},r},[]),label:d,yMeasureUnit:c?.[_]??(Array.isArray(n)?void 0:n),color:p.line,topColor:p.top,bottomColor:p.bottom}})},[a,n]),q=S&&a.length>0?a.some(c=>!c):!t;return e.jsx("div",{style:{width:"100%",height:h?`${h}px`:void 0},className:"w-full",children:e.jsx(z.GraphViewWithData,{series:T,loading:q,toolbar:M,size:h?"full":"default",containerClassName:"h-full",showLegend:S,onUnselectSeries:C,yMeasureUnit:N})})}exports.TradingView=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),B=require("sonner"),W=require("../../hooks/use-media-query.cjs"),z=require("../buttons/range-buttons/range-buttons.cjs"),l=require("../graph/graph.cjs"),H=require("../graph/graph-view.cjs"),P=require("./graph-dropdown.cjs"),$=({size:t=16})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Expand fullscreen",children:[e.jsx("title",{children:"Expand fullscreen"}),e.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})]}),Q=({size:t=16})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Exit fullscreen",children:[e.jsx("title",{children:"Exit fullscreen"}),e.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"})]});function J({data:t,yMeasureUnit:n,height:h=306,defaultGraph:g,onGraphSelected:v,graphs:b,isMultipleSelect:y,range:A,rangeList:E,setRange:L,onGraphExpanded:w,isGraphExpanded:R,onUnselectSeries:C,graphsWithNoData:D,loadingGraphs:I,noDataMessage:j="No data available for this graph",currentValueDecimals:k}){const a=i.useMemo(()=>Array.isArray(t)?t:t?[t]:[],[t]),S=i.useMemo(()=>Array.isArray(t)&&t.length>1,[t]),O=W.useIsMobile(),N=i.useCallback((c,f)=>{B.toast.error(j)},[j]),M=i.useMemo(()=>{if(n)return Array.isArray(n)?n[0]:n},[n]),T=e.jsxs("div",{className:"z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2",children:[e.jsx("div",{children:v&&b&&g&&e.jsx(P.GraphDropdown,{onSelected:v,items:b,defaultItem:g,multiple:y,graphsWithNoData:D,loadingGraphs:I,onNoDataSelected:N})}),e.jsxs("div",{className:"flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1",children:[e.jsx(z.RangeButtons,{range:A,rangeList:E,setRange:L}),!O&&w&&e.jsx("button",{type:"button",className:"px-2.5 py-1.5 flex min-w-[44px] min-h-[26px] justify-center items-center text-xs leading-[14px] font-medium text-center rounded-md border cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring bg-muted border-muted text-muted-foreground hover:border-secondary ml-1.5",onClick:w,children:R?e.jsx(Q,{size:16}):e.jsx($,{size:16})})]})]}),u=i.useRef(new Map),x=i.useRef(0),q=i.useMemo(()=>{const c=Array.isArray(n)?n:void 0;return a.map((f,_)=>{const d=f?.title||`Series ${_+1}`;if(!u.current.has(d)){const r=new Set(Array.from(u.current.values()));let o=x.current;for(let s=0;s<l.DEFAULT_SERIES_COLORS.length;s++){const m=(x.current+s)%l.DEFAULT_SERIES_COLORS.length;if(!r.has(m)){o=m;break}}u.current.set(d,o),x.current=(o+1)%l.DEFAULT_SERIES_COLORS.length}const F=u.current.get(d)??0,p=l.DEFAULT_SERIES_COLORS[F%l.DEFAULT_SERIES_COLORS.length];return{data:[...f?.data||[]].sort((r,o)=>{const s=typeof r.time=="number"?r.time:Number(r.time),m=typeof o.time=="number"?o.time:Number(o.time);return s-m}).reduce((r,o)=>{const s=o.time;return r.length===0||r[r.length-1].time!==s?r.push({time:s,value:o.value}):r[r.length-1]={time:s,value:o.value},r},[]),label:d,yMeasureUnit:c?.[_]??(Array.isArray(n)?void 0:n),color:p.line,topColor:p.top,bottomColor:p.bottom}})},[a,n]),V=S&&a.length>0?a.some(c=>!c):!t;return e.jsx("div",{style:{width:"100%",height:h?`${h}px`:void 0},className:"w-full",children:e.jsx(H.GraphViewWithData,{series:q,loading:V,toolbar:T,size:h?"full":"default",containerClassName:"h-full",showLegend:S,onUnselectSeries:C,yMeasureUnit:M,currentValueDecimals:k})})}exports.TradingView=J;
@@ -22,6 +22,7 @@ function i() {
22
22
  visible: !0
23
23
  },
24
24
  rightPriceScale: {
25
+ visible: !0,
25
26
  autoScale: !0,
26
27
  alignLabels: !0,
27
28
  borderVisible: !0,
@@ -87,6 +88,7 @@ const b = {
87
88
  visible: !0
88
89
  },
89
90
  rightPriceScale: {
91
+ visible: !0,
90
92
  autoScale: !0,
91
93
  alignLabels: !0,
92
94
  borderVisible: !0,
@@ -51,7 +51,7 @@ const { MIN_DISPLAY_THRESHOLD: c, MAX_EXPONENTIAL_THRESHOLD: L } = I, H = (t, e,
51
51
  token: G,
52
52
  none: O
53
53
  }, k = (t) => D[t] || D.token;
54
- function w(t, e, r = 8) {
54
+ function w(t, e, r = 4) {
55
55
  if (t === 0)
56
56
  return e ? `0 ${e}` : "0";
57
57
  const n = t.toLocaleString("en-US", {
@@ -1,27 +1,28 @@
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({
1
+ import { jsxs as a, jsx as l } from "react/jsx-runtime";
2
+ import { cn as i } from "../../utils/cn.js";
3
+ import { getXFormatter as c, formatExactValue as r } from "./formatters.js";
4
+ function u({
5
5
  point: e,
6
- xMeasureUnit: r,
6
+ xMeasureUnit: m,
7
7
  yMeasureUnit: t,
8
- className: l
8
+ className: s,
9
+ decimals: o
9
10
  }) {
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(
11
+ const d = c(m)(e.time, m), n = t !== "%" && t !== "$" && t !== "none" ? t : void 0, x = t === "$" ? `$${r(e.value, void 0, o)}` : t === "%" ? `${r(e.value, void 0, o)}%` : r(e.value, n, o);
12
+ return /* @__PURE__ */ a(
12
13
  "div",
13
14
  {
14
- className: x(
15
+ className: i(
15
16
  "absolute top-2 left-2 right-2 z-[100] pointer-events-none",
16
- l
17
+ s
17
18
  ),
18
19
  children: [
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 })
20
+ /* @__PURE__ */ l("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: x }),
21
+ /* @__PURE__ */ l("div", { className: "text-xs sm:text-sm font-medium text-muted-foreground whitespace-nowrap overflow-hidden text-ellipsis mt-0.5", children: d })
21
22
  ]
22
23
  }
23
24
  );
24
25
  }
25
26
  export {
26
- h as GraphCurrentValue
27
+ u as GraphCurrentValue
27
28
  };
@@ -1,65 +1,66 @@
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
- function T({
1
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
2
+ import { useRef as j, useState as k, useEffect as P } from "react";
3
+ import { cn as A } from "../../utils/cn.js";
4
+ import { getXFormatter as z, formatExactValue as x } from "./formatters.js";
5
+ import { DEFAULT_SERIES_COLORS as v } from "./graph.js";
6
+ function U({
7
7
  points: d,
8
- series: v,
9
- xMeasureUnit: x,
10
- yMeasureUnit: N,
11
- className: R,
8
+ series: N,
9
+ xMeasureUnit: g,
10
+ yMeasureUnit: R,
11
+ className: $,
12
12
  position: t,
13
- containerRef: g
13
+ containerRef: b,
14
+ decimals: u
14
15
  }) {
15
- const b = S(null), [u, l] = j(t), $ = A(x);
16
- k(() => {
16
+ const w = j(null), [f, l] = k(t), C = z(g);
17
+ P(() => {
17
18
  if (!t) {
18
19
  l(t);
19
20
  return;
20
21
  }
21
- const r = g?.current;
22
+ const r = b?.current;
22
23
  if (!r) {
23
24
  l(t);
24
25
  return;
25
26
  }
26
- const c = b.current;
27
+ const c = w.current;
27
28
  if (!c) {
28
29
  l(t);
29
30
  return;
30
31
  }
31
32
  const o = r.getBoundingClientRect(), i = c.getBoundingClientRect();
32
33
  let n = t.x, e = t.y;
33
- const s = i.width, f = i.height, a = 8;
34
+ const s = i.width, p = i.height, a = 8;
34
35
  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`,
36
+ const y = p + 8;
37
+ e - y < a ? e = t.y + 20 : e = t.y - y, l({ x: n, y: e });
38
+ }, [t, b]);
39
+ const E = f ? {
40
+ left: `${f.x}px`,
41
+ top: `${f.y}px`,
41
42
  transform: "translate(-50%, 0)"
42
43
  // Center horizontally
43
44
  } : {};
44
45
  if (d.size === 0)
45
46
  return null;
46
- const E = Array.from(d.values())[0], F = $(E.time, x);
47
+ const F = Array.from(d.values())[0], S = C(F.time, g);
47
48
  return /* @__PURE__ */ m(
48
49
  "div",
49
50
  {
50
- ref: b,
51
- className: P(
51
+ ref: w,
52
+ className: A(
52
53
  "absolute z-[100] pointer-events-none whitespace-nowrap",
53
- R
54
+ $
54
55
  ),
55
- style: C,
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__ */ 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) => {
56
+ style: E,
57
+ children: /* @__PURE__ */ h("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: [
58
+ /* @__PURE__ */ m("div", { className: "text-xs sm:text-sm font-medium text-muted-foreground mb-0.5 sm:mb-1 whitespace-nowrap", children: S }),
59
+ N.map((r, c) => {
59
60
  const o = d.get(r.label);
60
61
  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(
62
+ const i = v[c % v.length], n = r.color || i.line, e = r.yMeasureUnit || R, s = e !== "%" && e !== "$" && e !== "none" ? e : void 0, p = e === "$" ? `$${x(o.value, void 0, u)}` : e === "%" ? `${x(o.value, void 0, u)}%` : x(o.value, s, u);
63
+ return /* @__PURE__ */ h(
63
64
  "div",
64
65
  {
65
66
  className: "flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm whitespace-nowrap",
@@ -71,11 +72,11 @@ function T({
71
72
  style: { backgroundColor: n }
72
73
  }
73
74
  ),
74
- /* @__PURE__ */ p("span", { className: "text-muted-foreground whitespace-nowrap", children: [
75
+ /* @__PURE__ */ h("span", { className: "text-muted-foreground whitespace-nowrap", children: [
75
76
  r.label,
76
77
  ":"
77
78
  ] }),
78
- /* @__PURE__ */ m("span", { className: "font-medium text-foreground whitespace-nowrap", children: f })
79
+ /* @__PURE__ */ m("span", { className: "font-medium text-foreground whitespace-nowrap", children: p })
79
80
  ]
80
81
  },
81
82
  r.label
@@ -86,5 +87,5 @@ function T({
86
87
  );
87
88
  }
88
89
  export {
89
- T as GraphTooltip
90
+ U as GraphTooltip
90
91
  };
@@ -1,16 +1,16 @@
1
- import { jsxs as $, jsx as S } from "react/jsx-runtime";
2
- import { createChart as xt } from "lightweight-charts";
1
+ import { jsxs as Y, jsx as S } from "react/jsx-runtime";
2
+ import { createChart as yt } from "lightweight-charts";
3
3
  import * as ot from "react";
4
- import { useRef as C, useState as ct, useEffect as D } from "react";
4
+ import { useRef as C, useState as ut, useEffect as O } from "react";
5
5
  import { useIsMobile as Rt } from "../../hooks/use-media-query.js";
6
- import { cn as gt } from "../../utils/cn.js";
7
- import { resolveCSSColor as ut, generateColorsFromBase as rt } from "../../utils/colors.js";
8
- import { getDefaultOptions as ft, getDefaultSeries as wt, getDefaultVerticalLine as yt } from "./default-config.js";
9
- import { getXFormatter as dt, createAdaptiveYAxisFormatter as Vt } from "./formatters.js";
10
- import { GraphCurrentValue as Lt } from "./graph-current-value.js";
11
- import { GraphTooltip as Pt } from "./graph-tooltip.js";
12
- import { VertLine as Mt } from "./plugins/vertical-line.js";
13
- const Y = [
6
+ import { cn as mt } from "../../utils/cn.js";
7
+ import { resolveCSSColor as ft, generateColorsFromBase as rt } from "../../utils/colors.js";
8
+ import { getDefaultOptions as dt, getDefaultSeries as wt, getDefaultVerticalLine as Vt } from "./default-config.js";
9
+ import { getXFormatter as gt, createAdaptiveYAxisFormatter as Lt } from "./formatters.js";
10
+ import { GraphCurrentValue as Pt } from "./graph-current-value.js";
11
+ import { GraphTooltip as Mt } from "./graph-tooltip.js";
12
+ import { VertLine as At } from "./plugins/vertical-line.js";
13
+ const $ = [
14
14
  {
15
15
  line: "#02c39a",
16
16
  top: "rgba(2, 195, 154, 0.56)",
@@ -52,51 +52,52 @@ const Y = [
52
52
  bottom: "rgba(6, 182, 212, 0.04)"
53
53
  }
54
54
  ];
55
- function Ht({
56
- series: t,
55
+ function Yt({
56
+ series: o,
57
57
  className: H,
58
- showLegend: y = !1,
58
+ showLegend: w = !1,
59
59
  onUnselectSeries: q,
60
60
  xMeasureUnit: V = "time",
61
- yMeasureUnit: O = "token",
61
+ yMeasureUnit: D = "token",
62
62
  optionsOverrides: E,
63
- verticalLineOptions: j
63
+ verticalLineOptions: j,
64
+ currentValueDecimals: nt
64
65
  }) {
65
- const x = C(null), b = C(/* @__PURE__ */ new Map()), W = C(!1), X = C(/* @__PURE__ */ new Set()), nt = C(0), at = C(!0), Z = C(
66
+ const x = C(null), b = C(/* @__PURE__ */ new Map()), W = C(!1), X = C(/* @__PURE__ */ new Set()), at = C(0), lt = C(!0), Z = C(
66
67
  null
67
- ), mt = C(null), F = C(null), _ = C(null), T = Rt(), L = ot.useMemo(() => t.flatMap((e) => e.data), [t]), ht = ot.useMemo(() => {
68
- if (t.length > 0) {
69
- const e = t[t.length - 1];
68
+ ), ht = C(null), A = C(null), _ = C(null), k = Rt(), L = ot.useMemo(() => o.flatMap((e) => e.data), [o]), pt = ot.useMemo(() => {
69
+ if (o.length > 0) {
70
+ const e = o[o.length - 1];
70
71
  if (e.data.length > 0)
71
72
  return e.data[e.data.length - 1];
72
73
  }
73
- }, [t]), [lt, J] = ct(() => {
74
- if (!ht) return;
74
+ }, [o]), [it, J] = ut(() => {
75
+ if (!pt) return;
75
76
  const e = /* @__PURE__ */ new Map();
76
- for (const r of t)
77
+ for (const r of o)
77
78
  r.data.length > 0 && e.set(r.label, r.data[r.data.length - 1]);
78
79
  return e;
79
- }), [it, P] = ct(null);
80
- D(() => {
80
+ }), [st, P] = ut(null);
81
+ O(() => {
81
82
  const e = () => {
82
- if (x.current && F.current) {
83
- const f = F.current.clientWidth, a = F.current.clientHeight;
84
- x.current.resize(f, a), x.current.timeScale().fitContent();
83
+ if (x.current && A.current) {
84
+ const d = A.current.clientWidth, a = A.current.clientHeight;
85
+ x.current.resize(d, a), x.current.timeScale().fitContent();
85
86
  }
86
- }, r = F.current, l = r ? new ResizeObserver(e) : null;
87
+ }, r = A.current, l = r ? new ResizeObserver(e) : null;
87
88
  return r && l?.observe(r), () => {
88
89
  r && l?.unobserve(r);
89
90
  };
90
- }, []), D(() => {
91
+ }, []), O(() => {
91
92
  if (!_.current || W.current) return;
92
- const e = ft(), r = ut(
93
+ const e = dt(), r = ft(
93
94
  "hsl(var(--foreground))",
94
95
  "rgb(0, 0, 0)"
95
- ), l = xt(_.current, {
96
+ ), l = yt(_.current, {
96
97
  ...e,
97
98
  rightPriceScale: {
98
99
  ...e.rightPriceScale || {},
99
- visible: !T,
100
+ visible: !k,
100
101
  textColor: r
101
102
  },
102
103
  ...E
@@ -104,45 +105,45 @@ function Ht({
104
105
  return x.current = l, W.current = !0, () => {
105
106
  l.remove(), x.current = null, W.current = !1, b.current.clear();
106
107
  };
107
- }, [T, E]), D(() => {
108
+ }, [k, E]), O(() => {
108
109
  const e = x.current;
109
- if (!e || t.length === 0) return;
110
- const r = V === "time" ? dt(V, L) : dt(V), l = L.map((o) => o.value), {
111
- formatter: f,
110
+ if (!e || o.length === 0) return;
111
+ const r = V === "time" ? gt(V, L) : gt(V), l = L.map((t) => t.value), {
112
+ formatter: d,
112
113
  updateVisibleRange: a,
113
114
  updateLastValues: u
114
- } = Vt(l);
115
- Z.current = a, mt.current = u;
116
- const m = t.filter((o) => o.data.length > 0).map((o) => o.data[o.data.length - 1].value);
115
+ } = Lt(l);
116
+ Z.current = a, ht.current = u;
117
+ const m = o.filter((t) => t.data.length > 0).map((t) => t.data[t.data.length - 1].value);
117
118
  u(m);
118
- const v = ft();
119
+ const v = dt();
119
120
  e.applyOptions({
120
121
  localization: {
121
122
  ...v.localization || {},
122
123
  timeFormatter: r ? (
123
124
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
124
- ((o) => r(parseFloat(o), void 0))
125
+ ((t) => r(parseFloat(t), void 0))
125
126
  ) : void 0
126
127
  },
127
128
  timeScale: {
128
129
  ...v.timeScale || {},
129
130
  tickMarkFormatter: r ? (
130
131
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
131
- ((o) => r(parseFloat(o), void 0))
132
+ ((t) => r(parseFloat(t), void 0))
132
133
  ) : void 0,
133
134
  minBarSpacing: 0
134
135
  }
135
136
  });
136
- const M = (L.length > 0 ? Math.min(...L.map((o) => o.value)) : 0) < 0, R = L.some((o) => o.value === 0), d = !M && R, i = t.length > 1, c = i || T, s = ut(
137
+ const M = (L.length > 0 ? Math.min(...L.map((t) => t.value)) : 0) < 0, y = L.some((t) => t.value === 0), f = !M && y, i = o.length > 1, c = i || k, s = ft(
137
138
  "hsl(var(--foreground))",
138
139
  "rgb(0, 0, 0)"
139
140
  );
140
141
  e.applyOptions({
141
142
  rightPriceScale: {
142
143
  ...v.rightPriceScale || {},
143
- visible: !T,
144
+ visible: !c,
144
145
  textColor: s,
145
- ...d && {
146
+ ...f && {
146
147
  scaleMargins: {
147
148
  top: 0.3,
148
149
  bottom: 0
@@ -150,75 +151,75 @@ function Ht({
150
151
  }
151
152
  }
152
153
  });
153
- const g = new Set(b.current.keys()), w = new Set(t.map((o) => o.label));
154
- for (const o of g)
155
- if (!w.has(o)) {
156
- const n = b.current.get(o);
157
- n && (e.removeSeries(n), b.current.delete(o));
154
+ const g = new Set(b.current.keys()), R = new Set(o.map((t) => t.label));
155
+ for (const t of g)
156
+ if (!R.has(t)) {
157
+ const n = b.current.get(t);
158
+ n && (e.removeSeries(n), b.current.delete(t));
158
159
  }
159
- const N = wt(), B = [];
160
+ const F = wt(), B = [];
160
161
  let I = 0;
161
- for (let o = 0; o < t.length; o++) {
162
- const n = t[o], tt = Y[o % Y.length], G = n.color || tt.line;
163
- let A, k;
162
+ for (let t = 0; t < o.length; t++) {
163
+ const n = o[t], tt = $[t % $.length], G = n.color || tt.line;
164
+ let N, T;
164
165
  if (n.color)
165
166
  if (n.topColor && n.bottomColor)
166
- A = n.topColor, k = n.bottomColor;
167
+ N = n.topColor, T = n.bottomColor;
167
168
  else if (n.topColor) {
168
169
  const p = rt(G);
169
- A = n.topColor, k = p.bottomColor;
170
+ N = n.topColor, T = p.bottomColor;
170
171
  } else if (n.bottomColor)
171
- A = rt(G).topColor, k = n.bottomColor;
172
+ N = rt(G).topColor, T = n.bottomColor;
172
173
  else {
173
174
  const p = rt(G);
174
- A = p.topColor, k = p.bottomColor;
175
+ N = p.topColor, T = p.bottomColor;
175
176
  }
176
177
  else
177
- A = n.topColor || tt.top, k = n.bottomColor || tt.bottom;
178
+ N = n.topColor || tt.top, T = n.bottomColor || tt.bottom;
178
179
  if (n.data.length === 0) {
179
180
  const p = b.current.get(n.label);
180
181
  p && (e.removeSeries(p), b.current.delete(n.label));
181
182
  continue;
182
183
  }
183
- const vt = (n.data.length > 0 ? Math.min(...n.data.map((p) => p.value)) : 0) < 0, Ct = n.data.some((p) => p.value === 0), St = !vt && Ct, et = i ? I === 0 ? void 0 : `scale-${I}` : void 0;
184
+ const Ct = (n.data.length > 0 ? Math.min(...n.data.map((p) => p.value)) : 0) < 0, St = n.data.some((p) => p.value === 0), xt = !Ct && St, et = i ? I === 0 ? "right" : `scale-${I}` : "right";
184
185
  i && B.push({
185
186
  priceScaleId: et || "right",
186
- shouldPreventNegativeAxis: St,
187
+ shouldPreventNegativeAxis: xt,
187
188
  seriesIndex: I
188
189
  });
189
190
  let z = b.current.get(n.label);
190
191
  z ? (z.applyOptions({
191
192
  lineColor: G,
192
- topColor: A,
193
- bottomColor: k,
193
+ topColor: N,
194
+ bottomColor: T,
194
195
  priceScaleId: et,
195
196
  priceFormat: {
196
197
  type: "custom",
197
- formatter: f
198
+ formatter: d
198
199
  }
199
200
  }), z.setData(n.data)) : (z = e.addAreaSeries({
200
- ...N,
201
+ ...F,
201
202
  lineColor: G,
202
- topColor: A,
203
- bottomColor: k,
203
+ topColor: N,
204
+ bottomColor: T,
204
205
  priceScaleId: et,
205
206
  priceFormat: {
206
207
  type: "custom",
207
- formatter: f
208
+ formatter: d
208
209
  }
209
210
  }), z.setData(n.data), b.current.set(n.label, z)), I++;
210
211
  }
211
212
  if (i && B.length > 0)
212
- for (const o of B)
213
+ for (const t of B)
213
214
  try {
214
- const n = e.priceScale(o.priceScaleId);
215
+ const n = e.priceScale(t.priceScaleId);
215
216
  n && n.applyOptions({
216
- visible: !c,
217
+ visible: !1,
217
218
  autoScale: !0,
218
219
  scaleMargins: {
219
220
  top: 0.1,
220
221
  bottom: 0.1,
221
- ...o.shouldPreventNegativeAxis && {
222
+ ...t.shouldPreventNegativeAxis && {
222
223
  top: 0.3,
223
224
  bottom: 0
224
225
  }
@@ -231,62 +232,84 @@ function Ht({
231
232
  });
232
233
  } catch (n) {
233
234
  console.warn(
234
- `Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,
235
+ `Failed to configure price scale ${t.priceScaleId} for series ${t.seriesIndex}:`,
235
236
  n
236
237
  );
237
238
  }
238
- const Q = new Set(t.map((o) => o.label)), pt = Q.size !== X.current.size || [...Q].some((o) => !X.current.has(o)), bt = L.length !== nt.current;
239
- (at.current || pt || bt || T) && (e.timeScale().fitContent(), at.current = !1), X.current = Q, nt.current = L.length;
239
+ else if (!i)
240
+ try {
241
+ const t = e.priceScale("right");
242
+ t && t.applyOptions({
243
+ visible: !k,
244
+ autoScale: !0,
245
+ scaleMargins: {
246
+ top: 0.1,
247
+ bottom: 0.1,
248
+ ...f && {
249
+ top: 0.3,
250
+ bottom: 0
251
+ }
252
+ },
253
+ alignLabels: !0,
254
+ borderVisible: !0,
255
+ borderColor: "rgba(224, 227, 235, 0.1)",
256
+ entireTextOnly: !1,
257
+ textColor: s
258
+ });
259
+ } catch {
260
+ }
261
+ const Q = new Set(o.map((t) => t.label)), bt = Q.size !== X.current.size || [...Q].some((t) => !X.current.has(t)), vt = L.length !== at.current;
262
+ (lt.current || bt || vt || k) && (e.timeScale().fitContent(), lt.current = !1), X.current = Q, at.current = L.length;
240
263
  const U = /* @__PURE__ */ new Map();
241
- for (const o of t)
242
- o.data.length > 0 && U.set(o.label, o.data[o.data.length - 1]);
264
+ for (const t of o)
265
+ t.data.length > 0 && U.set(t.label, t.data[t.data.length - 1]);
243
266
  J(U.size > 0 ? U : void 0);
244
- }, [t, L, V, O, T]), D(() => {
267
+ }, [o, L, V, D, k]), O(() => {
245
268
  const e = x.current;
246
- if (!e || t.length === 0) return;
247
- const r = t.length === 1;
269
+ if (!e || o.length === 0) return;
270
+ const r = o.length === 1;
248
271
  let l;
249
- for (const a of t)
272
+ for (const a of o)
250
273
  if (a.data.length > 0) {
251
274
  l = a.data[a.data.length - 1].time;
252
275
  break;
253
276
  }
254
277
  if (!l) return;
255
- const f = (a) => {
278
+ const d = (a) => {
256
279
  const { time: u = l, seriesData: m, point: v } = a || {}, h = Array.from(b.current.values());
257
280
  if (!v || !u) {
258
- const d = /* @__PURE__ */ new Map();
259
- for (const i of t)
260
- i.data.length > 0 && d.set(i.label, i.data[i.data.length - 1]);
261
- if (J(d.size > 0 ? d : void 0), r)
281
+ const f = /* @__PURE__ */ new Map();
282
+ for (const i of o)
283
+ i.data.length > 0 && f.set(i.label, i.data[i.data.length - 1]);
284
+ if (J(f.size > 0 ? f : void 0), r)
262
285
  P(null);
263
286
  else if (h[0] && l) {
264
- const c = e.timeScale().timeToCoordinate(l), s = t[0];
287
+ const c = e.timeScale().timeToCoordinate(l), s = o[0];
265
288
  if (s.data.length > 0) {
266
- const g = s.data[s.data.length - 1].value, w = h[0].priceToCoordinate(g);
267
- c !== null && w !== null && P({ x: c, y: w });
289
+ const g = s.data[s.data.length - 1].value, R = h[0].priceToCoordinate(g);
290
+ c !== null && R !== null && P({ x: c, y: R });
268
291
  }
269
292
  }
270
293
  return;
271
294
  }
272
295
  const M = /* @__PURE__ */ new Map();
273
- let R;
274
- for (let d = 0; d < t.length; d++) {
275
- const i = t[d], c = h[d];
296
+ let y;
297
+ for (let f = 0; f < o.length; f++) {
298
+ const i = o[f], c = h[f];
276
299
  if (!c) continue;
277
- const s = m?.get(c), g = s && "value" in s ? s.value : void 0, w = i.data[i.data.length - 1], N = g !== void 0 ? g : w?.value ?? 0;
278
- d === 0 && (R = N), M.set(i.label, { value: N, time: u });
300
+ const s = m?.get(c), g = s && "value" in s ? s.value : void 0, R = i.data[i.data.length - 1], F = g !== void 0 ? g : R?.value ?? 0;
301
+ f === 0 && (y = F), M.set(i.label, { value: F, time: u });
279
302
  }
280
- if (J(M), R !== void 0 && h[0]) {
281
- const i = e.timeScale().timeToCoordinate(u), c = h[0].priceToCoordinate(R);
303
+ if (J(M), y !== void 0 && h[0]) {
304
+ const i = e.timeScale().timeToCoordinate(u), c = h[0].priceToCoordinate(y);
282
305
  if (i !== null && c !== null) {
283
- const s = F.current;
306
+ const s = A.current;
284
307
  if (s) {
285
308
  const g = s.querySelector(
286
309
  ".LightweightChart"
287
310
  );
288
311
  if (g) {
289
- const w = g.getBoundingClientRect(), N = s.getBoundingClientRect(), B = i + (w.left - N.left), I = c + (w.top - N.top);
312
+ const R = g.getBoundingClientRect(), F = s.getBoundingClientRect(), B = i + (R.left - F.left), I = c + (R.top - F.top);
290
313
  P({ x: B, y: I });
291
314
  } else
292
315
  P({ x: i, y: c });
@@ -297,19 +320,19 @@ function Ht({
297
320
  } else
298
321
  P(null);
299
322
  };
300
- return e.subscribeCrosshairMove(f), r || requestAnimationFrame(() => {
323
+ return e.subscribeCrosshairMove(d), r || requestAnimationFrame(() => {
301
324
  const a = Array.from(b.current.values());
302
- if (a[0] && l && t[0]?.data.length > 0) {
303
- const m = e.timeScale().timeToCoordinate(l), v = t[0].data[t[0].data.length - 1].value, h = a[0].priceToCoordinate(v);
325
+ if (a[0] && l && o[0]?.data.length > 0) {
326
+ const m = e.timeScale().timeToCoordinate(l), v = o[0].data[o[0].data.length - 1].value, h = a[0].priceToCoordinate(v);
304
327
  m !== null && h !== null && P({ x: m, y: h });
305
328
  }
306
329
  }), () => {
307
- e.unsubscribeCrosshairMove(f);
330
+ e.unsubscribeCrosshairMove(d);
308
331
  };
309
- }, [t]), D(() => {
332
+ }, [o]), O(() => {
310
333
  const e = x.current;
311
- if (!e || t.length === 0) return;
312
- const r = e.timeScale(), l = Math.max(...t.map((a) => a.data.length)), f = () => {
334
+ if (!e || o.length === 0) return;
335
+ const r = e.timeScale(), l = Math.max(...o.map((a) => a.data.length)), d = () => {
313
336
  if (l === 0) return;
314
337
  const a = r.getVisibleLogicalRange();
315
338
  if (!a) return;
@@ -318,29 +341,29 @@ function Ht({
318
341
  to: l - 1
319
342
  }, m = typeof a.from == "number" ? a.from : 0, v = typeof a.to == "number" ? a.to : l - 1;
320
343
  if (Z.current) {
321
- const d = Math.max(0, Math.floor(m)), i = Math.min(l - 1, Math.ceil(v)), c = [];
322
- for (const s of t)
323
- for (let g = d; g <= i && g < s.data.length; g++)
344
+ const f = Math.max(0, Math.floor(m)), i = Math.min(l - 1, Math.ceil(v)), c = [];
345
+ for (const s of o)
346
+ for (let g = f; g <= i && g < s.data.length; g++)
324
347
  c.push(s.data[g].value);
325
348
  c.length > 0 && Z.current(c);
326
349
  }
327
350
  const h = 0.01;
328
351
  let M = !1;
329
- const R = { ...a };
330
- m < u.from - h && (R.from = u.from, M = !0), v > u.to + h && (R.to = u.to, M = !0), M && r.setVisibleLogicalRange(R);
352
+ const y = { ...a };
353
+ m < u.from - h && (y.from = u.from, M = !0), v > u.to + h && (y.to = u.to, M = !0), M && r.setVisibleLogicalRange(y);
331
354
  };
332
- return r.subscribeVisibleLogicalRangeChange(f), () => {
355
+ return r.subscribeVisibleLogicalRangeChange(d), () => {
333
356
  r.unsubscribeVisibleLogicalRangeChange(
334
- f
357
+ d
335
358
  );
336
359
  };
337
- }, [t]), D(() => {
360
+ }, [o]), O(() => {
338
361
  const e = x.current, r = Array.from(b.current.values()), l = [];
339
362
  if (e && r.length > 0 && j) {
340
- const f = yt(), a = r[0];
363
+ const d = Vt(), a = r[0];
341
364
  for (const u of j) {
342
- const m = new Mt(e, a, u.xCoordinate, {
343
- ...f,
365
+ const m = new At(e, a, u.xCoordinate, {
366
+ ...d,
344
367
  ...u.options || {}
345
368
  });
346
369
  a.attachPrimitive(m), l.push(m);
@@ -348,48 +371,50 @@ function Ht({
348
371
  }
349
372
  return () => {
350
373
  if (r.length > 0) {
351
- const f = r[0];
374
+ const d = r[0];
352
375
  for (const a of l)
353
- f.detachPrimitive(a);
376
+ d.detachPrimitive(a);
354
377
  }
355
378
  };
356
379
  }, [j]);
357
- const K = t.length === 1, st = ot.useMemo(() => {
358
- if (K && t.length > 0) {
359
- const e = t[0];
380
+ const K = o.length === 1, ct = ot.useMemo(() => {
381
+ if (K && o.length > 0) {
382
+ const e = o[0];
360
383
  if (e.data.length > 0)
361
384
  return e.data[e.data.length - 1];
362
385
  }
363
- }, [K, t]);
364
- return /* @__PURE__ */ $(
386
+ }, [K, o]);
387
+ return /* @__PURE__ */ Y(
365
388
  "div",
366
389
  {
367
- ref: F,
368
- className: gt(
390
+ ref: A,
391
+ className: mt(
369
392
  "relative z-[1] w-full h-full overflow-hidden p-0",
370
393
  H
371
394
  ),
372
395
  children: [
373
- K && st && /* @__PURE__ */ S(
374
- Lt,
396
+ K && ct && /* @__PURE__ */ S(
397
+ Pt,
375
398
  {
376
- point: st,
399
+ point: ct,
377
400
  xMeasureUnit: V,
378
- yMeasureUnit: O
401
+ yMeasureUnit: D,
402
+ decimals: nt
379
403
  }
380
404
  ),
381
- lt && it && /* @__PURE__ */ S(
382
- Pt,
405
+ it && st && /* @__PURE__ */ S(
406
+ Mt,
383
407
  {
384
- points: lt,
408
+ points: it,
385
409
  xMeasureUnit: V,
386
- yMeasureUnit: O,
387
- series: t,
388
- position: it,
389
- containerRef: F
410
+ yMeasureUnit: D,
411
+ series: o,
412
+ position: st,
413
+ containerRef: A,
414
+ decimals: nt
390
415
  }
391
416
  ),
392
- y && /* @__PURE__ */ S(Ft, { series: t, onUnselect: q }),
417
+ w && /* @__PURE__ */ S(Ft, { series: o, onUnselect: q }),
393
418
  /* @__PURE__ */ S(
394
419
  "div",
395
420
  {
@@ -402,15 +427,15 @@ function Ht({
402
427
  );
403
428
  }
404
429
  function Ft({
405
- series: t,
430
+ series: o,
406
431
  onUnselect: H
407
432
  }) {
408
- return /* @__PURE__ */ S("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: t.map((y, q) => {
409
- const V = Y[q % Y.length], O = y.color || V.line, E = y.data.length === 0;
410
- return /* @__PURE__ */ $(
433
+ return /* @__PURE__ */ S("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: o.map((w, q) => {
434
+ const V = $[q % $.length], D = w.color || V.line, E = w.data.length === 0;
435
+ return /* @__PURE__ */ Y(
411
436
  "div",
412
437
  {
413
- className: gt(
438
+ className: mt(
414
439
  "flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
415
440
  E && "opacity-50"
416
441
  ),
@@ -419,11 +444,11 @@ function Ft({
419
444
  "div",
420
445
  {
421
446
  className: "w-3 h-3 rounded-sm",
422
- style: { backgroundColor: O }
447
+ style: { backgroundColor: D }
423
448
  }
424
449
  ),
425
- /* @__PURE__ */ $("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
426
- y.label,
450
+ /* @__PURE__ */ Y("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
451
+ w.label,
427
452
  E && " (no data)"
428
453
  ] }),
429
454
  H && /* @__PURE__ */ S(
@@ -431,11 +456,11 @@ function Ft({
431
456
  {
432
457
  type: "button",
433
458
  onClick: (j) => {
434
- j.stopPropagation(), H(y.label);
459
+ j.stopPropagation(), H(w.label);
435
460
  },
436
461
  className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
437
- "aria-label": `Remove ${y.label}`,
438
- children: /* @__PURE__ */ $(
462
+ "aria-label": `Remove ${w.label}`,
463
+ children: /* @__PURE__ */ Y(
439
464
  "svg",
440
465
  {
441
466
  xmlns: "http://www.w3.org/2000/svg",
@@ -460,11 +485,11 @@ function Ft({
460
485
  )
461
486
  ]
462
487
  },
463
- y.label
488
+ w.label
464
489
  );
465
490
  }) });
466
491
  }
467
492
  export {
468
- Y as DEFAULT_SERIES_COLORS,
469
- Ht as Graph
493
+ $ as DEFAULT_SERIES_COLORS,
494
+ Yt as Graph
470
495
  };
@@ -1,12 +1,12 @@
1
1
  import { jsx as t, jsxs as f } from "react/jsx-runtime";
2
- import { useMemo as d, useCallback as H, useRef as D } from "react";
3
- import { toast as O } from "sonner";
4
- import { useIsMobile as $ } from "../../hooks/use-media-query.js";
5
- import { RangeButtons as P } from "../buttons/range-buttons/range-buttons.js";
2
+ import { useMemo as d, useCallback as O, useRef as D } from "react";
3
+ import { toast as $ } from "sonner";
4
+ import { useIsMobile as P } from "../../hooks/use-media-query.js";
5
+ import { RangeButtons as q } from "../buttons/range-buttons/range-buttons.js";
6
6
  import { DEFAULT_SERIES_COLORS as i } from "../graph/graph.js";
7
- import { GraphViewWithData as q } from "../graph/graph-view.js";
8
- import { GraphDropdown as J } from "./graph-dropdown.js";
9
- const K = ({ size: e = 16 }) => /* @__PURE__ */ f(
7
+ import { GraphViewWithData as J } from "../graph/graph-view.js";
8
+ import { GraphDropdown as K } from "./graph-dropdown.js";
9
+ const Q = ({ size: e = 16 }) => /* @__PURE__ */ f(
10
10
  "svg",
11
11
  {
12
12
  width: e,
@@ -23,7 +23,7 @@ const K = ({ size: e = 16 }) => /* @__PURE__ */ f(
23
23
  /* @__PURE__ */ t("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" })
24
24
  ]
25
25
  }
26
- ), Q = ({ size: e = 16 }) => /* @__PURE__ */ f(
26
+ ), X = ({ size: e = 16 }) => /* @__PURE__ */ f(
27
27
  "svg",
28
28
  {
29
29
  width: e,
@@ -41,7 +41,7 @@ const K = ({ size: e = 16 }) => /* @__PURE__ */ f(
41
41
  ]
42
42
  }
43
43
  );
44
- function ie({
44
+ function se({
45
45
  data: e,
46
46
  yMeasureUnit: n,
47
47
  height: h = 306,
@@ -57,19 +57,20 @@ function ie({
57
57
  onUnselectSeries: j,
58
58
  graphsWithNoData: R,
59
59
  loadingGraphs: V,
60
- noDataMessage: A = "No data available for this graph"
60
+ noDataMessage: A = "No data available for this graph",
61
+ currentValueDecimals: B
61
62
  }) {
62
- const s = d(() => Array.isArray(e) ? e : e ? [e] : [], [e]), k = d(() => Array.isArray(e) && e.length > 1, [e]), B = $(), M = H(
63
+ const s = d(() => Array.isArray(e) ? e : e ? [e] : [], [e]), k = d(() => Array.isArray(e) && e.length > 1, [e]), M = P(), _ = O(
63
64
  (c, x) => {
64
- O.error(A);
65
+ $.error(A);
65
66
  },
66
67
  [A]
67
- ), _ = d(() => {
68
+ ), F = d(() => {
68
69
  if (n)
69
70
  return Array.isArray(n) ? n[0] : n;
70
- }, [n]), F = /* @__PURE__ */ f("div", { className: "z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2", children: [
71
+ }, [n]), T = /* @__PURE__ */ f("div", { className: "z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2", children: [
71
72
  /* @__PURE__ */ t("div", { children: b && w && g && /* @__PURE__ */ t(
72
- J,
73
+ K,
73
74
  {
74
75
  onSelected: b,
75
76
  items: w,
@@ -77,22 +78,22 @@ function ie({
77
78
  multiple: I,
78
79
  graphsWithNoData: R,
79
80
  loadingGraphs: V,
80
- onNoDataSelected: M
81
+ onNoDataSelected: _
81
82
  }
82
83
  ) }),
83
84
  /* @__PURE__ */ f("div", { className: "flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1", children: [
84
- /* @__PURE__ */ t(P, { range: N, rangeList: L, setRange: E }),
85
- !B && y && /* @__PURE__ */ t(
85
+ /* @__PURE__ */ t(q, { range: N, rangeList: L, setRange: E }),
86
+ !M && y && /* @__PURE__ */ t(
86
87
  "button",
87
88
  {
88
89
  type: "button",
89
90
  className: "px-2.5 py-1.5 flex min-w-[44px] min-h-[26px] justify-center items-center text-xs leading-[14px] font-medium text-center rounded-md border cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring bg-muted border-muted text-muted-foreground hover:border-secondary ml-1.5",
90
91
  onClick: y,
91
- children: S ? /* @__PURE__ */ t(Q, { size: 16 }) : /* @__PURE__ */ t(K, { size: 16 })
92
+ children: S ? /* @__PURE__ */ t(X, { size: 16 }) : /* @__PURE__ */ t(Q, { size: 16 })
92
93
  }
93
94
  )
94
95
  ] })
95
- ] }), a = D(/* @__PURE__ */ new Map()), p = D(0), T = d(() => {
96
+ ] }), a = D(/* @__PURE__ */ new Map()), p = D(0), W = d(() => {
96
97
  const c = Array.isArray(n) ? n : void 0;
97
98
  return s.map((x, C) => {
98
99
  const u = x?.title || `Series ${C + 1}`;
@@ -110,7 +111,7 @@ function ie({
110
111
  }
111
112
  a.current.set(u, o), p.current = (o + 1) % i.length;
112
113
  }
113
- const z = a.current.get(u) ?? 0, v = i[z % i.length];
114
+ const H = a.current.get(u) ?? 0, v = i[H % i.length];
114
115
  return {
115
116
  data: [...x?.data || []].sort((r, o) => {
116
117
  const l = typeof r.time == "number" ? r.time : Number(r.time), m = typeof o.time == "number" ? o.time : Number(o.time);
@@ -132,7 +133,7 @@ function ie({
132
133
  bottomColor: v.bottom
133
134
  };
134
135
  });
135
- }, [s, n]), W = k && s.length > 0 ? s.some((c) => !c) : !e;
136
+ }, [s, n]), z = k && s.length > 0 ? s.some((c) => !c) : !e;
136
137
  return /* @__PURE__ */ t(
137
138
  "div",
138
139
  {
@@ -142,21 +143,22 @@ function ie({
142
143
  },
143
144
  className: "w-full",
144
145
  children: /* @__PURE__ */ t(
145
- q,
146
+ J,
146
147
  {
147
- series: T,
148
- loading: W,
149
- toolbar: F,
148
+ series: W,
149
+ loading: z,
150
+ toolbar: T,
150
151
  size: h ? "full" : "default",
151
152
  containerClassName: "h-full",
152
153
  showLegend: k,
153
154
  onUnselectSeries: j,
154
- yMeasureUnit: _
155
+ yMeasureUnit: F,
156
+ currentValueDecimals: B
155
157
  }
156
158
  )
157
159
  }
158
160
  );
159
161
  }
160
162
  export {
161
- ie as TradingView
163
+ se as TradingView
162
164
  };
@@ -5,9 +5,14 @@ export interface GraphCurrentValueProps {
5
5
  xMeasureUnit: XMeasureUnits;
6
6
  yMeasureUnit: YMeasureUnits;
7
7
  className?: string;
8
+ /**
9
+ * Number of decimal places for current value display.
10
+ * If 0, rounds to whole numbers. Default is 4.
11
+ */
12
+ decimals?: number;
8
13
  }
9
14
  /**
10
15
  * GraphCurrentValue component displays the current value in single mode
11
16
  * without background, border, or legend - just date and value
12
17
  */
13
- export declare function GraphCurrentValue({ point, xMeasureUnit, yMeasureUnit, className, }: GraphCurrentValueProps): React.ReactElement;
18
+ export declare function GraphCurrentValue({ point, xMeasureUnit, yMeasureUnit, className, decimals, }: GraphCurrentValueProps): React.ReactElement;
@@ -16,9 +16,14 @@ export interface GraphTooltipProps {
16
16
  };
17
17
  /** Container element to constrain tooltip within bounds */
18
18
  containerRef?: React.RefObject<HTMLElement | null>;
19
+ /**
20
+ * Number of decimal places for value display.
21
+ * If 0, rounds to whole numbers. Default is 4.
22
+ */
23
+ decimals?: number;
19
24
  }
20
25
  /**
21
26
  * GraphTooltip component displays the current value and time on the graph
22
27
  * Supports single or multiple series
23
28
  */
24
- export declare function GraphTooltip({ points, series, xMeasureUnit, yMeasureUnit, className, position, containerRef, }: GraphTooltipProps): React.ReactElement | null;
29
+ export declare function GraphTooltip({ points, series, xMeasureUnit, yMeasureUnit, className, position, containerRef, decimals, }: GraphTooltipProps): React.ReactElement | null;
@@ -38,11 +38,16 @@ export interface GraphProps {
38
38
  xCoordinate: Time;
39
39
  options?: VerticalLineOptions;
40
40
  }>;
41
+ /**
42
+ * Number of decimal places for current value display.
43
+ * If 0, rounds to whole numbers. Default is 4.
44
+ */
45
+ currentValueDecimals?: number;
41
46
  }
42
47
  /**
43
48
  * Graph component that renders a chart using lightweight-charts library
44
49
  * with support for area series, custom tooltips, and vertical line annotations
45
50
  * Supports single or multiple series with different colors and legends
46
51
  */
47
- export declare function Graph({ series, className, showLegend, onUnselectSeries, xMeasureUnit, yMeasureUnit, optionsOverrides, verticalLineOptions, }: GraphProps): React.ReactElement;
52
+ export declare function Graph({ series, className, showLegend, onUnselectSeries, xMeasureUnit, yMeasureUnit, optionsOverrides, verticalLineOptions, currentValueDecimals, }: GraphProps): React.ReactElement;
48
53
  export {};
@@ -52,6 +52,11 @@ export interface TradingViewProps<T extends string = string> {
52
52
  loadingGraphs?: Set<T>;
53
53
  /** Message to show when user selects a graph with no data */
54
54
  noDataMessage?: string;
55
+ /**
56
+ * Number of decimal places for current value display.
57
+ * If 0, rounds to whole numbers. Default is 8 (full precision).
58
+ */
59
+ currentValueDecimals?: number;
55
60
  }
56
61
  /**
57
62
  * TradingView — comprehensive charting component with graph selection and time range controls.
@@ -108,4 +113,4 @@ export interface TradingViewProps<T extends string = string> {
108
113
  * />
109
114
  * ```
110
115
  */
111
- export declare function TradingView<T extends string = string>({ data, yMeasureUnit, height, defaultGraph, onGraphSelected, graphs, isMultipleSelect, range, rangeList, setRange, onGraphExpanded, isGraphExpanded, onUnselectSeries, graphsWithNoData, loadingGraphs, noDataMessage, }: TradingViewProps<T>): React.ReactElement;
116
+ export declare function TradingView<T extends string = string>({ data, yMeasureUnit, height, defaultGraph, onGraphSelected, graphs, isMultipleSelect, range, rangeList, setRange, onGraphExpanded, isGraphExpanded, onUnselectSeries, graphsWithNoData, loadingGraphs, noDataMessage, currentValueDecimals, }: TradingViewProps<T>): React.ReactElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/permissionless-ui",
3
- "version": "1.17.7",
3
+ "version": "1.17.9",
4
4
  "description": "Internal UI components",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/index.js",