1import{a as o,be as Xe,bf as W,bg as Ne,bh as qe,bi as J,bj as re,bk as K,bl as O,bm as ie,bn as X,bo as Q,bp as ke,bq as Ce,br as q,bs as ae,bt as Ye,bu as R,bv as U,bw as L,bx as Je,by as Ke,bz as Qe,bA as Ze,bB as je,f as es,aw as ye,j as e,b0 as ss,bC as ts,bd as Ie,bD as ns,t as Te,U as $,Y as z,b7 as V,D as F,b9 as Z,b8 as ee,bE as rs,bF as he,bG as as,N as P,M as w,Z as le,I as H,bH as Ae,bI as se,bJ as ve,b3 as we,b4 as Se,bK as Re,Q as os,R as is,bL as ce,X as Y,bM as cs,B as ls,a2 as ds,G as us,a3 as xs,q as ms,J as de,bN as Le,bO as Pe,bP as Fe,n as Me,aR as hs,bQ as fs,al as ps,bR as gs,bS as bs,bT as js,ba as me,a6 as Is,bU as Es,F as Ns,bV as ks,A as Cs,x as ys,bW as Ts,bX as As}from"./index-hZR_pMzJ.js";import{a as ue,L as vs}from"./LockHeader-HH3l0-ZL.js";import{V as ws}from"./VeNFTSelect-CVa6CY7j.js";function Ss({onFocus:t}){let[s,n]=o.useState(!0),r=Xe();return s?W.createElement(Ne,{as:"button",type:"button",features:qe.Focusable,onFocus:c=>{c.preventDefault();let u,l=50;function i(){if(l--<=0){u&&cancelAnimationFrame(u);return}if(t()){if(cancelAnimationFrame(u),!r.current)return;n(!1);return}u=requestAnimationFrame(i)}u=requestAnimationFrame(i)}}):null}const De=o.createContext(null);function Rs(){return{groups:new Map,get(t,s){var n;let r=this.groups.get(t);r||(r=new Map,this.groups.set(t,r));let c=(n=r.get(s))!=null?n:0;r.set(s,c+1);let u=Array.from(r.keys()).indexOf(s);function l(){let i=r.get(s);i>1?r.set(s,i-1):r.delete(s)}return[u,l]}}}function Ls({children:t}){let s=o.useRef(Rs());return o.createElement(De.Provider,{value:s},t)}function Be(t){let s=o.useContext(De);if(!s)throw new Error("You must wrap your component in a <StableCollection>");let n=o.useId(),[r,c]=s.current.get(t,n);return o.useEffect(()=>c,[]),r}var Ps=(t=>(t[t.Forwards=0]="Forwards",t[t.Backwards=1]="Backwards",t))(Ps||{}),Fs=(t=>(t[t.Less=-1]="Less",t[t.Equal=0]="Equal",t[t.Greater=1]="Greater",t))(Fs||{}),Ms=(t=>(t[t.SetSelectedIndex=0]="SetSelectedIndex",t[t.RegisterTab=1]="RegisterTab",t[t.UnregisterTab=2]="UnregisterTab",t[t.RegisterPanel=3]="RegisterPanel",t[t.UnregisterPanel=4]="UnregisterPanel",t))(Ms||{});let Ds={0(t,s){var n;let r=X(t.tabs,d=>d.current),c=X(t.panels,d=>d.current),u=r.filter(d=>{var h;return!((h=d.current)!=null&&h.hasAttribute("disabled"))}),l={...t,tabs:r,panels:c};if(s.index<0||s.index>r.length-1){let d=q(Math.sign(s.index-t.selectedIndex),{[-1]:()=>1,0:()=>q(Math.sign(s.index),{[-1]:()=>0,0:()=>0,1:()=>1}),1:()=>0});if(u.length===0)return l;let h=q(d,{0:()=>r.indexOf(u[0]),1:()=>r.indexOf(u[u.length-1])});return{...l,selectedIndex:h===-1?t.selectedIndex:h}}let i=r.slice(0,s.index),m=[...r.slice(s.index),...i].find(d=>u.includes(d));if(!m)return l;let g=(n=r.indexOf(m))!=null?n:t.selectedIndex;return g===-1&&(g=t.selectedIndex),{...l,selectedIndex:g}},1(t,s){if(t.tabs.includes(s.tab))return t;let n=t.tabs[t.selectedIndex],r=X([...t.tabs,s.tab],u=>u.current),c=t.selectedIndex;return t.info.current.isControlled||(c=r.indexOf(n),c===-1&&(c=t.selectedIndex)),{...t,tabs:r,selectedIndex:c}},2(t,s){return{...t,tabs:t.tabs.filter(n=>n!==s.tab)}},3(t,s){return t.panels.includes(s.panel)?t:{...t,panels:X([...t.panels,s.panel],n=>n.current)}},4(t,s){return{...t,panels:t.panels.filter(n=>n!==s.panel)}}},fe=o.createContext(null);fe.displayName="TabsDataContext";function _(t){let s=o.useContext(fe);if(s===null){let n=new Error(`<${t} /> is missing a parent <Tab.Group /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,_),n}return s}let pe=o.createContext(null);pe.displayName="TabsActionsContext";function ge(t){let s=o.useContext(pe);if(s===null){let n=new Error(`<${t} /> is missing a parent <Tab.Group /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,ge),n}return s}function Bs(t,s){return q(s.type,Ds,t,s)}let Os="div";function $s(t,s){let{defaultIndex:n=0,vertical:r=!1,manual:c=!1,onChange:u,selectedIndex:l=null,...i}=t;const m=r?"vertical":"horizontal",g=c?"manual":"auto";let d=l!==null,h=re({isControlled:d}),a=K(s),[x,f]=o.useReducer(Bs,{info:h,selectedIndex:l??n,tabs:[],panels:[]}),A=o.useMemo(()=>({selectedIndex:x.selectedIndex}),[x.selectedIndex]),I=re(u||(()=>{})),j=re(x.tabs),k=o.useMemo(()=>({orientation:m,activation:g,...x}),[m,g,x]),p=O(b=>(f({type:1,tab:b}),()=>f({type:2,tab:b}))),y=O(b=>(f({type:3,panel:b}),()=>f({type:4,panel:b}))),N=O(b=>{C.current!==b&&I.current(b),d||f({type:0,index:b})}),C=re(d?t.selectedIndex:x.selectedIndex),v=o.useMemo(()=>({registerTab:p,registerPanel:y,change:N}),[]);ie(()=>{f({type:0,index:l??n})},[l]),ie(()=>{if(C.current===void 0||x.tabs.length<=0)return;let b=X(x.tabs,S=>S.current);b.some((S,M)=>x.tabs[M]!==S)&&N(b.indexOf(x.tabs[C.current]))});let T={ref:a};return W.createElement(Ls,null,W.createElement(pe.Provider,{value:v},W.createElement(fe.Provider,{value:k},k.tabs.length<=0&&W.createElement(Ss,{onFocus:()=>{var b,S;for(let M of j.current)if(((b=M.current)==null?void 0:b.tabIndex)===0)return(S=M.current)==null||S.focus(),!0;return!1}}),Q({ourProps:T,theirProps:i,slot:A,defaultTag:Os,name:"Tabs"}))))}let zs="div";function Vs(t,s){let{orientation:n,selectedIndex:r}=_("Tab.List"),c=K(s),u=o.useMemo(()=>({selectedIndex:r}),[r]);return Q({ourProps:{ref:c,role:"tablist","aria-orientation":n},theirProps:t,slot:u,defaultTag:zs,name:"Tabs.List"})}let Us="button";function Ws(t,s){var n,r;let c=o.useId(),{id:u=`headlessui-tabs-tab-${c}`,disabled:l=!1,autoFocus:i=!1,...m}=t,{orientation:g,activation:d,selectedIndex:h,tabs:a,panels:x}=_("Tab"),f=ge("Tab"),A=_("Tab"),I=o.useRef(null),j=K(I,s);ie(()=>f.registerTab(I),[f,I]);let k=Be("tabs"),p=a.indexOf(I);p===-1&&(p=k);let y=p===h,N=O(E=>{var B;let ne=E();if(ne===ae.Success&&d==="auto"){let He=(B=Ye(I))==null?void 0:B.activeElement,be=A.tabs.findIndex(Ge=>Ge.current===He);be!==-1&&f.change(be)}return ne}),C=O(E=>{let B=a.map(ne=>
1ne.current).filter(Boolean);if(E.key===R.Space||E.key===R.Enter){E.preventDefault(),E.stopPropagation(),f.change(p);return}switch(E.key){case R.Home:case R.PageUp:return E.preventDefault(),E.stopPropagation(),N(()=>U(B,L.First));case R.End:case R.PageDown:return E.preventDefault(),E.stopPropagation(),N(()=>U(B,L.Last))}if(N(()=>q(g,{vertical(){return E.key===R.ArrowUp?U(B,L.Previous|L.WrapAround):E.key===R.ArrowDown?U(B,L.Next|L.WrapAround):ae.Error},horizontal(){return E.key===R.ArrowLeft?U(B,L.Previous|L.WrapAround):E.key===R.ArrowRight?U(B,L.Next|L.WrapAround):ae.Error}}))===ae.Success)return E.preventDefault()}),v=o.useRef(!1),T=O(()=>{var E;v.current||(v.current=!0,(E=I.current)==null||E.focus({preventScroll:!0}),f.change(p),Je(()=>{v.current=!1}))}),b=O(E=>{E.preventDefault()}),{isFocusVisible:S,focusProps:M}=ke({autoFocus:i}),{isHovered:G,hoverProps:xe}=Ke({isDisabled:l}),{pressed:te,pressProps:D}=Qe({disabled:l}),We=o.useMemo(()=>({selected:y,hover:G,active:te,focus:S,autofocus:i,disabled:l}),[y,G,S,te,i,l]),_e=Ce({ref:j,onKeyDown:C,onMouseDown:b,onClick:T,id:u,role:"tab",type:Ze(t,I),"aria-controls":(r=(n=x[p])==null?void 0:n.current)==null?void 0:r.id,"aria-selected":y,tabIndex:y?0:-1,disabled:l||void 0,autoFocus:i},M,xe,D);return Q({ourProps:_e,theirProps:m,slot:We,defaultTag:Us,name:"Tabs.Tab"})}let _s="div";function Hs(t,s){let{selectedIndex:n}=_("Tab.Panels"),r=K(s),c=o.useMemo(()=>({selectedIndex:n}),[n]);return Q({ourProps:{ref:r},theirProps:t,slot:c,defaultTag:_s,name:"Tabs.Panels"})}let Gs="div",Xs=je.RenderStrategy|je.Static;function qs(t,s){var n,r,c,u;let l=o.useId(),{id:i=`headlessui-tabs-panel-${l}`,tabIndex:m=0,...g}=t,{selectedIndex:d,tabs:h,panels:a}=_("Tab.Panel"),x=ge("Tab.Panel"),f=o.useRef(null),A=K(f,s);ie(()=>x.registerPanel(f),[x,f]);let I=Be("panels"),j=a.indexOf(f);j===-1&&(j=I);let k=j===d,{isFocusVisible:p,focusProps:y}=ke(),N=o.useMemo(()=>({selected:k,focus:p}),[k,p]),C=Ce({ref:A,id:i,role:"tabpanel","aria-labelledby":(r=(n=h[j])==null?void 0:n.current)==null?void 0:r.id,tabIndex:k?m:-1},y);return!k&&((c=g.unmount)==null||c)&&!((u=g.static)!=null&&u)?W.createElement(Ne,{"aria-hidden":"true",...C}):Q({ourProps:C,theirProps:g,slot:N,defaultTag:Gs,features:Xs,visible:k,name:"Tabs.Panel"})}let Ys=J(Ws),Oe=J($s),$e=J(Vs),ze=J(Hs),Ve=J(qs),Js=Object.assign(Ys,{Group:Oe,List:$e,Panels:ze,Panel:Ve});function Ks({tabs:t,handleTabChange:s,hideTabs:n,tabContentProps:r,urlParam:c="tab"}){const[u,l]=es(),[i,m]=o.useState(!1),{isSm:g}=ye(),d=o.useMemo(()=>{const a=u.get(c),x=t.findIndex(f=>f.urlParam===a);return x===-1?0:x},[u,t,c]);o.useEffect(()=>{s&&s(d)},[d]);const h=a=>{d!==a&&(m(!1),l({[c]:t[a].urlParam},{preserveParams:!0}),s&&s(a))};return t.length?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-5 sm:hidden",children:[e.jsxs("button",{type:"button",className:"-mt-3 flex w-full justify-between gap-6 border-b border-b-primary py-3 outline-none focus-visible:ring-2",onClick:()=>m(!0),children:[e.jsx("h2",{className:"text-sm font-semibold text-primary",children:t[d].title}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"sr-only",children:"Manage lock navigation"}),e.jsx(ss,{className:"size-4 text-primary"})]})]}),e.jsx(ts,{isOpen:i&&!g,title:"Manage locks",onClose:()=>m(!1),children:e.jsx("div",{className:"space-y-5",children:e.jsx("div",{className:"divide-y divide-accent-10",children:t.map((a,x)=>e.jsxs("button",{type:"button",className:Ie("flex w-full items-center justify-between px-3 py-4 text-sm font-semibold text-accent-50 transition-colors duration-100 hover:text-foreground",d===x&&"text-primary"),onClick:()=>h(x),children:[e.jsx("span",{children:a.title}),e.jsx("span",{children:d===x?e.jsx(ns,{className:"size-4 text-primary"}):e.jsx("span",{className:"block size-4 rounded-full border border-accent-30"})})]},`tab-${a.urlParam}`))})})})]}),e.jsxs(Oe,{selectedIndex:d,onChange:h,children:[e.jsx($e,{className:Te("-mt-4 hidden w-full items-center text-center sm:mb-8 sm:flex",n&&"!hidden"),children:t.map(a=>e.jsx(Js,{className:Ie("-mt-4 flex-1 border-b border-accent-10 p-4 text-sm font-semibold text-accent-50","outline-none transition hover:text-foreground data-[focus]:ring-2","data-[selected]:border-primary data-[selected]:text-primary"),children:a.title},`tab-${a.urlParam}`))}),e.jsx(ze,{children:t.map(a=>e.jsx(Ve,{className:"outline-none focus-visible:rounded-xl focus-visible:ring-2 sm:p-0",children:e.jsx("div",{children:a.content(r)})},`tab-panel-${a.urlParam}`))})]})]}):null}const Qs=z(["function increaseUnlockTime(uint, uint) external","error NotAp
1provedOrOwner()","error NotNormalNFT()","error PermanentLock()","error LockExpired()","error NoLockFound()","error LockDurationNotInFuture()","error LockDurationTooLong()"]);function Zs({venft:t,ts:s,setTx:n,refetchData:r,onPendingStateChange:c,onError:u}){const l=Math.floor(Date.now()/1e3),i=t.expiresAt,m=Math.max(0,i-l),g=Number(s),d=m+g;return e.jsx($,{write:{chainId:F.id,address:V,abi:Qs,functionName:"increaseUnlockTime",args:[t.id,BigInt(d)]},successMessage:"Lock extended",onSuccess:h=>{n(h),r()},onPendingStateChange:c,onError:u,autoExecute:!0,children:"Extend"})}function et({venft:t,setTx:s,refetchData:n,onPendingStateChange:r,onError:c,hideLoader:u}){return e.jsx($,{write:{chainId:F.id,address:V,abi:z(["function lockPermanent(uint) external"]),functionName:"lockPermanent",args:[t.id]},successMessage:"Auto Max-Lock enabled",onSuccess:l=>{s(l),n()},onPendingStateChange:r,onError:c,hideLoader:u,autoExecute:!0,children:"Extend"})}function st({venft:t,setTx:s,refetchData:n,onPendingStateChange:r,onError:c,hideLoader:u}){return e.jsx($,{write:{chainId:F.id,address:V,abi:z(["function unlockPermanent(uint) external"]),functionName:"unlockPermanent",args:[t.id]},successMessage:"Auto Max-Lock disabled",onSuccess:l=>{s(l),n()},onPendingStateChange:r,onError:c,hideLoader:u,autoExecute:!0,children:"Disable auto max-lock"})}const tt={CONFIRM:"Confirm your new unlock time",SUCCESS:"New unlock time confirmed"};function nt({venft:t,formState:s}){const{setFormState:n,setTx:r,tx:c,isVenftMaxLocked:u}=Z(),{refetch:l}=ee();o.useEffect(()=>{n({...s,permanent:t.permanent,ts:BigInt(rs)})},[t]);const[i,m]=o.useState(!1),[g,d]=o.useState(),h=a=>{a.preventDefault(),n({form:"EXTEND",state:"CONFIRM",amount:t.amount,ts:s.ts,permanent:s.permanent})};return e.jsxs(e.Fragment,{children:[s.state==="INITIAL"&&e.jsxs("form",{onSubmit:h,className:"space-y-5 sm:space-y-8",children:[e.jsxs("div",{className:Te("flex flex-col gap-5 rounded-xl border border-accent-30 p-6 transition",s.permanent&&"border-primary"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 border-b border-accent-10 pb-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Auto Max-Lock Mode"}),e.jsx(he,{strokeWidth:1.5,className:"size-4 text-green"})]}),e.jsxs(as,{checked:s.permanent,onChange:()=>n({...s,permanent:!s.permanent}),className:"group relative inline-flex h-5 w-8 shrink-0 cursor-pointer rounded-full border-2 border-transparent bg-accent-10 outline-none transition-colors duration-200 ease-in-out data-[checked]:bg-primary data-[focus]:ring-2 data-[focus]:ring-offset-2",children:[e.jsx("span",{className:"sr-only",children:"Use setting"}),e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none inline-block size-4 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out group-data-[checked]:translate-x-3"})]})]}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"hidden sm:block",children:"When activated, it sets the lock to maximum unlock time, until disabled. Once disabled, the regular vesting unlock time will apply. Maximum unlock time gives a 1-to-1 voting power to the amount of locked tokens."}),e.jsx("p",{className:"sm:hidden",children:"When activated, it sets the lock to maximum unlock time, until disabled."})]})]}),e.jsx(ue,{lockAmount:t.amount,ts:Number(s.ts),setTs:a=>n({...s,ts:BigInt(a)}),isPermaLocked:s.permanent,venft:t}),e.jsx(rt,{venft:t}),e.jsxs("div",{className:"flex items-center gap-4 [&>*]:flex-1",children:[e.jsx(P,{href:"/locks",size:"lg",color:"secondary",useButton:!0,children:"Change lock"}),e.jsx(w,{size:"lg",type:"submit",disabled:t.permanent&&s.permanent===t.permanent||!t.permanent&&Number(s.ts)===0&&!s.permanent||!t.permanent&&!s.permanent&&u,children:t.permanent&&!s.permanent?"Continue":e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline",children:"Extend lock time"}),e.jsx("span",{className:"sm:hidden",children:"Extend"})]})})]})]}),e.jsxs("div",{className:"space-y-4",children:[s.state!=="INITIAL"&&e.jsx(le,{title:tt[s.state],chainId:F.id,loading:i,txId:c,error:g}),e.jsxs("div",{className:"flex items-center gap-4 [&>*]:flex-1",children:[s.state==="CONFIRM"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{size:"lg",color:"secondary",onClick:()=>n({...s,state:"INITIAL"}),children:"Edit"}),t.permanent!==s.permanent?e.jsx(e.Fragment,{children:s.permanent?e.jsx(et,{venft:t,setTx:a=>{r(a),n({...s,state:"SUCCESS"})},refetchData:l,onPendingStateChange:m,onError:d}):e.jsx(st,{venft:t,setTx:a=>{r(a),n({...s,state:"SUCCESS"})},refetchData:l,onPendingStateChange:m,onError:d})}):e.jsx(Zs,{venft:t,ts:s.ts,setTx:a=>{r(a),n({...s,state:"SUCCESS"})},refetchData:l,onPendingStateChange:m,onError:d})]}),s.state==="SUCCESS"&&e.jsx(P,{href:"/locks",size:"lg",color:"secondary",useButton:!0,children:"Manage locks"})]})]})]})}const rt=({venft:t})=>{const[s,n]=o.useState(!1);return e.jsxs(H,{type:"warning",icon:Ae,children:[e.jsx("div",{className:"space-y-2",children:e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold",children:"Note:"})," You can extend the locked time or"," ",e.jsx(se,{href:`/lock/${t.id}?manage=increase`,className:"underline",children:"increase the lock amount"}),". These actions will increase your voting power. The maximum lock time is 4 years."," ",e.jsx("button",{type:"button",onClick:()=>n(!0),className:"underline",children:"Learn more"})," ","on how voting works."]})}),e.jsx(ve,{open:s,onClose:()=>
1n(!1),children:e.jsx(we,{components:Se,children:e.jsx(Re,{})})})]})};function at({token:t,venft:s,amount:n,setTx:r,refetchData:c,onPendingStateChange:u,onError:l,hideLoader:i,children:m}){const{address:g}=os(),{data:d}=is({bridge:t.address===Y?ce:void 0,originChain:t.chainId,destinationChain:F.id,recipient:g,amount:n,venftId:s.id});return t.address===Y?e.jsx($,{write:{chainId:t.chainId,address:ce,abi:z(["function sendTokenAndLock(address _recipient, uint256 _amount, uint256 _tokenId) external payable"]),functionName:"sendTokenAndLock",args:[g,n,s.id],value:d,query:{enabled:!!g&&s.canXChainIncrease&&!!d}},onSuccess:r,onPendingStateChange:h=>u?.(h),onError:h=>l?.(h),hideLoader:i,autoExecute:!0,children:m||"Lock"}):e.jsx($,{write:{chainId:F.id,address:V,abi:z(["function increaseAmount(uint, uint) external"]),functionName:"increaseAmount",args:[s.id,n]},successMessage:"Lock increased",onSuccess:h=>{r(h),c()},onPendingStateChange:h=>u?.(h),onError:h=>l?.(h),hideLoader:i,autoExecute:!0,children:m||"Increase"})}function ot({venft:t,formState:s}){const{setFormState:n,setTx:r,tx:c}=Z(),{appToken:u,refetch:l,setVenftsRefetchInterval:i}
1=ee(),[m,g]=o.useState(0),[d,h]=o.useState(0n),[a,x]=o.useState(u),f=o.useMemo(()=>cs.find(D=>D.id===a.chainId)?.name,[a.chainId]),[A,I]=o.useState(!1),[j,k]=o.useState(!1),[p,y]=o.useState(),N={ALLOWANCE:`Allow ${a.symbol} to be used`,CONFIRM:"Confirm your amount increase",SUCCESS:"Lock amount has been increased"},{bridgeLimit:C,initialBalance:v,waitingOnBridge:T}=ls(a,F.id,ce,t.amount,!!c,{enabled:a.address===Y}),b=a.address===Y,S=!b||C>=d,M=b&&v!==t.amount;o.useEffect(()=>(i?.(T?15e3:!1),()=>i?.(!1)),[T,i]),o.useEffect(()=>{s.state==="CONFIRM"&&M&&n({...s,state:"SUCCESS"})},[M,s,n]);const G=ds(a,b?ce:V,d),xe=D=>{D.preventDefault(),n({form:"INCREASE",state:G.approved?"CONFIRM":"ALLOWANCE",amount:d})};o.useEffect(()=>{y(void 0)},[s.state]);const te=!!a&&!!d&&(!b||b&&S)&&!A;return e.jsxs(e.Fragment,{children:[s.state==="INITIAL"&&e.jsxs("form",{className:"space-y-5 sm:space-y-8",onSubmit:xe,children:[e.jsx(us,{asset:a,assets:[],setAsset:x,amount:d,setAmount:h,percentShortcuts:!0,tokenFilter:ct,disabled:!!c,onInvalidChange:I,testId:"increase-lock-input",children:e.jsx("div",{title:`Add ${a.symbol} on ${f} to lock`,children:"Add to lock"})},"increase-lock-input"),e.jsx(ue,{lockAmount:d+t.amount,ts:m,setTs:g,venft:t,calculationOnly:!0}),e.jsx(it,{venft:t}),e.jsxs("div",{className:"flex items-center gap-4 [&>*]:flex-1",children:[e.jsx(P,{href:"/locks",size:"lg",color:"secondary",useButton:!0,children:"Change lock"}),e.jsx(w,{size:"lg",type:"submit",disabled:!te,children:"Increase"})]})]}),e.jsxs("div",{className:"space-y-4",children:[(s.state==="CONFIRM"||s.state==="SUCCESS")&&e.jsx(le,{title:N[s.state],chainId:F.id,loading:j,txId:c,error:p,additionalContent:b&&T&&e.jsxs("div",{className:"w-full space-y-2 text-balance rounded-lg bg-accent-10 p-4 text-sm text-accent-50",children:[e.jsxs("p",{className:"font-semibold",children:["Waiting for ",a.symbol," bridge on ",f,"."]}),e.jsx("p",{children:"This may take a few minutes. Your lock will update automatically when bridging is complete."})]})}),s.state==="ALLOWANCE"&&e.jsx(xs,{approval:G,onEdit:()=>n({...s,state:"INITIAL"}),onSuccess:()=>n({...s,state:"CONFIRM"})}),e.jsxs("div",{className:"flex items-center gap-4 [&>*]:flex-1",children:[s.state==="CONFIRM"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{type:"button",size:"lg",color:"secondary",onClick:()=>n({...s,state:"INITIAL"}),children:"Edit"}),e.jsx(at,{token:a,venft:t,amount:d,setTx:D=>{r(D),n({...s,state:"SUCCESS"})},refetchData:l,onPendingStateChange:k,onError:D=>y(D),children:j?"Waiting for transaction...":"Increase"})]}),s.state==="SUCCESS"&&e.jsx(P,{href:"/locks",size:"lg",color:"secondary",useButton:!0,children:"Manage locks"})]})]})]})}const it=({venft:t})=>{const[s,n]=o.useState(!1);return e.jsxs(H,{type:"warning",icon:Ae,children:[e.jsx("div",{className:"space-y-2",children:e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold",children:"Note:"})," You can increase the lock amount or"," ",e.jsx(se,{href:`/lock/${t.id}?manage=extend`,className:"underline",children:"extend the locked time"}),". These actions will increase your voting power. There is no limit for the locked amount."," ",e.jsx("button",{type:"button",onClick:()=>n(!0),className:"underline",children:"Learn more"})," ","on how voting works."]})}),e.jsx(ve,{open:s,onClose:()=>n(!1),children:e.jsx(we,{components:Se,children:e.jsx(Re,{})})})]})};function ct(t){return t.filter(s=>s[0].address===ms||s[0].address===Y)}function lt({from:t,to:s,setTx:n,onPendingStateChange:r,onError:c,hideLoader:u}){return e.jsx($,{write:{chainId:F.id,address:V,abi:z(["function merge(uint, uint) external"]),functionName:"merge",args:[t,s]},successMessage:"Locks merged",onSuccess:l=>{n(l)},onPendingStateChange:r,onError:c,hideLoader:u,autoExecute:!0,children:"Merge"})}function Ue(){return e.jsx(H,{type:"error",icon:de,children:"You've already voted this epoch, so merging or transferring isn't available. You'll be able to do this when the next epoch begins."})}function dt({venft:t,formState:s,refetch:n}){const{setFormState:r,tx:c,setTx:u,hasRebases:l,availableRewards:i,hasVoted:m,hasVotedThisEpoch:g}=Z(),{venfts:d,refetchRewards:h,appToken:a}
1=ee(),x=t,[f,A]=o.useState(),[I,j]=o.useState(!1),[k,p]=o.useState(),y={HAS_REBASE:"Claim rebase before you merge",HAS_REWARDS:"Claim rewards before you merge",NEEDS_RESET:"Lock needs a reset to continue",CONFIRM:"Confirm your lock merge",SUCCESS:"Your locks have been merged"},N=o.useMemo(()=>d?.filter(T=>T.id!==t.id),[d,t]),C=()=>l?"HAS_REBASE":i.length>0?"HAS_REWARDS":m?"NEEDS_RESET":"CONFIRM";o.useEffect(()=>{s.state!=="INITIAL"&&r({...s,state:C()})},[l,i,m]);const v=T=>{if(T.preventDefault(),!f||!x){toast.error("Please select a lock to merge.");return}r({form:"MERGE",state:C(),fromVenft:x.id,toVenft:f.id})};return g?e.jsx(Ue,{}):x.permanent?e.jsx(xt,{venft:x}):e.jsxs(e.Fragment,{children:[s.state==="INITIAL"&&e.jsxs("form",{onSubmit:v,className:"space-y-5 sm:space-y-8",children:[e.jsx("div",{children:e.jsx(ws,{venfts:N,selected:f,onSelect:T=>{A(T)},required:!0,children:"Select the lock you want to merge into"})}),e.jsx(ue,{lockAmount:t.amount,venft:t,calculationOnly:!0}),e.jsx(ut,{}),e.jsxs("div",{className:"flex items-center gap-4 [&>*]:flex-1",children:[e.jsx(P,{href:"/locks",size:"lg",color:"secondary",useButton:!0,children:"Change lock"}),e.jsx(w,{size:"lg",type:"submit",disabled:!f,children:"Merge"})]})]}),e.jsxs("div",{className:"space-y-4",children:[s.state!=="INITIAL"&&e.jsx(le,{title:y[s.state],chainId:a.chainId,loading:I,txId:c,error:k}),e.jsxs("div",{className:"flex items-center gap-4 [&>*]:flex-1",children:[s.state==="HAS_REBASE"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{type:"button",size:"lg",color:"secondary",onClick:()=>r({...s,state:"INITIAL"}),children:"Edit"}),e.jsx(Le,{venft:t,refetchData:n,onPendingStateChange:j,onError:p,variant:"button",children:"Claim rebase"})]}),s.state==="HAS_REWARDS"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{type:"button",size:"lg",color:"secondary",onClick:()=>r({...s,state:"INITIAL"}),children:"Edit"}),e.jsx(Pe,{venft:t,rewards:i,refetchData:h,onPendingStateChange:j,onError:p,variant:"button",children:"Claim rewards"})]}),s.state==="NEEDS_RESET"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{type:"button",size:"lg",color:"secondary",onClick:()=>r({...s,state:"INITIAL"}),children:"Edit"}),e.jsx(Fe,{venft:t,refetchData:n,onPendingStateChange:j,onError:p,useButton:!0})]}),s.state==="CONFIRM"&&f&&e.jsxs(e.Fragment,{children:[e.jsx(w,{type:"button",size:"lg",color:"secondary",onClick:()=>r({...s,state:"INITIAL"}),children:"Edit"}),e.jsx(lt,{from:x.id,to:f.id,setTx:T=>{u(T),r({...s,state:"SUCCESS"})},onPendingStateChange:j,onError:p})]}),s.state==="SUCCESS"&&e.jsx(P,{size:"lg",color:"secondary",href:"/locks",useButton:!0,children:"Manage locks"})]})]})]})}const ut=()=>e.jsx(H,{type:"error",icon:de,children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold",children:"Warning:"})," Merging two locks keeps the longer lock time and combines both amounts to increase your final voting power."]}),e.jsxs("p",{children:["Merging will reset any rewards and rebases. Before continuing, please be sure you have"," ",e.jsx(se,{href:"/dash#voting-rewards",className:"underline hover:no-underline",children:"claimed all available rewards"}),"."]})]})}),xt=({venft:t})=>e.jsxs(H,{type:"error",icon:de,children:[e.jsx("h3",{className:"sr-only",children:"Warning"}),"Merging a lock with an Auto Max-Lock"," ",e.jsx(he,{className:"inline-block size-3"})," is not allowed."," ",e.jsxs("div",{className:"inline sm:block",children:[e.jsx(se,{className:"underline hover:no-underline",href:`/lock/${t.id}?manage=extend`,children:"Disable"})," ","or choose another lock to continue."]})]});function mt({venft:t,toAddress:s,setTx:n,onPendingStateChange:r,onError:c}){return e.jsx($,{write:{chainId:F.id,address:V,abi:z(["function transferFrom(address, address, uint) external"]),functionName:"transferFrom",args:[t.account,s,t.id],query:{enabled:Me(s)}},successMessage:`Lock transferred to ${s}`,onSuccess:u=>{n(u)},onPendingStateChange:r,onError:c,autoExecute:!0,children:"Transfer"})}function ht({venft:t,formState:s,refetch:n}){const{setFormState:r,tx:c,setTx:u,hasRebases:l,availableRewards:i,hasVoted:m,hasVotedThisEpoch:g}=Z(),{refetchRewards:d,appToken:h}
1=ee(),a=o.useRef(null),[x,f]=o.useState(""),[A,I]=o.useState(!1),j=!a.current||!x.length?!0:Me(x),[k,p]=o.useState(!1),[y,N]=o.useState(),C={HAS_REBASE:"Claim rebase before you transfer",HAS_REWARDS:"Claim rewards before you transfer",NEEDS_RESET:"Lock needs a reset to continue",CONFIRM:"Confirm your lock transfer",SUCCESS:"Your lock has been transferred"},v=()=>l?"HAS_REBASE":i.length>0?"HAS_REWARDS":m?"NEEDS_RESET":"CONFIRM";o.useEffect(()=>{s.state!=="INITIAL"&&r({...s,state:v()})},[l,i,m]);const T=b=>{if(b.preventDefault(),!x){toast.error("Please enter a valid wallet address.");return}r({form:"TRANSFER",state:v(),to:x})};return g?e.jsx(Ue,{}):e.jsxs(e.Fragment,{children:[s.state==="INITIAL"&&e.jsxs("form",{onSubmit:T,className:"space-y-5 sm:space-y-8",children:[e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx("label",{className:"pl-2 font-semibold",htmlFor:"transfer-address",children:"Transfer to"}),e.jsx(hs,{ref:a,value:x,onChange:b=>f(b.target.value),onFocus:()=>I(!0),onBlur:()=>I(!1),id:"transfer-address",endIcon:x.length&&!A&&!j?e.jsx(fs,{content:e.jsx("p",{className:"whitespace-nowrap text-sm",children:"Invalid address"}),placement:"top",children:e.jsx(ps,{className:"mr-3 size-5 text-red",strokeWidth:1.5})}):e.jsx(gs,{className:"mr-3 size-5 text-accent-50",strokeWidth:1.5}),maxLength:42,placeholder:"0x...",required:!0,className:x.length&&!A&&!j?"!border-red":""}),e.jsx("p",{className:"pl-2 text-sm text-accent-50",children:"Wallet address where the lock will be transferred."})]}),e.jsx(ue,{lockAmount:t.amount,venft:t,calculationOnly:!0}),e.jsx(ft,{}),e.jsxs("div",{className:"flex items-center gap-4 [&>*]:flex-1",children:[e.jsx(P,{href:"/locks",size:"lg",color:"secondary",useButton:!0,children:"Change lock"}),e.jsx(w,{size:"lg",type:"submit",disabled:!x||!j,children:"Transfer"})]})]}),e.jsxs("div",{className:"space-y-4",children:[s.state!=="INITIAL"&&e.jsx(le,{title:C[s.state],chainId:h.chainId,loading:k,txId:c,error:y}),e.jsxs("div",{className:"flex items-center gap-4 [&>*]:flex-1",children:[s.state==="HAS_REBASE"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{type:"button",size:"lg",color:"secondary",onClick:()=>r({...s,state:"INITIAL"}),children:"Edit"}),e.jsx(Le,{venft:t,refetchData:n,onPendingStateChange:p,onError:N,variant:"button",children:"Claim rebase"})]}),s.state==="HAS_REWARDS"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{type:"button",size:"lg",color:"secondary",onClick:()=>r({...s,state:"INITIAL"}),children:"Edit"}),e.jsx(Pe,{venft:t,rewards:i,refetchData:d,onPendingStateChange:p,onError:N,variant:"button",children:"Claim rewards"})]}),s.state==="NEEDS_RESET"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{type:"button",size:"lg",color:"secondary",onClick:()=>r({...s,state:"INITIAL"}),children:"Edit"}),e.jsx(Fe,{venft:t,refetchData:n,onPendingStateChange:p,onError:N,useButton:!0})]}),s.state==="CONFIRM"&&e.jsxs(e.Fragment,{children:[e.jsx(P,{href:"/locks",size:"lg",color:"secondary",useButton:!0,children:"Change lock"}),e.jsx(mt,{venft:t,setTx:b=>{u(b),r({...s,state:"SUCCESS"})},toAddress:x,onPendingStateChange:p,onError:N})]}),s.state==="SUCCESS"&&e.jsx(P,{href:"/locks",size:"lg",color:"secondary",useButton:!0,children:"Manage locks"})]})]})]})}const ft=()=>e.jsx(H,{type:"error",icon:de,children:e.jsx("div",{className:"space-y-2",children:e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold",children:"Warning:"})," Transferring a lock will also transfer any rewards and rebases! Before continuing, please make sure you have"," ",e.jsx(se,{href:"/dash#voting-rewards",className:"underline hover:no-underline",children:"claimed all available rewards"}),"."]})})}),Ee="manage",oe=[{title:"Increase",form:"INCREASE",urlParam:"increase",content:({venft:t,formState:s})=>s.form==="INCREASE"?e.jsx(ot,{venft:t,formState:s}):null},{title:"Extend",form:"EXTEND",urlParam:"extend",content:({venft:t,formState:s})=>s.form==="EXTEND"?e.jsx(nt,{venft:t,formState:s}):null},{title:"Merge",form:"MERGE",urlParam:"merge",content:({venft:t,formState:s,refetch:n})=>s.form==="MERGE"?e.jsx(dt,{venft:t,refetch:n,formState:s}):null},{title:"Transfer",form:"TRANSFER",urlParam:"transfer",content:({venft:t,formState:s,refetch:n})=>s.form==="TRANSFER"?e.jsx(ht,{venft:t,refetch:n,formState:s}):null}];function jt(){const[t,s]=bs("/lock/:id"),{isSm:n}
1=ye(),{isLoading:r,appToken:c,venfts:u}=ee(),{error:l,formState:i,setFormState:m,setVenft:g}=Z(),d=s?.id?BigInt(s.id):void 0,h=u?.some(p=>p.id===d),{data:a,isLoading:x,error:f,refetch:A}=js(d),I=o.useRef();o.useEffect(()=>{a&&a.id!==I.current&&(m(me("INCREASE")),I.current=a.id),g(a)},[a]),o.useEffect(()=>{if(!a)return;const y=new URLSearchParams(window.location.search).get(Ee),N=oe.findIndex(v=>v.urlParam===y),C=oe[N===-1?0:N];i.form!==C.form&&m({...me(C.form),state:"INITIAL"})},[a,i.form]),o.useEffect(()=>{const p=l||f;p&&toast.error(p)},[l,f]);const j=o.useRef(null),k=o.useRef(!1);if(o.useEffect(()=>{k.current?j.current&&j.current.scrollIntoView({behavior:"smooth",block:"start"}):k.current=!0},[i.state]),(!a||x||r)&&!l)return e.jsx(Is,{message:"Loading onchain data..."});if(!h)throw new Error(`You are not the owner of lock #${d}.`);if(!t||!a)throw new Error("Invalid lock page URL.");return e.jsxs("div",{ref:j,className:"mx-auto max-w-screen-sm space-y-2",children:[e.jsx(vs,{title:"Manage lock",children:e.jsxs("div",{className:"flex w-full flex-col justify-between gap-4 sm:flex-row sm:items-center sm:gap-2",children:[e.jsx(Es,{venft:a}),e.jsx("div",{className:"flex w-full items-center gap-2 sm:w-auto sm:flex-shrink sm:flex-grow-0 [&>*]:flex-1",children:e.jsx(P,{href:"/locks",color:"secondary",size:n?"md":"sm",pill:!0,useButton:!0,children:"Change"})})]})}),i.state!=="INITIAL"&&e.jsx(Ns,{title:ks[i.form],onEdit:i.state==="SUCCESS"?void 0:()=>m({...i,state:"INITIAL"}),children:e.jsxs("div",{className:"flex items-center gap-3",children:[i.form==="INCREASE"&&e.jsx(Cs,{amount:i.amount,tokenAddress:c.address,chainId:c.chainId,showValue:!1,showSymbol:!0}),i.form==="EXTEND"&&e.jsxs("div",{className:"flex items-center text-xs",children:[e.jsx(ys,{ts:Number(a.expiresAt)+Number(i.ts)}),i.permanent&&e.jsxs("span",{className:"flex items-center",children:[e.jsx(he,{strokeWidth:1.5,className:"mx-2 size-4 text-green"}),"Auto Max-Lock"]})]}),i.form==="MERGE"&&e.jsxs("div",{className:"text-xs",children:["Lock #",a.id.toString()," ",e.jsx("span",{className:"px-1 text-accent-50",children:"into"})," Lock #",i.toVenft.toString()]}),i.form==="TRANSFER"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-accent-50",children:[e.jsx(Ts,{address:i.to,className:"text-foreground"}),e.jsx(As,{text:i.to.toLowerCase()})]})]})}),e.jsx("div",{className:"space-y-4 rounded-2xl bg-gradient-to-b from-accent-0 to-background p-5 sm:p-8",children:e.jsx(Ks,{tabs:oe,handleTabChange:p=>{m({...me(oe[p].form),state:"INITIAL"})},hideTabs:i.state!=="INITIAL",urlParam:Ee,tabContentProps:{venft:a,formState:i,refetch:A}})})]})}export{jt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.