@gearbox-protocol/ui-kit 3.12.2 → 3.13.0-next.2
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.
- package/dist/cjs/components/composites/strategies-table/components/rewards-tooltip/tooltip-content.cjs +1 -1
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/layout/main-aside-layout/main-aside-layout.cjs +1 -1
- package/dist/esm/components/composites/strategies-table/components/rewards-tooltip/tooltip-content.js +131 -122
- package/dist/esm/components/graph/graph.js +339 -293
- package/dist/esm/components/layout/main-aside-layout/main-aside-layout.js +70 -22
- package/dist/globals.css +1 -1
- package/dist/types/components/graph/graph.d.ts +8 -1
- package/dist/types/components/layout/main-aside-layout/main-aside-layout.d.ts +46 -5
- package/dist/types/components/trading-view/trading-view.d.ts +7 -0
- package/package.json +3 -3
- package/src/styles/base.css +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),B=require("@fortawesome/free-solid-svg-icons"),a=require("@gearbox-protocol/sdk"),k=require("viem"),D=require("../../../../icon-button/icon-button.cjs"),E=require("../../../../icons/fa-icon.cjs"),W=require("../../../../separate-line/separate-line.cjs"),T=require("../../../../skeleton/skeleton.cjs");require("react");const H=require("../../../../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk/common-utils");require("luxon");require("../../../../../utils/z-index.cjs");const b=require("../../../../tip-card/tip-card.cjs"),o=require("../../../../typed-intl/index.cjs"),c=require("../../../../typography/typography.cjs"),I=require("../../../../vertical-indicator/vertical-indicator.cjs"),f=require("../../../../vertical-list/vertical-list.cjs"),A=require("../../../../vspace/vspace.cjs"),p=require("../apy-feature/apy-feature.cjs"),d=require("../points-feature/points-feature.cjs"),O=require("./rewards-tooltip-root.cjs"),U=0;function X({cellInfo:n,targetToken:r,apyListByNetwork:s,tokensList:m,strategyCreditManagers:_,onClose:v,theme:Y="modal"}){const{maxAPY:R,minCreditManager:i,bonusAPY:P,maxLeverage:F,apyLoading:u,hasPoints:L,isPointsWithAPY:M,rewards:x,debtRewards:g,rewardRates:S,debtRewardRates:N,quotaRate:$}=n,q=i?.chainId||U,h=s?.[q]?.apyList?.[r]||0,l=s?.[q]?.extraCollateralAPYList?.[i?.pool||k.zeroAddress]?.[r],V=M||!L,z=h>0||l!==void 0&&l.value>0||x.length>0||g.length>0;return e.jsxs(O.RewardsTooltipRoot,{theme:Y,children:[v&&e.jsx("div",{style:{position:"absolute",top:"-10px",right:"-10px"},children:e.jsx(D.IconButton,{size:26,buttonType:"filledDark",onClick:v,children:e.jsx(E.FaIcon,{icon:B.faXmark,style:{width:"12px",height:"12px"}})})}),z&&e.jsxs(e.Fragment,{children:[e.jsx(b.TipCard,{textColor:"dark",children:e.jsxs(w,{title:e.jsx(o.FormattedMessageTyped,{messageId:"components.rewardsTooltip.without.title"}),children:[h>0&&e.jsx(T.Skeleton,{className:"inline-block align-text-bottom",width:50,loading:u,children:e.jsx(p.APYFeatureTooltip,{value:`${a.formatPercentage(h)}%`})}),l&&l.value>0&&e.jsx(T.Skeleton,{className:"inline-block align-text-bottom",width:50,loading:u,children:e.jsx(p.APYFeatureTooltip,{title:e.jsx(o.FormattedMessageTyped,{messageId:"components.rewardsTooltip.without.extra"}),tip:e.jsx(o.FormattedMessageTyped,{messageId:"components.rewardsTooltip.without.extra.tip"}),value:`${a.formatPercentage(l.value)}%`})}),x.map(t=>e.jsx(d.PointsFeatureTooltip,{reward:t,points:t.multiplier},["base",t.multiplier,t.name,t.type,t.units].join("-"))),g.map(t=>e.jsx(d.PointsFeatureTooltip,{reward:t,points:t.multiplier,tip:e.jsx(C,{tokensList:m,strategyCreditManagers:_,reward:t})},["debt",t.multiplier,t.name,t.type,t.units,t.cm].join("-")))]})}),e.jsx(A.VSpace,{height:16})]}),e.jsxs(b.TipCard,{textColor:"dark",borderColor:"gradient",children:[e.jsx(f.VerticalList,{children:e.jsxs(w,{title:e.jsx(o.FormattedMessageTyped,{messageId:"components.rewardsTooltip.with.title",values:{leverage:F>0?`${a.formatLeverage(Number(F))}×`:""}}),children:[V&&e.jsx(T.Skeleton,{className:"inline-block align-text-bottom",width:50,loading:u,children:e.jsx(p.APYFeatureTooltip,{value:`${a.formatPercentage(R)}%`})}),x.map((t,j)=>{const y=S?.[j]||0n;return e.jsx(d.PointsFeatureTooltip,{reward:t,points:y},["base",t.multiplier,t.name,t.type,t.units].join("-"))}),g.map((t,j)=>{const y=N?.[j]||0n;return e.jsx(d.PointsFeatureTooltip,{reward:t,points:y,tip:e.jsx(C,{tokensList:m,strategyCreditManagers:_,reward:t})},["debt",t.multiplier,t.name,t.type,t.units,t.cm].join("-"))})]})}),e.jsx(W.SeparateLine,{margin:16}),e.jsxs(f.VerticalList,{children:[i&&e.jsx(I.VerticalIndicator,{label:e.jsx(c.Typography,{as:"span",color:"secondary",children:e.jsx(o.FormattedMessageTyped,{values:{symbol:m?.[i.underlyingToken]?.title||"Utilization"},messageId:"components.rewardsTooltip.with.borrowRate"})}),value:e.jsx(c.Typography,{as:"span",color:"secondary",children:`${a.formatPercentage(i.baseBorrowRate)}%`})}),i&&e.jsx(I.VerticalIndicator,{label:e.jsx(c.Typography,{as:"span",color:"secondary",children:e.jsx(o.FormattedMessageTyped,{messageId:"components.rewardsTooltip.with.quotaRate"})}),value:e.jsx(c.Typography,{as:"span",color:"secondary",children:`${a.formatPercentage(Number($))}%`})})]})]}),P&&e.jsxs(e.Fragment,{children:[e.jsx(A.VSpace,{height:16}),e.jsx(b.TipCard,{backgroundColor:"gray-10",textColor:"light",borderColor:"dark",children:e.jsx(w,{title:e.jsx(o.FormattedMessageTyped,{messageId:"components.rewardsTooltip.with.bonusAPY.title"}),children:e.jsx("div",{className:"flex-col-12",children:e.jsx(p.APYFeatureTooltip,{theme:"light",tip:e.jsx(o.FormattedMessageTyped,{messageId:"components.rewardsTooltip.with.bonusAPY.tip"}),value:`${a.formatPercentage(P.value)}%`})})})})]})]})}function w({title:n,children:r,theme:s="main"}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:H.cn("flex-col-12",s==="main"?"mb-3":"mb-2"),children:e.jsx(c.Typography,{as:"span",variant:"bodySmall",weight:s==="main"?"bold":"normal",color:s==="main"?"default":"secondary",children:n})}),e.jsx("div",{className:"flex-row-row gap-2 w-full",children:r})]})}function C({reward:n,strategyCreditManagers:r,tokensList:s}){return n.cm==="any"?e.jsx(o.FormattedMessageTyped,{messageId:"components.strategiesTable.line.points.tipAny"}):e.jsx(o.FormattedMessageTyped,{messageId:"components.strategiesTable.line.points.tip",values:{symbol:s?.[r[n.cm]?.underlyingToken||k.zeroAddress]?.title||"unknown"}})}exports.RewardsTooltipContent=X;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),fe=require("lightweight-charts"),f=require("react"),Ae=require("../../hooks/use-media-query.cjs"),de=require("../../utils/cn.cjs"),D=require("../../utils/colors.cjs"),U=require("./default-config.cjs"),H=require("./formatters.cjs"),Oe=require("./graph-current-value.cjs"),De=require("./graph-tooltip.cjs"),qe=require("./plugins/vertical-line.cjs");function ze(e){const m=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const N=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(m,s,N.get?N:{enumerable:!0,get:()=>e[s]})}}return m.default=e,Object.freeze(m)}const ge=ze(f);function ke(e,m,s){const N=e.labelText??"",h=e.value,w=h===void 0?"":typeof h=="number"?m==="$"?`$${H.formatExactValue(h,void 0,s)}`:m==="%"?`${H.formatExactValue(h,void 0,s)}%`:H.formatExactValue(h,m!=="none"&&m!=="%"&&m!=="$"?m:void 0,s):String(h);return{labelText:N,valueStr:w}}function je(e,m){for(let s=e.length-1;s>=0;s--)if(Number(e[s].time)<=m)return e[s].value;return 0}const ee=[{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)"}],$e=137.5;function be(e){if(e<ee.length)return ee[e];const s=(e-ee.length)*$e%360,N=D.hslToHex(s,70,50),{topColor:h,bottomColor:w}=D.generateColorsFromBase(N);return{line:N,top:h,bottom:w}}function Be({series:e,className:m,showLegend:s=!1,onUnselectSeries:N,xMeasureUnit:h="time",yMeasureUnit:w="token",optionsOverrides:W,verticalLineOptions:S,currentValueDecimals:te,useSharedPriceScale:P=!1,showCurrentValue:Pe=!0,graphTitle:oe,yScaleMin:me,yScaleMinMultiple:he,visibleTimeFrom:A}){const L=f.useRef(null),V=f.useRef(new Map),re=f.useRef(!1),pe=f.useRef(!0),ne=f.useRef(null),Le=f.useRef(null),O=f.useRef(null),ae=f.useRef(null),K=f.useRef(null),y=Ae.useIsMobile(),M=ge.useMemo(()=>e.flatMap(t=>t.data),[e]),Te=ge.useMemo(()=>{if(e.length>0){const t=e[e.length-1];if(t.data.length>0)return t.data[t.data.length-1]}},[e]),[Ce,le]=f.useState(()=>{if(!Te)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}),[ve,E]=f.useState(null),[xe,Se]=f.useState([]);f.useEffect(()=>{const t=()=>{try{if(L.current&&O.current){const l=O.current.clientWidth,c=O.current.clientHeight;L.current.resize(l,c)}}catch{}},a=O.current,r=a?new ResizeObserver(t):null;return K.current=r,a&&r?.observe(a),()=>{a&&r?.unobserve(a),r?.disconnect(),K.current=null}},[]),f.useEffect(()=>{if(!ae.current||re.current)return;const t=U.getDefaultOptions(),a=D.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),r=fe.createChart(ae.current,{...t,rightPriceScale:{...t.rightPriceScale||{},visible:!y,textColor:a},...y&&{crosshair:{...t.crosshair,mode:fe.CrosshairMode.Magnet}},...W});return L.current=r,re.current=!0,()=>{K.current?.disconnect(),K.current=null,r.remove(),L.current=null,re.current=!1,V.current.clear()}},[y,W]),f.useEffect(()=>{const t=L.current;if(!t||e.length===0)return;const r=e.filter(o=>o.data.length>0).length<=1?me:he,l=h==="time"?H.getXFormatters(h,M):H.getXFormatters(h),c=M.map(o=>o.value),{formatter:u,tickmarksFormatter:d,updateVisibleRange:T,updateLastValues:p}=H.createAdaptiveYAxisFormatter(c,w,{yScaleMin:r});ne.current=T,Le.current=p;const F=e.filter(o=>o.data.length>0).map(o=>o.data[o.data.length-1].value);p(F);const k=U.getDefaultOptions();t.applyOptions({localization:{...k.localization||{},timeFormatter:o=>l.timeFormatter(parseFloat(o),void 0)},timeScale:{...k.timeScale||{},tickMarkFormatter:l.tickMarkFormatter,minBarSpacing:0}});const b=(M.length>0?Math.min(...M.map(o=>o.value)):0)<0,R=M.some(o=>o.value===0),C=!b&&R,x=e.length>1&&!P,v=e.length>1&&!P||y,_=D.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");t.applyOptions({rightPriceScale:{...k.rightPriceScale||{},visible:!v,textColor:_,...C&&{scaleMargins:{top:.3,bottom:0}}}});const X=new Set(V.current.keys()),se=new Set(e.map(o=>o.label));for(const o of X)if(!se.has(o)){const n=V.current.get(o);n&&(t.removeSeries(n),V.current.delete(o))}const Fe=U.getDefaultSeries(),ie=[];let J=0;for(let o=0;o<e.length;o++){const n=e[o],Z=be(o),q=n.lineColor??n.color??Z.line;let I,z;if(n.lineColor??n.color)if(n.topColor&&n.bottomColor)I=n.topColor,z=n.bottomColor;else if(n.topColor){const i=D.generateColorsFromBase(q);I=n.topColor,z=i.bottomColor}else if(n.bottomColor)I=D.generateColorsFromBase(q).topColor,z=n.bottomColor;else{const i=D.generateColorsFromBase(q);I=i.topColor,z=i.bottomColor}else I=n.topColor||Z.top,z=n.bottomColor||Z.bottom;if(n.data.length===0){const i=V.current.get(n.label);i&&(t.removeSeries(i),V.current.delete(n.label));continue}const Me=(n.data.length>0?Math.min(...n.data.map(i=>i.value)):0)<0,Ee=n.data.some(i=>i.value===0),_e=!Me&&Ee,Ne=P||!x||J===0?"right":`scale-${J}`;x&&ie.push({priceScaleId:Ne||"right",shouldPreventNegativeAxis:_e,seriesIndex:J});const we=(P||!x)&&r!==void 0&&typeof r=="number",Ve={lineColor:q,topColor:I,bottomColor:z,priceScaleId:Ne,priceFormat:{type:"custom",minMove:.01,formatter:we&&typeof r=="number"?i=>u(i<r?r:i):u,tickmarksFormatter:d},autoscaleInfoProvider:i=>{if(!we)return i();const G=i();if(G?.priceRange){const Y=r;G.priceRange.minValue=Y}return G}};let $=V.current.get(n.label);const B=n.data.map(i=>({...i,time:i.time}));if(A!==void 0&&B.length>0&&Number(B[0].time)>A){const i=Number(B[0].time),G=i-A,Y=86400,Ie=G>180*Y?7*Y:G>30*Y?Y:6*3600,ye=[];for(let ue=A;ue<i;ue+=Ie)ye.push({time:ue});B.unshift(...ye)}$?($.applyOptions(Ve),$.setData(B)):($=t.addSeries(fe.AreaSeries,{...Fe,...Ve}),$.setData(B),V.current.set(n.label,$)),J++}if(x&&ie.length>0)for(const o of ie)try{const n=t.priceScale(o.priceScaleId);n&&n.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:_})}catch(n){console.warn(`Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,n)}else if(!x)try{const o=t.priceScale("right");o&&o.applyOptions({visible:!y,autoScale:!0,scaleMargins:{top:.1,bottom:r!==void 0||C?0:.1,...C&&{top:.3}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:_})}catch{}if(r!==void 0&&!y&&(P||!x)&&t.applyOptions({handleScroll:{vertTouchDrag:!1}}),M.length>0){const o=M.map(I=>Number(I.time)),n=Math.min(...o),Z=A!==void 0?Math.min(A,n):n,q=Math.max(...o);t.timeScale().setVisibleRange({from:Z,to:q})}pe.current&&(pe.current=!1);const ce=new Map;for(const o of e)o.data.length>0&&ce.set(o.label,o.data[o.data.length-1]);le(ce.size>0?ce:void 0)},[e,M,h,w,y,P,me,he,A]),f.useEffect(()=>{const t=L.current;if(!t||e.length===0)return;const a=e.length===1;let r;for(const c of e)if(c.data.length>0){r=c.data[c.data.length-1].time;break}if(!r)return;const l=c=>{const{time:u=r,seriesData:d,point:T}=c||{},p=Array.from(V.current.values());if(!T||!u){const j=new Map;for(const b of e)b.data.length>0&&j.set(b.label,b.data[b.data.length-1]);if(le(j.size>0?j:void 0),a||P)E(null);else if(p[0]&&r){const R=t.timeScale().timeToCoordinate(r),C=e[0];if(C.data.length>0){const x=C.data[C.data.length-1].value,v=p[0].priceToCoordinate(x);R!==null&&v!==null&&E({x:R,y:v})}}return}const F=new Map;let k;for(let j=0;j<e.length;j++){const b=e[j],R=p[j];if(!R)continue;const C=d?.get(R),x=C&&"value"in C?C.value:void 0;let v;if(x!==void 0)v=x;else if(a){const _=Number(u),X=b.data.length>0?Number(b.data[0].time):Number.POSITIVE_INFINITY;_<X?v=Number.NaN:v=b.data[b.data.length-1]?.value??0}else v=je(b.data,Number(u));Number.isNaN(v)||(k===void 0&&(k=v),F.set(b.label,{value:v,time:u}))}if(le(F),k!==void 0&&p[0]){const b=t.timeScale().timeToCoordinate(u),R=p[0].priceToCoordinate(k);if(b!==null&&R!==null){const C=O.current;if(C){const x=C.querySelector(".LightweightChart");if(x){const v=x.getBoundingClientRect(),_=C.getBoundingClientRect(),X=b+(v.left-_.left),se=R+(v.top-_.top);E({x:X,y:se})}else E({x:b,y:R})}else E({x:b,y:R})}else E(null)}else E(null)};return t.subscribeCrosshairMove(l),y&&t.subscribeClick(l),!a&&!P&&requestAnimationFrame(()=>{const c=Array.from(V.current.values());if(c[0]&&r&&e[0]?.data.length>0){const d=t.timeScale().timeToCoordinate(r),T=e[0].data[e[0].data.length-1].value,p=c[0].priceToCoordinate(T);d!==null&&p!==null&&E({x:d,y:p})}}),()=>{t.unsubscribeCrosshairMove(l),y&&t.unsubscribeClick(l)}},[e,P,y]),f.useEffect(()=>{const t=L.current;if(!t||e.length===0)return;const a=t.timeScale(),r=()=>{if(!ne.current)return;const l=a.getVisibleRange();if(!l)return;const c=Number(l.from),u=Number(l.to),d=[];for(const T of e)for(const p of T.data){const F=Number(p.time);F>=c&&F<=u&&d.push(p.value)}d.length>0&&ne.current(d)};return a.subscribeVisibleLogicalRangeChange(r),()=>{a.unsubscribeVisibleLogicalRangeChange(r)}},[e]),f.useEffect(()=>{const t=L.current,a=Array.from(V.current.values()),r=[];if(t&&a.length>0&&S){const l=U.getDefaultVerticalLine(),c=a[0];for(const u of S){const d=new qe.VertLine(t,c,u.xCoordinate,{...l,...u.options||{}});c.attachPrimitive(d),r.push(d)}}return()=>{if(a.length>0){const l=a[0];for(const c of r)l.detachPrimitive(c)}}},[S]),f.useEffect(()=>{const t=L.current;if(!t||!S?.length){Se([]);return}const a=()=>{const c=t.timeScale(),u=S.map(d=>c.timeToCoordinate(d.xCoordinate)??null);Se(u)};a();const r=t.timeScale(),l=()=>{a()};return r.subscribeVisibleLogicalRangeChange(l),()=>{r.unsubscribeVisibleLogicalRangeChange(l)}},[S]);const Q=e.length===1,Re=ge.useMemo(()=>{if(Q&&e.length>0){const t=e[0];if(t.data.length>0)return t.data[t.data.length-1]}},[Q,e]);return g.jsxs("div",{ref:O,className:de.cn("relative z-[1] w-full h-full overflow-hidden p-0",m),children:[oe!=null&&oe!==!1&&Q?g.jsx("div",{className:"absolute top-2 left-2 right-2 z-[100] pointer-events-none",children:g.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:oe})}):Pe&&Q&&Re&&g.jsx(Oe.GraphCurrentValue,{point:Re,xMeasureUnit:h,yMeasureUnit:w,decimals:te}),Ce&&ve&&g.jsx(De.GraphTooltip,{points:Ce,xMeasureUnit:h,yMeasureUnit:w,series:e,position:ve,containerRef:O,decimals:te}),s&&g.jsx(Ge,{series:e,onUnselect:N}),S&&S.length>0&&xe.length===S.length&&g.jsx("div",{className:"absolute inset-0 z-[5] pointer-events-none","aria-hidden":!0,children:S.map((t,a)=>{const r=xe[a],l=t.options??{},c=l.showLabel!==!1;if(r===null||!c)return null;const{labelText:u,valueStr:d}=ke(l,w,te);if(!(u||d))return null;const p=l.labelBackgroundColor??l.color??"hsl(var(--background))",F=l.labelTextColor??"hsl(var(--foreground))",k=`${String(t.xCoordinate)}-${u}`;return g.jsxs("div",{className:"absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",style:{left:r,transform:"translateX(-50%)",backgroundColor:p,color:F},children:[u&&g.jsx("span",{className:"block",children:u}),d&&g.jsx("span",{className:de.cn("block",u&&"mt-0.5"),children:d})]},k)})}),g.jsx("div",{ref:ae,className:"LightweightChart w-full h-full overflow-hidden"})]})}function Ge({series:e,onUnselect:m}){return g.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((s,N)=>{const h=be(N),w=(s.lineColor??s.color)||h.line,W=s.data.length===0;return g.jsxs("div",{className:de.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",W&&"opacity-50"),children:[g.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:w}}),g.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[s.label,W&&" (no data)"]}),m&&g.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),m(s.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 ${s.label}`,children:g.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:[g.jsx("title",{children:"Close"}),g.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),g.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},s.label)})})}exports.DEFAULT_SERIES_COLORS=ee;exports.Graph=Be;exports.getSeriesColorPalette=be;exports.getStepForwardValue=je;exports.getVerticalLineTooltipContent=ke;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),ge=require("lightweight-charts"),f=require("react"),Oe=require("../../hooks/use-media-query.cjs"),he=require("../../utils/cn.cjs"),z=require("../../utils/colors.cjs"),ee=require("./default-config.cjs"),Y=require("./formatters.cjs"),ze=require("./graph-current-value.cjs"),Ae=require("./graph-tooltip.cjs"),qe=require("./plugins/vertical-line.cjs");function $e(e){const b=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const N=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(b,s,N.get?N:{enumerable:!0,get:()=>e[s]})}}return b.default=e,Object.freeze(b)}const de=$e(f);function Me(e,b,s){const N=e.labelText??"",m=e.value,w=m===void 0?"":typeof m=="number"?b==="$"?`$${Y.formatExactValue(m,void 0,s)}`:b==="%"?`${Y.formatExactValue(m,void 0,s)}%`:Y.formatExactValue(m,b!=="none"&&b!=="%"&&b!=="$"?b:void 0,s):String(m);return{labelText:N,valueStr:w}}function Pe(e,b){for(let s=e.length-1;s>=0;s--)if(Number(e[s].time)<=b)return e[s].value;return 0}const te=[{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)"}],We=137.5;function be(e){if(e<te.length)return te[e];const s=(e-te.length)*We%360,N=z.hslToHex(s,70,50),{topColor:m,bottomColor:w}=z.generateColorsFromBase(N);return{line:N,top:m,bottom:w}}function Be({series:e,className:b,showLegend:s=!1,onUnselectSeries:N,xMeasureUnit:m="time",yMeasureUnit:w="token",optionsOverrides:H,verticalLineOptions:S,currentValueDecimals:oe,useSharedPriceScale:j=!1,showCurrentValue:je=!0,graphTitle:re,yScaleMin:me,yScaleMinMultiple:pe,visibleTimeFrom:I,disableZoom:Q=!1}){const V=f.useRef(null),y=f.useRef(new Map),ne=f.useRef(!1),Ce=f.useRef(!0),ae=f.useRef(null),Te=f.useRef(null),O=f.useRef(null),le=f.useRef(null),J=f.useRef(null),k=Oe.useIsMobile(),D=de.useMemo(()=>e.flatMap(t=>t.data),[e]),Le=de.useMemo(()=>{if(e.length>0){const t=e[e.length-1];if(t.data.length>0)return t.data[t.data.length-1]}},[e]),[ve,se]=f.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}),[xe,E]=f.useState(null),[Se,Re]=f.useState([]);f.useEffect(()=>{const t=()=>{try{if(V.current&&O.current){const l=O.current.clientWidth,c=O.current.clientHeight;V.current.resize(l,c)}}catch{}},a=O.current,r=a?new ResizeObserver(t):null;return J.current=r,a&&r?.observe(a),()=>{a&&r?.unobserve(a),r?.disconnect(),J.current=null}},[]),f.useEffect(()=>{if(!le.current||ne.current)return;const t=ee.getDefaultOptions(),a=z.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),r=Q?{handleScale:{mouseWheel:!1,pinch:!1,axisPressedMouseMove:!1,axisDoubleClickReset:!1},handleScroll:{mouseWheel:!1,pressedMouseMove:!1,horzTouchDrag:!1,vertTouchDrag:!1}}:{},l=ge.createChart(le.current,{...t,rightPriceScale:{...t.rightPriceScale||{},visible:!k,textColor:a},...k&&{crosshair:{...t.crosshair,mode:ge.CrosshairMode.Magnet}},...r,...H});return V.current=l,ne.current=!0,()=>{J.current?.disconnect(),J.current=null,l.remove(),V.current=null,ne.current=!1,y.current.clear()}},[k,H,Q]),f.useEffect(()=>{const t=V.current;t&&t.applyOptions(Q?{handleScale:{mouseWheel:!1,pinch:!1,axisPressedMouseMove:!1,axisDoubleClickReset:!1},handleScroll:{mouseWheel:!1,pressedMouseMove:!1,horzTouchDrag:!1,vertTouchDrag:!1}}:{handleScale:{mouseWheel:!0,pinch:!0,axisPressedMouseMove:!0,axisDoubleClickReset:!0},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0}})},[Q]),f.useEffect(()=>{const t=V.current;if(!t||e.length===0)return;const r=e.filter(o=>o.data.length>0).length<=1?me:pe,l=m==="time"?Y.getXFormatters(m,D):Y.getXFormatters(m),c=D.map(o=>o.value),{formatter:u,tickmarksFormatter:d,updateVisibleRange:T,updateLastValues:p}=Y.createAdaptiveYAxisFormatter(c,w,{yScaleMin:r});ae.current=T,Te.current=p;const L=e.filter(o=>o.data.length>0).map(o=>o.data[o.data.length-1].value);p(L);const M=ee.getDefaultOptions();t.applyOptions({localization:{...M.localization||{},timeFormatter:o=>l.timeFormatter(parseFloat(o),void 0)},timeScale:{...M.timeScale||{},tickMarkFormatter:l.tickMarkFormatter,minBarSpacing:0}});const h=(D.length>0?Math.min(...D.map(o=>o.value)):0)<0,R=D.some(o=>o.value===0),C=!h&&R,x=e.length>1&&!j,v=e.length>1&&!j||k,F=z.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");t.applyOptions({rightPriceScale:{...M.rightPriceScale||{},visible:!v,textColor:F,...C&&{scaleMargins:{top:.3,bottom:0}}}});const X=new Set(y.current.keys()),ie=new Set(e.map(o=>o.label));for(const o of X)if(!ie.has(o)){const n=y.current.get(o);n&&(t.removeSeries(n),y.current.delete(o))}const De=ee.getDefaultSeries(),ce=[];let U=0;for(let o=0;o<e.length;o++){const n=e[o],K=be(o),A=n.lineColor??n.color??K.line;let _,q;if(n.lineColor??n.color)if(n.topColor&&n.bottomColor)_=n.topColor,q=n.bottomColor;else if(n.topColor){const i=z.generateColorsFromBase(A);_=n.topColor,q=i.bottomColor}else if(n.bottomColor)_=z.generateColorsFromBase(A).topColor,q=n.bottomColor;else{const i=z.generateColorsFromBase(A);_=i.topColor,q=i.bottomColor}else _=n.topColor||K.top,q=n.bottomColor||K.bottom;if(n.data.length===0){const i=y.current.get(n.label);i&&(t.removeSeries(i),y.current.delete(n.label));continue}const Ee=(n.data.length>0?Math.min(...n.data.map(i=>i.value)):0)<0,Fe=n.data.some(i=>i.value===0),_e=!Ee&&Fe,we=j||!x||U===0?"right":`scale-${U}`;x&&ce.push({priceScaleId:we||"right",shouldPreventNegativeAxis:_e,seriesIndex:U});const ye=(j||!x)&&r!==void 0&&typeof r=="number",Ve={lineColor:A,topColor:_,bottomColor:q,priceScaleId:we,priceFormat:{type:"custom",minMove:.01,formatter:ye&&typeof r=="number"?i=>u(i<r?r:i):u,tickmarksFormatter:d},autoscaleInfoProvider:i=>{if(!ye)return i();const B=i();if(B?.priceRange){const G=r;B.priceRange.minValue=G}return B}};let $=y.current.get(n.label);const W=n.data.map(i=>({...i,time:i.time}));if(I!==void 0&&W.length>0&&Number(W[0].time)>I){const i=Number(W[0].time),B=i-I,G=86400,Ie=B>180*G?7*G:B>30*G?G:6*3600,ke=[];for(let fe=I;fe<i;fe+=Ie)ke.push({time:fe});W.unshift(...ke)}$?($.applyOptions(Ve),$.setData(W)):($=t.addSeries(ge.AreaSeries,{...De,...Ve}),$.setData(W),y.current.set(n.label,$)),U++}if(x&&ce.length>0)for(const o of ce)try{const n=t.priceScale(o.priceScaleId);n&&n.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:F})}catch(n){console.warn(`Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,n)}else if(!x)try{const o=t.priceScale("right");o&&o.applyOptions({visible:!k,autoScale:!0,scaleMargins:{top:.1,bottom:r!==void 0||C?0:.1,...C&&{top:.3}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:F})}catch{}if(r!==void 0&&!k&&(j||!x)&&t.applyOptions({handleScroll:{vertTouchDrag:!1}}),D.length>0){const o=D.map(_=>Number(_.time)),n=Math.min(...o),K=I!==void 0?Math.min(I,n):n,A=Math.max(...o);t.timeScale().setVisibleRange({from:K,to:A})}Ce.current&&(Ce.current=!1);const ue=new Map;for(const o of e)o.data.length>0&&ue.set(o.label,o.data[o.data.length-1]);se(ue.size>0?ue:void 0)},[e,D,m,w,k,j,me,pe,I]),f.useEffect(()=>{const t=V.current;if(!t||e.length===0)return;const a=e.length===1;let r;for(const c of e)if(c.data.length>0){r=c.data[c.data.length-1].time;break}if(!r)return;const l=c=>{const{time:u=r,seriesData:d,point:T}=c||{},p=Array.from(y.current.values());if(!T||!u){const P=new Map;for(const h of e)h.data.length>0&&P.set(h.label,h.data[h.data.length-1]);if(se(P.size>0?P:void 0),a||j)E(null);else if(p[0]&&r){const R=t.timeScale().timeToCoordinate(r),C=e[0];if(C.data.length>0){const x=C.data[C.data.length-1].value,v=p[0].priceToCoordinate(x);R!==null&&v!==null&&E({x:R,y:v})}}return}const L=new Map;let M;for(let P=0;P<e.length;P++){const h=e[P],R=p[P];if(!R)continue;const C=d?.get(R),x=C&&"value"in C?C.value:void 0;let v;if(x!==void 0)v=x;else if(a){const F=Number(u),X=h.data.length>0?Number(h.data[0].time):Number.POSITIVE_INFINITY;F<X?v=Number.NaN:v=h.data[h.data.length-1]?.value??0}else v=Pe(h.data,Number(u));Number.isNaN(v)||(M===void 0&&(M=v),L.set(h.label,{value:v,time:u}))}if(se(L),M!==void 0&&p[0]){const h=t.timeScale().timeToCoordinate(u),R=p[0].priceToCoordinate(M);if(h!==null&&R!==null){const C=O.current;if(C){const x=C.querySelector(".LightweightChart");if(x){const v=x.getBoundingClientRect(),F=C.getBoundingClientRect(),X=h+(v.left-F.left),ie=R+(v.top-F.top);E({x:X,y:ie})}else E({x:h,y:R})}else E({x:h,y:R})}else E(null)}else E(null)};return t.subscribeCrosshairMove(l),k&&t.subscribeClick(l),!a&&!j&&requestAnimationFrame(()=>{const c=Array.from(y.current.values());if(c[0]&&r&&e[0]?.data.length>0){const d=t.timeScale().timeToCoordinate(r),T=e[0].data[e[0].data.length-1].value,p=c[0].priceToCoordinate(T);d!==null&&p!==null&&E({x:d,y:p})}}),()=>{t.unsubscribeCrosshairMove(l),k&&t.unsubscribeClick(l)}},[e,j,k]),f.useEffect(()=>{const t=V.current;if(!t||e.length===0)return;const a=t.timeScale(),r=()=>{if(!ae.current)return;const l=a.getVisibleRange();if(!l)return;const c=Number(l.from),u=Number(l.to),d=[];for(const T of e)for(const p of T.data){const L=Number(p.time);L>=c&&L<=u&&d.push(p.value)}d.length>0&&ae.current(d)};return a.subscribeVisibleLogicalRangeChange(r),()=>{a.unsubscribeVisibleLogicalRangeChange(r)}},[e]),f.useEffect(()=>{const t=V.current,a=Array.from(y.current.values()),r=[];if(t&&a.length>0&&S){const l=ee.getDefaultVerticalLine(),c=a[0];for(const u of S){const d=new qe.VertLine(t,c,u.xCoordinate,{...l,...u.options||{}});c.attachPrimitive(d),r.push(d)}}return()=>{if(a.length>0){const l=a[0];for(const c of r)l.detachPrimitive(c)}}},[S,e]),f.useEffect(()=>{const t=V.current;if(!t||!S?.length){Re([]);return}const a=()=>{const c=t.timeScale(),u=S.map(d=>c.timeToCoordinate(d.xCoordinate)??null);Re(u)};a();const r=t.timeScale(),l=()=>{a()};return r.subscribeVisibleLogicalRangeChange(l),()=>{r.unsubscribeVisibleLogicalRangeChange(l)}},[S,e]);const Z=e.length===1,Ne=de.useMemo(()=>{if(Z&&e.length>0){const t=e[0];if(t.data.length>0)return t.data[t.data.length-1]}},[Z,e]);return g.jsxs("div",{ref:O,className:he.cn("relative z-[1] w-full h-full overflow-hidden p-0",b),children:[re!=null&&re!==!1&&Z?g.jsx("div",{className:"absolute top-2 left-2 right-2 z-[100] pointer-events-none",children:g.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:re})}):je&&Z&&Ne&&g.jsx(ze.GraphCurrentValue,{point:Ne,xMeasureUnit:m,yMeasureUnit:w,decimals:oe}),ve&&xe&&g.jsx(Ae.GraphTooltip,{points:ve,xMeasureUnit:m,yMeasureUnit:w,series:e,position:xe,containerRef:O,decimals:oe}),s&&g.jsx(Ge,{series:e,onUnselect:N}),S&&S.length>0&&Se.length===S.length&&g.jsx("div",{className:"absolute inset-0 z-[5] pointer-events-none","aria-hidden":!0,children:S.map((t,a)=>{const r=Se[a],l=t.options??{},c=l.showLabel!==!1;if(r===null||!c)return null;const{labelText:u,valueStr:d}=Me(l,w,oe);if(!(u||d))return null;const p=l.labelBackgroundColor??l.color??"hsl(var(--background))",L=l.labelTextColor??"hsl(var(--foreground))",M=`${String(t.xCoordinate)}-${u}`;return g.jsxs("div",{className:"absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",style:{left:r,transform:"translateX(-50%)",backgroundColor:p,color:L},children:[u&&g.jsx("span",{className:"block",children:u}),d&&g.jsx("span",{className:he.cn("block",u&&"mt-0.5"),children:d})]},M)})}),g.jsx("div",{ref:le,className:"LightweightChart w-full h-full overflow-hidden"})]})}function Ge({series:e,onUnselect:b}){return g.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((s,N)=>{const m=be(N),w=(s.lineColor??s.color)||m.line,H=s.data.length===0;return g.jsxs("div",{className:he.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",H&&"opacity-50"),children:[g.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:w}}),g.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[s.label,H&&" (no data)"]}),b&&g.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),b(s.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 ${s.label}`,children:g.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:[g.jsx("title",{children:"Close"}),g.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),g.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},s.label)})})}exports.DEFAULT_SERIES_COLORS=te;exports.Graph=Be;exports.getSeriesColorPalette=be;exports.getStepForwardValue=Pe;exports.getVerticalLineTooltipContent=Me;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),w=require("react"),r=require("../../../utils/cn.cjs");function g(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const l in e)if(l!=="default"){const n=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(t,l,n.get?n:{enumerable:!0,get:()=>e[l]})}}return t.default=e,Object.freeze(t)}const d=g(w),m=d.forwardRef(({children:e,aside:t,asidePosition:l="right",asideClassName:n,mainClassName:c,mainRef:o,variant:s="default",className:p,...u},f)=>{const a=s==="detail",x=t==null?null:i.jsx("aside",{className:r.cn("min-w-0 shrink-0",a&&["w-full","z-30 lg:w-[420px] lg:min-w-[420px] lg:max-w-[420px]","xl:w-[460px] xl:min-w-[460px] xl:max-w-[460px]","max-h-full lg:max-h-[100vh] overflow-y-visible lg:overflow-y-auto","lg:max-[2449px]:sticky lg:max-[2449px]:top-4","min-[2450px]:fixed min-[2450px]:top-28 min-[2450px]:right-32"],n),children:t});return i.jsxs("div",{ref:f,className:r.cn("flex w-full flex-col-reverse gap-6 lg:flex-row lg:items-start",a&&["relative mx-auto min-w-0","max-w-[calc(80rem+420px+1.5rem)]","xl:max-w-[calc(80rem+460px+1.5rem)]","min-[2450px]:block min-[2450px]:max-w-none min-[2450px]:gap-0"],p),...u,children:[l==="left"&&x,i.jsx("div",{ref:o,className:r.cn("min-w-0 flex-1",a&&["relative z-0 w-full","min-[2450px]:mx-auto min-[2450px]:flex-none","min-[2450px]:max-w-[min(80rem,calc(100vw-460px-8rem))]"],c),children:e}),l==="right"&&x]})});m.displayName="MainAsideLayout";exports.MainAsideLayout=m;
|
|
@@ -1,160 +1,169 @@
|
|
|
1
|
-
import { jsxs as r, jsx as e, Fragment as
|
|
2
|
-
import { faXmark as
|
|
1
|
+
import { jsxs as r, jsx as e, Fragment as I } from "react/jsx-runtime";
|
|
2
|
+
import { faXmark as W } from "@fortawesome/free-solid-svg-icons";
|
|
3
3
|
import { formatPercentage as s, formatLeverage as _ } from "@gearbox-protocol/sdk";
|
|
4
|
-
import { zeroAddress as
|
|
4
|
+
import { zeroAddress as j } from "viem";
|
|
5
5
|
import { IconButton as H } from "../../../../icon-button/icon-button.js";
|
|
6
6
|
import { FaIcon as U } from "../../../../icons/fa-icon.js";
|
|
7
|
-
import { SeparateLine as
|
|
8
|
-
import { Skeleton as
|
|
7
|
+
import { SeparateLine as X } from "../../../../separate-line/separate-line.js";
|
|
8
|
+
import { Skeleton as v } from "../../../../skeleton/skeleton.js";
|
|
9
9
|
import "react";
|
|
10
|
-
import { cn as
|
|
10
|
+
import { cn as G } from "../../../../../utils/cn.js";
|
|
11
11
|
import "sonner";
|
|
12
12
|
import "@gearbox-protocol/sdk/common-utils";
|
|
13
13
|
import "luxon";
|
|
14
14
|
import "../../../../../utils/z-index.js";
|
|
15
|
-
import { TipCard as
|
|
15
|
+
import { TipCard as y } from "../../../../tip-card/tip-card.js";
|
|
16
16
|
import { FormattedMessageTyped as o } from "../../../../typed-intl/index.js";
|
|
17
|
-
import { Typography as
|
|
18
|
-
import { VerticalIndicator as
|
|
19
|
-
import { VerticalList as
|
|
20
|
-
import { VSpace as
|
|
21
|
-
import { APYFeatureTooltip as
|
|
22
|
-
import { PointsFeatureTooltip as
|
|
23
|
-
import { RewardsTooltipRoot as
|
|
24
|
-
const
|
|
25
|
-
function
|
|
17
|
+
import { Typography as p } from "../../../../typography/typography.js";
|
|
18
|
+
import { VerticalIndicator as R } from "../../../../vertical-indicator/vertical-indicator.js";
|
|
19
|
+
import { VerticalList as N } from "../../../../vertical-list/vertical-list.js";
|
|
20
|
+
import { VSpace as L } from "../../../../vspace/vspace.js";
|
|
21
|
+
import { APYFeatureTooltip as d } from "../apy-feature/apy-feature.js";
|
|
22
|
+
import { PointsFeatureTooltip as c } from "../points-feature/points-feature.js";
|
|
23
|
+
import { RewardsTooltipRoot as J } from "./rewards-tooltip-root.js";
|
|
24
|
+
const K = 0;
|
|
25
|
+
function ye({
|
|
26
26
|
cellInfo: a,
|
|
27
27
|
targetToken: n,
|
|
28
28
|
apyListByNetwork: i,
|
|
29
|
-
tokensList:
|
|
30
|
-
strategyCreditManagers:
|
|
31
|
-
onClose:
|
|
29
|
+
tokensList: h,
|
|
30
|
+
strategyCreditManagers: P,
|
|
31
|
+
onClose: A,
|
|
32
32
|
theme: F = "modal"
|
|
33
33
|
}) {
|
|
34
34
|
const {
|
|
35
35
|
maxAPY: S,
|
|
36
36
|
minCreditManager: l,
|
|
37
|
-
bonusAPY:
|
|
38
|
-
maxLeverage:
|
|
37
|
+
bonusAPY: C,
|
|
38
|
+
maxLeverage: Y,
|
|
39
39
|
apyLoading: u,
|
|
40
40
|
hasPoints: z,
|
|
41
41
|
isPointsWithAPY: D,
|
|
42
|
-
rewards:
|
|
43
|
-
debtRewards:
|
|
42
|
+
rewards: g,
|
|
43
|
+
debtRewards: w,
|
|
44
44
|
rewardRates: V,
|
|
45
45
|
debtRewardRates: q,
|
|
46
46
|
quotaRate: B
|
|
47
|
-
} = a,
|
|
48
|
-
return /* @__PURE__ */ r(
|
|
49
|
-
|
|
50
|
-
/* @__PURE__ */
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
b
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
d,
|
|
90
|
-
{
|
|
91
|
-
reward: t,
|
|
92
|
-
points: t.multiplier,
|
|
93
|
-
tip: /* @__PURE__ */ e(
|
|
94
|
-
$,
|
|
95
|
-
{
|
|
96
|
-
tokensList: c,
|
|
97
|
-
strategyCreditManagers: y,
|
|
98
|
-
reward: t
|
|
99
|
-
}
|
|
47
|
+
} = a, k = l?.chainId || K, b = i?.[k]?.apyList?.[n] || 0, m = i?.[k]?.extraCollateralAPYList?.[l?.pool || j]?.[n], E = D || !z, M = b > 0 || m !== void 0 && m.value > 0 || g.length > 0 || w.length > 0;
|
|
48
|
+
return /* @__PURE__ */ r(J, { theme: F, children: [
|
|
49
|
+
A && /* @__PURE__ */ e("div", { style: { position: "absolute", top: "-10px", right: "-10px" }, children: /* @__PURE__ */ e(H, { size: 26, buttonType: "filledDark", onClick: A, children: /* @__PURE__ */ e(U, { icon: W, style: { width: "12px", height: "12px" } }) }) }),
|
|
50
|
+
M && /* @__PURE__ */ r(I, { children: [
|
|
51
|
+
/* @__PURE__ */ e(y, { textColor: "dark", children: /* @__PURE__ */ r(
|
|
52
|
+
T,
|
|
53
|
+
{
|
|
54
|
+
title: /* @__PURE__ */ e(o, { messageId: "components.rewardsTooltip.without.title" }),
|
|
55
|
+
children: [
|
|
56
|
+
b > 0 && /* @__PURE__ */ e(
|
|
57
|
+
v,
|
|
58
|
+
{
|
|
59
|
+
className: "inline-block align-text-bottom",
|
|
60
|
+
width: 50,
|
|
61
|
+
loading: u,
|
|
62
|
+
children: /* @__PURE__ */ e(d, { value: `${s(b)}%` })
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
m && m.value > 0 && /* @__PURE__ */ e(
|
|
66
|
+
v,
|
|
67
|
+
{
|
|
68
|
+
className: "inline-block align-text-bottom",
|
|
69
|
+
width: 50,
|
|
70
|
+
loading: u,
|
|
71
|
+
children: /* @__PURE__ */ e(
|
|
72
|
+
d,
|
|
73
|
+
{
|
|
74
|
+
title: /* @__PURE__ */ e(o, { messageId: "components.rewardsTooltip.without.extra" }),
|
|
75
|
+
tip: /* @__PURE__ */ e(o, { messageId: "components.rewardsTooltip.without.extra.tip" }),
|
|
76
|
+
value: `${s(m.value)}%`
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
g.map((t) => /* @__PURE__ */ e(
|
|
82
|
+
c,
|
|
83
|
+
{
|
|
84
|
+
reward: t,
|
|
85
|
+
points: t.multiplier
|
|
86
|
+
},
|
|
87
|
+
["base", t.multiplier, t.name, t.type, t.units].join(
|
|
88
|
+
"-"
|
|
100
89
|
)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
90
|
+
)),
|
|
91
|
+
w.map((t) => /* @__PURE__ */ e(
|
|
92
|
+
c,
|
|
93
|
+
{
|
|
94
|
+
reward: t,
|
|
95
|
+
points: t.multiplier,
|
|
96
|
+
tip: /* @__PURE__ */ e(
|
|
97
|
+
$,
|
|
98
|
+
{
|
|
99
|
+
tokensList: h,
|
|
100
|
+
strategyCreditManagers: P,
|
|
101
|
+
reward: t
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
},
|
|
105
|
+
[
|
|
106
|
+
"debt",
|
|
107
|
+
t.multiplier,
|
|
108
|
+
t.name,
|
|
109
|
+
t.type,
|
|
110
|
+
t.units,
|
|
111
|
+
t.cm
|
|
112
|
+
].join("-")
|
|
113
|
+
))
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
) }),
|
|
117
|
+
/* @__PURE__ */ e(L, { height: 16 })
|
|
118
|
+
] }),
|
|
119
|
+
/* @__PURE__ */ r(y, { textColor: "dark", borderColor: "gradient", children: [
|
|
120
|
+
/* @__PURE__ */ e(N, { children: /* @__PURE__ */ r(
|
|
121
|
+
T,
|
|
113
122
|
{
|
|
114
123
|
title: /* @__PURE__ */ e(
|
|
115
124
|
o,
|
|
116
125
|
{
|
|
117
126
|
messageId: "components.rewardsTooltip.with.title",
|
|
118
127
|
values: {
|
|
119
|
-
leverage:
|
|
128
|
+
leverage: Y > 0 ? `${_(Number(Y))}×` : ""
|
|
120
129
|
}
|
|
121
130
|
}
|
|
122
131
|
),
|
|
123
132
|
children: [
|
|
124
133
|
E && /* @__PURE__ */ e(
|
|
125
|
-
|
|
134
|
+
v,
|
|
126
135
|
{
|
|
127
136
|
className: "inline-block align-text-bottom",
|
|
128
137
|
width: 50,
|
|
129
138
|
loading: u,
|
|
130
|
-
children: /* @__PURE__ */ e(
|
|
139
|
+
children: /* @__PURE__ */ e(d, { value: `${s(S)}%` })
|
|
131
140
|
}
|
|
132
141
|
),
|
|
133
|
-
|
|
134
|
-
const
|
|
142
|
+
g.map((t, f) => {
|
|
143
|
+
const x = V?.[f] || 0n;
|
|
135
144
|
return /* @__PURE__ */ e(
|
|
136
|
-
|
|
145
|
+
c,
|
|
137
146
|
{
|
|
138
147
|
reward: t,
|
|
139
|
-
points:
|
|
148
|
+
points: x
|
|
140
149
|
},
|
|
141
150
|
["base", t.multiplier, t.name, t.type, t.units].join(
|
|
142
151
|
"-"
|
|
143
152
|
)
|
|
144
153
|
);
|
|
145
154
|
}),
|
|
146
|
-
|
|
147
|
-
const
|
|
155
|
+
w.map((t, f) => {
|
|
156
|
+
const x = q?.[f] || 0n;
|
|
148
157
|
return /* @__PURE__ */ e(
|
|
149
|
-
|
|
158
|
+
c,
|
|
150
159
|
{
|
|
151
160
|
reward: t,
|
|
152
|
-
points:
|
|
161
|
+
points: x,
|
|
153
162
|
tip: /* @__PURE__ */ e(
|
|
154
163
|
$,
|
|
155
164
|
{
|
|
156
|
-
tokensList:
|
|
157
|
-
strategyCreditManagers:
|
|
165
|
+
tokensList: h,
|
|
166
|
+
strategyCreditManagers: P,
|
|
158
167
|
reward: t
|
|
159
168
|
}
|
|
160
169
|
)
|
|
@@ -172,52 +181,52 @@ function xe({
|
|
|
172
181
|
]
|
|
173
182
|
}
|
|
174
183
|
) }),
|
|
175
|
-
/* @__PURE__ */ e(
|
|
176
|
-
/* @__PURE__ */ r(
|
|
184
|
+
/* @__PURE__ */ e(X, { margin: 16 }),
|
|
185
|
+
/* @__PURE__ */ r(N, { children: [
|
|
177
186
|
l && /* @__PURE__ */ e(
|
|
178
|
-
|
|
187
|
+
R,
|
|
179
188
|
{
|
|
180
|
-
label: /* @__PURE__ */ e(
|
|
189
|
+
label: /* @__PURE__ */ e(p, { as: "span", color: "secondary", children: /* @__PURE__ */ e(
|
|
181
190
|
o,
|
|
182
191
|
{
|
|
183
192
|
values: {
|
|
184
|
-
symbol:
|
|
193
|
+
symbol: h?.[l.underlyingToken]?.title || "Utilization"
|
|
185
194
|
},
|
|
186
195
|
messageId: "components.rewardsTooltip.with.borrowRate"
|
|
187
196
|
}
|
|
188
197
|
) }),
|
|
189
|
-
value: /* @__PURE__ */ e(
|
|
198
|
+
value: /* @__PURE__ */ e(p, { as: "span", color: "secondary", children: `${s(
|
|
190
199
|
l.baseBorrowRate
|
|
191
200
|
)}%` })
|
|
192
201
|
}
|
|
193
202
|
),
|
|
194
203
|
l && /* @__PURE__ */ e(
|
|
195
|
-
|
|
204
|
+
R,
|
|
196
205
|
{
|
|
197
|
-
label: /* @__PURE__ */ e(
|
|
198
|
-
value: /* @__PURE__ */ e(
|
|
206
|
+
label: /* @__PURE__ */ e(p, { as: "span", color: "secondary", children: /* @__PURE__ */ e(o, { messageId: "components.rewardsTooltip.with.quotaRate" }) }),
|
|
207
|
+
value: /* @__PURE__ */ e(p, { as: "span", color: "secondary", children: `${s(Number(B))}%` })
|
|
199
208
|
}
|
|
200
209
|
)
|
|
201
210
|
] })
|
|
202
211
|
] }),
|
|
203
|
-
|
|
204
|
-
/* @__PURE__ */ e(
|
|
212
|
+
C && /* @__PURE__ */ r(I, { children: [
|
|
213
|
+
/* @__PURE__ */ e(L, { height: 16 }),
|
|
205
214
|
/* @__PURE__ */ e(
|
|
206
|
-
|
|
215
|
+
y,
|
|
207
216
|
{
|
|
208
217
|
backgroundColor: "gray-10",
|
|
209
218
|
textColor: "light",
|
|
210
219
|
borderColor: "dark",
|
|
211
220
|
children: /* @__PURE__ */ e(
|
|
212
|
-
|
|
221
|
+
T,
|
|
213
222
|
{
|
|
214
223
|
title: /* @__PURE__ */ e(o, { messageId: "components.rewardsTooltip.with.bonusAPY.title" }),
|
|
215
224
|
children: /* @__PURE__ */ e("div", { className: "flex-col-12", children: /* @__PURE__ */ e(
|
|
216
|
-
|
|
225
|
+
d,
|
|
217
226
|
{
|
|
218
227
|
theme: "light",
|
|
219
228
|
tip: /* @__PURE__ */ e(o, { messageId: "components.rewardsTooltip.with.bonusAPY.tip" }),
|
|
220
|
-
value: `${s(
|
|
229
|
+
value: `${s(C.value)}%`
|
|
221
230
|
}
|
|
222
231
|
) })
|
|
223
232
|
}
|
|
@@ -227,10 +236,10 @@ function xe({
|
|
|
227
236
|
] })
|
|
228
237
|
] });
|
|
229
238
|
}
|
|
230
|
-
function
|
|
231
|
-
return /* @__PURE__ */ r(
|
|
232
|
-
/* @__PURE__ */ e("div", { className:
|
|
233
|
-
|
|
239
|
+
function T({ title: a, children: n, theme: i = "main" }) {
|
|
240
|
+
return /* @__PURE__ */ r(I, { children: [
|
|
241
|
+
/* @__PURE__ */ e("div", { className: G("flex-col-12", i === "main" ? "mb-3" : "mb-2"), children: /* @__PURE__ */ e(
|
|
242
|
+
p,
|
|
234
243
|
{
|
|
235
244
|
as: "span",
|
|
236
245
|
variant: "bodySmall",
|
|
@@ -252,11 +261,11 @@ function $({
|
|
|
252
261
|
{
|
|
253
262
|
messageId: "components.strategiesTable.line.points.tip",
|
|
254
263
|
values: {
|
|
255
|
-
symbol: i?.[n[a.cm]?.underlyingToken ||
|
|
264
|
+
symbol: i?.[n[a.cm]?.underlyingToken || j]?.title || "unknown"
|
|
256
265
|
}
|
|
257
266
|
}
|
|
258
267
|
);
|
|
259
268
|
}
|
|
260
269
|
export {
|
|
261
|
-
|
|
270
|
+
ye as RewardsTooltipContent
|
|
262
271
|
};
|