@gearbox-protocol/ui-kit 4.5.1 → 4.6.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.
Files changed (22) hide show
  1. package/dist/cjs/components/base/apy-breakdown-body/apy-breakdown-body.cjs +1 -1
  2. package/dist/cjs/components/base/apy-breakdown-body/index.cjs +1 -1
  3. package/dist/cjs/components/base/info-list/info-list.cjs +1 -1
  4. package/dist/cjs/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.cjs +1 -1
  5. package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs +1 -1
  6. package/dist/cjs/components/compound-apy/compound-apy.cjs +1 -1
  7. package/dist/cjs/components/graph/graph.cjs +1 -1
  8. package/dist/cjs/components/yield-breakdown-tooltip/yield-breakdown.cjs +1 -1
  9. package/dist/esm/components/base/apy-breakdown-body/apy-breakdown-body.js +70 -45
  10. package/dist/esm/components/base/apy-breakdown-body/index.js +8 -7
  11. package/dist/esm/components/base/info-list/info-list.js +14 -13
  12. package/dist/esm/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.js +68 -64
  13. package/dist/esm/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.js +109 -105
  14. package/dist/esm/components/compound-apy/compound-apy.js +22 -20
  15. package/dist/esm/components/graph/graph.js +53 -52
  16. package/dist/esm/components/yield-breakdown-tooltip/yield-breakdown.js +92 -79
  17. package/dist/types/components/base/apy-breakdown-body/apy-breakdown-body.d.ts +5 -0
  18. package/dist/types/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.d.ts +3 -1
  19. package/dist/types/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.d.ts +3 -1
  20. package/dist/types/components/compound-apy/compound-apy.d.ts +3 -1
  21. package/dist/types/components/yield-breakdown-tooltip/yield-breakdown.d.ts +3 -1
  22. package/package.json +2 -2
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("../../../utils/cn.cjs"),i=require("../../../utils/internal/bps-to-percent.cjs"),c="—",u="400px";function x(t,n,s){return t==="7d"?s:n}function m(t,n=!1){const s=i.bpsToPercent(t),a=`${Math.abs(s).toFixed(2)}%`;return n&&s<0?`−${a}`:a}function f(t){return Number(Math.abs(i.bpsToPercent(t)).toFixed(2))}function p({title:t,chip:n,chipPositive:s=!1,chipTestId:a,children:r,testId:d}){return e.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-4 rounded-xl border border-border bg-card p-4","data-testid":d,children:[e.jsxs("div",{className:"flex min-h-6 items-center justify-between gap-3",children:[e.jsx("span",{className:"min-w-0 text-base font-semibold leading-5 text-foreground",children:t}),e.jsx("span",{className:o.cn("shrink-0 rounded-md px-2 py-0.5 text-sm font-semibold tabular-nums",s?"bg-success/20 text-success":"bg-muted text-muted-foreground"),"data-testid":a,children:n})]}),e.jsx("div",{className:"flex flex-col gap-3",children:r})]})}function b({label:t,value:n,subtext:s,muted:a=!1,testId:r,valueTestId:d,captionTestId:l}){return e.jsxs("div",{className:"flex items-start justify-between gap-3","data-testid":r,children:[e.jsx("span",{className:o.cn("min-w-0 text-sm font-semibold leading-5",a?"text-muted-foreground":"text-foreground"),children:t}),e.jsxs("span",{className:"flex shrink-0 flex-col items-end",children:[e.jsx("span",{className:o.cn("text-sm font-semibold leading-5 tabular-nums",a?"text-muted-foreground":"text-foreground"),"data-testid":d,children:n}),s!=null?e.jsx("span",{className:"text-xs leading-4 text-muted-foreground","data-testid":l,children:s}):null]})]})}function g(){return e.jsx("div",{className:"h-px w-full bg-divider"})}exports.APY_BREAKDOWN_TOOLTIP_WIDTH=u;exports.ApyBreakdownBody=p;exports.ApyBreakdownDivider=g;exports.ApyBreakdownRow=b;exports.BREAKDOWN_DASH=c;exports.breakdownRateValue=f;exports.formatBreakdownRate=m;exports.periodMessageId=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),c=require("react"),u=require("../../link/link.cjs"),d=require("../../../utils/cn.cjs"),i=require("../../../utils/internal/bps-to-percent.cjs"),m="—",x="400px";function f(s,e,t){return s==="7d"?t:e}function p(s,e=!1){const t=i.bpsToPercent(s),r=`${Math.abs(t).toFixed(2)}%`;return e&&t<0?`−${r}`:r}function g(s){return Number(Math.abs(i.bpsToPercent(s)).toFixed(2))}function b({title:s,chip:e,chipPositive:t=!1,chipTestId:r,children:a,testId:o}){return n.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-4 rounded-xl border border-border bg-card p-4","data-testid":o,children:[n.jsxs("div",{className:"flex min-h-6 items-center justify-between gap-3",children:[n.jsx("span",{className:"min-w-0 text-base font-semibold leading-5 text-foreground",children:s}),n.jsx("span",{className:d.cn("shrink-0 rounded-md px-2 py-0.5 text-sm font-semibold tabular-nums",t?"bg-success/20 text-success":"bg-muted text-muted-foreground"),"data-testid":r,children:e})]}),n.jsx("div",{className:"flex flex-col gap-3",children:a})]})}function w({label:s,value:e,subtext:t,muted:r=!1,testId:a,valueTestId:o,captionTestId:l}){return n.jsxs("div",{className:"flex items-start justify-between gap-3","data-testid":a,children:[n.jsx("span",{className:d.cn("min-w-0 text-sm font-semibold leading-5",r?"text-muted-foreground":"text-foreground"),children:s}),n.jsxs("span",{className:"flex shrink-0 flex-col items-end",children:[n.jsx("span",{className:d.cn("text-sm font-semibold leading-5 tabular-nums",r?"text-muted-foreground":"text-foreground"),"data-testid":o,children:e}),t!=null?n.jsx("span",{className:"text-xs leading-4 text-muted-foreground","data-testid":l,children:t}):null]})]})}function h(s){let e;try{e=new URL(s)}catch{return}if(!(e.protocol!=="https:"&&e.protocol!=="http:"))return e.hostname.split(".").slice(-2).join(".")}function j({links:s}){const e=(s??[]).flatMap(t=>{const r=h(t);return r?[{href:t,domain:r}]:[]});return e.length===0?null:n.jsx("span",{className:"block text-xs font-normal leading-4 text-muted-foreground",children:e.map(({href:t,domain:r},a)=>n.jsxs(c.Fragment,{children:[a>0?", ":null,n.jsx(u.Link,{href:t,external:!0,size:"unset",color:"secondary",children:r})]},t))})}function k(){return n.jsx("div",{className:"h-px w-full bg-divider"})}exports.APY_BREAKDOWN_TOOLTIP_WIDTH=x;exports.ApyBreakdownBody=b;exports.ApyBreakdownDivider=k;exports.ApyBreakdownRow=w;exports.BREAKDOWN_DASH=m;exports.RewardLinks=j;exports.breakdownRateValue=g;exports.formatBreakdownRate=p;exports.periodMessageId=f;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./apy-breakdown-body.cjs");exports.APY_BREAKDOWN_TOOLTIP_WIDTH=e.APY_BREAKDOWN_TOOLTIP_WIDTH;exports.ApyBreakdownBody=e.ApyBreakdownBody;exports.ApyBreakdownDivider=e.ApyBreakdownDivider;exports.ApyBreakdownRow=e.ApyBreakdownRow;exports.BREAKDOWN_DASH=e.BREAKDOWN_DASH;exports.breakdownRateValue=e.breakdownRateValue;exports.formatBreakdownRate=e.formatBreakdownRate;exports.periodMessageId=e.periodMessageId;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./apy-breakdown-body.cjs");exports.APY_BREAKDOWN_TOOLTIP_WIDTH=e.APY_BREAKDOWN_TOOLTIP_WIDTH;exports.ApyBreakdownBody=e.ApyBreakdownBody;exports.ApyBreakdownDivider=e.ApyBreakdownDivider;exports.ApyBreakdownRow=e.ApyBreakdownRow;exports.BREAKDOWN_DASH=e.BREAKDOWN_DASH;exports.RewardLinks=e.RewardLinks;exports.breakdownRateValue=e.breakdownRateValue;exports.formatBreakdownRate=e.formatBreakdownRate;exports.periodMessageId=e.periodMessageId;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("../stack/stack.cjs"),l=require("../text/use-title-text.cjs"),q=require("../values/constants.cjs");require("../../help-tip/help-tip.cjs");require("react");require("react-intl");require("clsx");require("tailwind-merge");require("@gearbox-protocol/sdk/onchain");require("../../../utils/z-index.cjs");require("viem");const d=require("../../points-icon/points-icon.cjs");require("../../token-icon/token-icon.cjs");const p=require("../../../utils/internal/apy-breakdown.cjs");require("../../tooltip/simple-tooltip.cjs");require("../../tooltip/tooltip.cjs");require("../../badge/badge.cjs");require("../../badge/chip.cjs");require("../../typography/typography.cjs");const f=require("../../vertical-indicator/vertical-indicator.cjs"),r=require("./constants.cjs");function _({children:t}){return e.jsx(u.Stack,{gap:"sm","data-testid":r.InfoListTest.root,children:t})}function o({title:t,size:i="sm",align:s="start","data-testid":n=r.InfoListTest.line,...a}){const c=l.useTitleText();return e.jsx(f.VerticalIndicator,{label:c(t),size:i,align:s,"data-testid":n,...a})}function m({data:t,title:i="components.yieldBreakdown.points"}){const s=t?p.pointProgramsOf(t):[];return s.length===0?null:e.jsx(o,{title:i,value:e.jsx("span",{className:"inline-flex flex-wrap items-center gap-1.5","data-testid":q.ValueTest.points,children:s.map(n=>e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(d.PointsIcon,{reward:{name:n.name,type:n.id},size:16}),e.jsx("span",{children:n.name})]},n.id))})})}exports.InfoListTest=r.InfoListTest;exports.InfoLine=o;exports.InfoList=_;exports.PointsInfoLine=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("../stack/stack.cjs"),l=require("../text/use-title-text.cjs"),q=require("../values/constants.cjs");require("../../help-tip/help-tip.cjs");require("react");require("react-intl");require("clsx");require("tailwind-merge");require("@gearbox-protocol/sdk/onchain");require("../../../utils/z-index.cjs");require("viem");require("../../link/link.cjs");const d=require("../../points-icon/points-icon.cjs");require("../../token-icon/token-icon.cjs");const p=require("../../../utils/internal/apy-breakdown.cjs");require("../../tooltip/simple-tooltip.cjs");require("../../tooltip/tooltip.cjs");require("../../badge/badge.cjs");require("../../badge/chip.cjs");require("../../typography/typography.cjs");const f=require("../../vertical-indicator/vertical-indicator.cjs"),r=require("./constants.cjs");function _({children:t}){return e.jsx(u.Stack,{gap:"sm","data-testid":r.InfoListTest.root,children:t})}function o({title:t,size:s="sm",align:i="start","data-testid":n=r.InfoListTest.line,...a}){const c=l.useTitleText();return e.jsx(f.VerticalIndicator,{label:c(t),size:s,align:i,"data-testid":n,...a})}function m({data:t,title:s="components.yieldBreakdown.points"}){const i=t?p.pointProgramsOf(t):[];return i.length===0?null:e.jsx(o,{title:s,value:e.jsx("span",{className:"inline-flex flex-wrap items-center gap-1.5","data-testid":q.ValueTest.points,children:i.map(n=>e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(d.PointsIcon,{reward:{name:n.name,type:n.id},size:16}),e.jsx("span",{children:n.name})]},n.id))})})}exports.InfoListTest=r.InfoListTest;exports.InfoLine=o;exports.InfoList=_;exports.PointsInfoLine=m;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("../apy-breakdown-body/apy-breakdown-body.cjs"),l=require("../../no-value/no-value.cjs"),m=require("../../points-icon/points-icon.cjs"),k=require("../../token-icon/token-icon.cjs"),r=require("../../typed-intl/index.cjs"),p=require("../../../utils/internal/apy-breakdown.cjs"),t=require("./constants.cjs");function u({data:s,period:a}){const d=s?p.totalApyOf(s):void 0,i=s?.organicApy,c=s?p.tokenRewardsOf(s):[],y=s?p.pointProgramsOf(s):[];return e.jsxs(o.ApyBreakdownBody,{testId:t.PoolApyBreakdownCardTest.root,title:e.jsx(r.FormattedMessageTyped,{messageId:o.periodMessageId(a,"components.poolApyBreakdownCard.title","components.poolApyBreakdownCard.title7d")}),chip:d==null?e.jsx(l.NoValue,{reason:a}):o.formatBreakdownRate(d,!0),chipPositive:(d??0)>0,chipTestId:t.PoolApyBreakdownCardTest.net,children:[e.jsx(o.ApyBreakdownRow,{valueTestId:t.PoolApyBreakdownCardTest.value,label:e.jsx(r.FormattedMessageTyped,{messageId:o.periodMessageId(a,"components.poolApyBreakdownCard.organicApy","components.poolApyBreakdownCard.organicApy7d")}),value:i==null?e.jsx(l.NoValue,{reason:a}):o.formatBreakdownRate(i)}),c.length>0?c.map(n=>e.jsx(o.ApyBreakdownRow,{valueTestId:t.PoolApyBreakdownCardTest.value,label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(r.FormattedMessageTyped,{messageId:o.periodMessageId(a,"components.poolApyBreakdownCard.tokenIncentiveApy","components.poolApyBreakdownCard.tokenIncentiveApy7d"),values:{symbol:n.token.symbol}})}),e.jsx(k.TokenIcon,{token:n.token,symbol:n.token.symbol,size:16,className:"shrink-0"})]}),value:o.formatBreakdownRate(n.supplyApr??0)},`incentive-${n.token.address}`)):e.jsx(o.ApyBreakdownRow,{valueTestId:t.PoolApyBreakdownCardTest.value,label:e.jsx(r.FormattedMessageTyped,{messageId:o.periodMessageId(a,"components.poolApyBreakdownCard.incentiveApy","components.poolApyBreakdownCard.incentiveApy7d")}),value:s==null?e.jsx(l.NoValue,{reason:a}):o.formatBreakdownRate(0)}),y.length>0?e.jsxs(e.Fragment,{children:[e.jsx(o.ApyBreakdownDivider,{}),y.map(n=>e.jsx(o.ApyBreakdownRow,{valueTestId:t.PoolApyBreakdownCardTest.points,label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(r.FormattedMessageTyped,{messageId:"components.yieldBreakdown.programPoints",values:{name:n.name}})}),e.jsx(m.PointsIcon,{reward:{name:n.name,type:n.id},size:16,className:"shrink-0"})]}),value:n.multiplier!=null?`${n.multiplier}×`:o.BREAKDOWN_DASH},n.id))]}):null]})}exports.PoolApyBreakdownCardTest=t.PoolApyBreakdownCardTest;exports.PoolApyBreakdownCard=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("../apy-breakdown-body/apy-breakdown-body.cjs"),d=require("../../no-value/no-value.cjs"),k=require("../../points-icon/points-icon.cjs"),u=require("../../token-icon/token-icon.cjs"),t=require("../../typed-intl/index.cjs"),p=require("../../../utils/internal/apy-breakdown.cjs"),r=require("./constants.cjs");function w({data:s,period:a,hideRewardLinks:m=!1}){const l=s?p.totalApyOf(s):void 0,i=s?.organicApy,c=s?p.tokenRewardsOf(s):[],y=s?p.pointProgramsOf(s):[];return e.jsxs(o.ApyBreakdownBody,{testId:r.PoolApyBreakdownCardTest.root,title:e.jsx(t.FormattedMessageTyped,{messageId:o.periodMessageId(a,"components.poolApyBreakdownCard.title","components.poolApyBreakdownCard.title7d")}),chip:l==null?e.jsx(d.NoValue,{reason:a}):o.formatBreakdownRate(l,!0),chipPositive:(l??0)>0,chipTestId:r.PoolApyBreakdownCardTest.net,children:[e.jsx(o.ApyBreakdownRow,{valueTestId:r.PoolApyBreakdownCardTest.value,label:e.jsx(t.FormattedMessageTyped,{messageId:o.periodMessageId(a,"components.poolApyBreakdownCard.organicApy","components.poolApyBreakdownCard.organicApy7d")}),value:i==null?e.jsx(d.NoValue,{reason:a}):o.formatBreakdownRate(i)}),c.length>0?c.map(n=>e.jsx(o.ApyBreakdownRow,{valueTestId:r.PoolApyBreakdownCardTest.value,label:e.jsxs("span",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(t.FormattedMessageTyped,{messageId:o.periodMessageId(a,"components.poolApyBreakdownCard.tokenIncentiveApy","components.poolApyBreakdownCard.tokenIncentiveApy7d"),values:{symbol:n.token.symbol}})}),e.jsx(u.TokenIcon,{token:n.token,symbol:n.token.symbol,size:16,className:"shrink-0"})]}),m?null:e.jsx(o.RewardLinks,{links:n.links})]}),value:o.formatBreakdownRate(n.supplyApr??0)},`incentive-${n.token.address}`)):e.jsx(o.ApyBreakdownRow,{valueTestId:r.PoolApyBreakdownCardTest.value,label:e.jsx(t.FormattedMessageTyped,{messageId:o.periodMessageId(a,"components.poolApyBreakdownCard.incentiveApy","components.poolApyBreakdownCard.incentiveApy7d")}),value:s==null?e.jsx(d.NoValue,{reason:a}):o.formatBreakdownRate(0)}),y.length>0?e.jsxs(e.Fragment,{children:[e.jsx(o.ApyBreakdownDivider,{}),y.map(n=>e.jsx(o.ApyBreakdownRow,{valueTestId:r.PoolApyBreakdownCardTest.points,label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(t.FormattedMessageTyped,{messageId:"components.yieldBreakdown.programPoints",values:{name:n.name}})}),e.jsx(k.PointsIcon,{reward:{name:n.name,type:n.id},size:16,className:"shrink-0"})]}),value:n.multiplier!=null?`${n.multiplier}×`:o.BREAKDOWN_DASH},n.id))]}):null]})}exports.PoolApyBreakdownCardTest=r.PoolApyBreakdownCardTest;exports.PoolApyBreakdownCard=w;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),k=require("@gearbox-protocol/sdk/onchain"),o=require("../apy-breakdown-body/apy-breakdown-body.cjs"),v=require("../../no-value/no-value.cjs"),M=require("../../points-icon/points-icon.cjs"),h=require("../../token-icon/token-icon.cjs"),i=require("../../typed-intl/index.cjs"),p=require("../../../utils/format-leverage.cjs"),B=require("../../../utils/internal/apy-breakdown.cjs"),r=require("./constants.cjs");function q(y){const{borrowApyAvg7D:t,quotaRateAvg7D:l,liquidationThreshold:s}=y;return t===void 0||l===void 0?null:{borrowApy:t,quotaRate:l,liquidationThreshold:s}}function N(y,t,l){const s=o.breakdownRateValue(y),n=l-t*s;return n>0&&t>0?s+Math.ceil(n/t*100)/100:s}function L({data:y,leverage:t,showFormula:l=!1,period:s}){const n=q(y),d=n&&y.collateralApyAvg7D?y.collateralApyAvg7D:void 0,x=n!==null&&d!==void 0,T=x&&n&&d?{organicApy:k.calcNetStrategyApy(n,d.organicApy,t),totalApy:k.calcNetStrategyApy(n,d.totalApy??d.organicApy,t),...d.rewards?{rewards:d.rewards}:{}}:null,c=x&&n?k.calcEffectiveBorrowApy(n,t):null,u=T===null?null:B.totalApyOf(T),b=u===null||c===null?null:u+c,_=d?B.positiveTokenRewardsOf(d):[],f=d?B.pointProgramsOf(d):[],I=_.map(a=>({reward:a,value:Math.round(t*(a.supplyApr??0))})),m=b===null?null:b-I.reduce((a,A)=>a+A.value,0),j=m!==null&&t>0?m/t:void 0,R=n&&c!==null&&t>0?(c-n.borrowApy*(t-1))/t:void 0,C=Number(p.formatLeverageExact(t)),w=c===null?void 0:o.breakdownRateValue(c),g=n&&R!==void 0&&w!==void 0?N(n.borrowApy+R,C,w):void 0,S=g!==void 0&&w!==void 0?C*g-w:void 0;return e.jsxs(o.ApyBreakdownBody,{testId:r.StrategyApyBreakdownCardTest.root,title:e.jsx(i.FormattedMessageTyped,{messageId:o.periodMessageId(s,"components.yieldBreakdown.titleNetAtLeverage","components.yieldBreakdown.titleNetAtLeverage7d"),values:{leverage:p.formatLeverage(t)}}),chip:u===null?e.jsx(v.NoValue,{reason:s}):o.formatBreakdownRate(u,!0),chipPositive:(u??0)>0,chipTestId:r.StrategyApyBreakdownCardTest.net,children:[e.jsx(o.ApyBreakdownRow,{testId:r.StrategyApyBreakdownCardTest.collateral,valueTestId:r.StrategyApyBreakdownCardTest.value,captionTestId:r.StrategyApyBreakdownCardTest.caption,label:e.jsx(i.FormattedMessageTyped,{messageId:o.periodMessageId(s,"components.yieldBreakdown.collateralApy","components.yieldBreakdown.collateralApy7d")}),value:m===null?e.jsx(v.NoValue,{reason:s}):o.formatBreakdownRate(m),subtext:l&&j!==void 0?e.jsx(i.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:p.formatLeverageExact(t),base:o.formatBreakdownRate(j)}}):void 0}),I.map(({reward:a,value:A})=>e.jsx(o.ApyBreakdownRow,{valueTestId:r.StrategyApyBreakdownCardTest.value,captionTestId:r.StrategyApyBreakdownCardTest.caption,label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(i.FormattedMessageTyped,{messageId:"components.apyParts.extraAPY",values:{symbol:a.token.symbol}})}),e.jsx(h.TokenIcon,{token:a.token,symbol:a.token.symbol,size:16,className:"shrink-0"})]}),value:o.formatBreakdownRate(A),subtext:l?e.jsx(i.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:p.formatLeverageExact(t),base:o.formatBreakdownRate(a.supplyApr??0)}}):void 0},`incentive-${a.token.address}-${a.supplyApr??0}`)),e.jsx(o.ApyBreakdownRow,{muted:!0,testId:r.StrategyApyBreakdownCardTest.borrow,valueTestId:r.StrategyApyBreakdownCardTest.value,captionTestId:r.StrategyApyBreakdownCardTest.caption,label:e.jsx(i.FormattedMessageTyped,{messageId:o.periodMessageId(s,"components.yieldBreakdown.borrowRate","components.yieldBreakdown.borrowRate7d")}),value:c===null?e.jsx(v.NoValue,{reason:s}):o.formatBreakdownRate(c),subtext:l&&g!==void 0&&S!==void 0?e.jsx(i.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.borrowFormula",values:{leverage:p.formatLeverageExact(t),totalRate:`${g.toFixed(2)}%`,borrowRate:`${Math.abs(S).toFixed(2)}%`}}):void 0}),f.length>0?e.jsxs(e.Fragment,{children:[e.jsx(o.ApyBreakdownDivider,{}),f.map(a=>e.jsx(o.ApyBreakdownRow,{valueTestId:r.StrategyApyBreakdownCardTest.points,captionTestId:r.StrategyApyBreakdownCardTest.caption,label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(i.FormattedMessageTyped,{messageId:"components.yieldBreakdown.programPoints",values:{name:a.name}})}),e.jsx(M.PointsIcon,{reward:{name:a.name,type:a.id},size:16,className:"shrink-0"})]}),value:a.multiplier!=null?`${p.formatLeverageExact(a.multiplier*t)}×`:o.BREAKDOWN_DASH,subtext:l&&a.multiplier!=null?e.jsx(i.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:p.formatLeverageExact(t),base:p.formatLeverageExact(a.multiplier)}}):void 0},a.id))]}):null]})}exports.StrategyApyBreakdownCardTest=r.StrategyApyBreakdownCardTest;exports.StrategyApyBreakdownCard=L;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("@gearbox-protocol/sdk/onchain"),o=require("../apy-breakdown-body/apy-breakdown-body.cjs"),B=require("../../no-value/no-value.cjs"),M=require("../../points-icon/points-icon.cjs"),q=require("../../token-icon/token-icon.cjs"),i=require("../../typed-intl/index.cjs"),p=require("../../../utils/format-leverage.cjs"),x=require("../../../utils/internal/apy-breakdown.cjs"),n=require("./constants.cjs");function N(y){const{borrowApyAvg7D:t,quotaRateAvg7D:l,liquidationThreshold:s}=y;return t===void 0||l===void 0?null:{borrowApy:t,quotaRate:l,liquidationThreshold:s}}function L(y,t,l){const s=o.breakdownRateValue(y),m=l-t*s;return m>0&&t>0?s+Math.ceil(m/t*100)/100:s}function F({data:y,leverage:t,showFormula:l=!1,period:s,hideRewardLinks:m=!1}){const r=N(y),d=r&&y.collateralApyAvg7D?y.collateralApyAvg7D:void 0,T=r!==null&&d!==void 0,b=T&&r&&d?{organicApy:v.calcNetStrategyApy(r,d.organicApy,t),totalApy:v.calcNetStrategyApy(r,d.totalApy??d.organicApy,t),...d.rewards?{rewards:d.rewards}:{}}:null,c=T&&r?v.calcEffectiveBorrowApy(r,t):null,u=b===null?null:x.totalApyOf(b),f=u===null||c===null?null:u+c,h=d?x.positiveTokenRewardsOf(d):[],I=d?x.pointProgramsOf(d):[],j=h.map(a=>({reward:a,value:Math.round(t*(a.supplyApr??0))})),w=f===null?null:f-j.reduce((a,A)=>a+A.value,0),R=w!==null&&t>0?w/t:void 0,C=r&&c!==null&&t>0?(c-r.borrowApy*(t-1))/t:void 0,S=Number(p.formatLeverageExact(t)),g=c===null?void 0:o.breakdownRateValue(c),k=r&&C!==void 0&&g!==void 0?L(r.borrowApy+C,S,g):void 0,_=k!==void 0&&g!==void 0?S*k-g:void 0;return e.jsxs(o.ApyBreakdownBody,{testId:n.StrategyApyBreakdownCardTest.root,title:e.jsx(i.FormattedMessageTyped,{messageId:o.periodMessageId(s,"components.yieldBreakdown.titleNetAtLeverage","components.yieldBreakdown.titleNetAtLeverage7d"),values:{leverage:p.formatLeverage(t)}}),chip:u===null?e.jsx(B.NoValue,{reason:s}):o.formatBreakdownRate(u,!0),chipPositive:(u??0)>0,chipTestId:n.StrategyApyBreakdownCardTest.net,children:[e.jsx(o.ApyBreakdownRow,{testId:n.StrategyApyBreakdownCardTest.collateral,valueTestId:n.StrategyApyBreakdownCardTest.value,captionTestId:n.StrategyApyBreakdownCardTest.caption,label:e.jsx(i.FormattedMessageTyped,{messageId:o.periodMessageId(s,"components.yieldBreakdown.collateralApy","components.yieldBreakdown.collateralApy7d")}),value:w===null?e.jsx(B.NoValue,{reason:s}):o.formatBreakdownRate(w),subtext:l&&R!==void 0?e.jsx(i.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:p.formatLeverageExact(t),base:o.formatBreakdownRate(R)}}):void 0}),j.map(({reward:a,value:A})=>e.jsx(o.ApyBreakdownRow,{valueTestId:n.StrategyApyBreakdownCardTest.value,captionTestId:n.StrategyApyBreakdownCardTest.caption,label:e.jsxs("span",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(i.FormattedMessageTyped,{messageId:"components.apyParts.extraAPY",values:{symbol:a.token.symbol}})}),e.jsx(q.TokenIcon,{token:a.token,symbol:a.token.symbol,size:16,className:"shrink-0"})]}),m?null:e.jsx(o.RewardLinks,{links:a.links})]}),value:o.formatBreakdownRate(A),subtext:l?e.jsx(i.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:p.formatLeverageExact(t),base:o.formatBreakdownRate(a.supplyApr??0)}}):void 0},`incentive-${a.token.address}-${a.supplyApr??0}`)),e.jsx(o.ApyBreakdownRow,{muted:!0,testId:n.StrategyApyBreakdownCardTest.borrow,valueTestId:n.StrategyApyBreakdownCardTest.value,captionTestId:n.StrategyApyBreakdownCardTest.caption,label:e.jsx(i.FormattedMessageTyped,{messageId:o.periodMessageId(s,"components.yieldBreakdown.borrowRate","components.yieldBreakdown.borrowRate7d")}),value:c===null?e.jsx(B.NoValue,{reason:s}):o.formatBreakdownRate(c),subtext:l&&k!==void 0&&_!==void 0?e.jsx(i.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.borrowFormula",values:{leverage:p.formatLeverageExact(t),totalRate:`${k.toFixed(2)}%`,borrowRate:`${Math.abs(_).toFixed(2)}%`}}):void 0}),I.length>0?e.jsxs(e.Fragment,{children:[e.jsx(o.ApyBreakdownDivider,{}),I.map(a=>e.jsx(o.ApyBreakdownRow,{valueTestId:n.StrategyApyBreakdownCardTest.points,captionTestId:n.StrategyApyBreakdownCardTest.caption,label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(i.FormattedMessageTyped,{messageId:"components.yieldBreakdown.programPoints",values:{name:a.name}})}),e.jsx(M.PointsIcon,{reward:{name:a.name,type:a.id},size:16,className:"shrink-0"})]}),value:a.multiplier!=null?`${p.formatLeverageExact(a.multiplier*t)}×`:o.BREAKDOWN_DASH,subtext:l&&a.multiplier!=null?e.jsx(i.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:p.formatLeverageExact(t),base:p.formatLeverageExact(a.multiplier)}}):void 0},a.id))]}):null]})}exports.StrategyApyBreakdownCardTest=n.StrategyApyBreakdownCardTest;exports.StrategyApyBreakdownCard=F;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("react"),w=require("../no-value/no-value.cjs"),_=require("../yield-breakdown-tooltip/yield-breakdown.cjs"),v=require("../../utils/cn.cjs");require("@gearbox-protocol/sdk/onchain");const C=require("../../utils/internal/format-percent.cjs");require("../../utils/z-index.cjs");const t=require("../../utils/internal/apy-breakdown.cjs"),q=require("../../utils/internal/bps-to-percent.cjs"),l=14;function P(){const n=`additional-incentives-${j.useId().replace(/:/g,"")}`;return e.jsxs("svg",{width:l,height:l,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"size-3.5 shrink-0 overflow-clip",role:"img","aria-label":"Incentives",children:[e.jsx("title",{children:"Incentives"}),e.jsx("path",{d:"M7 14C10.866 14 14 10.866 14 7C14 3.13401 10.866 0 7 0C3.13401 0 0 3.13401 0 7C0 10.866 3.13401 14 7 14Z",fill:`url(#${n})`}),e.jsx("path",{d:"M7 3.75V10.25M3.75 7H10.25",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:n,x1:"0",y1:"7",x2:"14",y2:"7",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{stopColor:"#FF2D8D"}),e.jsx("stop",{offset:"1",stopColor:"#FF6C20"})]})})]})}function c(n){return n==null?!1:t.positiveTokenRewardsOf(n).length>0||t.pointProgramsOf(n).length>0}function k({apy:n,maxLeverage:u,collateralApy:r,borrowApy:a,quotaRate:d,decimals:p=2,tooltip:h=!0,period:x,className:s}){if(!n)return e.jsx(w.NoValue,{});const i=t.totalApyOf(n),f=c(n)||c(r),m=h&&i>=1,o=()=>{const g=C.formatCompactPercent(q.bpsToPercent(i),p);return e.jsxs("div",{className:v.cn("inline-flex items-center gap-1.5",s),children:[e.jsx("span",{className:"inline-flex items-center",children:g}),f?e.jsx(P,{}):null]})};return m?e.jsx(_.YieldBreakdownTooltip,{supplyApy:n,maxLeverage:u,collateralApy:r,borrowApy:a,quotaRate:d,period:x,className:s,children:o()}):o()}exports.CompoundAPY=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),w=require("react"),_=require("../no-value/no-value.cjs"),v=require("../yield-breakdown-tooltip/yield-breakdown.cjs"),C=require("../../utils/cn.cjs");require("@gearbox-protocol/sdk/onchain");const q=require("../../utils/internal/format-percent.cjs");require("../../utils/z-index.cjs");const t=require("../../utils/internal/apy-breakdown.cjs"),P=require("../../utils/internal/bps-to-percent.cjs"),l=14;function k(){const n=`additional-incentives-${w.useId().replace(/:/g,"")}`;return e.jsxs("svg",{width:l,height:l,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"size-3.5 shrink-0 overflow-clip",role:"img","aria-label":"Incentives",children:[e.jsx("title",{children:"Incentives"}),e.jsx("path",{d:"M7 14C10.866 14 14 10.866 14 7C14 3.13401 10.866 0 7 0C3.13401 0 0 3.13401 0 7C0 10.866 3.13401 14 7 14Z",fill:`url(#${n})`}),e.jsx("path",{d:"M7 3.75V10.25M3.75 7H10.25",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:n,x1:"0",y1:"7",x2:"14",y2:"7",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{stopColor:"#FF2D8D"}),e.jsx("stop",{offset:"1",stopColor:"#FF6C20"})]})})]})}function c(n){return n==null?!1:t.positiveTokenRewardsOf(n).length>0||t.pointProgramsOf(n).length>0}function I({apy:n,maxLeverage:u,collateralApy:r,borrowApy:a,quotaRate:d,decimals:p=2,tooltip:h=!0,period:x,hideRewardLinks:f,className:s}){if(!n)return e.jsx(_.NoValue,{});const i=t.totalApyOf(n),m=c(n)||c(r),g=h&&i>=1,o=()=>{const j=q.formatCompactPercent(P.bpsToPercent(i),p);return e.jsxs("div",{className:C.cn("inline-flex items-center gap-1.5",s),children:[e.jsx("span",{className:"inline-flex items-center",children:j}),m?e.jsx(k,{}):null]})};return g?e.jsx(v.YieldBreakdownTooltip,{supplyApy:n,maxLeverage:u,collateralApy:r,borrowApy:a,quotaRate:d,period:x,hideRewardLinks:f,className:s,children:o()}):o()}exports.CompoundAPY=I;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),$=require("lightweight-charts"),g=require("react"),Y=require("./colors.cjs"),ct=require("../../hooks/use-media-query.cjs"),Q=require("../../utils/cn.cjs"),I=require("./default-config.cjs"),re=require("./formatters.cjs"),ut=require("./graph-current-value.cjs"),ft=require("./graph-tooltip.cjs"),ht=require("./plugins/vertical-line.cjs"),dt=require("./series-config.cjs"),Ke=require("./series-palette.cjs"),qe=require("./y-axis-scale.cjs");function pt(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const l in e)if(l!=="default"){const u=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(r,l,u.get?u:{enumerable:!0,get:()=>e[l]})}}return r.default=e,Object.freeze(r)}const ye=pt(g);function oe(e){return e.id??e.label}function $e({lastIndex:e,width:r,padLeft:l,padRight:u,paddingPx:h=I.AXIS_TIME_EDGE_PADDING_PX}){if(e<0)return null;const f=(l||u)&&r>0?h*Math.max(e,1)/r:0;return{from:l&&f!==0?-f:0,to:u?e+f:e}}function We(e,r,l){if(!l)return e.values().next().value;const u=e.get(l);if(u)return u;const h=r.find(f=>f.id===l||f.label===l);return h?e.get(oe(h)):void 0}class gt{_yTop;_yBottom;_color;constructor(r,l,u){this._yTop=r,this._yBottom=l,this._color=u}draw(r){r.useBitmapCoordinateSpace(l=>{const u=l.context,h=l.verticalPixelRatio,f=this._yTop===null?0:this._yTop*h,x=this._yBottom===null?l.bitmapSize.height:this._yBottom*h,R=Math.min(f,x),D=Math.max(f,x);u.fillStyle=this._color,u.fillRect(0,R,l.bitmapSize.width,D-R)})}}class mt{_source;_yTop=null;_yBottom=null;constructor(r){this._source=r}update(){const r=this._source.series;this._yTop=this._source.priceTop===void 0?null:r.priceToCoordinate(this._source.priceTop),this._yBottom=this._source.priceBottom===void 0?null:r.priceToCoordinate(this._source.priceBottom)}zOrder(){return"bottom"}renderer(){return new gt(this._yTop,this._yBottom,this._source.color)}}class bt{series;priceTop;priceBottom;color;_paneViews;constructor(r,l,u,h){this.series=r,this.priceTop=l,this.priceBottom=u,this.color=h,this._paneViews=[new mt(this)]}updateAllViews(){for(const r of this._paneViews)r.update()}paneViews(){return this._paneViews}}function St(e,r){switch(e){case $.LineStyle.Dotted:return[r,r];case $.LineStyle.Dashed:return[2*r,2*r];case $.LineStyle.LargeDashed:return[6*r,6*r];case $.LineStyle.SparseDotted:return[r,4*r];default:return[]}}class Ct{_y;_color;_lineWidth;_lineStyle;constructor(r,l,u,h){this._y=r,this._color=l,this._lineWidth=u,this._lineStyle=h}draw(r){r.useBitmapCoordinateSpace(l=>{if(this._y===null)return;const u=l.context,h=l.verticalPixelRatio,f=Math.max(1,Math.round(this._lineWidth*h)),x=Math.round(this._y*h);u.save(),u.strokeStyle=this._color,u.lineWidth=f,u.setLineDash(St(this._lineStyle,f)),u.beginPath(),u.moveTo(0,x),u.lineTo(l.bitmapSize.width,x),u.stroke(),u.restore()})}}class xt{_source;_y=null;constructor(r){this._source=r}update(){this._y=this._source.series.priceToCoordinate(this._source.price)}zOrder(){return"top"}renderer(){return new Ct(this._y,this._source.color,this._source.lineWidth,this._source.lineStyle)}}class vt{series;price;color;lineWidth;lineStyle;_paneViews;constructor(r,l,u,h,f){this.series=r,this.price=l,this.color=u,this.lineWidth=h,this.lineStyle=f,this._paneViews=[new xt(this)]}updateAllViews(){for(const r of this._paneViews)r.update()}paneViews(){return this._paneViews}}function He(e,r,l){const u=e.labelText??"",h=e.value,f=h===void 0?"":typeof h=="number"?r==="$"?`$${re.formatExactValue(h,void 0,l)}`:r==="%"?`${re.formatExactValue(h,void 0,l)}%`:re.formatExactValue(h,r!=="none"&&r!=="%"&&r!=="$"&&!re.isRatioUnit(r)?r:void 0,l):String(h);return{labelText:u,valueStr:f}}const _e=4;function Oe(e,r,l){const u={left:e,transform:"translateX(-50%)"};if(r<=0||!l||l<=0)return u;const h=l/2,f=_e+h,x=r-_e-h;return x<f?{left:r/2,transform:"translateX(-50%)"}:{left:Math.min(Math.max(e,f),x),transform:"translateX(-50%)"}}function Ze(e,r){for(let l=e.length-1;l>=0;l--)if(Number(e[l].time)<=r)return e[l].value;return 0}function yt({series:e,className:r,showLegend:l=!1,onUnselectSeries:u,xMeasureUnit:h="time",yMeasureUnit:f="token",optionsOverrides:x,verticalLineOptions:R,priceLineOptions:D,zoneOptions:F,currentValueDecimals:se,useSharedPriceScale:H=!1,dualYAxis:z=!1,defaultVisiblePriceScaleId:we="right",showCurrentValue:Qe=!0,graphTitle:pe,yScaleMin:Pe,yScaleMinMultiple:Re,visibleTimeFrom:le,disableZoom:Te=!1,hideDefaultTooltip:ge=!1}){const A=g.useRef(null),N=g.useRef(new Map),me=g.useRef(!1),Le=g.useRef(!0),Ne=g.useRef([]),ae=g.useRef(0),j=g.useRef(null),be=g.useRef(null),Ve=g.useRef(null),T=ct.useIsMobile(),ce=ye.useMemo(()=>e.flatMap(t=>t.data),[e]),Je=ye.useMemo(()=>{if(e.length>0){const t=e[e.length-1];if(t.data.length>0)return t.data[t.data.length-1]}},[e]),[ke,Se]=g.useState(()=>{if(!Je)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}),[Ee,J]=g.useState(null),[Ie,Me]=g.useState([]),[Ue,De]=g.useState(0),Ae=g.useRef(new Map),[et,tt]=g.useState({}),[U,ot]=g.useState(0);g.useEffect(()=>{const t=()=>{try{if(j.current&&De(j.current.clientWidth),A.current&&j.current){const s=j.current.clientWidth,c=j.current.clientHeight;A.current.resize(s,c);try{ae.current=A.current.paneSize().height}catch{}}}catch{}},a=j.current,n=a?new ResizeObserver(t):null;return Ve.current=n,a&&n?.observe(a),()=>{a&&n?.unobserve(a),n?.disconnect(),Ve.current=null}},[]),g.useEffect(()=>{if(!be.current||me.current)return;const t=I.getDefaultOptions(),a=Y.resolveCSSColor("hsl(var(--muted-foreground))","rgb(163, 163, 163)"),n=$.createChart(be.current,{...t,leftPriceScale:{...t.leftPriceScale||{},visible:!1,textColor:a},rightPriceScale:{...t.rightPriceScale||{},visible:!T,textColor:a},...T&&{crosshair:{...t.crosshair,mode:$.CrosshairMode.Magnet}}});A.current=n,me.current=!0;try{ae.current=n.paneSize().height}catch{ae.current=0}return ot(s=>s+1),()=>{n.remove(),A.current=null,me.current=!1,N.current.clear()}},[T]),g.useEffect(()=>{const t=A.current;t&&t.applyOptions(Te?{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}})},[U,Te]),g.useEffect(()=>{const t=A.current;!t||!x||t.applyOptions(x)},[U,x]),g.useEffect(()=>{const t=A.current;if(!t||e.length===0)return;const n=e.filter(i=>i.data.length>0).length<=1?Pe:Re,s=h==="time"?re.getXFormatters(h,ce):re.getXFormatters(h),c=new Map(dt.resolvePriceScaleSides(e).map(({series:i,side:o})=>[i.label,o])),p=(i,o,d)=>{const{formatter:k,tickmarksFormatter:E,updateVisibleRange:B}=re.createAdaptiveYAxisFormatter(i,o,{yScaleMin:n});return{formatter:k,tickmarksFormatter:E,updateVisibleRange:B,labels:d}},m=[];if(z)for(const i of["left","right"]){const o=new Set,d=[];let k=f;for(const E of e)if(E.data.length!==0&&c.get(E.label)===i){o.size===0&&E.yMeasureUnit&&(k=E.yMeasureUnit),o.add(E.label);for(const B of E.data)d.push(B.value)}o.size>0&&m.push(p(d,k,o))}else{const i=ce.map(d=>d.value),o=new Set(e.filter(d=>d.data.length>0).map(d=>d.label));m.push(p(i,f,o))}Ne.current=m;const _=new Map;for(const i of m)for(const o of i.labels)_.set(o,i);const w=I.getDefaultOptions();t.applyOptions({localization:{...w.localization||{},timeFormatter:i=>s.timeFormatter(parseFloat(i),void 0)},timeScale:{...w.timeScale||{},...x?.timeScale,tickMarkFormatter:s.tickMarkFormatter,minBarSpacing:0}});const v=!z&&e.length>1&&!H,G=z?T:e.length>1&&!H||T,V=Y.resolveCSSColor("hsl(var(--muted-foreground))","rgb(163, 163, 163)");t.applyOptions({...z&&{defaultVisiblePriceScaleId:we},leftPriceScale:{...w.leftPriceScale||{},...x?.leftPriceScale,visible:z&&!T,textColor:V},rightPriceScale:{...w.rightPriceScale||{},...x?.rightPriceScale,visible:z?!T:!G,textColor:V}});const ee=new Set(N.current.keys()),q=new Set(e.map(oe));for(const i of ee)if(!q.has(i)){const o=N.current.get(i);o&&(t.removeSeries(o),N.current.delete(i))}const b=I.getDefaultSeries(),M=[];let L=0;const W=e.find(i=>i.data.length>0),y=new Map;if(D&&D.length>0)for(const i of D){if(!Number.isFinite(i.price))continue;const o=i.seriesLabel??W?.label;if(!o)continue;const d=y.get(o)??[];d.push(i.price),y.set(o,d)}if(F&&F.length>0)for(const i of F){const o=i.seriesLabel??W?.label;if(!o)continue;const d=y.get(o)??[];Number.isFinite(i.priceTop)&&d.push(i.priceTop),Number.isFinite(i.priceBottom)&&d.push(i.priceBottom),y.set(o,d)}for(let i=0;i<e.length;i++){const o=e[i],d=oe(o),k=Ke.getSeriesColorPalette(i),E=o.lineColor??o.color??k.line;let B,Z;if(o.lineColor??o.color)if(o.topColor&&o.bottomColor)B=o.topColor,Z=o.bottomColor;else if(o.topColor){const S=Y.generateColorsFromBase(E);B=o.topColor,Z=S.bottomColor}else if(o.bottomColor)B=Y.generateColorsFromBase(E).topColor,Z=o.bottomColor;else{const S=Y.generateColorsFromBase(E);B=S.topColor,Z=S.bottomColor}else B=o.topColor||k.top,Z=o.bottomColor||k.bottom;if(o.data.length===0){const S=N.current.get(d);S&&(t.removeSeries(S),N.current.delete(d));continue}const ue=o.data.length>0?Math.min(...o.data.map(S=>S.value)):0,he=o.data.length>0?Math.max(...o.data.map(S=>S.value)):0,rt=ue<0,nt=o.data.some(S=>S.value===0),it=!rt&&nt,Be=qe.pickMinMove(he-ue),Fe=z?o.priceScaleId??(L===0?"left":"right"):H||!v||L===0?"right":`scale-${L}`;v&&M.push({priceScaleId:Fe||"right",seriesIndex:L});const Ce=(H||!v)&&n!==void 0&&typeof n=="number",st=y.get(o.label)??[],lt=S=>{const P=S();if(P?.priceRange){Ce&&(P.priceRange.minValue=n);for(const K of st)K<P.priceRange.minValue&&(P.priceRange.minValue=K),K>P.priceRange.maxValue&&(P.priceRange.maxValue=K);const ie=Ce?n:it&&P.priceRange.minValue>=0?0:void 0,de=ae.current>0?ae.current:j.current?.clientHeight??0;if(de>0){const K=qe.niceAxisRange({min:P.priceRange.minValue,max:P.priceRange.maxValue,floor:ie,scaleHeightPx:de,fontSizePx:I.AXIS_FONT_SIZE,tickMarkDensity:I.AXIS_TICK_MARK_DENSITY,minMove:Be,edgePaddingPx:I.AXIS_EDGE_LABEL_PADDING_PX,edgePaddingTopPx:I.AXIS_TOP_LABEL_PADDING_PX});P.priceRange.minValue=K.min,P.priceRange.maxValue=K.max}P.margins={above:I.AXIS_TOP_LABEL_PADDING_PX,below:I.AXIS_EDGE_LABEL_PADDING_PX}}return P},ze=_.get(o.label)??m[0],Xe=ze.formatter,at=ze.tickmarksFormatter,xe={lineColor:E,topColor:B,bottomColor:Z,priceScaleId:Fe,...o.seriesType==="line"&&{lineStyle:o.lineStyle??$.LineStyle.Solid},priceFormat:{type:"custom",minMove:Be,formatter:Ce&&typeof n=="number"?S=>Xe(S<n?n:S):Xe,tickmarksFormatter:at},autoscaleInfoProvider:lt},Ge=o.seriesType==="line";let X=N.current.get(d);const ne=o.data.map(S=>({...S,time:S.time}));if(le!==void 0&&ne.length>0&&Number(ne[0].time)>le){const S=Number(ne[0].time),P=S-le,ie=86400,de=P>180*ie?7*ie:P>30*ie?ie:6*3600,K=[];for(let ve=le;ve<S;ve+=de)K.push({time:ve});ne.unshift(...K)}X&&X.seriesType()!==(Ge?"Line":"Area")&&(t.removeSeries(X),N.current.delete(d),X=void 0),X?(X.applyOptions(xe),X.setData(ne)):(Ge?X=t.addSeries($.LineSeries,{...b,...xe}):X=t.addSeries($.AreaSeries,{...b,...xe}),X.setData(ne),N.current.set(d,X)),L++}if(z)try{const i=t.priceScale("left"),o=t.priceScale("right"),d={visible:!T,autoScale:!0,scaleMargins:{top:0,bottom:0},alignLabels:!0,entireTextOnly:!1,tickMarkDensity:I.AXIS_TICK_MARK_DENSITY,textColor:V,...x?.rightPriceScale};i?.applyOptions(d),o?.applyOptions(d)}catch{}else if(v&&M.length>0)for(const i of M)try{const o=t.priceScale(i.priceScaleId);o&&o.applyOptions({visible:!1,autoScale:!0,scaleMargins:{top:0,bottom:0},alignLabels:!0,entireTextOnly:!1,tickMarkDensity:I.AXIS_TICK_MARK_DENSITY,textColor:V})}catch(o){console.warn(`Failed to configure price scale ${i.priceScaleId} for series ${i.seriesIndex}:`,o)}else if(!v)try{const i=t.priceScale("right");i&&i.applyOptions({visible:!T,autoScale:!0,scaleMargins:{top:0,bottom:0},alignLabels:!0,entireTextOnly:!1,tickMarkDensity:I.AXIS_TICK_MARK_DENSITY,textColor:V,...x?.rightPriceScale})}catch{}n!==void 0&&!T&&(H||!v)&&t.applyOptions({handleScroll:{vertTouchDrag:!1}});let O=0;if(ce.length>0){const i=ce.map(d=>Number(d.time)).filter(d=>Number.isFinite(d)),o=new Set(i).size-1;if(o>=0){const d=()=>{const k=t.timeScale();if(h!=="time"){k.applyOptions({fixLeftEdge:!0,fixRightEdge:!0}),k.setVisibleLogicalRange({from:0,to:o});return}const E=z&&!T,B=z?!T:!G,Z=!E,ue=!B;k.applyOptions({fixLeftEdge:!Z,fixRightEdge:!ue}),O=requestAnimationFrame(()=>{const he=$e({lastIndex:o,width:k.width(),padLeft:Z,padRight:ue});try{he&&k.setVisibleLogicalRange(he)}catch{k.fitContent()}})};try{d()}catch{try{t.timeScale().fitContent(),d()}catch{}}}}Le.current&&(Le.current=!1),x&&t.applyOptions(x);const te=new Map;for(const i of e)i.data.length>0&&te.set(i.label,i.data[i.data.length-1]);return Se(te.size>0?te:void 0),()=>cancelAnimationFrame(O)},[U,e,ce,h,f,T,H,z,we,Pe,Re,le,D,F,x]),g.useEffect(()=>{const t=A.current;if(!t||e.length===0)return;const a=e.length===1;let n;for(const c of e)if(c.data.length>0){n=c.data[c.data.length-1].time;break}if(!n)return;const s=c=>{const{time:p=n,seriesData:m,point:_}=c||{},w=e[0],v=w?N.current.get(oe(w)):void 0;if(!_||!p){const q=new Map;for(const b of e)b.data.length>0&&q.set(b.label,b.data[b.data.length-1]);if(Se(q.size>0?q:void 0),a||H||ge)J(null);else if(v&&n){const b=e[0];if(b&&b.data.length>0){const L=t.timeScale().timeToCoordinate(n),W=b.data[b.data.length-1].value,y=v.priceToCoordinate(W);L!==null&&y!==null&&J({x:L,y})}}return}const G=new Map;let V,ee=v;for(let q=0;q<e.length;q++){const b=e[q],M=N.current.get(oe(b));if(!M)continue;const L=m?.get(M),W=L&&"value"in L?L.value:void 0;let y;if(W!==void 0)y=W;else if(a){const O=Number(p),te=b.data.length>0?Number(b.data[0].time):Number.POSITIVE_INFINITY;O<te?y=Number.NaN:y=b.data[b.data.length-1]?.value??0}else{const O=b.data.length>0?Number(b.data[0].time):Number.POSITIVE_INFINITY;if(Number(p)<O)continue;y=Ze(b.data,Number(p))}Number.isNaN(y)||(V===void 0&&(V=y,ee=M),G.set(b.label,{value:y,time:p}))}if(Se(G),V!==void 0&&ee){const b=t.timeScale().timeToCoordinate(p),M=ee.priceToCoordinate(V);if(b!==null&&M!==null){const L=j.current;if(L){const W=L.querySelector(".LightweightChart");if(W){const y=W.getBoundingClientRect(),O=L.getBoundingClientRect(),te=b+(y.left-O.left),i=M+(y.top-O.top);J({x:te,y:i})}else J({x:b,y:M})}else J({x:b,y:M})}else J(null)}else J(null)};return t.subscribeCrosshairMove(s),T&&t.subscribeClick(s),!a&&!H&&!ge&&requestAnimationFrame(()=>{const c=e[0],p=c?N.current.get(oe(c)):void 0;if(p&&n&&c.data.length>0){const _=t.timeScale().timeToCoordinate(n),w=c.data[c.data.length-1].value,v=p.priceToCoordinate(w);_!==null&&v!==null&&J({x:_,y:v})}}),()=>{t.unsubscribeCrosshairMove(s),T&&t.unsubscribeClick(s)}},[e,H,T,ge]),g.useEffect(()=>{const t=A.current;if(!t||e.length===0)return;const a=t.timeScale(),n=()=>{const s=Ne.current;if(s.length===0)return;const c=a.getVisibleRange();if(!c)return;const p=Number(c.from),m=Number(c.to);for(const _ of s){const w=[];for(const v of e)if(_.labels.has(v.label))for(const G of v.data){const V=Number(G.time);V>=p&&V<=m&&w.push(G.value)}w.length>0&&_.updateVisibleRange(w)}};return a.subscribeVisibleLogicalRangeChange(n),()=>{a.unsubscribeVisibleLogicalRangeChange(n)}},[e]),g.useEffect(()=>{const t=A.current,a=Array.from(N.current.values()),n=[];if(t&&a.length>0&&R){const s=I.getDefaultVerticalLine(),c=a[0];for(const p of R){const m={...s,...p.options||{}};m.color&&(m.color=Y.resolveCSSColor(m.color,m.color));const _=new ht.VertLine(t,c,p.xCoordinate,m);c.attachPrimitive(_),n.push(_)}}return()=>{if(a.length>0){const s=a[0];for(const c of n)try{s.detachPrimitive(c)}catch{}}}},[R,e,U]),g.useEffect(()=>{const t=[],a=[];if(D&&D.length>0){const n=Y.resolveCSSColor("hsl(var(--destructive))","rgb(239, 68, 68)");for(const s of D){if(!Number.isFinite(s.price))continue;const c=We(N.current,e,s.seriesLabel);if(!c)continue;const p=s.color?Y.resolveCSSColor(s.color,s.color):n,m=s.lineWidth??1,_=s.lineStyle??$.LineStyle.Dashed,w=c.createPriceLine({price:s.price,color:p,lineWidth:m,lineStyle:_,axisLabelVisible:s.axisLabelVisible??!0,title:s.title??""});t.push({series:c,line:w});const v=new vt(c,s.price,p,m,_);c.attachPrimitive(v),a.push({series:c,primitive:v})}}return()=>{for(const{series:n,primitive:s}of a)try{n.detachPrimitive(s)}catch{}for(const{series:n,line:s}of t)try{n.removePriceLine(s)}catch{}}},[D,e,U]),g.useEffect(()=>{const t=[];if(F&&F.length>0){const a="rgba(239, 68, 68, 0.12)";for(const n of F){const s=We(N.current,e,n.seriesLabel);if(!s)continue;const c=n.color?Y.resolveCSSColor(n.color,a):a,p=new bt(s,n.priceTop,n.priceBottom,c);s.attachPrimitive(p),t.push({series:s,zone:p})}}return()=>{for(const{series:a,zone:n}of t)try{a.detachPrimitive(n)}catch{}}},[F,e,U]),g.useEffect(()=>{const t=A.current;if(!t||!R?.length){Me([]);return}const a=()=>{const c=t.timeScale(),p=R.map(m=>c.timeToCoordinate(m.xCoordinate)??null);Me(p),j.current&&De(j.current.clientWidth)};a();const n=t.timeScale(),s=()=>{a()};return n.subscribeVisibleLogicalRangeChange(s),()=>{n.unsubscribeVisibleLogicalRangeChange(s)}},[R,e,U]),g.useLayoutEffect(()=>{tt(t=>{const a={};let n=!1;for(const[s,c]of Ae.current){if(!c)continue;const p=c.offsetWidth;a[s]=p,t[s]!==p&&(n=!0)}return Object.keys(t).length!==Object.keys(a).length&&(n=!0),n?a:t})});const fe=e.length===1,je=ye.useMemo(()=>{if(fe&&e.length>0){const t=e[0];if(t.data.length>0)return t.data[t.data.length-1]}},[fe,e]);return C.jsxs("div",{ref:j,className:Q.cn("relative z-[1] w-full h-full overflow-hidden p-0",r),children:[pe!=null&&pe!==!1&&fe?C.jsx("div",{className:"absolute top-2 left-2 right-2 z-[100] pointer-events-none",children:C.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:pe})}):Qe&&fe&&je&&C.jsx(ut.GraphCurrentValue,{point:je,xMeasureUnit:h,yMeasureUnit:f,decimals:se}),ke&&Ee&&C.jsx(ft.GraphTooltip,{points:ke,xMeasureUnit:h,yMeasureUnit:f,series:e,position:Ee,containerRef:j,decimals:se}),l&&C.jsx(Ye,{series:e,onUnselect:u}),R&&R.length>0&&Ie.length===R.length&&C.jsx("div",{className:"absolute inset-0 z-[5] pointer-events-none","aria-hidden":!0,children:R.map((t,a)=>{const n=Ie[a],s=t.options??{};if(n===null)return null;const{labelText:c,valueStr:p}=He(s,f,se),m=s.tooltipText??"";if(!(c||p||m))return null;const w=s.labelBackgroundColor??s.color??"hsl(var(--background))",v=s.labelTextColor??"hsl(var(--foreground))",G=`${String(t.xCoordinate)}-${c}-${m}`,V=Oe(n,Ue,et[a]);return C.jsxs("div",{ref:ee=>{Ae.current.set(a,ee)},className:Q.cn("group absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",m&&"pointer-events-auto cursor-default"),style:{...V,backgroundColor:w,color:v},children:[c&&C.jsx("span",{className:"block",children:c}),p&&C.jsx("span",{className:Q.cn("block",c&&"mt-0.5"),children:p}),m&&C.jsx("span",{className:"pointer-events-none absolute right-0 top-full z-10 mt-1 hidden w-[280px] whitespace-normal rounded border border-border bg-popover px-2.5 py-1.5 text-left leading-snug text-popover-foreground shadow-md group-hover:block",role:"tooltip",children:m})]},G)})}),C.jsx("div",{ref:be,className:"LightweightChart w-full h-full overflow-hidden"})]})}function Ye({series:e,markers:r,onUnselect:l,inline:u=!1}){const h=e.every(f=>f.data.length===0);return C.jsxs("div",{className:Q.cn("flex flex-wrap",u?"items-center justify-center gap-6":"absolute top-0 left-2 z-[10] gap-2"),children:[e.map((f,x)=>{const R=Ke.getSeriesColorPalette(x),D=(f.lineColor??f.color)||R.line,F=!h&&f.data.length===0;return C.jsxs("div",{className:Q.cn("flex shrink-0 items-center gap-1.5",!u&&"px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",F&&"opacity-50"),children:[C.jsx("div",{className:Q.cn("shrink-0",u?"size-2 rounded-full":"h-3 w-3 rounded-sm"),style:{backgroundColor:D}}),C.jsxs("span",{className:Q.cn("font-medium text-foreground",u?"text-sm":"text-[10px] sm:text-xs"),children:[f.label,F&&" (no data)"]}),l&&C.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),l(f.label)},className:"ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer","aria-label":`Remove ${f.label}`,children:C.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:[C.jsx("title",{children:"Close"}),C.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),C.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},f.id??f.label)}),r?.map(f=>C.jsxs("div",{className:Q.cn("flex shrink-0 items-center gap-1.5",!u&&"px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border"),children:[C.jsx("div",{className:"h-3 w-0.5 shrink-0",style:{backgroundColor:f.color}}),C.jsx("span",{className:Q.cn("font-medium text-foreground",u?"text-sm":"text-[10px] sm:text-xs"),children:f.label})]},f.id))]})}exports.Graph=yt;exports.GraphLegend=Ye;exports.VERTICAL_LINE_LABEL_EDGE_PADDING=_e;exports.getStepForwardValue=Ze;exports.getVerticalLineLabelStyle=Oe;exports.getVerticalLineTooltipContent=He;exports.seriesIdentity=oe;exports.visibleLogicalRangeFor=$e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),$=require("lightweight-charts"),g=require("react"),Y=require("./colors.cjs"),ct=require("../../hooks/use-media-query.cjs"),Q=require("../../utils/cn.cjs"),I=require("./default-config.cjs"),re=require("./formatters.cjs"),ut=require("./graph-current-value.cjs"),ft=require("./graph-tooltip.cjs"),ht=require("./plugins/vertical-line.cjs"),dt=require("./series-config.cjs"),Ke=require("./series-palette.cjs"),qe=require("./y-axis-scale.cjs");function pt(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const l in e)if(l!=="default"){const u=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(r,l,u.get?u:{enumerable:!0,get:()=>e[l]})}}return r.default=e,Object.freeze(r)}const ye=pt(g);function oe(e){return e.id??e.label}function $e({lastIndex:e,width:r,padLeft:l,padRight:u,paddingPx:h=I.AXIS_TIME_EDGE_PADDING_PX}){if(e<0)return null;const f=(l||u)&&r>0?h*Math.max(e,1)/r:0;return{from:l&&f!==0?-f:0,to:u?e+f:e}}function We(e,r,l){if(!l)return e.values().next().value;const u=e.get(l);if(u)return u;const h=r.find(f=>f.id===l||f.label===l);return h?e.get(oe(h)):void 0}class gt{_yTop;_yBottom;_color;constructor(r,l,u){this._yTop=r,this._yBottom=l,this._color=u}draw(r){r.useBitmapCoordinateSpace(l=>{const u=l.context,h=l.verticalPixelRatio,f=this._yTop===null?0:this._yTop*h,x=this._yBottom===null?l.bitmapSize.height:this._yBottom*h,R=Math.min(f,x),D=Math.max(f,x);u.fillStyle=this._color,u.fillRect(0,R,l.bitmapSize.width,D-R)})}}class mt{_source;_yTop=null;_yBottom=null;constructor(r){this._source=r}update(){const r=this._source.series;this._yTop=this._source.priceTop===void 0?null:r.priceToCoordinate(this._source.priceTop),this._yBottom=this._source.priceBottom===void 0?null:r.priceToCoordinate(this._source.priceBottom)}zOrder(){return"bottom"}renderer(){return new gt(this._yTop,this._yBottom,this._source.color)}}class bt{series;priceTop;priceBottom;color;_paneViews;constructor(r,l,u,h){this.series=r,this.priceTop=l,this.priceBottom=u,this.color=h,this._paneViews=[new mt(this)]}updateAllViews(){for(const r of this._paneViews)r.update()}paneViews(){return this._paneViews}}function St(e,r){switch(e){case $.LineStyle.Dotted:return[r,r];case $.LineStyle.Dashed:return[2*r,2*r];case $.LineStyle.LargeDashed:return[6*r,6*r];case $.LineStyle.SparseDotted:return[r,4*r];default:return[]}}class Ct{_y;_color;_lineWidth;_lineStyle;constructor(r,l,u,h){this._y=r,this._color=l,this._lineWidth=u,this._lineStyle=h}draw(r){r.useBitmapCoordinateSpace(l=>{if(this._y===null)return;const u=l.context,h=l.verticalPixelRatio,f=Math.max(1,Math.round(this._lineWidth*h)),x=Math.round(this._y*h);u.save(),u.strokeStyle=this._color,u.lineWidth=f,u.setLineDash(St(this._lineStyle,f)),u.beginPath(),u.moveTo(0,x),u.lineTo(l.bitmapSize.width,x),u.stroke(),u.restore()})}}class xt{_source;_y=null;constructor(r){this._source=r}update(){this._y=this._source.series.priceToCoordinate(this._source.price)}zOrder(){return"top"}renderer(){return new Ct(this._y,this._source.color,this._source.lineWidth,this._source.lineStyle)}}class vt{series;price;color;lineWidth;lineStyle;_paneViews;constructor(r,l,u,h,f){this.series=r,this.price=l,this.color=u,this.lineWidth=h,this.lineStyle=f,this._paneViews=[new xt(this)]}updateAllViews(){for(const r of this._paneViews)r.update()}paneViews(){return this._paneViews}}function He(e,r,l){const u=e.labelText??"",h=e.value,f=h===void 0?"":typeof h=="number"?r==="$"?`$${re.formatExactValue(h,void 0,l)}`:r==="%"?`${re.formatExactValue(h,void 0,l)}%`:re.formatExactValue(h,r!=="none"&&r!=="%"&&r!=="$"&&!re.isRatioUnit(r)?r:void 0,l):String(h);return{labelText:u,valueStr:f}}const _e=4;function Oe(e,r,l){const u={left:e,transform:"translateX(-50%)"};if(r<=0||!l||l<=0)return u;const h=l/2,f=_e+h,x=r-_e-h;return x<f?{left:r/2,transform:"translateX(-50%)"}:{left:Math.min(Math.max(e,f),x),transform:"translateX(-50%)"}}function Ze(e,r){for(let l=e.length-1;l>=0;l--)if(Number(e[l].time)<=r)return e[l].value;return 0}function yt({series:e,className:r,showLegend:l=!1,onUnselectSeries:u,xMeasureUnit:h="time",yMeasureUnit:f="token",optionsOverrides:x,verticalLineOptions:R,priceLineOptions:D,zoneOptions:F,currentValueDecimals:se,useSharedPriceScale:H=!1,dualYAxis:z=!1,defaultVisiblePriceScaleId:we="right",showCurrentValue:Qe=!0,graphTitle:pe,yScaleMin:Pe,yScaleMinMultiple:Re,visibleTimeFrom:le,disableZoom:Te=!1,hideDefaultTooltip:ge=!1}){const A=g.useRef(null),V=g.useRef(new Map),me=g.useRef(!1),Le=g.useRef(!0),Ne=g.useRef([]),ae=g.useRef(0),j=g.useRef(null),be=g.useRef(null),Ve=g.useRef(null),T=ct.useIsMobile(),ce=ye.useMemo(()=>e.flatMap(t=>t.data),[e]),Je=ye.useMemo(()=>{if(e.length>0){const t=e[e.length-1];if(t.data.length>0)return t.data[t.data.length-1]}},[e]),[ke,Se]=g.useState(()=>{if(!Je)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}),[Ee,J]=g.useState(null),[Ie,Me]=g.useState([]),[Ue,De]=g.useState(0),Ae=g.useRef(new Map),[et,tt]=g.useState({}),[U,ot]=g.useState(0);g.useEffect(()=>{const t=()=>{try{if(j.current&&De(j.current.clientWidth),A.current&&j.current){const s=j.current.clientWidth,c=j.current.clientHeight;A.current.resize(s,c);try{ae.current=A.current.paneSize().height}catch{}}}catch{}},a=j.current,n=a?new ResizeObserver(t):null;return Ve.current=n,a&&n?.observe(a),()=>{a&&n?.unobserve(a),n?.disconnect(),Ve.current=null}},[]),g.useEffect(()=>{if(!be.current||me.current)return;const t=I.getDefaultOptions(),a=Y.resolveCSSColor("hsl(var(--muted-foreground))","rgb(163, 163, 163)"),n=$.createChart(be.current,{...t,leftPriceScale:{...t.leftPriceScale||{},visible:!1,textColor:a},rightPriceScale:{...t.rightPriceScale||{},visible:!T,textColor:a},...T&&{crosshair:{...t.crosshair,mode:$.CrosshairMode.Magnet}}});A.current=n,me.current=!0;try{ae.current=n.paneSize().height}catch{ae.current=0}return ot(s=>s+1),()=>{n.remove(),A.current=null,me.current=!1,V.current.clear()}},[T]),g.useEffect(()=>{const t=A.current;t&&t.applyOptions(Te?{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}})},[U,Te]),g.useEffect(()=>{const t=A.current;!t||!x||t.applyOptions(x)},[U,x]),g.useEffect(()=>{const t=A.current;if(!t||e.length===0)return;const n=e.filter(i=>i.data.length>0).length<=1?Pe:Re,s=h==="time"?re.getXFormatters(h,ce):re.getXFormatters(h),c=new Map(dt.resolvePriceScaleSides(e).map(({series:i,side:o})=>[i.label,o])),p=(i,o,d)=>{const{formatter:E,tickmarksFormatter:N,updateVisibleRange:B}=re.createAdaptiveYAxisFormatter(i,o,{yScaleMin:n});return{formatter:E,tickmarksFormatter:N,updateVisibleRange:B,labels:d}},m=[];if(z)for(const i of["left","right"]){const o=new Set,d=[];let E=f;for(const N of e)if(N.data.length!==0&&c.get(N.label)===i){o.size===0&&N.yMeasureUnit&&(E=N.yMeasureUnit),o.add(N.label);for(const B of N.data)d.push(B.value)}o.size>0&&m.push(p(d,E,o))}else{const i=ce.map(d=>d.value),o=new Set(e.filter(d=>d.data.length>0).map(d=>d.label));m.push(p(i,f,o))}Ne.current=m;const _=new Map;for(const i of m)for(const o of i.labels)_.set(o,i);const w=I.getDefaultOptions();t.applyOptions({localization:{...w.localization||{},timeFormatter:i=>s.timeFormatter(parseFloat(i),void 0)},timeScale:{...w.timeScale||{},...x?.timeScale,tickMarkFormatter:s.tickMarkFormatter,minBarSpacing:0}});const v=!z&&e.length>1&&!H,G=z?T:e.length>1&&!H||T,k=Y.resolveCSSColor("hsl(var(--muted-foreground))","rgb(163, 163, 163)");t.applyOptions({...z&&{defaultVisiblePriceScaleId:we},leftPriceScale:{...w.leftPriceScale||{},...x?.leftPriceScale,visible:z&&!T,textColor:k},rightPriceScale:{...w.rightPriceScale||{},...x?.rightPriceScale,visible:z?!T:!G,textColor:k}});const ee=new Set(V.current.keys()),q=new Set(e.map(oe));for(const i of ee)if(!q.has(i)){const o=V.current.get(i);o&&(t.removeSeries(o),V.current.delete(i))}const b=I.getDefaultSeries(),M=[];let L=0;const W=e.find(i=>i.data.length>0),y=new Map;if(D&&D.length>0)for(const i of D){if(!Number.isFinite(i.price))continue;const o=i.seriesLabel??W?.label;if(!o)continue;const d=y.get(o)??[];d.push(i.price),y.set(o,d)}if(F&&F.length>0)for(const i of F){const o=i.seriesLabel??W?.label;if(!o)continue;const d=y.get(o)??[];Number.isFinite(i.priceTop)&&d.push(i.priceTop),Number.isFinite(i.priceBottom)&&d.push(i.priceBottom),y.set(o,d)}for(let i=0;i<e.length;i++){const o=e[i],d=oe(o),E=Ke.getSeriesColorPalette(i),N=o.lineColor??o.color??E.line;let B,Z;if(o.lineColor??o.color)if(o.topColor&&o.bottomColor)B=o.topColor,Z=o.bottomColor;else if(o.topColor){const S=Y.generateColorsFromBase(N);B=o.topColor,Z=S.bottomColor}else if(o.bottomColor)B=Y.generateColorsFromBase(N).topColor,Z=o.bottomColor;else{const S=Y.generateColorsFromBase(N);B=S.topColor,Z=S.bottomColor}else B=o.topColor||E.top,Z=o.bottomColor||E.bottom;if(o.data.length===0){const S=V.current.get(d);S&&(t.removeSeries(S),V.current.delete(d));continue}const ue=o.data.length>0?Math.min(...o.data.map(S=>S.value)):0,he=o.data.length>0?Math.max(...o.data.map(S=>S.value)):0,rt=ue<0,nt=o.data.some(S=>S.value===0),it=!rt&&nt,Be=qe.pickMinMove(he-ue),Fe=z?o.priceScaleId??(L===0?"left":"right"):H||!v||L===0?"right":`scale-${L}`;v&&M.push({priceScaleId:Fe||"right",seriesIndex:L});const Ce=(H||!v)&&n!==void 0&&typeof n=="number",st=y.get(o.label)??[],lt=S=>{const P=S();if(P?.priceRange){Ce&&(P.priceRange.minValue=n);for(const K of st)K<P.priceRange.minValue&&(P.priceRange.minValue=K),K>P.priceRange.maxValue&&(P.priceRange.maxValue=K);const ie=Ce?n:it&&P.priceRange.minValue>=0?0:void 0,de=ae.current>0?ae.current:j.current?.clientHeight??0;if(de>0){const K=qe.niceAxisRange({min:P.priceRange.minValue,max:P.priceRange.maxValue,floor:ie,scaleHeightPx:de,fontSizePx:I.AXIS_FONT_SIZE,tickMarkDensity:I.AXIS_TICK_MARK_DENSITY,minMove:Be,edgePaddingPx:I.AXIS_EDGE_LABEL_PADDING_PX,edgePaddingTopPx:I.AXIS_TOP_LABEL_PADDING_PX});P.priceRange.minValue=K.min,P.priceRange.maxValue=K.max}P.margins={above:I.AXIS_TOP_LABEL_PADDING_PX,below:I.AXIS_EDGE_LABEL_PADDING_PX}}return P},ze=_.get(o.label)??m[0],Xe=ze.formatter,at=ze.tickmarksFormatter,xe={lineColor:N,topColor:B,bottomColor:Z,priceScaleId:Fe,...o.seriesType==="line"&&{color:N,lineStyle:o.lineStyle??$.LineStyle.Solid},priceFormat:{type:"custom",minMove:Be,formatter:Ce&&typeof n=="number"?S=>Xe(S<n?n:S):Xe,tickmarksFormatter:at},autoscaleInfoProvider:lt},Ge=o.seriesType==="line";let X=V.current.get(d);const ne=o.data.map(S=>({...S,time:S.time}));if(le!==void 0&&ne.length>0&&Number(ne[0].time)>le){const S=Number(ne[0].time),P=S-le,ie=86400,de=P>180*ie?7*ie:P>30*ie?ie:6*3600,K=[];for(let ve=le;ve<S;ve+=de)K.push({time:ve});ne.unshift(...K)}X&&X.seriesType()!==(Ge?"Line":"Area")&&(t.removeSeries(X),V.current.delete(d),X=void 0),X?(X.applyOptions(xe),X.setData(ne)):(Ge?X=t.addSeries($.LineSeries,{...b,...xe}):X=t.addSeries($.AreaSeries,{...b,...xe}),X.setData(ne),V.current.set(d,X)),L++}if(z)try{const i=t.priceScale("left"),o=t.priceScale("right"),d={visible:!T,autoScale:!0,scaleMargins:{top:0,bottom:0},alignLabels:!0,entireTextOnly:!1,tickMarkDensity:I.AXIS_TICK_MARK_DENSITY,textColor:k,...x?.rightPriceScale};i?.applyOptions(d),o?.applyOptions(d)}catch{}else if(v&&M.length>0)for(const i of M)try{const o=t.priceScale(i.priceScaleId);o&&o.applyOptions({visible:!1,autoScale:!0,scaleMargins:{top:0,bottom:0},alignLabels:!0,entireTextOnly:!1,tickMarkDensity:I.AXIS_TICK_MARK_DENSITY,textColor:k})}catch(o){console.warn(`Failed to configure price scale ${i.priceScaleId} for series ${i.seriesIndex}:`,o)}else if(!v)try{const i=t.priceScale("right");i&&i.applyOptions({visible:!T,autoScale:!0,scaleMargins:{top:0,bottom:0},alignLabels:!0,entireTextOnly:!1,tickMarkDensity:I.AXIS_TICK_MARK_DENSITY,textColor:k,...x?.rightPriceScale})}catch{}n!==void 0&&!T&&(H||!v)&&t.applyOptions({handleScroll:{vertTouchDrag:!1}});let O=0;if(ce.length>0){const i=ce.map(d=>Number(d.time)).filter(d=>Number.isFinite(d)),o=new Set(i).size-1;if(o>=0){const d=()=>{const E=t.timeScale();if(h!=="time"){E.applyOptions({fixLeftEdge:!0,fixRightEdge:!0}),E.setVisibleLogicalRange({from:0,to:o});return}const N=z&&!T,B=z?!T:!G,Z=!N,ue=!B;E.applyOptions({fixLeftEdge:!Z,fixRightEdge:!ue}),O=requestAnimationFrame(()=>{const he=$e({lastIndex:o,width:E.width(),padLeft:Z,padRight:ue});try{he&&E.setVisibleLogicalRange(he)}catch{E.fitContent()}})};try{d()}catch{try{t.timeScale().fitContent(),d()}catch{}}}}Le.current&&(Le.current=!1),x&&t.applyOptions(x);const te=new Map;for(const i of e)i.data.length>0&&te.set(i.label,i.data[i.data.length-1]);return Se(te.size>0?te:void 0),()=>cancelAnimationFrame(O)},[U,e,ce,h,f,T,H,z,we,Pe,Re,le,D,F,x]),g.useEffect(()=>{const t=A.current;if(!t||e.length===0)return;const a=e.length===1;let n;for(const c of e)if(c.data.length>0){n=c.data[c.data.length-1].time;break}if(!n)return;const s=c=>{const{time:p=n,seriesData:m,point:_}=c||{},w=e[0],v=w?V.current.get(oe(w)):void 0;if(!_||!p){const q=new Map;for(const b of e)b.data.length>0&&q.set(b.label,b.data[b.data.length-1]);if(Se(q.size>0?q:void 0),a||H||ge)J(null);else if(v&&n){const b=e[0];if(b&&b.data.length>0){const L=t.timeScale().timeToCoordinate(n),W=b.data[b.data.length-1].value,y=v.priceToCoordinate(W);L!==null&&y!==null&&J({x:L,y})}}return}const G=new Map;let k,ee=v;for(let q=0;q<e.length;q++){const b=e[q],M=V.current.get(oe(b));if(!M)continue;const L=m?.get(M),W=L&&"value"in L?L.value:void 0;let y;if(W!==void 0)y=W;else if(a){const O=Number(p),te=b.data.length>0?Number(b.data[0].time):Number.POSITIVE_INFINITY;O<te?y=Number.NaN:y=b.data[b.data.length-1]?.value??0}else{const O=b.data.length>0?Number(b.data[0].time):Number.POSITIVE_INFINITY;if(Number(p)<O)continue;y=Ze(b.data,Number(p))}Number.isNaN(y)||(k===void 0&&(k=y,ee=M),G.set(b.label,{value:y,time:p}))}if(Se(G),k!==void 0&&ee){const b=t.timeScale().timeToCoordinate(p),M=ee.priceToCoordinate(k);if(b!==null&&M!==null){const L=j.current;if(L){const W=L.querySelector(".LightweightChart");if(W){const y=W.getBoundingClientRect(),O=L.getBoundingClientRect(),te=b+(y.left-O.left),i=M+(y.top-O.top);J({x:te,y:i})}else J({x:b,y:M})}else J({x:b,y:M})}else J(null)}else J(null)};return t.subscribeCrosshairMove(s),T&&t.subscribeClick(s),!a&&!H&&!ge&&requestAnimationFrame(()=>{const c=e[0],p=c?V.current.get(oe(c)):void 0;if(p&&n&&c.data.length>0){const _=t.timeScale().timeToCoordinate(n),w=c.data[c.data.length-1].value,v=p.priceToCoordinate(w);_!==null&&v!==null&&J({x:_,y:v})}}),()=>{t.unsubscribeCrosshairMove(s),T&&t.unsubscribeClick(s)}},[e,H,T,ge]),g.useEffect(()=>{const t=A.current;if(!t||e.length===0)return;const a=t.timeScale(),n=()=>{const s=Ne.current;if(s.length===0)return;const c=a.getVisibleRange();if(!c)return;const p=Number(c.from),m=Number(c.to);for(const _ of s){const w=[];for(const v of e)if(_.labels.has(v.label))for(const G of v.data){const k=Number(G.time);k>=p&&k<=m&&w.push(G.value)}w.length>0&&_.updateVisibleRange(w)}};return a.subscribeVisibleLogicalRangeChange(n),()=>{a.unsubscribeVisibleLogicalRangeChange(n)}},[e]),g.useEffect(()=>{const t=A.current,a=Array.from(V.current.values()),n=[];if(t&&a.length>0&&R){const s=I.getDefaultVerticalLine(),c=a[0];for(const p of R){const m={...s,...p.options||{}};m.color&&(m.color=Y.resolveCSSColor(m.color,m.color));const _=new ht.VertLine(t,c,p.xCoordinate,m);c.attachPrimitive(_),n.push(_)}}return()=>{if(a.length>0){const s=a[0];for(const c of n)try{s.detachPrimitive(c)}catch{}}}},[R,e,U]),g.useEffect(()=>{const t=[],a=[];if(D&&D.length>0){const n=Y.resolveCSSColor("hsl(var(--destructive))","rgb(239, 68, 68)");for(const s of D){if(!Number.isFinite(s.price))continue;const c=We(V.current,e,s.seriesLabel);if(!c)continue;const p=s.color?Y.resolveCSSColor(s.color,s.color):n,m=s.lineWidth??1,_=s.lineStyle??$.LineStyle.Dashed,w=c.createPriceLine({price:s.price,color:p,lineWidth:m,lineStyle:_,axisLabelVisible:s.axisLabelVisible??!0,title:s.title??""});t.push({series:c,line:w});const v=new vt(c,s.price,p,m,_);c.attachPrimitive(v),a.push({series:c,primitive:v})}}return()=>{for(const{series:n,primitive:s}of a)try{n.detachPrimitive(s)}catch{}for(const{series:n,line:s}of t)try{n.removePriceLine(s)}catch{}}},[D,e,U]),g.useEffect(()=>{const t=[];if(F&&F.length>0){const a="rgba(239, 68, 68, 0.12)";for(const n of F){const s=We(V.current,e,n.seriesLabel);if(!s)continue;const c=n.color?Y.resolveCSSColor(n.color,a):a,p=new bt(s,n.priceTop,n.priceBottom,c);s.attachPrimitive(p),t.push({series:s,zone:p})}}return()=>{for(const{series:a,zone:n}of t)try{a.detachPrimitive(n)}catch{}}},[F,e,U]),g.useEffect(()=>{const t=A.current;if(!t||!R?.length){Me([]);return}const a=()=>{const c=t.timeScale(),p=R.map(m=>c.timeToCoordinate(m.xCoordinate)??null);Me(p),j.current&&De(j.current.clientWidth)};a();const n=t.timeScale(),s=()=>{a()};return n.subscribeVisibleLogicalRangeChange(s),()=>{n.unsubscribeVisibleLogicalRangeChange(s)}},[R,e,U]),g.useLayoutEffect(()=>{tt(t=>{const a={};let n=!1;for(const[s,c]of Ae.current){if(!c)continue;const p=c.offsetWidth;a[s]=p,t[s]!==p&&(n=!0)}return Object.keys(t).length!==Object.keys(a).length&&(n=!0),n?a:t})});const fe=e.length===1,je=ye.useMemo(()=>{if(fe&&e.length>0){const t=e[0];if(t.data.length>0)return t.data[t.data.length-1]}},[fe,e]);return C.jsxs("div",{ref:j,className:Q.cn("relative z-[1] w-full h-full overflow-hidden p-0",r),children:[pe!=null&&pe!==!1&&fe?C.jsx("div",{className:"absolute top-2 left-2 right-2 z-[100] pointer-events-none",children:C.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:pe})}):Qe&&fe&&je&&C.jsx(ut.GraphCurrentValue,{point:je,xMeasureUnit:h,yMeasureUnit:f,decimals:se}),ke&&Ee&&C.jsx(ft.GraphTooltip,{points:ke,xMeasureUnit:h,yMeasureUnit:f,series:e,position:Ee,containerRef:j,decimals:se}),l&&C.jsx(Ye,{series:e,onUnselect:u}),R&&R.length>0&&Ie.length===R.length&&C.jsx("div",{className:"absolute inset-0 z-[5] pointer-events-none","aria-hidden":!0,children:R.map((t,a)=>{const n=Ie[a],s=t.options??{};if(n===null)return null;const{labelText:c,valueStr:p}=He(s,f,se),m=s.tooltipText??"";if(!(c||p||m))return null;const w=s.labelBackgroundColor??s.color??"hsl(var(--background))",v=s.labelTextColor??"hsl(var(--foreground))",G=`${String(t.xCoordinate)}-${c}-${m}`,k=Oe(n,Ue,et[a]);return C.jsxs("div",{ref:ee=>{Ae.current.set(a,ee)},className:Q.cn("group absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",m&&"pointer-events-auto cursor-default"),style:{...k,backgroundColor:w,color:v},children:[c&&C.jsx("span",{className:"block",children:c}),p&&C.jsx("span",{className:Q.cn("block",c&&"mt-0.5"),children:p}),m&&C.jsx("span",{className:"pointer-events-none absolute right-0 top-full z-10 mt-1 hidden w-[280px] whitespace-normal rounded border border-border bg-popover px-2.5 py-1.5 text-left leading-snug text-popover-foreground shadow-md group-hover:block",role:"tooltip",children:m})]},G)})}),C.jsx("div",{ref:be,className:"LightweightChart w-full h-full overflow-hidden"})]})}function Ye({series:e,markers:r,onUnselect:l,inline:u=!1}){const h=e.every(f=>f.data.length===0);return C.jsxs("div",{className:Q.cn("flex flex-wrap",u?"items-center justify-center gap-6":"absolute top-0 left-2 z-[10] gap-2"),children:[e.map((f,x)=>{const R=Ke.getSeriesColorPalette(x),D=(f.lineColor??f.color)||R.line,F=!h&&f.data.length===0;return C.jsxs("div",{className:Q.cn("flex shrink-0 items-center gap-1.5",!u&&"px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",F&&"opacity-50"),children:[C.jsx("div",{className:Q.cn("shrink-0",u?"size-2 rounded-full":"h-3 w-3 rounded-sm"),style:{backgroundColor:D}}),C.jsxs("span",{className:Q.cn("font-medium text-foreground",u?"text-sm":"text-[10px] sm:text-xs"),children:[f.label,F&&" (no data)"]}),l&&C.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),l(f.label)},className:"ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer","aria-label":`Remove ${f.label}`,children:C.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:[C.jsx("title",{children:"Close"}),C.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),C.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},f.id??f.label)}),r?.map(f=>C.jsxs("div",{className:Q.cn("flex shrink-0 items-center gap-1.5",!u&&"px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border"),children:[C.jsx("div",{className:"h-3 w-0.5 shrink-0",style:{backgroundColor:f.color}}),C.jsx("span",{className:Q.cn("font-medium text-foreground",u?"text-sm":"text-[10px] sm:text-xs"),children:f.label})]},f.id))]})}exports.Graph=yt;exports.GraphLegend=Ye;exports.VERTICAL_LINE_LABEL_EDGE_PADDING=_e;exports.getStepForwardValue=Ze;exports.getVerticalLineLabelStyle=Oe;exports.getVerticalLineTooltipContent=He;exports.seriesIdentity=oe;exports.visibleLogicalRangeFor=$e;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("../base/apy-breakdown-body/apy-breakdown-body.cjs"),B=require("../base/pool-apy-breakdown-card/pool-apy-breakdown-card.cjs"),g=require("../points-icon/points-icon.cjs"),x=require("../token-icon/token-icon.cjs"),l=require("../typed-intl/index.cjs"),j=require("../../utils/format-leverage.cjs"),u=require("../../utils/internal/apy-breakdown.cjs"),A=require("./yield-breakdown-tooltip.cjs");function v({supplyApy:a,maxLeverage:r,collateralApy:m,borrowApy:d,quotaRate:i,period:s,children:t,className:p,open:y}){const c=r!==void 0&&r>0;return e.jsx(A.ApyBreakdownTooltip,{placement:"bottom",title:e.jsx("span",{className:p,children:t}),triggerClassName:p,open:y,children:c?e.jsx(_,{supplyApy:a,maxLeverage:r,collateralApy:m,borrowApy:d,quotaRate:i,period:s}):e.jsx(B.PoolApyBreakdownCard,{data:a,period:s})})}function _({supplyApy:a,maxLeverage:r,collateralApy:m,borrowApy:d,quotaRate:i,period:s}){const t=m,p=t?u.tokenRewardsOf(t):[],y=u.pointProgramsOf(a),c=u.totalApyOf(a),w=d!=null||i!=null?(d??0)+(i??0):void 0,k=y.filter(o=>o.multiplier!=null);return e.jsxs(n.ApyBreakdownBody,{title:e.jsx(l.FormattedMessageTyped,{messageId:n.periodMessageId(s,"components.yieldBreakdown.titleNetAtLeverage","components.yieldBreakdown.titleNetAtLeverage7d"),values:{leverage:j.formatLeverage(r)}}),chip:n.formatBreakdownRate(c,!0),chipPositive:c>0,children:[t?.organicApy!=null?e.jsx(n.ApyBreakdownRow,{muted:t.organicApy<0,label:e.jsx(l.FormattedMessageTyped,{messageId:n.periodMessageId(s,"components.yieldBreakdown.collateralApy","components.yieldBreakdown.collateralApy7d")}),value:n.formatBreakdownRate(t.organicApy)}):null,p.map(o=>o.supplyApr==null?null:e.jsx(n.ApyBreakdownRow,{muted:o.supplyApr<0,label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(l.FormattedMessageTyped,{messageId:"components.apyParts.extraAPY",values:{symbol:o.token.symbol}})}),e.jsx(x.TokenIcon,{token:o.token,size:20})]}),value:n.formatBreakdownRate(o.supplyApr)},`incentive-${o.token.address}-${o.supplyApr}`)),w!=null?e.jsx(n.ApyBreakdownRow,{muted:!0,label:e.jsx(l.FormattedMessageTyped,{messageId:n.periodMessageId(s,"components.yieldBreakdown.borrowRate","components.yieldBreakdown.borrowRate7d")}),value:n.formatBreakdownRate(w)}):null,k.length>0?e.jsxs(e.Fragment,{children:[e.jsx(n.ApyBreakdownDivider,{}),k.map(o=>e.jsx(n.ApyBreakdownRow,{label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(l.FormattedMessageTyped,{messageId:"components.yieldBreakdown.programPoints",values:{name:o.name}})}),e.jsx(g.PointsIcon,{reward:{name:o.name,type:o.id},size:20})]}),value:`${o.multiplier}×`},`points-${o.id}`))]}):null]})}exports.YieldBreakdownTooltip=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("../base/apy-breakdown-body/apy-breakdown-body.cjs"),g=require("../base/pool-apy-breakdown-card/pool-apy-breakdown-card.cjs"),x=require("../points-icon/points-icon.cjs"),j=require("../token-icon/token-icon.cjs"),l=require("../typed-intl/index.cjs"),A=require("../../utils/format-leverage.cjs"),k=require("../../utils/internal/apy-breakdown.cjs"),f=require("./yield-breakdown-tooltip.cjs");function v({supplyApy:a,maxLeverage:r,collateralApy:u,borrowApy:d,quotaRate:i,period:t,hideRewardLinks:p=!1,children:s,className:c,open:y}){const m=r!==void 0&&r>0;return e.jsx(f.ApyBreakdownTooltip,{placement:"bottom",title:e.jsx("span",{className:c,children:s}),triggerClassName:c,open:y,children:m?e.jsx(_,{supplyApy:a,maxLeverage:r,collateralApy:u,borrowApy:d,quotaRate:i,period:t,hideRewardLinks:p}):e.jsx(g.PoolApyBreakdownCard,{data:a,period:t,hideRewardLinks:p})})}function _({supplyApy:a,maxLeverage:r,collateralApy:u,borrowApy:d,quotaRate:i,period:t,hideRewardLinks:p}){const s=u,c=s?k.tokenRewardsOf(s):[],y=k.pointProgramsOf(a),m=k.totalApyOf(a),w=d!=null||i!=null?(d??0)+(i??0):void 0,B=y.filter(o=>o.multiplier!=null);return e.jsxs(n.ApyBreakdownBody,{title:e.jsx(l.FormattedMessageTyped,{messageId:n.periodMessageId(t,"components.yieldBreakdown.titleNetAtLeverage","components.yieldBreakdown.titleNetAtLeverage7d"),values:{leverage:A.formatLeverage(r)}}),chip:n.formatBreakdownRate(m,!0),chipPositive:m>0,children:[s?.organicApy!=null?e.jsx(n.ApyBreakdownRow,{muted:s.organicApy<0,label:e.jsx(l.FormattedMessageTyped,{messageId:n.periodMessageId(t,"components.yieldBreakdown.collateralApy","components.yieldBreakdown.collateralApy7d")}),value:n.formatBreakdownRate(s.organicApy)}):null,c.map(o=>o.supplyApr==null?null:e.jsx(n.ApyBreakdownRow,{muted:o.supplyApr<0,label:e.jsxs("span",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(l.FormattedMessageTyped,{messageId:"components.apyParts.extraAPY",values:{symbol:o.token.symbol}})}),e.jsx(j.TokenIcon,{token:o.token,size:20})]}),p?null:e.jsx(n.RewardLinks,{links:o.links})]}),value:n.formatBreakdownRate(o.supplyApr)},`incentive-${o.token.address}-${o.supplyApr}`)),w!=null?e.jsx(n.ApyBreakdownRow,{muted:!0,label:e.jsx(l.FormattedMessageTyped,{messageId:n.periodMessageId(t,"components.yieldBreakdown.borrowRate","components.yieldBreakdown.borrowRate7d")}),value:n.formatBreakdownRate(w)}):null,B.length>0?e.jsxs(e.Fragment,{children:[e.jsx(n.ApyBreakdownDivider,{}),B.map(o=>e.jsx(n.ApyBreakdownRow,{label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(l.FormattedMessageTyped,{messageId:"components.yieldBreakdown.programPoints",values:{name:o.name}})}),e.jsx(x.PointsIcon,{reward:{name:o.name,type:o.id},size:20})]}),value:`${o.multiplier}×`},`points-${o.id}`))]}):null]})}exports.YieldBreakdownTooltip=v;
@@ -1,33 +1,35 @@
1
- import { jsxs as d, jsx as a } from "react/jsx-runtime";
1
+ import { jsxs as s, jsx as a } from "react/jsx-runtime";
2
+ import { Fragment as m } from "react";
3
+ import { Link as u } from "../../link/link.js";
2
4
  import { cn as i } from "../../../utils/cn.js";
3
5
  import { bpsToPercent as l } from "../../../utils/internal/bps-to-percent.js";
4
- const x = "—", p = "400px";
5
- function b(e, n, t) {
6
- return e === "7d" ? t : n;
6
+ const w = "—", N = "400px";
7
+ function k(n, e, t) {
8
+ return n === "7d" ? t : e;
7
9
  }
8
- function g(e, n = !1) {
9
- const t = l(e), s = `${Math.abs(t).toFixed(2)}%`;
10
- return n && t < 0 ? `−${s}` : s;
10
+ function y(n, e = !1) {
11
+ const t = l(n), r = `${Math.abs(t).toFixed(2)}%`;
12
+ return e && t < 0 ? `−${r}` : r;
11
13
  }
12
- function h(e) {
13
- return Number(Math.abs(l(e)).toFixed(2));
14
+ function v(n) {
15
+ return Number(Math.abs(l(n)).toFixed(2));
14
16
  }
15
- function N({
16
- title: e,
17
- chip: n,
17
+ function A({
18
+ title: n,
19
+ chip: e,
18
20
  chipPositive: t = !1,
19
- chipTestId: s,
20
- children: r,
21
- testId: o
21
+ chipTestId: r,
22
+ children: o,
23
+ testId: d
22
24
  }) {
23
- return /* @__PURE__ */ d(
25
+ return /* @__PURE__ */ s(
24
26
  "div",
25
27
  {
26
28
  className: "flex w-full min-w-0 flex-col gap-4 rounded-xl border border-border bg-card p-4",
27
- "data-testid": o,
29
+ "data-testid": d,
28
30
  children: [
29
- /* @__PURE__ */ d("div", { className: "flex min-h-6 items-center justify-between gap-3", children: [
30
- /* @__PURE__ */ a("span", { className: "min-w-0 text-base font-semibold leading-5 text-foreground", children: e }),
31
+ /* @__PURE__ */ s("div", { className: "flex min-h-6 items-center justify-between gap-3", children: [
32
+ /* @__PURE__ */ a("span", { className: "min-w-0 text-base font-semibold leading-5 text-foreground", children: n }),
31
33
  /* @__PURE__ */ a(
32
34
  "span",
33
35
  {
@@ -35,51 +37,51 @@ function N({
35
37
  "shrink-0 rounded-md px-2 py-0.5 text-sm font-semibold tabular-nums",
36
38
  t ? "bg-success/20 text-success" : "bg-muted text-muted-foreground"
37
39
  ),
38
- "data-testid": s,
39
- children: n
40
+ "data-testid": r,
41
+ children: e
40
42
  }
41
43
  )
42
44
  ] }),
43
- /* @__PURE__ */ a("div", { className: "flex flex-col gap-3", children: r })
45
+ /* @__PURE__ */ a("div", { className: "flex flex-col gap-3", children: o })
44
46
  ]
45
47
  }
46
48
  );
47
49
  }
48
- function w({
49
- label: e,
50
- value: n,
50
+ function B({
51
+ label: n,
52
+ value: e,
51
53
  subtext: t,
52
- muted: s = !1,
53
- testId: r,
54
- valueTestId: o,
54
+ muted: r = !1,
55
+ testId: o,
56
+ valueTestId: d,
55
57
  captionTestId: c
56
58
  }) {
57
- return /* @__PURE__ */ d(
59
+ return /* @__PURE__ */ s(
58
60
  "div",
59
61
  {
60
62
  className: "flex items-start justify-between gap-3",
61
- "data-testid": r,
63
+ "data-testid": o,
62
64
  children: [
63
65
  /* @__PURE__ */ a(
64
66
  "span",
65
67
  {
66
68
  className: i(
67
69
  "min-w-0 text-sm font-semibold leading-5",
68
- s ? "text-muted-foreground" : "text-foreground"
70
+ r ? "text-muted-foreground" : "text-foreground"
69
71
  ),
70
- children: e
72
+ children: n
71
73
  }
72
74
  ),
73
- /* @__PURE__ */ d("span", { className: "flex shrink-0 flex-col items-end", children: [
75
+ /* @__PURE__ */ s("span", { className: "flex shrink-0 flex-col items-end", children: [
74
76
  /* @__PURE__ */ a(
75
77
  "span",
76
78
  {
77
79
  className: i(
78
80
  "text-sm font-semibold leading-5 tabular-nums",
79
- s ? "text-muted-foreground" : "text-foreground"
81
+ r ? "text-muted-foreground" : "text-foreground"
80
82
  ),
81
- "data-testid": o,
82
- children: n
83
+ "data-testid": d,
84
+ children: e
83
85
  }
84
86
  ),
85
87
  t != null ? /* @__PURE__ */ a(
@@ -95,16 +97,39 @@ function w({
95
97
  }
96
98
  );
97
99
  }
98
- function y() {
100
+ function f(n) {
101
+ let e;
102
+ try {
103
+ e = new URL(n);
104
+ } catch {
105
+ return;
106
+ }
107
+ if (!(e.protocol !== "https:" && e.protocol !== "http:"))
108
+ return e.hostname.split(".").slice(-2).join(".");
109
+ }
110
+ function R({
111
+ links: n
112
+ }) {
113
+ const e = (n ?? []).flatMap((t) => {
114
+ const r = f(t);
115
+ return r ? [{ href: t, domain: r }] : [];
116
+ });
117
+ return e.length === 0 ? null : /* @__PURE__ */ a("span", { className: "block text-xs font-normal leading-4 text-muted-foreground", children: e.map(({ href: t, domain: r }, o) => /* @__PURE__ */ s(m, { children: [
118
+ o > 0 ? ", " : null,
119
+ /* @__PURE__ */ a(u, { href: t, external: !0, size: "unset", color: "secondary", children: r })
120
+ ] }, t)) });
121
+ }
122
+ function D() {
99
123
  return /* @__PURE__ */ a("div", { className: "h-px w-full bg-divider" });
100
124
  }
101
125
  export {
102
- p as APY_BREAKDOWN_TOOLTIP_WIDTH,
103
- N as ApyBreakdownBody,
104
- y as ApyBreakdownDivider,
105
- w as ApyBreakdownRow,
106
- x as BREAKDOWN_DASH,
107
- h as breakdownRateValue,
108
- g as formatBreakdownRate,
109
- b as periodMessageId
126
+ N as APY_BREAKDOWN_TOOLTIP_WIDTH,
127
+ A as ApyBreakdownBody,
128
+ D as ApyBreakdownDivider,
129
+ B as ApyBreakdownRow,
130
+ w as BREAKDOWN_DASH,
131
+ R as RewardLinks,
132
+ v as breakdownRateValue,
133
+ y as formatBreakdownRate,
134
+ k as periodMessageId
110
135
  };
@@ -1,11 +1,12 @@
1
- import { APY_BREAKDOWN_TOOLTIP_WIDTH as a, ApyBreakdownBody as r, ApyBreakdownDivider as d, ApyBreakdownRow as A, BREAKDOWN_DASH as B, breakdownRateValue as w, formatBreakdownRate as k, periodMessageId as n } from "./apy-breakdown-body.js";
1
+ import { APY_BREAKDOWN_TOOLTIP_WIDTH as o, ApyBreakdownBody as r, ApyBreakdownDivider as d, ApyBreakdownRow as w, BREAKDOWN_DASH as A, RewardLinks as B, breakdownRateValue as k, formatBreakdownRate as n, periodMessageId as R } from "./apy-breakdown-body.js";
2
2
  export {
3
- a as APY_BREAKDOWN_TOOLTIP_WIDTH,
3
+ o as APY_BREAKDOWN_TOOLTIP_WIDTH,
4
4
  r as ApyBreakdownBody,
5
5
  d as ApyBreakdownDivider,
6
- A as ApyBreakdownRow,
7
- B as BREAKDOWN_DASH,
8
- w as breakdownRateValue,
9
- k as formatBreakdownRate,
10
- n as periodMessageId
6
+ w as ApyBreakdownRow,
7
+ A as BREAKDOWN_DASH,
8
+ B as RewardLinks,
9
+ k as breakdownRateValue,
10
+ n as formatBreakdownRate,
11
+ R as periodMessageId
11
12
  };
@@ -10,6 +10,7 @@ import "tailwind-merge";
10
10
  import "@gearbox-protocol/sdk/onchain";
11
11
  import "../../../utils/z-index.js";
12
12
  import "viem";
13
+ import "../../link/link.js";
13
14
  import { PointsIcon as c } from "../../points-icon/points-icon.js";
14
15
  import "../../token-icon/token-icon.js";
15
16
  import { pointProgramsOf as d } from "../../../utils/internal/apy-breakdown.js";
@@ -20,15 +21,15 @@ import "../../badge/chip.js";
20
21
  import "../../typography/typography.js";
21
22
  import { VerticalIndicator as u } from "../../vertical-indicator/vertical-indicator.js";
22
23
  import { InfoListTest as n } from "./constants.js";
23
- function E({
24
+ function F({
24
25
  children: t
25
26
  }) {
26
27
  return /* @__PURE__ */ o(a, { gap: "sm", "data-testid": n.root, children: t });
27
28
  }
28
29
  function x({
29
30
  title: t,
30
- size: r = "sm",
31
- align: e = "start",
31
+ size: e = "sm",
32
+ align: r = "start",
32
33
  "data-testid": i = n.line,
33
34
  ...m
34
35
  }) {
@@ -37,28 +38,28 @@ function x({
37
38
  u,
38
39
  {
39
40
  label: p(t),
40
- size: r,
41
- align: e,
41
+ size: e,
42
+ align: r,
42
43
  "data-testid": i,
43
44
  ...m
44
45
  }
45
46
  );
46
47
  }
47
- function F({
48
+ function G({
48
49
  data: t,
49
- title: r = "components.yieldBreakdown.points"
50
+ title: e = "components.yieldBreakdown.points"
50
51
  }) {
51
- const e = t ? d(t) : [];
52
- return e.length === 0 ? null : /* @__PURE__ */ o(
52
+ const r = t ? d(t) : [];
53
+ return r.length === 0 ? null : /* @__PURE__ */ o(
53
54
  x,
54
55
  {
55
- title: r,
56
+ title: e,
56
57
  value: /* @__PURE__ */ o(
57
58
  "span",
58
59
  {
59
60
  className: "inline-flex flex-wrap items-center gap-1.5",
60
61
  "data-testid": f.points,
61
- children: e.map((i) => /* @__PURE__ */ s("span", { className: "inline-flex items-center gap-1", children: [
62
+ children: r.map((i) => /* @__PURE__ */ s("span", { className: "inline-flex items-center gap-1", children: [
62
63
  /* @__PURE__ */ o(
63
64
  c,
64
65
  {
@@ -75,7 +76,7 @@ function F({
75
76
  }
76
77
  export {
77
78
  x as InfoLine,
78
- E as InfoList,
79
+ F as InfoList,
79
80
  n as InfoListTest,
80
- F as PointsInfoLine
81
+ G as PointsInfoLine
81
82
  };