@gearbox-protocol/permissionless-ui 1.26.3 → 1.26.4
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 o=require("../../utils/colors.cjs"),e={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 r=o.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:r},layout:{background:{color:"transparent"},textColor:r,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:e.lineColor,lineWidth:2}}function a(){return{showLabel:!0,color:e.lineColor,labelBackgroundColor:e.lineColor,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=e;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 o=require("../../utils/colors.cjs"),e={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 r=o.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");return{timeScale:{borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",visible:!0,fixLeftEdge:!0,fixRightEdge:!0},rightPriceScale:{visible:!0,autoScale:!0,alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:r},layout:{background:{color:"transparent"},textColor:r,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:e.lineColor,lineWidth:2}}function a(){return{showLabel:!0,color:e.lineColor,labelBackgroundColor:e.lineColor,width:2}}const s={timeScale:{borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",visible:!0,fixLeftEdge:!0,fixRightEdge:!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=e;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 f=require("react/jsx-runtime"),ut=require("lightweight-charts"),u=require("react"),At=require("../../hooks/use-media-query.cjs"),gt=require("../../utils/cn.cjs"),I=require("../../utils/colors.cjs"),X=require("./default-config.cjs"),D=require("./formatters.cjs"),It=require("./graph-current-value.cjs"),yt=require("./graph-tooltip.cjs"),Ot=require("./plugins/vertical-line.cjs");function zt(t){const C=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const g in t)if(g!=="default"){const L=Object.getOwnPropertyDescriptor(t,g);Object.defineProperty(C,g,L.get?L:{enumerable:!0,get:()=>t[g]})}}return C.default=t,Object.freeze(C)}const ft=zt(u);function Vt(t,C,g){const L=t.labelText??"",b=t.value,w=b===void 0?"":typeof b=="number"?C==="$"?`$${D.formatExactValue(b,void 0,g)}`:C==="%"?`${D.formatExactValue(b,void 0,g)}%`:D.formatExactValue(b,C!=="none"&&C!=="%"&&C!=="$"?C:void 0,g):String(b);return{labelText:L,valueStr:w}}const Z=[{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:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 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:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"},{line:"#ea580c",top:"rgba(234, 88, 12, 0.56)",bottom:"rgba(234, 88, 12, 0.04)"},{line:"#84cc16",top:"rgba(132, 204, 22, 0.56)",bottom:"rgba(132, 204, 22, 0.04)"},{line:"#d946ef",top:"rgba(217, 70, 239, 0.56)",bottom:"rgba(217, 70, 239, 0.04)"},{line:"#0ea5e9",top:"rgba(14, 165, 233, 0.56)",bottom:"rgba(14, 165, 233, 0.04)"},{line:"#14b8a6",top:"rgba(20, 184, 166, 0.56)",bottom:"rgba(20, 184, 166, 0.04)"},{line:"#eab308",top:"rgba(234, 179, 8, 0.56)",bottom:"rgba(234, 179, 8, 0.04)"},{line:"#f43f5e",top:"rgba(244, 63, 94, 0.56)",bottom:"rgba(244, 63, 94, 0.04)"},{line:"#6366f1",top:"rgba(99, 102, 241, 0.56)",bottom:"rgba(99, 102, 241, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#78716c",top:"rgba(120, 113, 108, 0.56)",bottom:"rgba(120, 113, 108, 0.04)"},{line:"#64748b",top:"rgba(100, 116, 139, 0.56)",bottom:"rgba(100, 116, 139, 0.04)"},{line:"#475569",top:"rgba(71, 85, 105, 0.56)",bottom:"rgba(71, 85, 105, 0.04)"}],qt=137.5;function dt(t){if(t<Z.length)return Z[t];const g=(t-Z.length)*qt%360,L=I.hslToHex(g,70,50),{topColor:b,bottomColor:w}=I.generateColorsFromBase(L);return{line:L,top:b,bottom:w}}function Dt({series:t,className:C,showLegend:g=!1,onUnselectSeries:L,xMeasureUnit:b="time",yMeasureUnit:w="token",optionsOverrides:$,verticalLineOptions:y,currentValueDecimals:G,useSharedPriceScale:N=!1,showCurrentValue:Lt=!0,graphTitle:K,yScaleMin:bt,yScaleMinMultiple:mt}){const k=u.useRef(null),j=u.useRef(new Map),Q=u.useRef(!1),J=u.useRef(new Set),ht=u.useRef(0),pt=u.useRef(!0),U=u.useRef(null),jt=u.useRef(null),M=u.useRef(null),tt=u.useRef(null),V=At.useIsMobile(),_=ft.useMemo(()=>t.flatMap(e=>e.data),[t]),kt=ft.useMemo(()=>{if(t.length>0){const e=t[t.length-1];if(e.data.length>0)return e.data[e.data.length-1]}},[t]),[Y,et]=u.useState(()=>{if(!kt)return;const e=new Map;for(const a of t)a.data.length>0&&e.set(a.label,a.data[a.data.length-1]);return e}),[ot,A]=u.useState(null),[Ct,vt]=u.useState([]);u.useEffect(()=>{const e=()=>{if(k.current&&M.current){const s=M.current.clientWidth,l=M.current.clientHeight;k.current.resize(s,l),k.current.timeScale().fitContent()}},a=M.current,n=a?new ResizeObserver(e):null;return a&&n?.observe(a),()=>{a&&n?.unobserve(a)}},[]),u.useEffect(()=>{if(!tt.current||Q.current)return;const e=X.getDefaultOptions(),a=I.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),n=ut.createChart(tt.current,{...e,rightPriceScale:{...e.rightPriceScale||{},visible:!V,textColor:a},...V&&{crosshair:{...e.crosshair,mode:ut.CrosshairMode.Magnet}},...$});return k.current=n,Q.current=!0,()=>{n.remove(),k.current=null,Q.current=!1,j.current.clear()}},[V,$]),u.useEffect(()=>{const e=k.current;if(!e||t.length===0)return;const n=t.filter(o=>o.data.length>0).length<=1?bt:mt,s=b==="time"?D.getXFormatters(b,_):D.getXFormatters(b),l=_.map(o=>o.value),{formatter:c,tickmarksFormatter:m,updateVisibleRange:P,updateLastValues:v}=D.createAdaptiveYAxisFormatter(l,w,{yScaleMin:n});U.current=P,jt.current=v;const T=t.filter(o=>o.data.length>0).map(o=>o.data[o.data.length-1].value);v(T);const S=X.getDefaultOptions();e.applyOptions({localization:{...S.localization||{},timeFormatter:o=>s.timeFormatter(parseFloat(o),void 0)},timeScale:{...S.timeScale||{},tickMarkFormatter:s.tickMarkFormatter,minBarSpacing:0}});const h=(_.length>0?Math.min(..._.map(o=>o.value)):0)<0,x=_.some(o=>o.value===0),p=!h&&x,d=t.length>1&&!N,F=t.length>1&&!N||V,E=I.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");e.applyOptions({rightPriceScale:{...S.rightPriceScale||{},visible:!F,textColor:E,...p&&{scaleMargins:{top:.3,bottom:0}}}});const nt=new Set(j.current.keys()),rt=new Set(t.map(o=>o.label));for(const o of nt)if(!rt.has(o)){const r=j.current.get(o);r&&(e.removeSeries(r),j.current.delete(o))}const Pt=X.getDefaultSeries(),at=[];let H=0;for(let o=0;o<t.length;o++){const r=t[o],it=dt(o),W=r.lineColor??r.color??it.line;let O,z;if(r.lineColor??r.color)if(r.topColor&&r.bottomColor)O=r.topColor,z=r.bottomColor;else if(r.topColor){const i=I.generateColorsFromBase(W);O=r.topColor,z=i.bottomColor}else if(r.bottomColor)O=I.generateColorsFromBase(W).topColor,z=r.bottomColor;else{const i=I.generateColorsFromBase(W);O=i.topColor,z=i.bottomColor}else O=r.topColor||it.top,z=r.bottomColor||it.bottom;if(r.data.length===0){const i=j.current.get(r.label);i&&(e.removeSeries(i),j.current.delete(r.label));continue}const Ft=(r.data.length>0?Math.min(...r.data.map(i=>i.value)):0)<0,Et=r.data.some(i=>i.value===0),Mt=!Ft&&Et,St=N||!d||H===0?"right":`scale-${H}`;d&&at.push({priceScaleId:St||"right",shouldPreventNegativeAxis:Mt,seriesIndex:H});const Rt=(N||!d)&&n!==void 0&&typeof n=="number",wt={lineColor:W,topColor:O,bottomColor:z,priceScaleId:St,priceFormat:{type:"custom",minMove:.01,formatter:Rt&&typeof n=="number"?i=>c(i<n?n:i):c,tickmarksFormatter:m},autoscaleInfoProvider:i=>{if(!Rt)return i();const ct=i();if(ct?.priceRange){const _t=n;ct.priceRange.minValue=_t}return ct}};let q=j.current.get(r.label);q?(q.applyOptions(wt),q.setData(r.data.map(i=>({...i,time:i.time})))):(q=e.addSeries(ut.AreaSeries,{...Pt,...wt}),q.setData(r.data.map(i=>({...i,time:i.time}))),j.current.set(r.label,q)),H++}if(d&&at.length>0)for(const o of at)try{const r=e.priceScale(o.priceScaleId);r&&r.applyOptions({visible:!1,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:E})}catch(r){console.warn(`Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,r)}else if(!d)try{const o=e.priceScale("right");o&&o.applyOptions({visible:!V,autoScale:!0,scaleMargins:{top:.1,bottom:n!==void 0||p?0:.1,...p&&{top:.3}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:E})}catch{}n!==void 0&&!V&&(N||!d)&&e.applyOptions({handleScroll:{vertTouchDrag:!1}});const lt=new Set(t.map(o=>o.label)),Tt=lt.size!==J.current.size||[...lt].some(o=>!J.current.has(o)),Nt=_.length!==ht.current;(pt.current||Tt||Nt||V)&&(e.timeScale().fitContent(),pt.current=!1),J.current=lt,ht.current=_.length;const st=new Map;for(const o of t)o.data.length>0&&st.set(o.label,o.data[o.data.length-1]);et(st.size>0?st:void 0)},[t,_,b,w,V,N,bt,mt]),u.useEffect(()=>{const e=k.current;if(!e||t.length===0)return;const a=t.length===1;let n;for(const l of t)if(l.data.length>0){n=l.data[l.data.length-1].time;break}if(!n)return;const s=l=>{const{time:c=n,seriesData:m,point:P}=l||{},v=Array.from(j.current.values());if(!P||!c){const R=new Map;for(const h of t)h.data.length>0&&R.set(h.label,h.data[h.data.length-1]);if(et(R.size>0?R:void 0),a||N)A(null);else if(v[0]&&n){const x=e.timeScale().timeToCoordinate(n),p=t[0];if(p.data.length>0){const d=p.data[p.data.length-1].value,F=v[0].priceToCoordinate(d);x!==null&&F!==null&&A({x,y:F})}}return}const T=new Map;let S;for(let R=0;R<t.length;R++){const h=t[R],x=v[R];if(!x)continue;const p=m?.get(x),d=p&&"value"in p?p.value:void 0,F=h.data[h.data.length-1],E=d!==void 0?d:F?.value??0;R===0&&(S=E),T.set(h.label,{value:E,time:c})}if(et(T),S!==void 0&&v[0]){const h=e.timeScale().timeToCoordinate(c),x=v[0].priceToCoordinate(S);if(h!==null&&x!==null){const p=M.current;if(p){const d=p.querySelector(".LightweightChart");if(d){const F=d.getBoundingClientRect(),E=p.getBoundingClientRect(),nt=h+(F.left-E.left),rt=x+(F.top-E.top);A({x:nt,y:rt})}else A({x:h,y:x})}else A({x:h,y:x})}else A(null)}else A(null)};return e.subscribeCrosshairMove(s),V&&e.subscribeClick(s),!a&&!N&&requestAnimationFrame(()=>{const l=Array.from(j.current.values());if(l[0]&&n&&t[0]?.data.length>0){const m=e.timeScale().timeToCoordinate(n),P=t[0].data[t[0].data.length-1].value,v=l[0].priceToCoordinate(P);m!==null&&v!==null&&A({x:m,y:v})}}),()=>{e.unsubscribeCrosshairMove(s),V&&e.unsubscribeClick(s)}},[t,N,V]),u.useEffect(()=>{const e=k.current;if(!e||t.length===0)return;const a=e.timeScale(),n=Math.max(...t.map(l=>l.data.length)),s=()=>{if(n===0)return;const l=a.getVisibleLogicalRange();if(!l)return;const c={from:0,to:n-1},m=typeof l.from=="number"?l.from:0,P=typeof l.to=="number"?l.to:n-1;if(U.current){const R=Math.max(0,Math.floor(m)),h=Math.min(n-1,Math.ceil(P)),x=[];for(const p of t)for(let d=R;d<=h&&d<p.data.length;d++)x.push(p.data[d].value);x.length>0&&U.current(x)}const v=.01;let T=!1;const S={...l};m<c.from-v&&(S.from=c.from,T=!0),P>c.to+v&&(S.to=c.to,T=!0),T&&a.setVisibleLogicalRange(S)};return a.subscribeVisibleLogicalRangeChange(s),()=>{a.unsubscribeVisibleLogicalRangeChange(s)}},[t]),u.useEffect(()=>{const e=k.current,a=Array.from(j.current.values()),n=[];if(e&&a.length>0&&y){const s=X.getDefaultVerticalLine(),l=a[0];for(const c of y){const m=new Ot.VertLine(e,l,c.xCoordinate,{...s,...c.options||{}});l.attachPrimitive(m),n.push(m)}}return()=>{if(a.length>0){const s=a[0];for(const l of n)s.detachPrimitive(l)}}},[y]),u.useEffect(()=>{const e=k.current;if(!e||!y?.length){vt([]);return}const a=()=>{const l=e.timeScale(),c=y.map(m=>l.timeToCoordinate(m.xCoordinate)??null);vt(c)};a();const n=e.timeScale(),s=()=>{a()};return n.subscribeVisibleLogicalRangeChange(s),()=>{n.unsubscribeVisibleLogicalRangeChange(s)}},[y]);const B=t.length===1,xt=ft.useMemo(()=>{if(B&&t.length>0){const e=t[0];if(e.data.length>0)return e.data[e.data.length-1]}},[B,t]);return f.jsxs("div",{ref:M,className:gt.cn("relative z-[1] w-full h-full overflow-hidden p-0",C),children:[K!=null&&K!==!1&&B?f.jsx("div",{className:"absolute top-2 left-2 right-2 z-[100] pointer-events-none",children:f.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:K})}):Lt&&B&&xt&&f.jsx(It.GraphCurrentValue,{point:xt,xMeasureUnit:b,yMeasureUnit:w,decimals:G}),Y&&ot&&f.jsx(yt.GraphTooltip,{points:Y,xMeasureUnit:b,yMeasureUnit:w,series:t,position:ot,containerRef:M,decimals:G}),Y&&!ot&&!B&&V&&f.jsx(yt.GraphTooltip,{points:Y,xMeasureUnit:b,yMeasureUnit:w,series:t,containerRef:M,decimals:G,className:"top-2 left-2"}),g&&f.jsx($t,{series:t,onUnselect:L}),y&&y.length>0&&Ct.length===y.length&&f.jsx("div",{className:"absolute inset-0 z-[5] pointer-events-none","aria-hidden":!0,children:y.map((e,a)=>{const n=Ct[a],s=e.options??{},l=s.showLabel!==!1;if(n===null||!l)return null;const{labelText:c,valueStr:m}=Vt(s,w,G);if(!(c||m))return null;const v=s.labelBackgroundColor??s.color??"hsl(var(--background))",T=s.labelTextColor??"hsl(var(--foreground))",S=`${String(e.xCoordinate)}-${c}`;return f.jsxs("div",{className:"absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",style:{left:n,transform:"translateX(-50%)",backgroundColor:v,color:T},children:[c&&f.jsx("span",{className:"block",children:c}),m&&f.jsx("span",{className:gt.cn("block",c&&"mt-0.5"),children:m})]},S)})}),f.jsx("div",{ref:tt,className:"LightweightChart w-full h-full overflow-hidden"})]})}function $t({series:t,onUnselect:C}){return f.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:t.map((g,L)=>{const b=dt(L),w=(g.lineColor??g.color)||b.line,$=g.data.length===0;return f.jsxs("div",{className:gt.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",$&&"opacity-50"),children:[f.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:w}}),f.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[g.label,$&&" (no data)"]}),C&&f.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),C(g.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 ${g.label}`,children:f.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:[f.jsx("title",{children:"Close"}),f.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),f.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},g.label)})})}exports.DEFAULT_SERIES_COLORS=Z;exports.Graph=Dt;exports.getSeriesColorPalette=dt;exports.getVerticalLineTooltipContent=Vt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),ue=require("lightweight-charts"),c=require("react"),Ae=require("../../hooks/use-media-query.cjs"),ge=require("../../utils/cn.cjs"),I=require("../../utils/colors.cjs"),X=require("./default-config.cjs"),D=require("./formatters.cjs"),Ie=require("./graph-current-value.cjs"),ye=require("./graph-tooltip.cjs"),Oe=require("./plugins/vertical-line.cjs");function ze(e){const m=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const f in e)if(f!=="default"){const y=Object.getOwnPropertyDescriptor(e,f);Object.defineProperty(m,f,y.get?y:{enumerable:!0,get:()=>e[f]})}}return m.default=e,Object.freeze(m)}const fe=ze(c);function Ve(e,m,f){const y=e.labelText??"",b=e.value,x=b===void 0?"":typeof b=="number"?m==="$"?`$${D.formatExactValue(b,void 0,f)}`:m==="%"?`${D.formatExactValue(b,void 0,f)}%`:D.formatExactValue(b,m!=="none"&&m!=="%"&&m!=="$"?m:void 0,f):String(b);return{labelText:y,valueStr:x}}const Z=[{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:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 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:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"},{line:"#ea580c",top:"rgba(234, 88, 12, 0.56)",bottom:"rgba(234, 88, 12, 0.04)"},{line:"#84cc16",top:"rgba(132, 204, 22, 0.56)",bottom:"rgba(132, 204, 22, 0.04)"},{line:"#d946ef",top:"rgba(217, 70, 239, 0.56)",bottom:"rgba(217, 70, 239, 0.04)"},{line:"#0ea5e9",top:"rgba(14, 165, 233, 0.56)",bottom:"rgba(14, 165, 233, 0.04)"},{line:"#14b8a6",top:"rgba(20, 184, 166, 0.56)",bottom:"rgba(20, 184, 166, 0.04)"},{line:"#eab308",top:"rgba(234, 179, 8, 0.56)",bottom:"rgba(234, 179, 8, 0.04)"},{line:"#f43f5e",top:"rgba(244, 63, 94, 0.56)",bottom:"rgba(244, 63, 94, 0.04)"},{line:"#6366f1",top:"rgba(99, 102, 241, 0.56)",bottom:"rgba(99, 102, 241, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#78716c",top:"rgba(120, 113, 108, 0.56)",bottom:"rgba(120, 113, 108, 0.04)"},{line:"#64748b",top:"rgba(100, 116, 139, 0.56)",bottom:"rgba(100, 116, 139, 0.04)"},{line:"#475569",top:"rgba(71, 85, 105, 0.56)",bottom:"rgba(71, 85, 105, 0.04)"}],qe=137.5;function de(e){if(e<Z.length)return Z[e];const f=(e-Z.length)*qe%360,y=I.hslToHex(f,70,50),{topColor:b,bottomColor:x}=I.generateColorsFromBase(y);return{line:y,top:b,bottom:x}}function De({series:e,className:m,showLegend:f=!1,onUnselectSeries:y,xMeasureUnit:b="time",yMeasureUnit:x="token",optionsOverrides:$,verticalLineOptions:S,currentValueDecimals:G,useSharedPriceScale:L=!1,showCurrentValue:ke=!0,graphTitle:K,yScaleMin:be,yScaleMinMultiple:me}){const j=c.useRef(null),V=c.useRef(new Map),Q=c.useRef(!1),J=c.useRef(new Set),he=c.useRef(0),pe=c.useRef(!0),U=c.useRef(null),je=c.useRef(null),_=c.useRef(null),ee=c.useRef(null),R=Ae.useIsMobile(),M=fe.useMemo(()=>e.flatMap(t=>t.data),[e]),Le=fe.useMemo(()=>{if(e.length>0){const t=e[e.length-1];if(t.data.length>0)return t.data[t.data.length-1]}},[e]),[Y,te]=c.useState(()=>{if(!Le)return;const t=new Map;for(const a of e)a.data.length>0&&t.set(a.label,a.data[a.data.length-1]);return t}),[oe,A]=c.useState(null),[Ce,ve]=c.useState([]);c.useEffect(()=>{const t=()=>{if(j.current&&_.current){const l=_.current.clientWidth,i=_.current.clientHeight;j.current.resize(l,i),j.current.timeScale().fitContent()}},a=_.current,n=a?new ResizeObserver(t):null;return a&&n?.observe(a),()=>{a&&n?.unobserve(a)}},[]),c.useEffect(()=>{if(!ee.current||Q.current)return;const t=X.getDefaultOptions(),a=I.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),n=ue.createChart(ee.current,{...t,rightPriceScale:{...t.rightPriceScale||{},visible:!R,textColor:a},...R&&{crosshair:{...t.crosshair,mode:ue.CrosshairMode.Magnet}},...$});return j.current=n,Q.current=!0,()=>{n.remove(),j.current=null,Q.current=!1,V.current.clear()}},[R,$]),c.useEffect(()=>{const t=j.current;if(!t||e.length===0)return;const n=e.filter(o=>o.data.length>0).length<=1?be:me,l=b==="time"?D.getXFormatters(b,M):D.getXFormatters(b),i=M.map(o=>o.value),{formatter:g,tickmarksFormatter:d,updateVisibleRange:N,updateLastValues:h}=D.createAdaptiveYAxisFormatter(i,x,{yScaleMin:n});U.current=N,je.current=h;const P=e.filter(o=>o.data.length>0).map(o=>o.data[o.data.length-1].value);h(P);const T=X.getDefaultOptions();t.applyOptions({localization:{...T.localization||{},timeFormatter:o=>l.timeFormatter(parseFloat(o),void 0)},timeScale:{...T.timeScale||{},tickMarkFormatter:l.tickMarkFormatter,minBarSpacing:0}});const p=(M.length>0?Math.min(...M.map(o=>o.value)):0)<0,w=M.some(o=>o.value===0),C=!p&&w,v=e.length>1&&!L,F=e.length>1&&!L||R,E=I.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");t.applyOptions({rightPriceScale:{...T.rightPriceScale||{},visible:!F,textColor:E,...C&&{scaleMargins:{top:.3,bottom:0}}}});const ne=new Set(V.current.keys()),re=new Set(e.map(o=>o.label));for(const o of ne)if(!re.has(o)){const r=V.current.get(o);r&&(t.removeSeries(r),V.current.delete(o))}const Ne=X.getDefaultSeries(),ae=[];let H=0;for(let o=0;o<e.length;o++){const r=e[o],ie=de(o),W=r.lineColor??r.color??ie.line;let O,z;if(r.lineColor??r.color)if(r.topColor&&r.bottomColor)O=r.topColor,z=r.bottomColor;else if(r.topColor){const s=I.generateColorsFromBase(W);O=r.topColor,z=s.bottomColor}else if(r.bottomColor)O=I.generateColorsFromBase(W).topColor,z=r.bottomColor;else{const s=I.generateColorsFromBase(W);O=s.topColor,z=s.bottomColor}else O=r.topColor||ie.top,z=r.bottomColor||ie.bottom;if(r.data.length===0){const s=V.current.get(r.label);s&&(t.removeSeries(s),V.current.delete(r.label));continue}const Fe=(r.data.length>0?Math.min(...r.data.map(s=>s.value)):0)<0,Ee=r.data.some(s=>s.value===0),_e=!Fe&&Ee,Se=L||!v||H===0?"right":`scale-${H}`;v&&ae.push({priceScaleId:Se||"right",shouldPreventNegativeAxis:_e,seriesIndex:H});const Re=(L||!v)&&n!==void 0&&typeof n=="number",we={lineColor:W,topColor:O,bottomColor:z,priceScaleId:Se,priceFormat:{type:"custom",minMove:.01,formatter:Re&&typeof n=="number"?s=>g(s<n?n:s):g,tickmarksFormatter:d},autoscaleInfoProvider:s=>{if(!Re)return s();const ce=s();if(ce?.priceRange){const Me=n;ce.priceRange.minValue=Me}return ce}};let q=V.current.get(r.label);q?(q.applyOptions(we),q.setData(r.data.map(s=>({...s,time:s.time})))):(q=t.addSeries(ue.AreaSeries,{...Ne,...we}),q.setData(r.data.map(s=>({...s,time:s.time}))),V.current.set(r.label,q)),H++}if(v&&ae.length>0)for(const o of ae)try{const r=t.priceScale(o.priceScaleId);r&&r.applyOptions({visible:!1,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:E})}catch(r){console.warn(`Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,r)}else if(!v)try{const o=t.priceScale("right");o&&o.applyOptions({visible:!R,autoScale:!0,scaleMargins:{top:.1,bottom:n!==void 0||C?0:.1,...C&&{top:.3}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:E})}catch{}n!==void 0&&!R&&(L||!v)&&t.applyOptions({handleScroll:{vertTouchDrag:!1}});const le=new Set(e.map(o=>o.label)),Pe=le.size!==J.current.size||[...le].some(o=>!J.current.has(o)),Te=M.length!==he.current;(pe.current||Pe||Te||R)&&(t.timeScale().fitContent(),pe.current=!1),J.current=le,he.current=M.length;const se=new Map;for(const o of e)o.data.length>0&&se.set(o.label,o.data[o.data.length-1]);te(se.size>0?se:void 0)},[e,M,b,x,R,L,be,me]),c.useEffect(()=>{const t=j.current;if(!t||e.length===0)return;const a=e.length===1;let n;for(const i of e)if(i.data.length>0){n=i.data[i.data.length-1].time;break}if(!n)return;const l=i=>{const{time:g=n,seriesData:d,point:N}=i||{},h=Array.from(V.current.values());if(!N||!g){const k=new Map;for(const p of e)p.data.length>0&&k.set(p.label,p.data[p.data.length-1]);if(te(k.size>0?k:void 0),a||L)A(null);else if(h[0]&&n){const w=t.timeScale().timeToCoordinate(n),C=e[0];if(C.data.length>0){const v=C.data[C.data.length-1].value,F=h[0].priceToCoordinate(v);w!==null&&F!==null&&A({x:w,y:F})}}return}const P=new Map;let T;for(let k=0;k<e.length;k++){const p=e[k],w=h[k];if(!w)continue;const C=d?.get(w),v=C&&"value"in C?C.value:void 0,F=p.data[p.data.length-1],E=v!==void 0?v:F?.value??0;k===0&&(T=E),P.set(p.label,{value:E,time:g})}if(te(P),T!==void 0&&h[0]){const p=t.timeScale().timeToCoordinate(g),w=h[0].priceToCoordinate(T);if(p!==null&&w!==null){const C=_.current;if(C){const v=C.querySelector(".LightweightChart");if(v){const F=v.getBoundingClientRect(),E=C.getBoundingClientRect(),ne=p+(F.left-E.left),re=w+(F.top-E.top);A({x:ne,y:re})}else A({x:p,y:w})}else A({x:p,y:w})}else A(null)}else A(null)};return t.subscribeCrosshairMove(l),R&&t.subscribeClick(l),!a&&!L&&requestAnimationFrame(()=>{const i=Array.from(V.current.values());if(i[0]&&n&&e[0]?.data.length>0){const d=t.timeScale().timeToCoordinate(n),N=e[0].data[e[0].data.length-1].value,h=i[0].priceToCoordinate(N);d!==null&&h!==null&&A({x:d,y:h})}}),()=>{t.unsubscribeCrosshairMove(l),R&&t.unsubscribeClick(l)}},[e,L,R]),c.useEffect(()=>{const t=j.current;if(!t||e.length===0)return;const a=t.timeScale(),n=()=>{if(!U.current)return;const l=a.getVisibleRange();if(!l)return;const i=Number(l.from),g=Number(l.to),d=[];for(const N of e)for(const h of N.data){const P=Number(h.time);P>=i&&P<=g&&d.push(h.value)}d.length>0&&U.current(d)};return a.subscribeVisibleLogicalRangeChange(n),()=>{a.unsubscribeVisibleLogicalRangeChange(n)}},[e]),c.useEffect(()=>{const t=j.current,a=Array.from(V.current.values()),n=[];if(t&&a.length>0&&S){const l=X.getDefaultVerticalLine(),i=a[0];for(const g of S){const d=new Oe.VertLine(t,i,g.xCoordinate,{...l,...g.options||{}});i.attachPrimitive(d),n.push(d)}}return()=>{if(a.length>0){const l=a[0];for(const i of n)l.detachPrimitive(i)}}},[S]),c.useEffect(()=>{const t=j.current;if(!t||!S?.length){ve([]);return}const a=()=>{const i=t.timeScale(),g=S.map(d=>i.timeToCoordinate(d.xCoordinate)??null);ve(g)};a();const n=t.timeScale(),l=()=>{a()};return n.subscribeVisibleLogicalRangeChange(l),()=>{n.unsubscribeVisibleLogicalRangeChange(l)}},[S]);const B=e.length===1,xe=fe.useMemo(()=>{if(B&&e.length>0){const t=e[0];if(t.data.length>0)return t.data[t.data.length-1]}},[B,e]);return u.jsxs("div",{ref:_,className:ge.cn("relative z-[1] w-full h-full overflow-hidden p-0",m),children:[K!=null&&K!==!1&&B?u.jsx("div",{className:"absolute top-2 left-2 right-2 z-[100] pointer-events-none",children:u.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:K})}):ke&&B&&xe&&u.jsx(Ie.GraphCurrentValue,{point:xe,xMeasureUnit:b,yMeasureUnit:x,decimals:G}),Y&&oe&&u.jsx(ye.GraphTooltip,{points:Y,xMeasureUnit:b,yMeasureUnit:x,series:e,position:oe,containerRef:_,decimals:G}),Y&&!oe&&!B&&R&&u.jsx(ye.GraphTooltip,{points:Y,xMeasureUnit:b,yMeasureUnit:x,series:e,containerRef:_,decimals:G,className:"top-2 left-2"}),f&&u.jsx($e,{series:e,onUnselect:y}),S&&S.length>0&&Ce.length===S.length&&u.jsx("div",{className:"absolute inset-0 z-[5] pointer-events-none","aria-hidden":!0,children:S.map((t,a)=>{const n=Ce[a],l=t.options??{},i=l.showLabel!==!1;if(n===null||!i)return null;const{labelText:g,valueStr:d}=Ve(l,x,G);if(!(g||d))return null;const h=l.labelBackgroundColor??l.color??"hsl(var(--background))",P=l.labelTextColor??"hsl(var(--foreground))",T=`${String(t.xCoordinate)}-${g}`;return u.jsxs("div",{className:"absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",style:{left:n,transform:"translateX(-50%)",backgroundColor:h,color:P},children:[g&&u.jsx("span",{className:"block",children:g}),d&&u.jsx("span",{className:ge.cn("block",g&&"mt-0.5"),children:d})]},T)})}),u.jsx("div",{ref:ee,className:"LightweightChart w-full h-full overflow-hidden"})]})}function $e({series:e,onUnselect:m}){return u.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((f,y)=>{const b=de(y),x=(f.lineColor??f.color)||b.line,$=f.data.length===0;return u.jsxs("div",{className:ge.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",$&&"opacity-50"),children:[u.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:x}}),u.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[f.label,$&&" (no data)"]}),m&&u.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),m(f.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 ${f.label}`,children:u.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:[u.jsx("title",{children:"Close"}),u.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},f.label)})})}exports.DEFAULT_SERIES_COLORS=Z;exports.Graph=De;exports.getSeriesColorPalette=de;exports.getVerticalLineTooltipContent=Ve;
|
|
@@ -19,7 +19,9 @@ function i() {
|
|
|
19
19
|
timeScale: {
|
|
20
20
|
borderVisible: !0,
|
|
21
21
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
22
|
-
visible: !0
|
|
22
|
+
visible: !0,
|
|
23
|
+
fixLeftEdge: !0,
|
|
24
|
+
fixRightEdge: !0
|
|
23
25
|
},
|
|
24
26
|
rightPriceScale: {
|
|
25
27
|
visible: !0,
|
|
@@ -81,7 +83,9 @@ const s = {
|
|
|
81
83
|
timeScale: {
|
|
82
84
|
borderVisible: !0,
|
|
83
85
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
84
|
-
visible: !0
|
|
86
|
+
visible: !0,
|
|
87
|
+
fixLeftEdge: !0,
|
|
88
|
+
fixRightEdge: !0
|
|
85
89
|
},
|
|
86
90
|
rightPriceScale: {
|
|
87
91
|
visible: !0,
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createChart as Gt, CrosshairMode as
|
|
1
|
+
import { jsxs as H, jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { createChart as Gt, CrosshairMode as Bt, AreaSeries as Ot } from "lightweight-charts";
|
|
3
3
|
import * as ct from "react";
|
|
4
|
-
import { useRef as
|
|
4
|
+
import { useRef as k, useState as ut, useEffect as D } from "react";
|
|
5
5
|
import { useIsMobile as Yt } from "../../hooks/use-media-query.js";
|
|
6
6
|
import { cn as dt } from "../../utils/cn.js";
|
|
7
|
-
import { resolveCSSColor as
|
|
8
|
-
import { getDefaultOptions as
|
|
7
|
+
import { resolveCSSColor as yt, generateColorsFromBase as q, hslToHex as Ht } from "../../utils/colors.js";
|
|
8
|
+
import { getDefaultOptions as Vt, getDefaultSeries as jt, getDefaultVerticalLine as Wt } from "./default-config.js";
|
|
9
9
|
import { getXFormatters as kt, createAdaptiveYAxisFormatter as _t, formatExactValue as ft } from "./formatters.js";
|
|
10
10
|
import { GraphCurrentValue as Xt } from "./graph-current-value.js";
|
|
11
|
-
import { GraphTooltip as
|
|
11
|
+
import { GraphTooltip as Nt } from "./graph-tooltip.js";
|
|
12
12
|
import { VertLine as qt } from "./plugins/vertical-line.js";
|
|
13
|
-
function Zt(e,
|
|
14
|
-
const
|
|
13
|
+
function Zt(e, C, b) {
|
|
14
|
+
const I = e.labelText ?? "", f = e.value, v = f === void 0 ? "" : typeof f == "number" ? C === "$" ? `$${ft(f, void 0, b)}` : C === "%" ? `${ft(f, void 0, b)}%` : ft(
|
|
15
15
|
f,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
C !== "none" && C !== "%" && C !== "$" ? C : void 0,
|
|
17
|
+
b
|
|
18
18
|
) : String(f);
|
|
19
|
-
return { labelText:
|
|
19
|
+
return { labelText: I, valueStr: v };
|
|
20
20
|
}
|
|
21
21
|
const gt = [
|
|
22
22
|
// 0 green (emerald)
|
|
@@ -134,31 +134,31 @@ const gt = [
|
|
|
134
134
|
bottom: "rgba(71, 85, 105, 0.04)"
|
|
135
135
|
}
|
|
136
136
|
], Kt = 137.5;
|
|
137
|
-
function
|
|
137
|
+
function Lt(e) {
|
|
138
138
|
if (e < gt.length)
|
|
139
139
|
return gt[e];
|
|
140
|
-
const
|
|
141
|
-
return { line:
|
|
140
|
+
const b = (e - gt.length) * Kt % 360, I = Ht(b, 70, 50), { topColor: f, bottomColor: v } = q(I);
|
|
141
|
+
return { line: I, top: f, bottom: v };
|
|
142
142
|
}
|
|
143
143
|
function ge({
|
|
144
144
|
series: e,
|
|
145
|
-
className:
|
|
146
|
-
showLegend:
|
|
147
|
-
onUnselectSeries:
|
|
145
|
+
className: C,
|
|
146
|
+
showLegend: b = !1,
|
|
147
|
+
onUnselectSeries: I,
|
|
148
148
|
xMeasureUnit: f = "time",
|
|
149
|
-
yMeasureUnit:
|
|
150
|
-
optionsOverrides:
|
|
151
|
-
verticalLineOptions:
|
|
152
|
-
currentValueDecimals:
|
|
153
|
-
useSharedPriceScale:
|
|
149
|
+
yMeasureUnit: v = "token",
|
|
150
|
+
optionsOverrides: O,
|
|
151
|
+
verticalLineOptions: x,
|
|
152
|
+
currentValueDecimals: j,
|
|
153
|
+
useSharedPriceScale: N = !1,
|
|
154
154
|
showCurrentValue: Pt = !0,
|
|
155
155
|
graphTitle: Z,
|
|
156
156
|
yScaleMin: mt,
|
|
157
157
|
yScaleMinMultiple: bt
|
|
158
158
|
}) {
|
|
159
|
-
const
|
|
159
|
+
const V = k(null), R = k(/* @__PURE__ */ new Map()), K = k(!1), J = k(/* @__PURE__ */ new Set()), pt = k(0), ht = k(!0), Q = k(
|
|
160
160
|
null
|
|
161
|
-
), Tt =
|
|
161
|
+
), Tt = k(null), M = k(null), U = k(null), S = Yt(), z = ct.useMemo(() => e.flatMap((t) => t.data), [e]), Ft = ct.useMemo(() => {
|
|
162
162
|
if (e.length > 0) {
|
|
163
163
|
const t = e[e.length - 1];
|
|
164
164
|
if (t.data.length > 0)
|
|
@@ -170,81 +170,81 @@ function ge({
|
|
|
170
170
|
for (const a of e)
|
|
171
171
|
a.data.length > 0 && t.set(a.label, a.data[a.data.length - 1]);
|
|
172
172
|
return t;
|
|
173
|
-
}), [et,
|
|
174
|
-
|
|
173
|
+
}), [et, $] = ut(null), [Ct, vt] = ut([]);
|
|
174
|
+
D(() => {
|
|
175
175
|
const t = () => {
|
|
176
|
-
if (
|
|
177
|
-
const
|
|
178
|
-
|
|
176
|
+
if (V.current && M.current) {
|
|
177
|
+
const l = M.current.clientWidth, s = M.current.clientHeight;
|
|
178
|
+
V.current.resize(l, s), V.current.timeScale().fitContent();
|
|
179
179
|
}
|
|
180
|
-
}, a =
|
|
180
|
+
}, a = M.current, n = a ? new ResizeObserver(t) : null;
|
|
181
181
|
return a && n?.observe(a), () => {
|
|
182
182
|
a && n?.unobserve(a);
|
|
183
183
|
};
|
|
184
|
-
}, []),
|
|
184
|
+
}, []), D(() => {
|
|
185
185
|
if (!U.current || K.current) return;
|
|
186
|
-
const t =
|
|
186
|
+
const t = Vt(), a = yt(
|
|
187
187
|
"hsl(var(--foreground))",
|
|
188
188
|
"rgb(0, 0, 0)"
|
|
189
189
|
), n = Gt(U.current, {
|
|
190
190
|
...t,
|
|
191
191
|
rightPriceScale: {
|
|
192
192
|
...t.rightPriceScale || {},
|
|
193
|
-
visible: !
|
|
193
|
+
visible: !S,
|
|
194
194
|
textColor: a
|
|
195
195
|
},
|
|
196
|
-
...
|
|
196
|
+
...S && {
|
|
197
197
|
crosshair: {
|
|
198
198
|
...t.crosshair,
|
|
199
|
-
mode:
|
|
199
|
+
mode: Bt.Magnet
|
|
200
200
|
}
|
|
201
201
|
},
|
|
202
|
-
...
|
|
202
|
+
...O
|
|
203
203
|
});
|
|
204
|
-
return
|
|
205
|
-
n.remove(),
|
|
204
|
+
return V.current = n, K.current = !0, () => {
|
|
205
|
+
n.remove(), V.current = null, K.current = !1, R.current.clear();
|
|
206
206
|
};
|
|
207
|
-
}, [
|
|
208
|
-
const t =
|
|
207
|
+
}, [S, O]), D(() => {
|
|
208
|
+
const t = V.current;
|
|
209
209
|
if (!t || e.length === 0) return;
|
|
210
|
-
const n = e.filter((o) => o.data.length > 0).length <= 1 ? mt : bt,
|
|
210
|
+
const n = e.filter((o) => o.data.length > 0).length <= 1 ? mt : bt, l = f === "time" ? kt(f, z) : kt(f), s = z.map((o) => o.value), {
|
|
211
211
|
formatter: c,
|
|
212
|
-
tickmarksFormatter:
|
|
212
|
+
tickmarksFormatter: u,
|
|
213
213
|
updateVisibleRange: L,
|
|
214
|
-
updateLastValues:
|
|
215
|
-
} = _t(
|
|
214
|
+
updateLastValues: g
|
|
215
|
+
} = _t(s, v, {
|
|
216
216
|
yScaleMin: n
|
|
217
217
|
});
|
|
218
|
-
Q.current = L, Tt.current =
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
const
|
|
218
|
+
Q.current = L, Tt.current = g;
|
|
219
|
+
const P = e.filter((o) => o.data.length > 0).map((o) => o.data[o.data.length - 1].value);
|
|
220
|
+
g(P);
|
|
221
|
+
const T = Vt();
|
|
222
222
|
t.applyOptions({
|
|
223
223
|
localization: {
|
|
224
|
-
...
|
|
224
|
+
...T.localization || {},
|
|
225
225
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
226
226
|
timeFormatter: (o) => (
|
|
227
227
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
228
|
-
|
|
228
|
+
l.timeFormatter(parseFloat(o), void 0)
|
|
229
229
|
)
|
|
230
230
|
},
|
|
231
231
|
timeScale: {
|
|
232
|
-
...
|
|
232
|
+
...T.timeScale || {},
|
|
233
233
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
234
|
-
tickMarkFormatter:
|
|
234
|
+
tickMarkFormatter: l.tickMarkFormatter,
|
|
235
235
|
minBarSpacing: 0
|
|
236
236
|
}
|
|
237
237
|
});
|
|
238
|
-
const d = (z.length > 0 ? Math.min(...z.map((o) => o.value)) : 0) < 0,
|
|
238
|
+
const d = (z.length > 0 ? Math.min(...z.map((o) => o.value)) : 0) < 0, w = z.some((o) => o.value === 0), p = !d && w, h = e.length > 1 && !N, F = e.length > 1 && !N || S, A = yt(
|
|
239
239
|
"hsl(var(--foreground))",
|
|
240
240
|
"rgb(0, 0, 0)"
|
|
241
241
|
);
|
|
242
242
|
t.applyOptions({
|
|
243
243
|
rightPriceScale: {
|
|
244
|
-
...
|
|
244
|
+
...T.rightPriceScale || {},
|
|
245
245
|
visible: !F,
|
|
246
|
-
textColor:
|
|
247
|
-
...
|
|
246
|
+
textColor: A,
|
|
247
|
+
...p && {
|
|
248
248
|
scaleMargins: {
|
|
249
249
|
top: 0.3,
|
|
250
250
|
bottom: 0
|
|
@@ -252,82 +252,82 @@ function ge({
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
});
|
|
255
|
-
const ot = new Set(
|
|
255
|
+
const ot = new Set(R.current.keys()), nt = new Set(e.map((o) => o.label));
|
|
256
256
|
for (const o of ot)
|
|
257
257
|
if (!nt.has(o)) {
|
|
258
|
-
const r =
|
|
259
|
-
r && (t.removeSeries(r),
|
|
258
|
+
const r = R.current.get(o);
|
|
259
|
+
r && (t.removeSeries(r), R.current.delete(o));
|
|
260
260
|
}
|
|
261
|
-
const
|
|
261
|
+
const At = jt(), rt = [];
|
|
262
262
|
let _ = 0;
|
|
263
263
|
for (let o = 0; o < e.length; o++) {
|
|
264
|
-
const r = e[o], it =
|
|
265
|
-
let
|
|
264
|
+
const r = e[o], it = Lt(o), X = r.lineColor ?? r.color ?? it.line;
|
|
265
|
+
let E, G;
|
|
266
266
|
if (r.lineColor ?? r.color)
|
|
267
267
|
if (r.topColor && r.bottomColor)
|
|
268
|
-
|
|
268
|
+
E = r.topColor, G = r.bottomColor;
|
|
269
269
|
else if (r.topColor) {
|
|
270
|
-
const
|
|
271
|
-
|
|
270
|
+
const i = q(X);
|
|
271
|
+
E = r.topColor, G = i.bottomColor;
|
|
272
272
|
} else if (r.bottomColor)
|
|
273
|
-
|
|
273
|
+
E = q(X).topColor, G = r.bottomColor;
|
|
274
274
|
else {
|
|
275
|
-
const
|
|
276
|
-
|
|
275
|
+
const i = q(X);
|
|
276
|
+
E = i.topColor, G = i.bottomColor;
|
|
277
277
|
}
|
|
278
278
|
else
|
|
279
|
-
|
|
279
|
+
E = r.topColor || it.top, G = r.bottomColor || it.bottom;
|
|
280
280
|
if (r.data.length === 0) {
|
|
281
|
-
const
|
|
282
|
-
|
|
281
|
+
const i = R.current.get(r.label);
|
|
282
|
+
i && (t.removeSeries(i), R.current.delete(r.label));
|
|
283
283
|
continue;
|
|
284
284
|
}
|
|
285
|
-
const zt = (r.data.length > 0 ? Math.min(...r.data.map((
|
|
286
|
-
|
|
285
|
+
const zt = (r.data.length > 0 ? Math.min(...r.data.map((i) => i.value)) : 0) < 0, $t = r.data.some((i) => i.value === 0), Dt = !zt && $t, St = N || !h || _ === 0 ? "right" : `scale-${_}`;
|
|
286
|
+
h && rt.push({
|
|
287
287
|
priceScaleId: St || "right",
|
|
288
|
-
shouldPreventNegativeAxis:
|
|
288
|
+
shouldPreventNegativeAxis: Dt,
|
|
289
289
|
seriesIndex: _
|
|
290
290
|
});
|
|
291
|
-
const wt = (
|
|
291
|
+
const wt = (N || !h) && n !== void 0 && typeof n == "number", Rt = {
|
|
292
292
|
lineColor: X,
|
|
293
|
-
topColor:
|
|
293
|
+
topColor: E,
|
|
294
294
|
bottomColor: G,
|
|
295
295
|
priceScaleId: St,
|
|
296
296
|
priceFormat: {
|
|
297
297
|
type: "custom",
|
|
298
298
|
minMove: 0.01,
|
|
299
|
-
formatter: wt && typeof n == "number" ? (
|
|
300
|
-
|
|
299
|
+
formatter: wt && typeof n == "number" ? (i) => c(
|
|
300
|
+
i < n ? n : i
|
|
301
301
|
) : c,
|
|
302
|
-
tickmarksFormatter:
|
|
302
|
+
tickmarksFormatter: u
|
|
303
303
|
},
|
|
304
|
-
autoscaleInfoProvider: (
|
|
305
|
-
if (!wt) return
|
|
306
|
-
const st =
|
|
304
|
+
autoscaleInfoProvider: (i) => {
|
|
305
|
+
if (!wt) return i();
|
|
306
|
+
const st = i();
|
|
307
307
|
if (st?.priceRange) {
|
|
308
|
-
const
|
|
309
|
-
st.priceRange.minValue =
|
|
308
|
+
const Et = n;
|
|
309
|
+
st.priceRange.minValue = Et;
|
|
310
310
|
}
|
|
311
311
|
return st;
|
|
312
312
|
}
|
|
313
313
|
};
|
|
314
|
-
let
|
|
315
|
-
|
|
316
|
-
r.data.map((
|
|
317
|
-
...
|
|
318
|
-
time:
|
|
314
|
+
let B = R.current.get(r.label);
|
|
315
|
+
B ? (B.applyOptions(Rt), B.setData(
|
|
316
|
+
r.data.map((i) => ({
|
|
317
|
+
...i,
|
|
318
|
+
time: i.time
|
|
319
319
|
}))
|
|
320
|
-
)) : (
|
|
321
|
-
...
|
|
320
|
+
)) : (B = t.addSeries(Ot, {
|
|
321
|
+
...At,
|
|
322
322
|
...Rt
|
|
323
|
-
}),
|
|
324
|
-
r.data.map((
|
|
325
|
-
...
|
|
326
|
-
time:
|
|
323
|
+
}), B.setData(
|
|
324
|
+
r.data.map((i) => ({
|
|
325
|
+
...i,
|
|
326
|
+
time: i.time
|
|
327
327
|
}))
|
|
328
|
-
),
|
|
328
|
+
), R.current.set(r.label, B)), _++;
|
|
329
329
|
}
|
|
330
|
-
if (
|
|
330
|
+
if (h && rt.length > 0)
|
|
331
331
|
for (const o of rt)
|
|
332
332
|
try {
|
|
333
333
|
const r = t.priceScale(o.priceScaleId);
|
|
@@ -346,7 +346,7 @@ function ge({
|
|
|
346
346
|
borderVisible: !0,
|
|
347
347
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
348
348
|
entireTextOnly: !1,
|
|
349
|
-
textColor:
|
|
349
|
+
textColor: A
|
|
350
350
|
});
|
|
351
351
|
} catch (r) {
|
|
352
352
|
console.warn(
|
|
@@ -354,17 +354,17 @@ function ge({
|
|
|
354
354
|
r
|
|
355
355
|
);
|
|
356
356
|
}
|
|
357
|
-
else if (!
|
|
357
|
+
else if (!h)
|
|
358
358
|
try {
|
|
359
359
|
const o = t.priceScale("right");
|
|
360
360
|
o && o.applyOptions({
|
|
361
|
-
visible: !
|
|
361
|
+
visible: !S,
|
|
362
362
|
autoScale: !0,
|
|
363
363
|
scaleMargins: {
|
|
364
364
|
top: 0.1,
|
|
365
365
|
// No bottom margin when yScaleMin is set so the scale doesn't extend below the minimum (avoids negative labels like -10M)
|
|
366
|
-
bottom: n !== void 0 ||
|
|
367
|
-
...
|
|
366
|
+
bottom: n !== void 0 || p ? 0 : 0.1,
|
|
367
|
+
...p && {
|
|
368
368
|
top: 0.3
|
|
369
369
|
}
|
|
370
370
|
},
|
|
@@ -372,17 +372,17 @@ function ge({
|
|
|
372
372
|
borderVisible: !0,
|
|
373
373
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
374
374
|
entireTextOnly: !1,
|
|
375
|
-
textColor:
|
|
375
|
+
textColor: A
|
|
376
376
|
});
|
|
377
377
|
} catch {
|
|
378
378
|
}
|
|
379
|
-
n !== void 0 && !
|
|
379
|
+
n !== void 0 && !S && (N || !h) && t.applyOptions({
|
|
380
380
|
handleScroll: {
|
|
381
381
|
vertTouchDrag: !1
|
|
382
382
|
}
|
|
383
383
|
});
|
|
384
|
-
const at = new Set(e.map((o) => o.label)),
|
|
385
|
-
(
|
|
384
|
+
const at = new Set(e.map((o) => o.label)), It = at.size !== J.current.size || [...at].some((o) => !J.current.has(o)), Mt = z.length !== pt.current;
|
|
385
|
+
(ht.current || It || Mt || S) && (t.timeScale().fitContent(), ht.current = !1), J.current = at, pt.current = z.length;
|
|
386
386
|
const lt = /* @__PURE__ */ new Map();
|
|
387
387
|
for (const o of e)
|
|
388
388
|
o.data.length > 0 && lt.set(o.label, o.data[o.data.length - 1]);
|
|
@@ -391,141 +391,133 @@ function ge({
|
|
|
391
391
|
e,
|
|
392
392
|
z,
|
|
393
393
|
f,
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
394
|
+
v,
|
|
395
|
+
S,
|
|
396
|
+
N,
|
|
397
397
|
mt,
|
|
398
398
|
bt
|
|
399
|
-
]),
|
|
400
|
-
const t =
|
|
399
|
+
]), D(() => {
|
|
400
|
+
const t = V.current;
|
|
401
401
|
if (!t || e.length === 0) return;
|
|
402
402
|
const a = e.length === 1;
|
|
403
403
|
let n;
|
|
404
|
-
for (const
|
|
405
|
-
if (
|
|
406
|
-
n =
|
|
404
|
+
for (const s of e)
|
|
405
|
+
if (s.data.length > 0) {
|
|
406
|
+
n = s.data[s.data.length - 1].time;
|
|
407
407
|
break;
|
|
408
408
|
}
|
|
409
409
|
if (!n) return;
|
|
410
|
-
const
|
|
411
|
-
const { time: c = n, seriesData:
|
|
410
|
+
const l = (s) => {
|
|
411
|
+
const { time: c = n, seriesData: u, point: L } = s || {}, g = Array.from(R.current.values());
|
|
412
412
|
if (!L || !c) {
|
|
413
|
-
const
|
|
413
|
+
const y = /* @__PURE__ */ new Map();
|
|
414
414
|
for (const d of e)
|
|
415
|
-
d.data.length > 0 &&
|
|
416
|
-
if (tt(
|
|
417
|
-
|
|
418
|
-
else if (
|
|
419
|
-
const
|
|
420
|
-
if (
|
|
421
|
-
const
|
|
422
|
-
|
|
415
|
+
d.data.length > 0 && y.set(d.label, d.data[d.data.length - 1]);
|
|
416
|
+
if (tt(y.size > 0 ? y : void 0), a || N)
|
|
417
|
+
$(null);
|
|
418
|
+
else if (g[0] && n) {
|
|
419
|
+
const w = t.timeScale().timeToCoordinate(n), p = e[0];
|
|
420
|
+
if (p.data.length > 0) {
|
|
421
|
+
const h = p.data[p.data.length - 1].value, F = g[0].priceToCoordinate(h);
|
|
422
|
+
w !== null && F !== null && $({ x: w, y: F });
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
return;
|
|
426
426
|
}
|
|
427
|
-
const
|
|
428
|
-
let
|
|
429
|
-
for (let
|
|
430
|
-
const d = e[
|
|
431
|
-
if (!
|
|
432
|
-
const
|
|
433
|
-
|
|
427
|
+
const P = /* @__PURE__ */ new Map();
|
|
428
|
+
let T;
|
|
429
|
+
for (let y = 0; y < e.length; y++) {
|
|
430
|
+
const d = e[y], w = g[y];
|
|
431
|
+
if (!w) continue;
|
|
432
|
+
const p = u?.get(w), h = p && "value" in p ? p.value : void 0, F = d.data[d.data.length - 1], A = h !== void 0 ? h : F?.value ?? 0;
|
|
433
|
+
y === 0 && (T = A), P.set(d.label, { value: A, time: c });
|
|
434
434
|
}
|
|
435
|
-
if (tt(
|
|
436
|
-
const d = t.timeScale().timeToCoordinate(c),
|
|
437
|
-
if (d !== null &&
|
|
438
|
-
const
|
|
439
|
-
if (
|
|
440
|
-
const
|
|
435
|
+
if (tt(P), T !== void 0 && g[0]) {
|
|
436
|
+
const d = t.timeScale().timeToCoordinate(c), w = g[0].priceToCoordinate(T);
|
|
437
|
+
if (d !== null && w !== null) {
|
|
438
|
+
const p = M.current;
|
|
439
|
+
if (p) {
|
|
440
|
+
const h = p.querySelector(
|
|
441
441
|
".LightweightChart"
|
|
442
442
|
);
|
|
443
|
-
if (
|
|
444
|
-
const F =
|
|
445
|
-
|
|
443
|
+
if (h) {
|
|
444
|
+
const F = h.getBoundingClientRect(), A = p.getBoundingClientRect(), ot = d + (F.left - A.left), nt = w + (F.top - A.top);
|
|
445
|
+
$({ x: ot, y: nt });
|
|
446
446
|
} else
|
|
447
|
-
|
|
447
|
+
$({ x: d, y: w });
|
|
448
448
|
} else
|
|
449
|
-
|
|
449
|
+
$({ x: d, y: w });
|
|
450
450
|
} else
|
|
451
|
-
|
|
451
|
+
$(null);
|
|
452
452
|
} else
|
|
453
|
-
|
|
453
|
+
$(null);
|
|
454
454
|
};
|
|
455
|
-
return t.subscribeCrosshairMove(
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
458
|
-
const
|
|
459
|
-
|
|
455
|
+
return t.subscribeCrosshairMove(l), S && t.subscribeClick(l), !a && !N && requestAnimationFrame(() => {
|
|
456
|
+
const s = Array.from(R.current.values());
|
|
457
|
+
if (s[0] && n && e[0]?.data.length > 0) {
|
|
458
|
+
const u = t.timeScale().timeToCoordinate(n), L = e[0].data[e[0].data.length - 1].value, g = s[0].priceToCoordinate(L);
|
|
459
|
+
u !== null && g !== null && $({ x: u, y: g });
|
|
460
460
|
}
|
|
461
461
|
}), () => {
|
|
462
|
-
t.unsubscribeCrosshairMove(
|
|
462
|
+
t.unsubscribeCrosshairMove(l), S && t.unsubscribeClick(l);
|
|
463
463
|
};
|
|
464
|
-
}, [e,
|
|
465
|
-
const t =
|
|
464
|
+
}, [e, N, S]), D(() => {
|
|
465
|
+
const t = V.current;
|
|
466
466
|
if (!t || e.length === 0) return;
|
|
467
|
-
const a = t.timeScale(), n =
|
|
468
|
-
if (
|
|
469
|
-
const l = a.
|
|
467
|
+
const a = t.timeScale(), n = () => {
|
|
468
|
+
if (!Q.current) return;
|
|
469
|
+
const l = a.getVisibleRange();
|
|
470
470
|
if (!l) return;
|
|
471
|
-
const c =
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
for (let u = x; u <= d && u < m.data.length; u++)
|
|
479
|
-
h.push(m.data[u].value);
|
|
480
|
-
h.length > 0 && Q.current(h);
|
|
481
|
-
}
|
|
482
|
-
const b = 0.01;
|
|
483
|
-
let N = !1;
|
|
484
|
-
const v = { ...l };
|
|
485
|
-
g < c.from - b && (v.from = c.from, N = !0), L > c.to + b && (v.to = c.to, N = !0), N && a.setVisibleLogicalRange(v);
|
|
471
|
+
const s = Number(l.from), c = Number(l.to), u = [];
|
|
472
|
+
for (const L of e)
|
|
473
|
+
for (const g of L.data) {
|
|
474
|
+
const P = Number(g.time);
|
|
475
|
+
P >= s && P <= c && u.push(g.value);
|
|
476
|
+
}
|
|
477
|
+
u.length > 0 && Q.current(u);
|
|
486
478
|
};
|
|
487
|
-
return a.subscribeVisibleLogicalRangeChange(
|
|
479
|
+
return a.subscribeVisibleLogicalRangeChange(n), () => {
|
|
488
480
|
a.unsubscribeVisibleLogicalRangeChange(
|
|
489
|
-
|
|
481
|
+
n
|
|
490
482
|
);
|
|
491
483
|
};
|
|
492
|
-
}, [e]),
|
|
493
|
-
const t =
|
|
494
|
-
if (t && a.length > 0 &&
|
|
495
|
-
const
|
|
496
|
-
for (const c of
|
|
497
|
-
const
|
|
498
|
-
...
|
|
484
|
+
}, [e]), D(() => {
|
|
485
|
+
const t = V.current, a = Array.from(R.current.values()), n = [];
|
|
486
|
+
if (t && a.length > 0 && x) {
|
|
487
|
+
const l = Wt(), s = a[0];
|
|
488
|
+
for (const c of x) {
|
|
489
|
+
const u = new qt(t, s, c.xCoordinate, {
|
|
490
|
+
...l,
|
|
499
491
|
...c.options || {}
|
|
500
492
|
});
|
|
501
|
-
|
|
493
|
+
s.attachPrimitive(u), n.push(u);
|
|
502
494
|
}
|
|
503
495
|
}
|
|
504
496
|
return () => {
|
|
505
497
|
if (a.length > 0) {
|
|
506
|
-
const
|
|
507
|
-
for (const
|
|
508
|
-
|
|
498
|
+
const l = a[0];
|
|
499
|
+
for (const s of n)
|
|
500
|
+
l.detachPrimitive(s);
|
|
509
501
|
}
|
|
510
502
|
};
|
|
511
|
-
}, [
|
|
512
|
-
const t =
|
|
513
|
-
if (!t || !
|
|
503
|
+
}, [x]), D(() => {
|
|
504
|
+
const t = V.current;
|
|
505
|
+
if (!t || !x?.length) {
|
|
514
506
|
vt([]);
|
|
515
507
|
return;
|
|
516
508
|
}
|
|
517
509
|
const a = () => {
|
|
518
|
-
const
|
|
510
|
+
const s = t.timeScale(), c = x.map((u) => s.timeToCoordinate(u.xCoordinate) ?? null);
|
|
519
511
|
vt(c);
|
|
520
512
|
};
|
|
521
513
|
a();
|
|
522
|
-
const n = t.timeScale(),
|
|
514
|
+
const n = t.timeScale(), l = () => {
|
|
523
515
|
a();
|
|
524
516
|
};
|
|
525
|
-
return n.subscribeVisibleLogicalRangeChange(
|
|
526
|
-
n.unsubscribeVisibleLogicalRangeChange(
|
|
517
|
+
return n.subscribeVisibleLogicalRangeChange(l), () => {
|
|
518
|
+
n.unsubscribeVisibleLogicalRangeChange(l);
|
|
527
519
|
};
|
|
528
|
-
}, [
|
|
520
|
+
}, [x]);
|
|
529
521
|
const Y = e.length === 1, xt = ct.useMemo(() => {
|
|
530
522
|
if (Y && e.length > 0) {
|
|
531
523
|
const t = e[0];
|
|
@@ -533,85 +525,85 @@ function ge({
|
|
|
533
525
|
return t.data[t.data.length - 1];
|
|
534
526
|
}
|
|
535
527
|
}, [Y, e]);
|
|
536
|
-
return /* @__PURE__ */
|
|
528
|
+
return /* @__PURE__ */ H(
|
|
537
529
|
"div",
|
|
538
530
|
{
|
|
539
|
-
ref:
|
|
531
|
+
ref: M,
|
|
540
532
|
className: dt(
|
|
541
533
|
"relative z-[1] w-full h-full overflow-hidden p-0",
|
|
542
|
-
|
|
534
|
+
C
|
|
543
535
|
),
|
|
544
536
|
children: [
|
|
545
|
-
Z != null && Z !== !1 && Y ? /* @__PURE__ */
|
|
537
|
+
Z != null && Z !== !1 && Y ? /* @__PURE__ */ m("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ m("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: Z }) }) : Pt && Y && xt && /* @__PURE__ */ m(
|
|
546
538
|
Xt,
|
|
547
539
|
{
|
|
548
540
|
point: xt,
|
|
549
541
|
xMeasureUnit: f,
|
|
550
|
-
yMeasureUnit:
|
|
551
|
-
decimals:
|
|
542
|
+
yMeasureUnit: v,
|
|
543
|
+
decimals: j
|
|
552
544
|
}
|
|
553
545
|
),
|
|
554
|
-
W && et && /* @__PURE__ */
|
|
555
|
-
|
|
546
|
+
W && et && /* @__PURE__ */ m(
|
|
547
|
+
Nt,
|
|
556
548
|
{
|
|
557
549
|
points: W,
|
|
558
550
|
xMeasureUnit: f,
|
|
559
|
-
yMeasureUnit:
|
|
551
|
+
yMeasureUnit: v,
|
|
560
552
|
series: e,
|
|
561
553
|
position: et,
|
|
562
|
-
containerRef:
|
|
563
|
-
decimals:
|
|
554
|
+
containerRef: M,
|
|
555
|
+
decimals: j
|
|
564
556
|
}
|
|
565
557
|
),
|
|
566
|
-
W && !et && !Y &&
|
|
567
|
-
|
|
558
|
+
W && !et && !Y && S && /* @__PURE__ */ m(
|
|
559
|
+
Nt,
|
|
568
560
|
{
|
|
569
561
|
points: W,
|
|
570
562
|
xMeasureUnit: f,
|
|
571
|
-
yMeasureUnit:
|
|
563
|
+
yMeasureUnit: v,
|
|
572
564
|
series: e,
|
|
573
|
-
containerRef:
|
|
574
|
-
decimals:
|
|
565
|
+
containerRef: M,
|
|
566
|
+
decimals: j,
|
|
575
567
|
className: "top-2 left-2"
|
|
576
568
|
}
|
|
577
569
|
),
|
|
578
|
-
|
|
579
|
-
|
|
570
|
+
b && /* @__PURE__ */ m(Jt, { series: e, onUnselect: I }),
|
|
571
|
+
x && x.length > 0 && Ct.length === x.length && /* @__PURE__ */ m(
|
|
580
572
|
"div",
|
|
581
573
|
{
|
|
582
574
|
className: "absolute inset-0 z-[5] pointer-events-none",
|
|
583
575
|
"aria-hidden": !0,
|
|
584
|
-
children:
|
|
585
|
-
const n = Ct[a],
|
|
586
|
-
if (n === null || !
|
|
587
|
-
const { labelText: c, valueStr:
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
576
|
+
children: x.map((t, a) => {
|
|
577
|
+
const n = Ct[a], l = t.options ?? {}, s = l.showLabel !== !1;
|
|
578
|
+
if (n === null || !s) return null;
|
|
579
|
+
const { labelText: c, valueStr: u } = Zt(
|
|
580
|
+
l,
|
|
581
|
+
v,
|
|
582
|
+
j
|
|
591
583
|
);
|
|
592
|
-
if (!(c ||
|
|
593
|
-
const
|
|
594
|
-
return /* @__PURE__ */
|
|
584
|
+
if (!(c || u)) return null;
|
|
585
|
+
const g = l.labelBackgroundColor ?? l.color ?? "hsl(var(--background))", P = l.labelTextColor ?? "hsl(var(--foreground))", T = `${String(t.xCoordinate)}-${c}`;
|
|
586
|
+
return /* @__PURE__ */ H(
|
|
595
587
|
"div",
|
|
596
588
|
{
|
|
597
589
|
className: "absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
|
|
598
590
|
style: {
|
|
599
591
|
left: n,
|
|
600
592
|
transform: "translateX(-50%)",
|
|
601
|
-
backgroundColor:
|
|
602
|
-
color:
|
|
593
|
+
backgroundColor: g,
|
|
594
|
+
color: P
|
|
603
595
|
},
|
|
604
596
|
children: [
|
|
605
|
-
c && /* @__PURE__ */
|
|
606
|
-
|
|
597
|
+
c && /* @__PURE__ */ m("span", { className: "block", children: c }),
|
|
598
|
+
u && /* @__PURE__ */ m("span", { className: dt("block", c && "mt-0.5"), children: u })
|
|
607
599
|
]
|
|
608
600
|
},
|
|
609
|
-
|
|
601
|
+
T
|
|
610
602
|
);
|
|
611
603
|
})
|
|
612
604
|
}
|
|
613
605
|
),
|
|
614
|
-
/* @__PURE__ */
|
|
606
|
+
/* @__PURE__ */ m(
|
|
615
607
|
"div",
|
|
616
608
|
{
|
|
617
609
|
ref: U,
|
|
@@ -624,39 +616,39 @@ function ge({
|
|
|
624
616
|
}
|
|
625
617
|
function Jt({
|
|
626
618
|
series: e,
|
|
627
|
-
onUnselect:
|
|
619
|
+
onUnselect: C
|
|
628
620
|
}) {
|
|
629
|
-
return /* @__PURE__ */
|
|
630
|
-
const f =
|
|
631
|
-
return /* @__PURE__ */
|
|
621
|
+
return /* @__PURE__ */ m("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: e.map((b, I) => {
|
|
622
|
+
const f = Lt(I), v = (b.lineColor ?? b.color) || f.line, O = b.data.length === 0;
|
|
623
|
+
return /* @__PURE__ */ H(
|
|
632
624
|
"div",
|
|
633
625
|
{
|
|
634
626
|
className: dt(
|
|
635
627
|
"flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
636
|
-
|
|
628
|
+
O && "opacity-50"
|
|
637
629
|
),
|
|
638
630
|
children: [
|
|
639
|
-
/* @__PURE__ */
|
|
631
|
+
/* @__PURE__ */ m(
|
|
640
632
|
"div",
|
|
641
633
|
{
|
|
642
634
|
className: "w-3 h-3 rounded-sm",
|
|
643
|
-
style: { backgroundColor:
|
|
635
|
+
style: { backgroundColor: v }
|
|
644
636
|
}
|
|
645
637
|
),
|
|
646
|
-
/* @__PURE__ */
|
|
647
|
-
|
|
648
|
-
|
|
638
|
+
/* @__PURE__ */ H("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
|
|
639
|
+
b.label,
|
|
640
|
+
O && " (no data)"
|
|
649
641
|
] }),
|
|
650
|
-
|
|
642
|
+
C && /* @__PURE__ */ m(
|
|
651
643
|
"button",
|
|
652
644
|
{
|
|
653
645
|
type: "button",
|
|
654
|
-
onClick: (
|
|
655
|
-
|
|
646
|
+
onClick: (x) => {
|
|
647
|
+
x.stopPropagation(), C(b.label);
|
|
656
648
|
},
|
|
657
649
|
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
658
|
-
"aria-label": `Remove ${
|
|
659
|
-
children: /* @__PURE__ */
|
|
650
|
+
"aria-label": `Remove ${b.label}`,
|
|
651
|
+
children: /* @__PURE__ */ H(
|
|
660
652
|
"svg",
|
|
661
653
|
{
|
|
662
654
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -671,9 +663,9 @@ function Jt({
|
|
|
671
663
|
className: "text-muted-foreground hover:text-foreground",
|
|
672
664
|
"aria-hidden": "true",
|
|
673
665
|
children: [
|
|
674
|
-
/* @__PURE__ */
|
|
675
|
-
/* @__PURE__ */
|
|
676
|
-
/* @__PURE__ */
|
|
666
|
+
/* @__PURE__ */ m("title", { children: "Close" }),
|
|
667
|
+
/* @__PURE__ */ m("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
668
|
+
/* @__PURE__ */ m("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
677
669
|
]
|
|
678
670
|
}
|
|
679
671
|
)
|
|
@@ -681,13 +673,13 @@ function Jt({
|
|
|
681
673
|
)
|
|
682
674
|
]
|
|
683
675
|
},
|
|
684
|
-
|
|
676
|
+
b.label
|
|
685
677
|
);
|
|
686
678
|
}) });
|
|
687
679
|
}
|
|
688
680
|
export {
|
|
689
681
|
gt as DEFAULT_SERIES_COLORS,
|
|
690
682
|
ge as Graph,
|
|
691
|
-
|
|
683
|
+
Lt as getSeriesColorPalette,
|
|
692
684
|
Zt as getVerticalLineTooltipContent
|
|
693
685
|
};
|