@gearbox-protocol/permissionless-ui 1.15.4 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("class-variance-authority"),u=require("react"),b=require("../../utils/cn.cjs"),w=require("./graph.cjs");function N(s){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(a,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return a.default=s,Object.freeze(a)}const k=N(u),j=g.cva("relative w-full overflow-hidden rounded-lg border-border border bg-card text-card-foreground",{variants:{variant:{default:"shadow",elevated:"shadow-lg",outlined:"border-2",ghost:"border-0 shadow-none"},size:{sm:"h-48 sm:h-64",default:"h-64 sm:h-96",lg:"h-96 sm:h-[32rem]",xl:"h-[32rem] sm:h-[48rem]",full:"h-full"},padding:{none:"p-0",sm:"p-2",default:"p-4 sm:p-6",lg:"p-6"}},defaultVariants:{variant:"default",size:"default",padding:"default"}}),p=k.forwardRef(({className:s,variant:a,size:t,padding:n,title:l,description:i,toolbar:r,loading:d=!1,emptyMessage:o,error:c,children:h,...f},x)=>{const m=l||i||r;return e.jsxs("div",{ref:x,className:b.cn("flex flex-col",j({variant:a,size:t,padding:n,className:s})),...f,children:[m&&e.jsxs("div",{className:"mb-4 flex items-start justify-between gap-4 flex-shrink-0",children:[(l||i)&&e.jsxs("div",{className:"flex-1",children:[l&&e.jsx("h3",{className:"text-base sm:text-lg font-semibold leading-none tracking-tight",children:l}),i&&e.jsx("p",{className:"mt-1 text-xs sm:text-sm text-muted-foreground",children:i})]}),r&&e.jsx("div",{className:"flex-shrink-0 w-full",children:r})]}),e.jsxs("div",{className:"relative flex-1 w-full min-h-0",children:[d&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-transparent backdrop-blur-sm",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground",children:"Loading..."})]})}),c&&e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 text-destructive",children:[e.jsx("svg",{className:"h-12 w-12",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"text-xs sm:text-sm font-medium",children:c})]})}),!c&&!h&&o&&e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 text-muted-foreground",children:[e.jsx("svg",{className:"h-12 w-12",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"})}),e.jsx("span",{className:"text-xs sm:text-sm",children:o})]})}),!c&&h]})]})});p.displayName="GraphView";function y({series:s,onUnselectSeries:a,loading:t,title:n,description:l,toolbar:i,emptyMessage:r="No data available",error:d,containerClassName:o,variant:c,size:h,padding:f,...x}){const m=s.length>0,v=!t&&!m;return e.jsx(p,{className:o,variant:c,size:h,padding:f,title:n,description:l,toolbar:i,loading:t,error:d,emptyMessage:v?r:void 0,children:m&&!v&&!t&&e.jsx(w.Graph,{series:s,...a?{onUnselectSeries:a}:{},...x})})}function V(s=0){const a=u.useRef(null),t=u.useRef(null),[n,l]=u.useState(null);return u.useEffect(()=>{const i=()=>{if(a.current&&t.current){const o=t.current.clientWidth,c=a.current.clientWidth;l(o-c-s)}},r=t.current,d=r?new ResizeObserver(i):null;return r&&d?.observe(r),()=>{r&&d?.unobserve(r)}},[s]),{graphWidth:n,parentRef:t,asideRef:a}}exports.GraphView=p;exports.GraphViewWithData=y;exports.graphViewVariants=j;exports.useGraphAside=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("class-variance-authority"),u=require("react"),w=require("../../utils/cn.cjs"),N=require("./graph.cjs");function k(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(a,s,r.get?r:{enumerable:!0,get:()=>t[s]})}}return a.default=t,Object.freeze(a)}const y=k(u),v=b.cva("relative w-full overflow-hidden rounded-lg border-border border bg-card text-card-foreground",{variants:{variant:{default:"shadow",elevated:"shadow-lg",outlined:"border-2",ghost:"border-0 shadow-none"},size:{sm:"h-48 sm:h-64",default:"h-64 sm:h-96",lg:"h-96 sm:h-[32rem]",xl:"h-[32rem] sm:h-[48rem]",full:"h-full"},padding:{none:"p-0",sm:"p-2",default:"p-4 sm:p-6",lg:"p-6"}},defaultVariants:{variant:"default",size:"default",padding:"default"}}),g=y.forwardRef(({className:t,variant:a,size:s,padding:r,title:l,description:i,toolbar:n,loading:c=!1,emptyMessage:o,error:d,children:h,...m},f)=>{const x=l||i||n;return e.jsxs("div",{ref:f,className:w.cn("flex flex-col",v({variant:a,size:s,padding:r,className:t})),...m,children:[x&&e.jsxs("div",{className:"mb-4 flex items-start justify-between gap-4 flex-shrink-0",children:[(l||i)&&e.jsxs("div",{className:"flex-1",children:[l&&e.jsx("h3",{className:"text-base sm:text-lg font-semibold leading-none tracking-tight",children:l}),i&&e.jsx("p",{className:"mt-1 text-xs sm:text-sm text-muted-foreground",children:i})]}),n&&e.jsx("div",{className:"flex-shrink-0 w-full",children:n})]}),e.jsxs("div",{className:"relative flex-1 w-full min-h-0",children:[c&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-transparent backdrop-blur-sm",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground",children:"Loading..."})]})}),d&&e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 text-destructive",children:[e.jsx("svg",{className:"h-12 w-12",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"text-xs sm:text-sm font-medium",children:d})]})}),!d&&!h&&o&&e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 text-muted-foreground",children:[e.jsx("svg",{className:"h-12 w-12",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"})}),e.jsx("span",{className:"text-xs sm:text-sm",children:o})]})}),!d&&h]})]})});g.displayName="GraphView";function V({series:t,onUnselectSeries:a,loading:s,title:r,description:l,toolbar:i,emptyMessage:n="No data available",error:c,containerClassName:o,variant:d,size:h,padding:m,...f}){t.length>0&&t.some(p=>p.data.length>0),t.length>0&&t.some(p=>p.data.length>0);const x=!s&&t.length===0,j=t.length>0;return e.jsx(g,{className:o,variant:d,size:h,padding:m,title:r,description:l,toolbar:i,loading:s,error:c,emptyMessage:x?n:void 0,children:j&&!c&&e.jsx(N.Graph,{series:t,...a?{onUnselectSeries:a}:{},...f})})}function R(t=0){const a=u.useRef(null),s=u.useRef(null),[r,l]=u.useState(null);return u.useEffect(()=>{const i=()=>{if(a.current&&s.current){const o=s.current.clientWidth,d=a.current.clientWidth;l(o-d-t)}},n=s.current,c=n?new ResizeObserver(i):null;return n&&c?.observe(n),()=>{n&&c?.unobserve(n)}},[t]),{graphWidth:r,parentRef:s,asideRef:a}}exports.GraphView=g;exports.GraphViewWithData=V;exports.graphViewVariants=v;exports.useGraphAside=R;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),re=require("lightweight-charts"),g=require("react"),ne=require("../../hooks/use-media-query.cjs"),ae=require("../../utils/cn.cjs"),A=require("../../utils/colors.cjs"),I=require("./default-config.cjs"),Y=require("./formatters.cjs"),le=require("./graph-current-value.cjs"),ie=require("./graph-tooltip.cjs"),se=require("./plugins/vertical-line.cjs");function ce(e){const R=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const h in e)if(h!=="default"){const _=Object.getOwnPropertyDescriptor(e,h);Object.defineProperty(R,h,_.get?_:{enumerable:!0,get:()=>e[h]})}}return R.default=e,Object.freeze(R)}const Z=ce(g),D=[{line:"#02c39a",top:"rgba(2, 195, 154, 0.56)",bottom:"rgba(2, 195, 154, 0.04)"},{line:"#3b82f6",top:"rgba(59, 130, 246, 0.56)",bottom:"rgba(59, 130, 246, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 0.04)"},{line:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#8b5cf6",top:"rgba(139, 92, 246, 0.56)",bottom:"rgba(139, 92, 246, 0.04)"},{line:"#ec4899",top:"rgba(236, 72, 153, 0.56)",bottom:"rgba(236, 72, 153, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"}];function ue({series:e,className:R,showLegend:h=!1,onUnselectSeries:_,xMeasureUnit:w="time",yMeasureUnit:T="token",optionsOverrides:z,verticalLineOptions:B}){const x=g.useRef(null),y=g.useRef(new Map),G=g.useRef(!1),j=g.useRef(null),H=g.useRef(null),k=ne.useIsMobile(),E=Z.useMemo(()=>e.flatMap(o=>o.data),[e]),U=Z.useMemo(()=>{if(e.length>0){const o=e[e.length-1];if(o.data.length>0)return o.data[o.data.length-1]}},[e]),[Q,$]=g.useState(()=>{if(!U)return;const o=new Map;for(const n of e)n.data.length>0&&o.set(n.label,n.data[n.data.length-1]);return o}),[J,P]=g.useState(null);g.useEffect(()=>{const o=()=>{if(x.current&&j.current){const c=j.current.clientWidth,a=j.current.clientHeight;x.current.resize(c,a),x.current.timeScale().fitContent()}},n=j.current,l=n?new ResizeObserver(o):null;return n&&l?.observe(n),()=>{n&&l?.unobserve(n)}},[]),g.useEffect(()=>{if(!H.current||G.current)return;const o=I.getDefaultOptions(),n=A.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=re.createChart(H.current,{...o,rightPriceScale:{...o.rightPriceScale||{},visible:!k,textColor:n},...z});return x.current=l,G.current=!0,()=>{l.remove(),x.current=null,G.current=!1,y.current.clear()}},[k,z]),g.useEffect(()=>{const o=x.current;if(!o||e.length===0)return;const n=w==="time"?Y.getXFormatter(w,E):Y.getXFormatter(w),l=Y.getYFormatter(T),c=I.getDefaultOptions();o.applyOptions({localization:{...c.localization||{},timeFormatter:n?(t=>n(parseFloat(t),void 0)):void 0},timeScale:{...c.timeScale||{},tickMarkFormatter:n?(t=>n(parseFloat(t),void 0)):void 0,minBarSpacing:0}});const f=(E.length>0?Math.min(...E.map(t=>t.value)):0)<0,b=E.some(t=>t.value===0),V=!f&&b,i=e.length>1,L=i||k,S=A.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");o.applyOptions({rightPriceScale:{...c.rightPriceScale||{},visible:!k,textColor:S,...V&&{scaleMargins:{top:.3,bottom:0}}}});const m=new Set(y.current.keys()),s=new Set(e.map(t=>t.label));for(const t of m)if(!s.has(t)){const r=y.current.get(t);r&&(o.removeSeries(r),y.current.delete(t))}const p=I.getDefaultSeries(),u=[];for(let t=0;t<e.length;t++){const r=e[t],q=D[t%D.length],M=r.color||q.line;let F,O;if(r.color)if(r.topColor&&r.bottomColor)F=r.topColor,O=r.bottomColor;else if(r.topColor){const C=A.generateColorsFromBase(M);F=r.topColor,O=C.bottomColor}else if(r.bottomColor)F=A.generateColorsFromBase(M).topColor,O=r.bottomColor;else{const C=A.generateColorsFromBase(M);F=C.topColor,O=C.bottomColor}else F=r.topColor||q.top,O=r.bottomColor||q.bottom;const ee=(r.data.length>0?Math.min(...r.data.map(C=>C.value)):0)<0,te=r.data.some(C=>C.value===0),oe=!ee&&te,W=i?t===0?void 0:`scale-${t}`:void 0;i&&u.push({priceScaleId:W||"right",shouldPreventNegativeAxis:oe,seriesIndex:t});let N=y.current.get(r.label);N?(N.applyOptions({lineColor:M,topColor:F,bottomColor:O,priceScaleId:W}),N.setData(r.data)):(N=o.addAreaSeries({...p,lineColor:M,topColor:F,bottomColor:O,priceScaleId:W,priceFormat:{type:"custom",formatter:C=>l(parseFloat(C.toString()),void 0,"short")}}),N.setData(r.data),y.current.set(r.label,N))}if(i&&u.length>0)for(const t of u)try{const r=o.priceScale(t.priceScaleId);r&&r.applyOptions({visible:!L,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...t.shouldPreventNegativeAxis&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:S})}catch(r){console.warn(`Failed to configure price scale ${t.priceScaleId} for series ${t.seriesIndex}:`,r)}o.timeScale().fitContent();const v=new Map;for(const t of e)t.data.length>0&&v.set(t.label,t.data[t.data.length-1]);$(v.size>0?v:void 0)},[e,E,w,T,k]),g.useEffect(()=>{const o=x.current;if(!o||e.length===0)return;const n=e.length===1;let l;for(const a of e)if(a.data.length>0){l=a.data[a.data.length-1].time;break}if(!l)return;const c=a=>{const{time:f=l,seriesData:b,point:V}=a||{},i=Array.from(y.current.values());if(!V||!f){const m=new Map;for(const s of e)s.data.length>0&&m.set(s.label,s.data[s.data.length-1]);if($(m.size>0?m:void 0),n)P(null);else if(i[0]&&l){const p=o.timeScale().timeToCoordinate(l),u=e[0];if(u.data.length>0){const v=u.data[u.data.length-1].value,t=i[0].priceToCoordinate(v);p!==null&&t!==null&&P({x:p,y:t})}}return}const L=new Map;let S;for(let m=0;m<e.length;m++){const s=e[m],p=i[m];if(!p)continue;const u=b?.get(p),v=u&&"value"in u?u.value:void 0,t=s.data[s.data.length-1],r=v!==void 0?v:t?.value??0;m===0&&(S=r),L.set(s.label,{value:r,time:f})}if($(L),S!==void 0&&i[0]){const s=o.timeScale().timeToCoordinate(f),p=i[0].priceToCoordinate(S);if(s!==null&&p!==null){const u=j.current;if(u){const v=u.querySelector(".LightweightChart");if(v){const t=v.getBoundingClientRect(),r=u.getBoundingClientRect(),q=s+(t.left-r.left),M=p+(t.top-r.top);P({x:q,y:M})}else P({x:s,y:p})}else P({x:s,y:p})}else P(null)}else P(null)};return o.subscribeCrosshairMove(c),n||requestAnimationFrame(()=>{const a=Array.from(y.current.values());if(a[0]&&l&&e[0]?.data.length>0){const b=o.timeScale().timeToCoordinate(l),V=e[0].data[e[0].data.length-1].value,i=a[0].priceToCoordinate(V);b!==null&&i!==null&&P({x:b,y:i})}}),()=>{o.unsubscribeCrosshairMove(c)}},[e]),g.useEffect(()=>{const o=x.current;if(!o||e.length===0)return;const n=o.timeScale(),l=Math.max(...e.map(a=>a.data.length)),c=()=>{if(l===0)return;const a=n.getVisibleLogicalRange();if(!a)return;const f={from:0,to:l-1},b=typeof a.from=="number"?a.from:0,V=typeof a.to=="number"?a.to:l-1,i=.01;let L=!1;const S={...a};b<f.from-i&&(S.from=f.from,L=!0),V>f.to+i&&(S.to=f.to,L=!0),L&&n.setVisibleLogicalRange(S)};return n.subscribeVisibleLogicalRangeChange(c),()=>{n.unsubscribeVisibleLogicalRangeChange(c)}},[e]),g.useEffect(()=>{const o=x.current,n=Array.from(y.current.values()),l=[];if(o&&n.length>0&&B){const c=I.getDefaultVerticalLine(),a=n[0];for(const f of B){const b=new se.VertLine(o,a,f.xCoordinate,{...c,...f.options||{}});a.attachPrimitive(b),l.push(b)}}return()=>{if(n.length>0){const c=n[0];for(const a of l)c.detachPrimitive(a)}}},[B]);const X=e.length===1,K=Z.useMemo(()=>{if(X&&e.length>0){const o=e[0];if(o.data.length>0)return o.data[o.data.length-1]}},[X,e]);return d.jsxs("div",{ref:j,className:ae.cn("relative z-[1] w-full h-full overflow-hidden p-0",R),children:[X&&K&&d.jsx(le.GraphCurrentValue,{point:K,xMeasureUnit:w,yMeasureUnit:T}),Q&&J&&d.jsx(ie.GraphTooltip,{points:Q,xMeasureUnit:w,yMeasureUnit:T,series:e,position:J,containerRef:j}),h&&d.jsx(fe,{series:e,onUnselect:_}),d.jsx("div",{ref:H,className:"LightweightChart w-full h-full overflow-hidden"})]})}function fe({series:e,onUnselect:R}){return d.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((h,_)=>{const w=D[_%D.length],T=h.color||w.line;return d.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",children:[d.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:T}}),d.jsx("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:h.label}),R&&d.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),R(h.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 ${h.label}`,children:d.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:[d.jsx("title",{children:"Close"}),d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},h.label)})})}exports.DEFAULT_SERIES_COLORS=D;exports.Graph=ue;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),me=require("lightweight-charts"),i=require("react"),he=require("../../hooks/use-media-query.cjs"),se=require("../../utils/cn.cjs"),B=require("../../utils/colors.cjs"),$=require("./default-config.cjs"),ee=require("./formatters.cjs"),pe=require("./graph-current-value.cjs"),be=require("./graph-tooltip.cjs"),ve=require("./plugins/vertical-line.cjs");function Ce(e){const L=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const h in e)if(h!=="default"){const k=Object.getOwnPropertyDescriptor(e,h);Object.defineProperty(L,h,k.get?k:{enumerable:!0,get:()=>e[h]})}}return L.default=e,Object.freeze(L)}const te=Ce(i),G=[{line:"#02c39a",top:"rgba(2, 195, 154, 0.56)",bottom:"rgba(2, 195, 154, 0.04)"},{line:"#3b82f6",top:"rgba(59, 130, 246, 0.56)",bottom:"rgba(59, 130, 246, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 0.04)"},{line:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#8b5cf6",top:"rgba(139, 92, 246, 0.56)",bottom:"rgba(139, 92, 246, 0.04)"},{line:"#ec4899",top:"rgba(236, 72, 153, 0.56)",bottom:"rgba(236, 72, 153, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"}];function Se({series:e,className:L,showLegend:h=!1,onUnselectSeries:k,xMeasureUnit:P="time",yMeasureUnit:E="token",optionsOverrides:A,verticalLineOptions:D}){const S=i.useRef(null),x=i.useRef(new Map),X=i.useRef(!1),oe=i.useRef(new Set),re=i.useRef(null),ne=i.useRef(!0),V=i.useRef(null),W=i.useRef(null),z=he.useIsMobile(),T=te.useMemo(()=>e.flatMap(t=>t.data),[e]),ce=te.useMemo(()=>{if(e.length>0){const t=e[e.length-1];if(t.data.length>0)return t.data[t.data.length-1]}},[e]),[ae,Y]=i.useState(()=>{if(!ce)return;const t=new Map;for(const n of e)n.data.length>0&&t.set(n.label,n.data[n.data.length-1]);return t}),[le,M]=i.useState(null);i.useEffect(()=>{const t=()=>{if(S.current&&V.current){const u=V.current.clientWidth,a=V.current.clientHeight;S.current.resize(u,a),S.current.timeScale().fitContent()}},n=V.current,l=n?new ResizeObserver(t):null;return n&&l?.observe(n),()=>{n&&l?.unobserve(n)}},[]),i.useEffect(()=>{if(!W.current||X.current)return;const t=$.getDefaultOptions(),n=B.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=me.createChart(W.current,{...t,rightPriceScale:{...t.rightPriceScale||{},visible:!z,textColor:n},...A});return S.current=l,X.current=!0,()=>{l.remove(),S.current=null,X.current=!1,x.current.clear()}},[z,A]),i.useEffect(()=>{const t=S.current;if(!t||e.length===0)return;const n=P==="time"?ee.getXFormatter(P,T):ee.getXFormatter(P),l=ee.getYFormatter(E),u=$.getDefaultOptions();t.applyOptions({localization:{...u.localization||{},timeFormatter:n?(o=>n(parseFloat(o),void 0)):void 0},timeScale:{...u.timeScale||{},tickMarkFormatter:n?(o=>n(parseFloat(o),void 0)):void 0,minBarSpacing:0}});const g=(T.length>0?Math.min(...T.map(o=>o.value)):0)<0,R=T.some(o=>o.value===0),N=!g&&R,s=e.length>1,j=s||z,y=B.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");t.applyOptions({rightPriceScale:{...u.rightPriceScale||{},visible:!z,textColor:y,...N&&{scaleMargins:{top:.3,bottom:0}}}});const b=new Set(x.current.keys()),c=new Set(e.map(o=>o.label));for(const o of b)if(!c.has(o)){const r=x.current.get(o);r&&(t.removeSeries(r),x.current.delete(o))}const v=$.getDefaultSeries(),f=[];let C=0;for(let o=0;o<e.length;o++){const r=e[o],K=G[o%G.length],I=r.color||K.line;let O,_;if(r.color)if(r.topColor&&r.bottomColor)O=r.topColor,_=r.bottomColor;else if(r.topColor){const d=B.generateColorsFromBase(I);O=r.topColor,_=d.bottomColor}else if(r.bottomColor)O=B.generateColorsFromBase(I).topColor,_=r.bottomColor;else{const d=B.generateColorsFromBase(I);O=d.topColor,_=d.bottomColor}else O=r.topColor||K.top,_=r.bottomColor||K.bottom;if(r.data.length===0){const d=x.current.get(r.label);d&&(t.removeSeries(d),x.current.delete(r.label));continue}const fe=(r.data.length>0?Math.min(...r.data.map(d=>d.value)):0)<0,ge=r.data.some(d=>d.value===0),de=!fe&&ge,U=s?C===0?void 0:`scale-${C}`:void 0;s&&f.push({priceScaleId:U||"right",shouldPreventNegativeAxis:de,seriesIndex:C});let q=x.current.get(r.label);q?(q.applyOptions({lineColor:I,topColor:O,bottomColor:_,priceScaleId:U}),q.setData(r.data)):(q=t.addAreaSeries({...v,lineColor:I,topColor:O,bottomColor:_,priceScaleId:U,priceFormat:{type:"custom",formatter:d=>l(parseFloat(d.toString()),void 0,"short")}}),q.setData(r.data),x.current.set(r.label,q)),C++}if(s&&f.length>0)for(const o of f)try{const r=t.priceScale(o.priceScaleId);r&&r.applyOptions({visible:!j,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...o.shouldPreventNegativeAxis&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:y})}catch(r){console.warn(`Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,r)}let p=null;if(T.length>0){const o=T.map(r=>typeof r.time=="number"?r.time:Number(r.time));p={from:Math.min(...o),to:Math.max(...o)}}const w=new Set(e.map(o=>o.label)),H=oe.current,Q=w.size!==H.size||[...w].some(o=>!H.has(o)),F=re.current,ue=p&&F&&(Math.abs(p.from-F.from)>(F.to-F.from)*.1||Math.abs(p.to-F.to)>(F.to-F.from)*.1);(ne.current||Q||ue||!F)&&(requestAnimationFrame(()=>{S.current&&S.current.timeScale().fitContent()}),ne.current=!1),oe.current=w,re.current=p;const J=new Map;for(const o of e)o.data.length>0&&J.set(o.label,o.data[o.data.length-1]);Y(J.size>0?J:void 0)},[e,T,P,E,z]),i.useEffect(()=>{const t=S.current;if(!t||e.length===0)return;const n=e.length===1;let l;for(const a of e)if(a.data.length>0){l=a.data[a.data.length-1].time;break}if(!l)return;const u=a=>{const{time:g=l,seriesData:R,point:N}=a||{},s=Array.from(x.current.values());if(!N||!g){const b=new Map;for(const c of e)c.data.length>0&&b.set(c.label,c.data[c.data.length-1]);if(Y(b.size>0?b:void 0),n)M(null);else if(s[0]&&l){const v=t.timeScale().timeToCoordinate(l),f=e[0];if(f.data.length>0){const C=f.data[f.data.length-1].value,p=s[0].priceToCoordinate(C);v!==null&&p!==null&&M({x:v,y:p})}}return}const j=new Map;let y;for(let b=0;b<e.length;b++){const c=e[b],v=s[b];if(!v)continue;const f=R?.get(v),C=f&&"value"in f?f.value:void 0,p=c.data[c.data.length-1],w=C!==void 0?C:p?.value??0;b===0&&(y=w),j.set(c.label,{value:w,time:g})}if(Y(j),y!==void 0&&s[0]){const c=t.timeScale().timeToCoordinate(g),v=s[0].priceToCoordinate(y);if(c!==null&&v!==null){const f=V.current;if(f){const C=f.querySelector(".LightweightChart");if(C){const p=C.getBoundingClientRect(),w=f.getBoundingClientRect(),H=c+(p.left-w.left),Q=v+(p.top-w.top);M({x:H,y:Q})}else M({x:c,y:v})}else M({x:c,y:v})}else M(null)}else M(null)};return t.subscribeCrosshairMove(u),n||requestAnimationFrame(()=>{const a=Array.from(x.current.values());if(a[0]&&l&&e[0]?.data.length>0){const R=t.timeScale().timeToCoordinate(l),N=e[0].data[e[0].data.length-1].value,s=a[0].priceToCoordinate(N);R!==null&&s!==null&&M({x:R,y:s})}}),()=>{t.unsubscribeCrosshairMove(u)}},[e]),i.useEffect(()=>{const t=S.current;if(!t||e.length===0)return;const n=t.timeScale(),l=Math.max(...e.map(a=>a.data.length)),u=()=>{if(l===0)return;const a=n.getVisibleLogicalRange();if(!a)return;const g={from:0,to:l-1},R=typeof a.from=="number"?a.from:0,N=typeof a.to=="number"?a.to:l-1,s=.01;let j=!1;const y={...a};R<g.from-s&&(y.from=g.from,j=!0),N>g.to+s&&(y.to=g.to,j=!0),j&&n.setVisibleLogicalRange(y)};return n.subscribeVisibleLogicalRangeChange(u),()=>{n.unsubscribeVisibleLogicalRangeChange(u)}},[e]),i.useEffect(()=>{const t=S.current,n=Array.from(x.current.values()),l=[];if(t&&n.length>0&&D){const u=$.getDefaultVerticalLine(),a=n[0];for(const g of D){const R=new ve.VertLine(t,a,g.xCoordinate,{...u,...g.options||{}});a.attachPrimitive(R),l.push(R)}}return()=>{if(n.length>0){const u=n[0];for(const a of l)u.detachPrimitive(a)}}},[D]);const Z=e.length===1,ie=te.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 m.jsxs("div",{ref:V,className:se.cn("relative z-[1] w-full h-full overflow-hidden p-0",L),children:[Z&&ie&&m.jsx(pe.GraphCurrentValue,{point:ie,xMeasureUnit:P,yMeasureUnit:E}),ae&&le&&m.jsx(be.GraphTooltip,{points:ae,xMeasureUnit:P,yMeasureUnit:E,series:e,position:le,containerRef:V}),h&&m.jsx(xe,{series:e,onUnselect:k}),m.jsx("div",{ref:W,className:"LightweightChart w-full h-full overflow-hidden"})]})}function xe({series:e,onUnselect:L}){return m.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((h,k)=>{const P=G[k%G.length],E=h.color||P.line,A=h.data.length===0;return m.jsxs("div",{className:se.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",A&&"opacity-50"),children:[m.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:E}}),m.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[h.label,A&&" (no data)"]}),L&&m.jsx("button",{type:"button",onClick:D=>{D.stopPropagation(),L(h.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 ${h.label}`,children:m.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-muted-foreground hover:text-foreground","aria-hidden":"true",children:[m.jsx("title",{children:"Close"}),m.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),m.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},h.label)})})}exports.DEFAULT_SERIES_COLORS=G;exports.Graph=Se;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("react/jsx-runtime");require("react");const _=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk");const n=require("../../utils/format-money.cjs"),u=15e3,c=11e3,q=10500,s=t=>{if(!t)return;const e=Number(t);return e>=u?"good":e>c?"medium":e>q?"bad":e>n.PERCENTAGE_FACTOR?"critical":"liquidation"};function C({value:t,debt:e,decimals:a=3,zone:r,showColor:l=!0,className:d,...m}){const o=e!==void 0&&e===0n,i=(()=>{if(!o)return r??s(t)})(),f=()=>{if(!l||i===void 0)return"";switch(i){case"good":return"text-green-600";case"medium":return"text-yellow-600";case"bad":return"text-orange-500";case"critical":case"liquidation":return"text-destructive";default:return""}},g=()=>{if(o)return"N/A";const F=Number(t)/n.PERCENTAGE_FACTOR,A=n.formatPercentAmount(F,a);return String(A)};return H.jsx("div",{className:_.cn("font-medium",f(),d),...m,children:g()})}exports.BAD_HF=c;exports.GOOD_HF=u;exports.HealthFactor=C;exports.getHFZones=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("react/jsx-runtime");require("react");const _=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk");const n=require("../../utils/format-money.cjs"),u=15e3,c=11e3,q=10500,s=t=>{if(!t)return;const e=Number(t);return e>=u?"good":e>c?"medium":e>q?"bad":e>n.PERCENTAGE_FACTOR?"critical":"liquidation"};function C({value:t,debt:e,decimals:a=3,zone:r,showColor:l=!0,className:d,...m}){const o=e!==void 0&&e===0n,i=(()=>{if(!o)return r??s(t)})(),f=()=>{if(!l||i===void 0)return"";switch(i){case"good":return"text-green-600";case"medium":return"text-yellow-600";case"bad":return"text-orange-500";case"critical":case"liquidation":return"text-destructive";default:return""}},g=()=>{if(o)return"N/A";const F=Number(t)/n.PERCENTAGE_FACTOR,A=n.formatPercentAmount(F,a,!1);return String(A)};return H.jsx("div",{className:_.cn("font-medium",f(),d),...m,children:g()})}exports.BAD_HF=c;exports.GOOD_HF=u;exports.HealthFactor=C;exports.getHFZones=s;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),w=require("lucide-react"),l=require("react"),o=require("../select/select.cjs");function k({items:i,defaultItem:r,onSelected:h,multiple:a=!1,graphsWithNoData:b,loadingGraphs:g,onNoDataSelected:v}){const _=()=>{if(a){const n=Array.isArray(r)?r:[r];return n.length===0?"":String(n[0].value)}const e=Array.isArray(r)?r[0]:r;return String(e?.value||"")},p=()=>{if(a){const n=Array.isArray(r)?r:[r];return new Set(n.map(s=>s.value))}const e=Array.isArray(r)?r[0]:r;return new Set([e?.value].filter(Boolean))},[S,A]=l.useState(p),[u,f]=l.useState(_()),[C,N]=l.useState(!1),y=l.useRef(!1);l.useEffect(()=>{if(a){const e=Array.isArray(r)?r:[r],n=new Set(e.map(s=>s.value));A(n),e.length>0&&f(String(e[0].value))}else{const e=Array.isArray(r)?r[0]:r;e?.value&&f(String(e.value))}},[r,a]);const O=l.useCallback(e=>{if(!e&&a&&y.current){y.current=!1;return}N(e)},[a]),j=l.useCallback(e=>{const n=i.find(s=>String(s.value)===e);if(n&&!g?.has(n.value)){if(b?.has(n.value)){v&&v(n.value,n.label);return}a?(y.current=!0,A(s=>{const c=new Set(s);if(c.has(n.value)){if(c.size<=1)return s;c.delete(n.value)}else c.add(n.value);return h(Array.from(c)),c})):(f(e),h(n.value))}},[a,h,i,b,g,v]),x=l.useMemo(()=>{if(!a){const s=i.find(d=>String(d.value)===u),c=Array.isArray(r)?r[0]:r;return s||c}const e=Array.from(S).map(s=>i.find(c=>c.value===s)).filter(s=>!!s);return e.length===0?(Array.isArray(r)?r:[r])[0]:e.length===1?e[0]:{value:e[0].value,label:`${e.length} selected`}},[a,r,i,S,u]),R=l.useMemo(()=>a?"__multiple_placeholder__":u,[a,u]);return!i.length||i.length===1&&!a?t.jsx("div",{className:"flex items-center",style:{width:"max-content"},children:t.jsx("div",{className:"text-xl leading-6",children:x.label})}):t.jsxs(o.Select,{value:R,onValueChange:j,open:C,onOpenChange:O,children:[t.jsx(o.SelectTrigger,{className:"w-auto min-w-[16rem]",children:t.jsx(o.SelectValue,{children:x.label})}),t.jsxs(o.SelectContent,{className:"min-w-[16rem]",children:[a&&t.jsx(o.SelectItem,{value:"__multiple_placeholder__",className:"hidden",disabled:!0,children:x.label}),i.map((e,n)=>{const s=a&&S.has(e.value),c=g?.has(e.value),d=c;return t.jsx(o.SelectItem,{value:String(e.value),disabled:d,onSelect:V=>{a&&V.preventDefault(),j(String(e.value))},className:d?"opacity-50 cursor-not-allowed":"",children:t.jsxs("div",{className:"flex items-center gap-2",children:[a&&t.jsx("span",{className:`flex h-4 w-4 items-center justify-center rounded-[4px] border border-primary shadow transition-colors ${s?"bg-primary text-primary-foreground":""}`,children:s&&t.jsx(w.Check,{className:"h-4 w-4"})}),e.label,c&&t.jsx(w.Loader2,{className:"ml-1 h-4 w-4 animate-spin text-muted-foreground"})]})},`graph-item-${n}-${String(e.value)}`)})]})]})}exports.GraphDropdown=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),w=require("lucide-react"),t=require("react"),o=require("../select/select.cjs");function k({items:i,defaultItem:r,onSelected:g,multiple:a=!1,graphsWithNoData:A,loadingGraphs:v,onNoDataSelected:S}){const _=()=>{if(a){const n=Array.isArray(r)?r:[r];return n.length===0?"":String(n[0].value)}const e=Array.isArray(r)?r[0]:r;return String(e?.value||"")},C=()=>{if(a){const n=Array.isArray(r)?r:[r];return new Set(n.map(s=>s.value))}const e=Array.isArray(r)?r[0]:r;return new Set([e?.value].filter(Boolean))},[u,b]=t.useState(C),[d,y]=t.useState(_()),[p,N]=t.useState(!1),f=t.useRef(!1);t.useEffect(()=>{if(a){const e=Array.isArray(r)?r:[r],n=new Set(e.map(s=>s.value));b(n),e.length>0&&y(String(e[0].value))}else{const e=Array.isArray(r)?r[0]:r;e?.value&&y(String(e.value))}},[r,a]);const O=t.useCallback(e=>{if(!e&&a&&f.current){f.current=!1;return}N(e)},[a]),j=t.useCallback(e=>{const n=i.find(s=>String(s.value)===e);if(n&&!v?.has(n.value)){if(A?.has(n.value)&&!(a&&u.has(n.value))){S&&S(n.value,n.label);return}a?(f.current=!0,b(s=>{const c=new Set(s);if(c.has(n.value)){if(c.size<=1)return s;c.delete(n.value)}else c.add(n.value);return g(Array.from(c)),c})):(y(e),g(n.value))}},[a,g,i,A,v,S,u]),x=t.useMemo(()=>{if(!a){const s=i.find(h=>String(h.value)===d),c=Array.isArray(r)?r[0]:r;return s||c}const e=Array.from(u).map(s=>i.find(c=>c.value===s)).filter(s=>!!s);return e.length===0?(Array.isArray(r)?r:[r])[0]:e.length===1?e[0]:{value:e[0].value,label:`${e.length} selected`}},[a,r,i,u,d]),R=t.useMemo(()=>a?"__multiple_placeholder__":d,[a,d]);return!i.length||i.length===1&&!a?l.jsx("div",{className:"flex items-center",style:{width:"max-content"},children:l.jsx("div",{className:"text-xl leading-6",children:x.label})}):l.jsxs(o.Select,{value:R,onValueChange:j,open:p,onOpenChange:O,children:[l.jsx(o.SelectTrigger,{className:"w-auto min-w-[16rem]",children:l.jsx(o.SelectValue,{children:x.label})}),l.jsxs(o.SelectContent,{className:"min-w-[16rem]",children:[a&&l.jsx(o.SelectItem,{value:"__multiple_placeholder__",className:"hidden",disabled:!0,children:x.label}),i.map((e,n)=>{const s=a&&u.has(e.value),c=v?.has(e.value),h=c;return l.jsx(o.SelectItem,{value:String(e.value),disabled:h,onSelect:V=>{a&&V.preventDefault(),j(String(e.value))},className:h?"opacity-50 cursor-not-allowed":"",children:l.jsxs("div",{className:"flex items-center gap-2",children:[a&&l.jsx("span",{className:`flex h-4 w-4 items-center justify-center rounded-[4px] border border-primary shadow transition-colors ${s?"bg-primary text-primary-foreground":""}`,children:s&&l.jsx(w.Check,{className:"h-4 w-4"})}),e.label,c&&l.jsx(w.Loader2,{className:"ml-1 h-4 w-4 animate-spin text-muted-foreground"})]})},`graph-item-${n}-${String(e.value)}`)})]})]})}exports.GraphDropdown=k;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),F=require("sonner"),B=require("../../hooks/use-media-query.cjs"),W=require("../buttons/range-buttons/range-buttons.cjs"),a=require("../graph/graph.cjs"),z=require("../graph/graph-view.cjs"),H=require("./graph-dropdown.cjs"),P=({size:t=16})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Expand fullscreen",children:[e.jsx("title",{children:"Expand fullscreen"}),e.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})]}),$=({size:t=16})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Exit fullscreen",children:[e.jsx("title",{children:"Exit fullscreen"}),e.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"})]});function Q({data:t,yMeasureUnit:n,height:x=306,defaultGraph:g,onGraphSelected:v,graphs:b,isMultipleSelect:y,range:A,rangeList:E,setRange:L,onGraphExpanded:w,isGraphExpanded:R,onUnselectSeries:C,graphsWithNoData:D,loadingGraphs:I,noDataMessage:j="No data available for this graph"}){const u=i.useMemo(()=>Array.isArray(t)?t:t?[t]:[],[t]),S=i.useMemo(()=>Array.isArray(t)&&t.length>1,[t]),k=B.useIsMobile(),O=i.useCallback((d,l)=>{F.toast.error(j)},[j]),N=i.useMemo(()=>{if(n)return Array.isArray(n)?n[0]:n},[n]),M=e.jsxs("div",{className:"z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2",children:[e.jsx("div",{children:v&&b&&g&&e.jsx(H.GraphDropdown,{onSelected:v,items:b,defaultItem:g,multiple:y,graphsWithNoData:D,loadingGraphs:I,onNoDataSelected:O})}),e.jsxs("div",{className:"flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1",children:[e.jsx(W.RangeButtons,{range:A,rangeList:E,setRange:L}),!k&&w&&e.jsx("button",{type:"button",className:"px-2.5 py-1.5 flex min-w-[44px] min-h-[26px] justify-center items-center text-xs leading-[14px] font-medium text-center rounded-md border cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring bg-muted border-muted text-muted-foreground hover:border-secondary ml-1.5",onClick:w,children:R?e.jsx($,{size:16}):e.jsx(P,{size:16})})]})]}),c=i.useRef(new Map),f=i.useRef(0),T=i.useMemo(()=>{const d=Array.isArray(n)?n:void 0;return u.map((l,_)=>{const m=l?.title||`Series ${_+1}`;if(!c.current.has(m)){const r=new Set(Array.from(c.current.values()));let o=f.current;for(let s=0;s<a.DEFAULT_SERIES_COLORS.length;s++){const h=(f.current+s)%a.DEFAULT_SERIES_COLORS.length;if(!r.has(h)){o=h;break}}c.current.set(m,o),f.current=(o+1)%a.DEFAULT_SERIES_COLORS.length}const V=c.current.get(m)??0,p=a.DEFAULT_SERIES_COLORS[V%a.DEFAULT_SERIES_COLORS.length];return{data:[...l?.data||[]].sort((r,o)=>{const s=typeof r.time=="number"?r.time:Number(r.time),h=typeof o.time=="number"?o.time:Number(o.time);return s-h}).reduce((r,o)=>{const s=o.time;return r.length===0||r[r.length-1].time!==s?r.push({time:s,value:o.value}):r[r.length-1]={time:s,value:o.value},r},[]),label:m,yMeasureUnit:d?.[_]??(Array.isArray(n)?void 0:n),color:p.line,topColor:p.top,bottomColor:p.bottom}}).filter(l=>l.data.length>0)},[u,n]),q=S&&u.length>0?u.some(d=>!d):!t;return e.jsx("div",{style:{width:"100%",height:x?`${x}px`:void 0},className:"w-full",children:e.jsx(z.GraphViewWithData,{series:T,loading:q,toolbar:M,size:x?"full":"default",containerClassName:"h-full",showLegend:S,onUnselectSeries:C,yMeasureUnit:N})})}exports.TradingView=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),F=require("sonner"),B=require("../../hooks/use-media-query.cjs"),W=require("../buttons/range-buttons/range-buttons.cjs"),l=require("../graph/graph.cjs"),z=require("../graph/graph-view.cjs"),H=require("./graph-dropdown.cjs"),P=({size:t=16})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Expand fullscreen",children:[e.jsx("title",{children:"Expand fullscreen"}),e.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})]}),$=({size:t=16})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Exit fullscreen",children:[e.jsx("title",{children:"Exit fullscreen"}),e.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"})]});function Q({data:t,yMeasureUnit:n,height:h=306,defaultGraph:g,onGraphSelected:v,graphs:b,isMultipleSelect:y,range:A,rangeList:E,setRange:L,onGraphExpanded:w,isGraphExpanded:R,onUnselectSeries:C,graphsWithNoData:D,loadingGraphs:I,noDataMessage:j="No data available for this graph"}){const a=i.useMemo(()=>Array.isArray(t)?t:t?[t]:[],[t]),S=i.useMemo(()=>Array.isArray(t)&&t.length>1,[t]),k=B.useIsMobile(),O=i.useCallback((c,f)=>{F.toast.error(j)},[j]),N=i.useMemo(()=>{if(n)return Array.isArray(n)?n[0]:n},[n]),M=e.jsxs("div",{className:"z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2",children:[e.jsx("div",{children:v&&b&&g&&e.jsx(H.GraphDropdown,{onSelected:v,items:b,defaultItem:g,multiple:y,graphsWithNoData:D,loadingGraphs:I,onNoDataSelected:O})}),e.jsxs("div",{className:"flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1",children:[e.jsx(W.RangeButtons,{range:A,rangeList:E,setRange:L}),!k&&w&&e.jsx("button",{type:"button",className:"px-2.5 py-1.5 flex min-w-[44px] min-h-[26px] justify-center items-center text-xs leading-[14px] font-medium text-center rounded-md border cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring bg-muted border-muted text-muted-foreground hover:border-secondary ml-1.5",onClick:w,children:R?e.jsx($,{size:16}):e.jsx(P,{size:16})})]})]}),u=i.useRef(new Map),x=i.useRef(0),T=i.useMemo(()=>{const c=Array.isArray(n)?n:void 0;return a.map((f,_)=>{const d=f?.title||`Series ${_+1}`;if(!u.current.has(d)){const r=new Set(Array.from(u.current.values()));let o=x.current;for(let s=0;s<l.DEFAULT_SERIES_COLORS.length;s++){const m=(x.current+s)%l.DEFAULT_SERIES_COLORS.length;if(!r.has(m)){o=m;break}}u.current.set(d,o),x.current=(o+1)%l.DEFAULT_SERIES_COLORS.length}const V=u.current.get(d)??0,p=l.DEFAULT_SERIES_COLORS[V%l.DEFAULT_SERIES_COLORS.length];return{data:[...f?.data||[]].sort((r,o)=>{const s=typeof r.time=="number"?r.time:Number(r.time),m=typeof o.time=="number"?o.time:Number(o.time);return s-m}).reduce((r,o)=>{const s=o.time;return r.length===0||r[r.length-1].time!==s?r.push({time:s,value:o.value}):r[r.length-1]={time:s,value:o.value},r},[]),label:d,yMeasureUnit:c?.[_]??(Array.isArray(n)?void 0:n),color:p.line,topColor:p.top,bottomColor:p.bottom}})},[a,n]),q=S&&a.length>0?a.some(c=>!c):!t;return e.jsx("div",{style:{width:"100%",height:h?`${h}px`:void 0},className:"w-full",children:e.jsx(z.GraphViewWithData,{series:T,loading:q,toolbar:M,size:h?"full":"default",containerClassName:"h-full",showLegend:S,onUnselectSeries:C,yMeasureUnit:N})})}exports.TradingView=Q;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@gearbox-protocol/sdk"),p=10000000000000000n;function E(t){return BigInt(t.toFixed(18).replace(".",""))}function T(t,e){const f=typeof t=="number"&&t<0||typeof t=="bigint"&&t<0n?"-":"",r=typeof t=="number"?E(Math.abs(t)):o.BigIntMath.abs(t),i=r<p&&r>0n,m=i?"0.01":o.formatBN(r,o.WAD_DECIMALS_POW,e),a=`${f}$${m}`;return i?`< ${a}`:a}const N=1e4;function u(t,e){const n=typeof t=="number"?t:Number(t);return Number.isNaN(n)||n===void 0||n===null?"0":n===0?0:n>N?n.toExponential(e):n.toFixed(e)}function l(t,e=2){return`${u(t,e)}%`}const c=1e4;function A(t,e=2){const n=Number(t)/Number(c);return`${u(n,e)}%`}const s=1000n;function b(t,e=1){return t===void 0?"-":`${(t/Number(s)).toFixed(e)}%`}exports.PERCENTAGE_FACTOR=c;exports.SLIPPAGE_DECIMALS=s;exports.formatMoney=T;exports.formatPercentAmount=u;exports.percentTemplate=l;exports.percentageTemplate=A;exports.slippageTemplate=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@gearbox-protocol/sdk"),p=10000000000000000n;function E(t){return BigInt(t.toFixed(18).replace(".",""))}function T(t,e){const n=typeof t=="number"&&t<0||typeof t=="bigint"&&t<0n?"-":"",o=typeof t=="number"?E(Math.abs(t)):u.BigIntMath.abs(t),a=o<p&&o>0n,m=a?"0.01":u.formatBN(o,u.WAD_DECIMALS_POW,e),c=`${n}$${m}`;return a?`< ${c}`:c}const N=1e4;function i(t,e,r=!0){const n=typeof t=="number"?t:Number(t);return Number.isNaN(n)||n===void 0||n===null?"0":n===0?0:r&&n>N?n.toExponential(e):n.toFixed(e)}function l(t,e=2){return`${i(t,e)}%`}const s=1e4;function A(t,e=2){const r=Number(t)/Number(s);return`${i(r,e)}%`}const f=1000n;function b(t,e=1){return t===void 0?"-":`${(t/Number(f)).toFixed(e)}%`}exports.PERCENTAGE_FACTOR=s;exports.SLIPPAGE_DECIMALS=f;exports.formatMoney=T;exports.formatPercentAmount=i;exports.percentTemplate=l;exports.percentageTemplate=A;exports.slippageTemplate=b;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=1e-10,S=1e-4,F=1e11;function c(t){const i=Math.abs(t);return i<10?4:i<100?2:1}function l(t){return t.replace(/\.?0+$/,"")}function g(t,i={}){const{format:e="full",minimumFractionDigits:o=0,maximumFractionDigits:f,maxExponentialThreshold:d=F,adaptiveDecimals:u=!1}=i,s=f!==void 0?f:e==="short"?1:0,a=Math.abs(t);if(e==="short"){if(a>=5e8){const r=t/1e9,n=u?c(r):s;return`${l(r.toFixed(n))}B`}if(a>=1e6){const r=t/1e6,n=u?c(r):s;return`${l(r.toFixed(n))}M`}if(a>=1e3){const r=t/1e3,n=u?c(r):s;return`${l(r.toFixed(n))}K`}}return d&&a>d?t.toExponential(2):new Intl.NumberFormat("en-US",{minimumFractionDigits:o,maximumFractionDigits:s}).format(t)}function h(t,i){const e=10**i;return(Math.floor(t*e)/e).toFixed(i).replace(/\.?0+$/,"")}function x(t){return Math.abs(t)<m}function D(t){const i=Math.abs(t);return i<m&&i>0}function b(t,i){if(!D(t))return null;const e=`<${S}`;return i?`${e}${i}`:e}const p={EPSILON:m,MIN_DISPLAY_THRESHOLD:S,MAX_EXPONENTIAL_THRESHOLD:F};function N(t,i=2,e=6){if(!Number.isFinite(t))return"∞";const o=1/10**i;return t<o&&t!==0?t.toFixed(e).replace(/\.?0+$/,""):t>1?new Intl.NumberFormat("en-US",{minimumFractionDigits:i,maximumFractionDigits:i}).format(t):t.toFixed(i)}exports.FORMAT_CONSTANTS=p;exports.formatNumberWithSuffix=g;exports.formatPrice=N;exports.formatSmallValue=b;exports.getAdaptiveDecimals=c;exports.isBelowDisplayThreshold=D;exports.isEffectivelyZero=x;exports.toSignificantDigits=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=1e-10,h=1e-4,D=1e11;function m(t){const e=Math.abs(t);return e<10?4:e<100?2:1}function u(t){return t.replace(/\.?0+$/,"")}function S(t,e={}){const{format:i="full",minimumFractionDigits:r=0,maximumFractionDigits:o,maxExponentialThreshold:l=D,adaptiveDecimals:a=!1}=e,s=o!==void 0?o:i==="short"?1:0,f=Math.abs(t);if(i==="short"){if(f>=5e8){const n=t/1e9,c=a?m(n):s;return`${u(n.toFixed(c))}B`}if(f>=1e6){const n=t/1e6,c=a?m(n):s;return`${u(n.toFixed(c))}M`}if(f>=1e3){const n=t/1e3,c=a?m(n):s;return`${u(n.toFixed(c))}K`}}return l&&f>l?t.toExponential(2):new Intl.NumberFormat("en-US",{minimumFractionDigits:r,maximumFractionDigits:s}).format(t)}function F(t,e){const i=Math.abs(t);if(i>=1){const r=10**e;return(Math.floor(t*r)/r).toFixed(e).replace(/\.?0+$/,"")}if(i>0){const r=Math.floor(Math.log10(i)),o=Math.max(e,Math.abs(r)+e),a=Math.min(o,10);return t.toFixed(a).replace(/\.?0+$/,"")}return"0"}function M(t){return Math.abs(t)<d}function x(t){const e=Math.abs(t);return e<d&&e>0}function b(t,e){if(!x(t))return null;const i=`<${h}`;return e?`${i}${e}`:i}const g={EPSILON:d,MIN_DISPLAY_THRESHOLD:h,MAX_EXPONENTIAL_THRESHOLD:D};function p(t,e=2,i=6){if(!Number.isFinite(t))return"∞";const r=1/10**e;return t<r&&t!==0?t.toFixed(i).replace(/\.?0+$/,""):t>1?new Intl.NumberFormat("en-US",{minimumFractionDigits:e,maximumFractionDigits:e}).format(t):t.toFixed(e)}exports.FORMAT_CONSTANTS=g;exports.formatNumberWithSuffix=S;exports.formatPrice=p;exports.formatSmallValue=b;exports.getAdaptiveDecimals=m;exports.isBelowDisplayThreshold=x;exports.isEffectivelyZero=M;exports.toSignificantDigits=F;
@@ -1,10 +1,10 @@
1
- import { jsxs as d, jsx as e } from "react/jsx-runtime";
2
- import { cva as N } from "class-variance-authority";
3
- import * as b from "react";
4
- import { useRef as v, useState as w, useEffect as k } from "react";
5
- import { cn as j } from "../../utils/cn.js";
6
- import { Graph as W } from "./graph.js";
7
- const V = N(
1
+ import { jsxs as o, jsx as e } from "react/jsx-runtime";
2
+ import { cva as b } from "class-variance-authority";
3
+ import * as w from "react";
4
+ import { useRef as v, useState as k, useEffect as j } from "react";
5
+ import { cn as W } from "../../utils/cn.js";
6
+ import { Graph as R } from "./graph.js";
7
+ const V = b(
8
8
  "relative w-full overflow-hidden rounded-lg border-border border bg-card text-card-foreground",
9
9
  {
10
10
  variants: {
@@ -34,45 +34,45 @@ const V = N(
34
34
  padding: "default"
35
35
  }
36
36
  }
37
- ), g = b.forwardRef(
37
+ ), g = w.forwardRef(
38
38
  ({
39
- className: i,
40
- variant: r,
41
- size: a,
39
+ className: t,
40
+ variant: n,
41
+ size: r,
42
42
  padding: m,
43
43
  title: s,
44
- description: n,
45
- toolbar: t,
46
- loading: c = !1,
47
- emptyMessage: o,
48
- error: l,
44
+ description: l,
45
+ toolbar: a,
46
+ loading: i = !1,
47
+ emptyMessage: c,
48
+ error: d,
49
49
  children: h,
50
- ...u
51
- }, x) => {
52
- const f = s || n || t;
53
- return /* @__PURE__ */ d(
50
+ ...f
51
+ }, u) => {
52
+ const x = s || l || a;
53
+ return /* @__PURE__ */ o(
54
54
  "div",
55
55
  {
56
- ref: x,
57
- className: j(
56
+ ref: u,
57
+ className: W(
58
58
  "flex flex-col",
59
- V({ variant: r, size: a, padding: m, className: i })
59
+ V({ variant: n, size: r, padding: m, className: t })
60
60
  ),
61
- ...u,
61
+ ...f,
62
62
  children: [
63
- f && /* @__PURE__ */ d("div", { className: "mb-4 flex items-start justify-between gap-4 flex-shrink-0", children: [
64
- (s || n) && /* @__PURE__ */ d("div", { className: "flex-1", children: [
63
+ x && /* @__PURE__ */ o("div", { className: "mb-4 flex items-start justify-between gap-4 flex-shrink-0", children: [
64
+ (s || l) && /* @__PURE__ */ o("div", { className: "flex-1", children: [
65
65
  s && /* @__PURE__ */ e("h3", { className: "text-base sm:text-lg font-semibold leading-none tracking-tight", children: s }),
66
- n && /* @__PURE__ */ e("p", { className: "mt-1 text-xs sm:text-sm text-muted-foreground", children: n })
66
+ l && /* @__PURE__ */ e("p", { className: "mt-1 text-xs sm:text-sm text-muted-foreground", children: l })
67
67
  ] }),
68
- t && /* @__PURE__ */ e("div", { className: "flex-shrink-0 w-full", children: t })
68
+ a && /* @__PURE__ */ e("div", { className: "flex-shrink-0 w-full", children: a })
69
69
  ] }),
70
- /* @__PURE__ */ d("div", { className: "relative flex-1 w-full min-h-0", children: [
71
- c && /* @__PURE__ */ e("div", { className: "absolute inset-0 z-10 flex items-center justify-center bg-transparent backdrop-blur-sm", children: /* @__PURE__ */ d("div", { className: "flex flex-col items-center gap-2", children: [
70
+ /* @__PURE__ */ o("div", { className: "relative flex-1 w-full min-h-0", children: [
71
+ i && /* @__PURE__ */ e("div", { className: "absolute inset-0 z-10 flex items-center justify-center bg-transparent backdrop-blur-sm", children: /* @__PURE__ */ o("div", { className: "flex flex-col items-center gap-2", children: [
72
72
  /* @__PURE__ */ e("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" }),
73
73
  /* @__PURE__ */ e("span", { className: "text-xs sm:text-sm text-muted-foreground", children: "Loading..." })
74
74
  ] }) }),
75
- l && /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ d("div", { className: "flex flex-col items-center gap-2 text-destructive", children: [
75
+ d && /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ o("div", { className: "flex flex-col items-center gap-2 text-destructive", children: [
76
76
  /* @__PURE__ */ e(
77
77
  "svg",
78
78
  {
@@ -92,9 +92,9 @@ const V = N(
92
92
  )
93
93
  }
94
94
  ),
95
- /* @__PURE__ */ e("span", { className: "text-xs sm:text-sm font-medium", children: l })
95
+ /* @__PURE__ */ e("span", { className: "text-xs sm:text-sm font-medium", children: d })
96
96
  ] }) }),
97
- !l && !h && o && /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ d("div", { className: "flex flex-col items-center gap-2 text-muted-foreground", children: [
97
+ !d && !h && c && /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ o("div", { className: "flex flex-col items-center gap-2 text-muted-foreground", children: [
98
98
  /* @__PURE__ */ e(
99
99
  "svg",
100
100
  {
@@ -114,9 +114,9 @@ const V = N(
114
114
  )
115
115
  }
116
116
  ),
117
- /* @__PURE__ */ e("span", { className: "text-xs sm:text-sm", children: o })
117
+ /* @__PURE__ */ e("span", { className: "text-xs sm:text-sm", children: c })
118
118
  ] }) }),
119
- !l && h
119
+ !d && h
120
120
  ] })
121
121
  ]
122
122
  }
@@ -124,63 +124,64 @@ const V = N(
124
124
  }
125
125
  );
126
126
  g.displayName = "GraphView";
127
- function H({
128
- series: i,
129
- onUnselectSeries: r,
130
- loading: a,
127
+ function M({
128
+ series: t,
129
+ onUnselectSeries: n,
130
+ loading: r,
131
131
  title: m,
132
132
  description: s,
133
- toolbar: n,
134
- emptyMessage: t = "No data available",
135
- error: c,
136
- containerClassName: o,
137
- variant: l,
133
+ toolbar: l,
134
+ emptyMessage: a = "No data available",
135
+ error: i,
136
+ containerClassName: c,
137
+ variant: d,
138
138
  size: h,
139
- padding: u,
140
- ...x
139
+ padding: f,
140
+ ...u
141
141
  }) {
142
- const f = i.length > 0, p = !a && !f;
142
+ t.length > 0 && t.some((p) => p.data.length > 0), t.length > 0 && t.some((p) => p.data.length > 0);
143
+ const x = !r && t.length === 0, N = t.length > 0;
143
144
  return /* @__PURE__ */ e(
144
145
  g,
145
146
  {
146
- className: o,
147
- variant: l,
147
+ className: c,
148
+ variant: d,
148
149
  size: h,
149
- padding: u,
150
+ padding: f,
150
151
  title: m,
151
152
  description: s,
152
- toolbar: n,
153
- loading: a,
154
- error: c,
155
- emptyMessage: p ? t : void 0,
156
- children: f && !p && !a && /* @__PURE__ */ e(
157
- W,
153
+ toolbar: l,
154
+ loading: r,
155
+ error: i,
156
+ emptyMessage: x ? a : void 0,
157
+ children: N && !i && /* @__PURE__ */ e(
158
+ R,
158
159
  {
159
- series: i,
160
- ...r ? { onUnselectSeries: r } : {},
161
- ...x
160
+ series: t,
161
+ ...n ? { onUnselectSeries: n } : {},
162
+ ...u
162
163
  }
163
164
  )
164
165
  }
165
166
  );
166
167
  }
167
- function D(i = 0) {
168
- const r = v(null), a = v(null), [m, s] = w(null);
169
- return k(() => {
170
- const n = () => {
171
- if (r.current && a.current) {
172
- const o = a.current.clientWidth, l = r.current.clientWidth;
173
- s(o - l - i);
168
+ function A(t = 0) {
169
+ const n = v(null), r = v(null), [m, s] = k(null);
170
+ return j(() => {
171
+ const l = () => {
172
+ if (n.current && r.current) {
173
+ const c = r.current.clientWidth, d = n.current.clientWidth;
174
+ s(c - d - t);
174
175
  }
175
- }, t = a.current, c = t ? new ResizeObserver(n) : null;
176
- return t && c?.observe(t), () => {
177
- t && c?.unobserve(t);
176
+ }, a = r.current, i = a ? new ResizeObserver(l) : null;
177
+ return a && i?.observe(a), () => {
178
+ a && i?.unobserve(a);
178
179
  };
179
- }, [i]), { graphWidth: m, parentRef: a, asideRef: r };
180
+ }, [t]), { graphWidth: m, parentRef: r, asideRef: n };
180
181
  }
181
182
  export {
182
183
  g as GraphView,
183
- H as GraphViewWithData,
184
+ M as GraphViewWithData,
184
185
  V as graphViewVariants,
185
- D as useGraphAside
186
+ A as useGraphAside
186
187
  };