"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),m=require("@argent/x-shared"),b=require("../../features/icons/SwitchPrimaryIcon.cjs"),u=require("@chakra-ui/react"),x=require("react"),a=require("./context.cjs"),g=require("./utils.cjs"),y=require("../LoadingPulse.cjs"),d=require("../typography.generated.cjs"),v=require("../TokenIcon.cjs");function I({...o}){const{id:n,amount:e,isDisabled:r,isLoading:i}=a.useCompoundInputContext(),c=x.useRef(null),s=x.useRef(null),p=e!=null&&e.hasError?"text-danger":e!=null&&e.value?"text-primary":"text-secondary",l=e==null?void 0:e.isFiatInput,h=l?(e==null?void 0:e.fiatSymbol)||"$":void 0,f=l?20:0;return x.useEffect(()=>{if(c.current&&s.current){const C=c.current.offsetWidth;s.current.style.width=`${C+f}px`}},[e==null?void 0:e.value,f]),e?t.jsx(y.LoadingPulse,{isLoading:i&&!e.value,ml:"3",children:t.jsxs(u.Flex,{alignItems:"center",justifyContent:"flex-end",position:"relative",children:[t.jsx(u.Flex,{ref:c,position:"absolute",visibility:"hidden",fontSize:"h3",fontWeight:"700",whiteSpace:"pre",children:e.value||"0"}),t.jsx(u.Input,{ref:s,placeholder:"0",color:p,p:"0",pl:`${f}px`,minH:"min-content",maxW:"190px",...!l&&{width:"100% !important"},backgroundColor:"transparent",variant:"flat",fontSize:"h3",fontWeight:"700",textAlign:"right",value:e.value,onChange:e.onChange,isDisabled:r,isReadOnly:e.isReadOnly,_disabled:{opacity:1,cursor:"default"},_hover:{backgroundColor:"transparent"},_focus:{boxShadow:"none",backgroundColor:"transparent"},_readOnly:{pointerEvents:"none",border:"none",cursor:"default"},tabIndex:e.isReadOnly?-1:1,"data-testid":n,...o}),l&&t.jsx(d.L1,{color:p,fontSize:"h3",fontWeight:"700",position:"absolute",left:"0",top:"50%",transform:"translateY(-50%)",pointerEvents:"none",children:h})]})}):null}function j({children:o,...n}){var r,i;const{token:e}=a.useCompoundInputContext();return t.jsx(u.Flex,{alignItems:"center",children:t.jsx(u.Button,{pl:"2",pr:"3",py:"1.5",height:"min-content",minH:"min-content",width:"min-content",rounded:"full",onClick:e==null?void 0:e.onClick,leftIcon:e!=null&&e.selected?t.jsx(v.TokenIcon,{name:((r=e==null?void 0:e.selected)==null?void 0:r.name)||"?",url:(i=e==null?void 0:e.selected)==null?void 0:i.iconUrl,size:"5",borderRadius:"50%"}):void 0,backgroundColor:"button-secondary",...n,children:t.jsx(d.B2,{children:e!=null&&e.selected?e.selected.symbol||e.selected.name:o})})})}function w({percentage:o,...n}){const{amount:e}=a.useCompoundInputContext(),{onPercentageClick:r}=e||{};if(r)return t.jsxs(d.L1Bold,{onClick:()=>r(o),cursor:"pointer",role:"button",whiteSpace:"nowrap",color:"text-secondary",_hover:{color:"text-primary"},...n,children:[o,"%"]})}function S({...o}){var r;const{amount:n}=a.useCompoundInputContext(),e=x.useMemo(()=>{if(!(n!=null&&n.conversionValue))return;const{isFiatInput:i,conversionValue:c}=n,s=c.value??"0",p=c.symbol,l=m.abbreviateNumber(s);return i?`${l} ${p}`:`${p}${l}`},[n]);return t.jsxs(d.L1,{color:"text-secondary",...o,children:[((r=n==null?void 0:n.conversionValue)==null?void 0:r.approx)&&t.jsx(t.Fragment,{children:"≈ "}),e]})}function R({...o}){var r,i;const{token:n}=a.useCompoundInputContext(),e=((r=n==null?void 0:n.selected)==null?void 0:r.onBalanceClick)||void 0;if(((i=n==null?void 0:n.selected)==null?void 0:i.balance)!==void 0)return t.jsx(d.L1,{color:"text-secondary",onClick:e,cursor:e?"pointer":"default",_hover:{color:e?"text-primary":"text-secondary"},...o,children:n==null?void 0:n.selected.balance})}function q({...o}){const{amount:n}=a.useCompoundInputContext(),{onSwitchClick:e}=n||{};return e?t.jsx(u.Flex,{onClick:e,alignItems:"center",justifyContent:"center",cursor:"pointer",borderRadius:"full",p:"1",color:"icon-secondary",_hover:{color:"text-primary",backgroundColor:"button-secondary"},...o,children:t.jsx(b,{width:"12px",height:"12px"})}):null}function B({children:o,...n}){return t.jsx(u.Flex,{position:"relative",flexDirection:"column",gap:"2",padding:"4",backgroundColor:"surface-elevated",width:"100%",borderRadius:"xl",...n,children:o})}function F({...o}){const{amount:n}=a.useCompoundInputContext(),e=g.usePriceImpactConfig();if(!(n!=null&&n.priceImpact))return null;const{value:r,type:i}=(n==null?void 0:n.priceImpact)||{},c=r===0?"(0.00%)":`(${r.toFixed(2)}%)`,s=e[i].textColor;return t.jsx(d.L1,{color:s,...o,children:c})}exports.Container=B;exports.ConversionValue=S;exports.InputAmount=I;exports.InputToken=j;exports.PercentageButton=w;exports.PriceImpact=F;exports.SwitchButton=q;exports.TokenBalance=R;
