<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[852],{82838:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/lend",function(){return n(40860)}])},79197:function(e,t,n){"use strict";n.d(t,{P:function(){return s}});var l=n(85893),a=n(58278),r=n(19215),i=n(67294);function s(e){let{onTrigger:t}=e,n=(0,i.useRef)(null),s=(0,r.Y)(n,{amount:1});return(0,i.useEffect)(()=&gt;{s&amp;&amp;t()},[s]),(0,l.jsx)(a.x,{ref:n,h:"4rem"})}},78498:function(e,t,n){"use strict";n.d(t,{v:function(){return s}});var l=n(85893),a=n(9536),r=n(61520),i=n(51906);function s(e){let{size:t,gridCol:n,span:a={base:12,sm:6,md:4,lg:3}}=e;return Array(t).fill("").map((e,t)=&gt;n?(0,l.jsx)(i.r.Col,{span:a,children:(0,l.jsx)(o,{index:t})},"skeletonNft-".concat(t)):(0,l.jsx)(o,{index:t},"skeletonNft-".concat(t)))}function o(e){let{index:t}=e;return(0,l.jsx)(r.U,{initial:{y:"1.5rem",opacity:0},animate:{y:0,opacity:1},exit:{y:"1.5rem",opacity:0},transition:{duration:.5,ease:"easeInOut",delay:.75+.05*t},children:(0,l.jsx)(a.An,{})},"stepTwo-skeletonNft-".concat(t))}},40860:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return eb}});var l=n(85893),a=n(78639),r=n.n(a),i=n(8207),s=n(54410),o=n(58278),c=n(24920),d=n(21741),u=n(12162),p=n(41664),x=n.n(p),m=n(61520),h=n(71620);function f(e){let{onNextPressed:t}=e;return(0,l.jsxs)(i.K,{gap:"xl",className:r().wrapper,children:[(0,l.jsxs)(i.K,{gap:"md",children:[(0,l.jsxs)(i.K,{gap:"xs",children:[(0,l.jsx)(m.U,{delayNum:0,text:!0,children:(0,l.jsx)(s.x,{size:"xs",c:"dimmed",className:"overline-text",fw:"bold",children:"STEP 1"})},"stepOne-overline"),(0,l.jsx)(m.U,{delayNum:1,text:!0,children:(0,l.jsx)(s.x,{size:"1.6rem",fw:"bold",lh:"2rem",children:"Welcome to the Lending Process of WeRent App"})},"stepOne-title")]}),(0,l.jsxs)(i.K,{gap:4,children:[(0,l.jsx)(m.U,{delayNum:2,children:(0,l.jsx)(s.x,{children:"Before continue, We suggest to click the “How to Lend” button below to check our latest documentation."})},"stepOne-description"),!h.th&amp;&amp;(0,l.jsx)(m.U,{delayNum:3,children:(0,l.jsxs)(s.x,{maw:"64ch",children:["We also have a campaign called ",(0,l.jsx)("b",{children:"Lend to Earn"})," that will reward you for each successful lend transactions."]})},"stepOne-secondDescription")]}),(0,l.jsx)(m.U,{delayNum:4,children:(0,l.jsx)(s.x,{children:"You can start lending your NFTs by clicking the “Next” button. Enjoy Lending!"})},"stepOne-extraDescription")]}),(0,l.jsxs)(o.x,{className:r()["lend-actions"],children:[(0,l.jsx)(m.U,{initial:{x:"-1rem",opacity:0},animate:{x:0,opacity:1},exit:{x:"-1rem",opacity:0},delayNum:4,children:(0,l.jsx)(c.z,{fullWidth:!0,variant:"secondary",component:x(),href:"https://webuynft.gitbook.io/werent/how-werent-works",target:"_blank",leftSection:(0,l.jsx)(d.Z,{}),children:"How to Lend"})},"stepOne-gitbookButton"),(0,l.jsx)(m.U,{initial:{x:"-1rem",opacity:0},animate:{x:0,opacity:1},exit:{x:"-1rem",opacity:0},delayNum:5,children:(0,l.jsx)(c.z,{fullWidth:!0,rightSection:(0,l.jsx)(u.Z,{}),onClick:t,children:"Next"})},"stepOne-nextButton")]})]})}var y=n(95429),g=n(91130),j=n(80929),b=n(3119),v=n(92313),w=n(3249),N=n(40167),T=n(102),C=n(60967),_=n(54680),S=n(51906),E=n(33507),k=n(24176),I=n(43495),A=n(97179),P=n(83215),L=n(35911),U=n(49979),F=n(47624),z=n(44483),D=n(52321),B=n(80047),O=n(73554);function K(e){var t;let{selectedNFT:n,onLendPressed:a,onBackPressed:d,isLending:u}=e,{networkName:p}=(0,U.S)(),h=(0,A.c)({initialValues:{maxDuration:1,dailyPrice:1e-4,collateralPrice:1e-4,currency:"USDT",isAgree:!1,isCollateralized:!1,category:D.aA[0].value},validate:(0,P.F)(L.Q)});return(0,l.jsxs)(i.K,{gap:"xl",className:r().wrapper,children:[(0,l.jsxs)(i.K,{gap:"sm",children:[(0,l.jsx)(m.U,{initial:{x:"-1rem",opacity:0},animate:{x:0,opacity:1},exit:{x:"-1rem",opacity:0},delayNum:0,children:(0,l.jsx)(c.z,{onClick:d,variant:"subtle",size:"sm",leftSection:(0,l.jsx)(E.Z,{}),className:r()["back-button"],children:"Go Back"})},"stepThree-backButton"),(0,l.jsxs)(i.K,{gap:"xs",children:[(0,l.jsx)(m.U,{text:!0,delayNum:1,children:(0,l.jsx)(s.x,{size:"xs",c:"dimmed",className:"overline-text",fw:"bold",children:"STEP 3"})},"stepThree-overline"),(0,l.jsx)(m.U,{text:!0,delayNum:2,children:(0,l.jsx)(s.x,{size:"1.6rem",fw:"bold",lh:"2rem",children:"Fill the form to lend the NFT"})},"stepThree-title")]})]}),(0,l.jsxs)(y.k,{className:r()["content-wrapper"],children:[(0,l.jsxs)(i.K,{className:r()["detail-nft_wrapper"],children:[(0,l.jsx)(m.U,{initial:{x:"-1rem",opacity:0},animate:{x:0,opacity:1},exit:{x:"-1rem",opacity:0},delayNum:2,children:(0,l.jsx)(g.o,{ratio:1,className:r()["nft-image_wrapper"],children:(0,l.jsx)(o.x,{className:r()["nft-image_inner"],children:(0,l.jsx)(j.E,{className:r()["nft-image"],alt:n.contractAddress,src:n.animationUrl||(0,F.h)(null!==(t=n.image)&amp;&amp;void 0!==t?t:""),fallbackSrc:"/images/nftDefault.png"})})})},"stepThree-nftImage"),(0,l.jsx)(R,{nft:n}),(0,l.jsx)(W,{mt:"md",nft:n,visibleFrom:"md"})]}),(0,l.jsx)(m.U,{initial:{x:"1rem",opacity:0},animate:{x:0,opacity:1},exit:{x:"1rem",opacity:0},transition:{duration:.5,ease:"easeInOut",delay:.15*3},children:(0,l.jsx)("form",{className:r()["form-wrapper"],onSubmit:h.onSubmit(e=&gt;{a(e)}),children:(0,l.jsxs)(i.K,{w:"100%",gap:"md",pos:"relative",style:{isolation:"isolate"},children:[(0,l.jsx)(b.f,{visible:u,zIndex:1e3,overlayProps:{blur:2,backgroundOpacity:0}}),(0,l.jsx)(m.U,{text:!0,delayNum:5,children:(0,l.jsx)(s.x,{size:"sm",fw:"bold",c:"dimmed",className:"overline-text",children:"Lend Form"})},"stepThree-lendFormTitle"),(0,l.jsx)(m.U,{delayNum:6,children:(0,l.jsx)(v.P,{label:"Category",placeholder:"Choose category",data:D.aA,disabled:"ERC1155"===n.ercType,...h.getInputProps("category")})},"stepThree-input1"),(0,l.jsx)(m.U,{delayNum:7,children:(0,l.jsxs)(y.k,{className:r()["input-wrapper"],children:[(0,l.jsx)(v.P,{label:"Max rent duration",placeholder:"Choose duration",data:["1","3","7","30","90","180"],rightSection:(0,l.jsx)(s.x,{children:"Days"}),rightSectionWidth:"6ch",disabled:"ERC1155"===n.ercType,...h.getInputProps("maxDuration"),value:"".concat(h.values.maxDuration),onChange:e=&gt;h.setFieldValue("maxDuration",parseInt(null!=e?e:"1"))}),(0,l.jsx)(v.P,{label:"Currency",placeholder:"Choose Currency",data:[{label:O.bT[p],value:(0,F.kC)(null!=p?p:"-")},{label:O.bT.USDT,value:"USDT"}],disabled:"ERC1155"===n.ercType,...h.getInputProps("currency")})]})},"stepThree-input2"),(0,l.jsx)(m.U,{delayNum:8,children:(0,l.jsx)(w.Y,{label:"Daily Rental Fee",placeholder:"Enter Fee",decimalScale:4,fixedDecimalScale:!0,min:1e-4,max:9999.9999,disabled:"ERC1155"===n.ercType,rightSection:(0,l.jsx)(z.i,{type:h.values.currency.toLocaleUpperCase(),size:"1.5rem"}),rightSectionWidth:"3rem",...h.getInputProps("dailyPrice")})},"stepThree-input3"),(0,l.jsx)(m.U,{delayNum:9,children:(0,l.jsxs)(i.K,{gap:"xs",children:[(0,l.jsx)(N.X,{label:"Collateralized",size:"md",...h.getInputProps("isCollateralized",{type:"checkbox"})}),(0,l.jsx)(T.U,{in:h.values.isCollateralized,children:(0,l.jsx)(w.Y,{label:"Collateral",placeholder:"Input Collateral Amount",decimalScale:4,fixedDecimalScale:!0,min:1e-4,max:9999.9999,className:r()["collateral-input"],disabled:"ERC1155"===n.ercType,rightSection:(0,l.jsx)(z.i,{type:h.values.currency.toLocaleUpperCase(),size:"1.5rem"}),rightSectionWidth:"3rem",...h.getInputProps("collateralPrice")})})]})},"stepThree-input4"),(0,l.jsx)(m.U,{delayNum:9,children:(0,l.jsx)(N.X,{label:(0,l.jsxs)(l.Fragment,{children:["I accept the"," ",(0,l.jsx)(C.e,{component:x(),href:"https://app.werentnft.io/Terms_of_Service_WeRent.pdf",target:"_blank",inherit:!0,children:"Terms and Conditions"})]}),size:"md",disabled:"ERC1155"===n.ercType,...h.getInputProps("isAgree",{type:"checkbox"})})},"stepThree-input5"),(0,l.jsx)(m.U,{delayNum:10,children:(0,l.jsx)(B.x,{children:(0,l.jsx)(c.z,{fullWidth:!0,mt:"md",type:"submit",loading:u,disabled:"ERC1155"===n.ercType,children:"Lend NFT"})})},"stepThree-submitButton"),"ERC1155"===n.ercType?(0,l.jsx)(m.U,{delayNum:10,children:(0,l.jsx)(_.b,{variant:"light",color:"red.5",title:"NFT is not supported",icon:(0,l.jsx)(k.Z,{})})},"stepThree-alert"):null]})})},"stepThree-formWrapper"),(0,l.jsx)(W,{mt:"xl",nft:n,hiddenFrom:"md"})]})]})}function R(e){let{nft:t,...n}=e;return(0,l.jsxs)(i.K,{...n,gap:4,children:[(0,l.jsx)(m.U,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{duration:.35,ease:"easeInOut",delay:.6},children:(0,l.jsx)(s.x,{fw:"bold",className:"".concat(r()["nft-header_collection-name"]," overline-text"),children:t.collectionName})},"stepThree-collectionName"),(0,l.jsx)(m.U,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{duration:.35,ease:"easeInOut",delay:.75},children:(0,l.jsx)(s.x,{size:"1.85rem",fw:"bold",lh:"2.4rem",children:t.nftName})},"stepThree-nftName")]})}function W(e){var t;let{nft:n,...a}=e,o=[(0,l.jsxs)(y.k,{justify:"space-between",className:r()["nft-body_item"],children:[(0,l.jsx)(s.x,{fw:"bold",c:"dimmed",size:"sm",className:"overline-text",children:"Token ID"}),(0,l.jsx)(s.x,{size:"sm",fw:"bold",className:"overline-text",children:n.nftId})]},"stepThree-nftBody1"),(0,l.jsxs)(y.k,{justify:"space-between",className:r()["nft-body_item"],children:[(0,l.jsx)(s.x,{fw:"bold",c:"dimmed",size:"sm",className:"overline-text",children:"ERC Type"}),(0,l.jsx)(s.x,{size:"sm",fw:"bold",className:"overline-text",children:n.ercType})]},"stepThree-nftBody2"),(0,l.jsxs)(y.k,{justify:"space-between",className:r()["nft-body_item"],children:[(0,l.jsx)(s.x,{fw:"bold",c:"dimmed",size:"sm",className:"overline-text",children:"Contract Address"}),(0,l.jsx)(s.x,{size:"sm",fw:"bold",className:"overline-text",children:(0,F.dt)(n.contractAddress)})]},"stepThree-nftBody3"),(0,l.jsxs)(i.K,{className:r()["nft-body_item"],children:[(0,l.jsx)(s.x,{fw:"bold",c:"dimmed",size:"sm",className:"overline-text",children:"Description"}),(0,l.jsx)(s.x,{children:null!==(t=n.description)&amp;&amp;void 0!==t?t:"-"})]},"stepThree-nftBody4")];return(0,l.jsxs)(i.K,{gap:"md",className:r()["nft-body_wrapper"],...a,children:[(0,l.jsx)(m.U,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{duration:.35,ease:"easeInOut",delay:1.2},children:(0,l.jsx)(s.x,{size:"sm",fw:"bold",c:"dimmed",className:"overline-text",hiddenFrom:"md",children:"Asset Details"})},"stepThree-assetTitle"),(0,l.jsx)(S.r,{className:r()["nft-body_inner"],children:o.map((e,t)=&gt;(0,l.jsx)(S.r.Col,{span:{base:12,sm:t&lt;2?6:12},children:(0,l.jsx)(I.E.div,{initial:{y:"1rem",opacity:0},animate:{y:0,opacity:1},exit:{y:"1rem",opacity:0},transition:{duration:.5,ease:"easeInOut",delay:.15*(9+t)},children:e},"stepThree-nftBody".concat(t))},"stepThree-nftBody".concat(t)))})]})}var Y=n(9536),Z=n(67294),M=n(30201),H=n(89365),G=n(79197),X=n(78498);function Q(e){let{value:t,onNextPressed:n,onBackPressed:a,onNFTSelected:d}=e,{user:p,networkName:x}=(0,U.S)(),[h,f]=(0,Z.useState)(null),{data:y,isLoading:g}=M.S.account.getMyNFTs.useQuery({network:x,cursor:h},{enabled:null!==p}),j=e=&gt;null!==t&amp;&amp;t.contractAddress===e.contractAddress&amp;&amp;t.nftId===e.nftId;return(0,l.jsxs)(i.K,{gap:"xl",className:r().wrapper,children:[(0,l.jsxs)(i.K,{gap:"sm",children:[(0,l.jsxs)(i.K,{gap:"xs",children:[(0,l.jsx)(m.U,{delayNum:0,text:!0,children:(0,l.jsx)(s.x,{size:"xs",c:"dimmed",className:"overline-text",fw:"bold",children:"STEP 2"})},"stepTwo-overline"),(0,l.jsx)(m.U,{delayNum:1,text:!0,children:(0,l.jsx)(s.x,{size:"1.6rem",fw:"bold",lh:"2rem",children:"Choose the NFT you want to lend"})},"stepTwo-title")]}),(0,l.jsx)(m.U,{delayNum:2,text:!0,children:(0,l.jsx)(s.x,{maw:"48ch",children:"Select one of the following NFTs to lend."})},"stepTwo-overline")]}),(0,l.jsxs)(o.x,{className:r()["lend-actions"],children:[(0,l.jsx)(m.U,{initial:{x:"-1rem",opacity:0},animate:{x:0,opacity:1},exit:{x:"-1rem",opacity:0},delayNum:3,children:(0,l.jsx)(c.z,{fullWidth:!0,onClick:a,variant:"outline",leftSection:(0,l.jsx)(E.Z,{}),children:"Go Back"})},"stepTwo-backButton"),(0,l.jsx)(m.U,{initial:{x:"-1rem",opacity:0},animate:{x:0,opacity:1},exit:{x:"-1rem",opacity:0},delayNum:4,children:(0,l.jsx)(c.z,{fullWidth:!0,rightSection:(0,l.jsx)(u.Z,{}),onClick:n,disabled:null===t,children:"Next"})},"stepTwo-nextButton")]}),g?(0,l.jsx)(S.r,{children:(0,l.jsx)(X.v,{size:6,gridCol:!0,span:{base:12,sm:6,md:4,lg:3}})}):void 0===y||0===y.result.length?(0,l.jsx)(H.u,{title:"You have no NFT"}):(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)(S.r,{children:[y.result.map((e,t)=&gt;(0,l.jsx)(S.r.Col,{span:{base:12,sm:6,md:4,lg:3},children:(0,l.jsx)(Y._d,{network:x,nft:e,active:j(e),onClick:()=&gt;d(e)})},"nft-".concat(t))),null!==y.cursor&amp;&amp;y.cursor.length&gt;0&amp;&amp;(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(X.v,{size:6,gridCol:!0,span:{base:12,sm:6,md:4,lg:3}}),(0,l.jsx)(G.P,{onTrigger:()=&gt;f(y.cursor)})]})]})})]})}var V=n(78734);function q(){let{openWeb3Modal:e,isConnecting:t}=(0,U.S)();return(0,l.jsxs)(i.K,{gap:"xl",className:r().wrapper,children:[(0,l.jsxs)(i.K,{gap:"md",children:[(0,l.jsxs)(i.K,{gap:"xs",children:[(0,l.jsx)(m.U,{delayNum:0,text:!0,children:(0,l.jsx)(s.x,{size:"xs",c:"dimmed",className:"overline-text",fw:"bold",children:"STEP 0"})},"stepZero-overline"),(0,l.jsx)(m.U,{delayNum:1,text:!0,children:(0,l.jsx)(s.x,{size:"1.6rem",fw:"bold",lh:"2rem",children:"Welcome to the Lending Process of WeRent App"})},"stepZero-title")]}),(0,l.jsxs)(i.K,{gap:4,children:[(0,l.jsx)(m.U,{delayNum:2,children:(0,l.jsxs)(s.x,{children:["Before anything, you have to"," ",(0,l.jsx)(s.x,{component:"span",fw:"bold",children:"connect your account"})," ","first before continuing the Lending Process."]})},"stepZero-description"),!h.th&amp;&amp;(0,l.jsx)(m.U,{delayNum:3,children:(0,l.jsxs)(s.x,{children:["We also have a campaign called ",(0,l.jsx)("b",{children:"Lend to Earn"})," that will reward you for each successful lend transactions."]})},"stepOne-secondDescription")]}),(0,l.jsx)(m.U,{delayNum:4,children:(0,l.jsx)(s.x,{children:"You can read our gitbook to learn more about how to lend."})},"stepZero-extraDescription")]}),(0,l.jsxs)(o.x,{className:r()["lend-actions"],children:[(0,l.jsx)(m.U,{initial:{x:"-1rem",opacity:0},animate:{x:0,opacity:1},exit:{x:"-1rem",opacity:0},delayNum:4,children:(0,l.jsx)(c.z,{fullWidth:!0,component:x(),href:"https://webuynft.gitbook.io/werent/how-werent-works",target:"_blank",leftSection:(0,l.jsx)(d.Z,{}),variant:"secondary",children:"How to Lend"})},"stepZero-gitbookButton"),(0,l.jsx)(m.U,{initial:{x:"-1rem",opacity:0},animate:{x:0,opacity:1},exit:{x:"-1rem",opacity:0},delayNum:5,children:(0,l.jsx)(c.z,{fullWidth:!0,loading:t,onClick:e,leftSection:(0,l.jsx)(V.Z,{}),children:"Connect"})},"stepZero-connectButton")]})]})}var J=n(70579),$=n(53167),ee=n(55350),et=n(4517),en=n(46129),el=n(5899),ea=n(28008),er=n(11163),ei=n(17185),es=n(57435),eo=n(58459),ec=n(20527),ed=n(44378);let eu=(e,t)=&gt;{if(t&gt;32)throw"number above maximum value";return e&lt;0&amp;&amp;(e=Math.pow(2,t)-1+e+1),"0x"+(e&gt;&gt;&gt;0).toString(16).toUpperCase().padStart(2*Math.ceil(t/8),"0")},ep=e=&gt;{let t;if(e&gt;9999.9999)throw Error("too high");let n=e.toString().split(".");if(2==n.length){let e=n[0],l=n[1];for(;l.length&lt;4;)l+="0";let a=eu(Number(e),16),r=eu(Number(l),16);t=a.concat(r.slice(2))}else{if(1!=n.length)throw Error("price packing issue");t=eu(Number(n[0]),16).concat("0000")}return t},ex=e=&gt;{let t=new TextEncoder().encode(e);for(t.byteLength&gt;32&amp;&amp;(t=t.slice(0,32));t.byteLength&lt;32;){let e=new Uint8Array(1),n=new Uint8Array(t.byteLength+1);for(let e=0;e&lt;t.byteLength;e++)n[e]=t[e];n.set(e,t.byteLength),t=n}let n="0x";for(let e=0;e&lt;t.length;e++)n+=t[e].toString(16).padStart(2,"0");return n};var em=n(94836),eh=n(71301);let ef=(e,t)=&gt;{var n,l,a,r,i,s,o,c,d,u;let{dataNft:p,formValues:x}=e,{onConfirm:m,onTrxSuccess:h,onHashPresent:f,onTimeout:y}=t,{network:g}=(0,U.S)(),j=(0,ec.m)(null==x?void 0:x.isCollateralized),[b,v]=(0,Z.useState)("approve"),[w,N]=(0,Z.useState)(em.ET),T=(0,eh.Y)(()=&gt;N(e=&gt;e-1),1e3),{write:C,reset:_}=(0,ed.P)({address:null==p?void 0:p.contractAddress,abi:eo,chainId:null==g?void 0:g.id,functionName:"setApprovalForAll",args:[j,!0]},{onSuccess:()=&gt;{null==h||h("approve"),setTimeout(()=&gt;{(null==x?void 0:x.isCollateralized)?(k(),v("collat")):(S(),v("free-collat"))},em.bO)},onError:(e,t)=&gt;{m("CANCEL",e),t&amp;&amp;"TransactionExecutionError"===t.name&amp;&amp;(0,J.c)("error",{title:"Failed to update your NFT",message:"You can retry again later"})},onHashPresent:e=&gt;{P(),null==f||f("approve",e)}}),{write:S,reset:E}=(0,ed.P)({address:j,functionName:"lend",chainId:null==g?void 0:g.id,abi:es,args:[[0],[null!==(n=null==p?void 0:p.contractAddress)&amp;&amp;void 0!==n?n:""],[parseInt(null!==(l=null==p?void 0:p.nftId)&amp;&amp;void 0!==l?l:"0")],[1],[null!==(a=null==x?void 0:x.maxDuration)&amp;&amp;void 0!==a?a:0],[ep(null!==(r=null==x?void 0:x.dailyPrice)&amp;&amp;void 0!==r?r:0)],[(null==x?void 0:x.currency)==="USDT"?1:0],[!0]]},{onSuccess:e=&gt;{null==h||h("free-collat"),m("SUCCESS",e)},onError:(e,t)=&gt;{m(e?"FAILED":"CANCEL",e),t&amp;&amp;"TransactionExecutionError"===t.name&amp;&amp;(0,J.c)("error",{title:"Failed to update your NFT",message:"You can retry again later"})},onHashPresent:e=&gt;{null==f||f("free-collat",e)}}),{write:k,reset:I}=(0,ed.P)({address:j,functionName:"lend",chainId:null==g?void 0:g.id,abi:ei,args:[[null!==(i=null==p?void 0:p.contractAddress)&amp;&amp;void 0!==i?i:""],[parseInt(null!==(s=null==p?void 0:p.nftId)&amp;&amp;void 0!==s?s:"0")],[1],[null!==(o=null==x?void 0:x.maxDuration)&amp;&amp;void 0!==o?o:0],[ep(null!==(c=null==x?void 0:x.dailyPrice)&amp;&amp;void 0!==c?c:0)],[ep(null!==(d=null==x?void 0:x.collateralPrice)&amp;&amp;void 0!==d?d:0)],[(null==x?void 0:x.currency)!=="USDT"],[ex(null!==(u=null==x?void 0:x.category)&amp;&amp;void 0!==u?u:"")]]},{onSuccess:e=&gt;{null==h||h("collat"),m("SUCCESS",e)},onError:(e,t)=&gt;{m(e?"FAILED":"CANCEL",e),t&amp;&amp;"TransactionExecutionError"===t.name&amp;&amp;(0,J.c)("error",{title:"Failed to update your NFT",message:"You can retry again later"})},onHashPresent:e=&gt;{null==f||f("collat",e)}}),A=()=&gt;{N(em.ET),T.active||T.start()},P=()=&gt;{T.stop(),N(em.ET)},L=()=&gt;{_(),E(),I(),v("approve"),P()};return(0,Z.useEffect)(()=&gt;{T.active&amp;&amp;w&lt;=0&amp;&amp;(T.stop(),null==y||y())},[w]),{approveWrite:()=&gt;{A(),C()},collatWrite:k,freeCollatWrite:S,cancelTrx:()=&gt;{"approve"===b&amp;&amp;(m("CANCEL"),L())},waitTrx:A,resetState:L}};var ey=n(6713),eg=n(38188),ej=n(40612);function eb(){let e=(0,er.useRouter)(),{user:t,userLoading:n,networkName:a}=(0,U.S)(),[r,i]=(0,Z.useState)(!1),[o,c]=(0,Z.useState)(0),[d,u]=(0,en.n)([{text:"Preparing NFT",type:"loading",show:!1},{text:"Validating NFT",type:"loading",show:!1},{text:"Approving NFT",type:"loading",show:!1},{text:"Updating NFT permission",type:"loading",show:!1},{text:"Updating NFT info",type:"loading",show:!1}]),[p,x]=(0,el.v)({isLending:!1,trxType:"approve",trxId:null}),[m,h]=(0,Z.useState)(null),[y,g]=(0,Z.useState)(null),{approveWrite:j,collatWrite:b,freeCollatWrite:v,cancelTrx:w,waitTrx:N,resetState:T}=ef({dataNft:m,formValues:y},{onHashPresent:()=&gt;{r||eg.qk.closeAll()},onTrxSuccess:e=&gt;{"approve"===e?(u.setItemProp(2,"type","completed"),x({trxType:"lend"})):("collat"===e||"free-collat"===e)&amp;&amp;(u.setItemProp(3,"type","completed"),u.setItemProp(4,"show",!0))},onConfirm:(e,t)=&gt;{"CANCEL"!==e||r||eg.qk.closeAll(),P(e,t)},onTimeout:()=&gt;{(0,ey.i)({title:"Transaction takes too long",children:(0,l.jsx)(s.x,{size:"md",maw:"48ch",children:"You can cancel the transaction now. Please note that even if you approve the transaction after canceling, it will still be considered failed."}),withCloseButton:!1,closeOnCancel:!0,closeOnConfirm:!0,cancelProps:{children:"Okay, Cancel the transaction",c:"red",onClick:()=&gt;{I(),w()}},confirmProps:{children:"No, wait for another ".concat(em.ET/60," more minutes"),c:"teal",onClick:()=&gt;{N()}}})}}),{mutate:C}=M.S.transaction.lend.checkNFT.useMutation({onSuccess:e=&gt;{if(e)(0,J.c)("error",{title:"NFT is not available",message:"NFT is currently still in an ongoing transaction, please wait for 5 to 10 minutes."}),I();else if(y&amp;&amp;m&amp;&amp;a){let e={network:a,nftAddress:m.contractAddress,nftId:m.nftId,isFreeCollateral:!y.isCollateralized,useNativeToken:"USDT"!==y.currency,category:y.category};y.isCollateralized&amp;&amp;delete e.category,_(e)}},onError:()=&gt;{I()}}),{mutate:_}=M.S.transaction.lend.notify.useMutation({onSuccess:e=&gt;{x({trxId:e.trxId}),y&amp;&amp;(u.setItemProp(1,"type","completed"),e.isApprovedNft?A(y):(u.setItemProp(2,"show",!0),j()))},onError:e=&gt;{var t,n;(null===(t=e.data)||void 0===t?void 0:t.APIError)==="LOAN_ALREADY_EXIST"?((0,J.c)("error",{title:"NFT is in transaction",message:"NFT is currently in an ongoing transaction, please wait for 5 to 10 minutes."}),I()):(null===(n=e.data)||void 0===n?void 0:n.APIError)==="TRX_ALREADY_EXIST"&amp;&amp;((0,J.c)("error",{title:"NFT is in an ongoing transaction",message:"Please wait for another 5 to 10 minutes."}),I())}}),{mutate:S,mutateAsync:E}=M.S.transaction.lend.confirm.useMutation({onSuccess:(t,n)=&gt;{"CANCEL"===n.status||"FAILED"===n.status?I():"SUCCESS"===n.status&amp;&amp;(u.setItemProp(4,"type","completed"),(0,J.c)("success",{title:"Lending completed",message:"Your NFT is now available for renting",autoClose:3e3,onClose:()=&gt;{e.reload()}}))}}),k=async e=&gt;{null!==a&amp;&amp;null!==m&amp;&amp;(u.setItemProp(0,"show",!0),x({isLending:!0}),g(e))},I=()=&gt;{g(null),T(),u.applyWhere(e=&gt;e.show&amp;&amp;"completed"!==e.type,e=&gt;({text:e.text,show:!0,type:"failed"})),setTimeout(()=&gt;{u.apply(e=&gt;({...e,show:!1,type:"loading"}))},5e3),x({isLending:!1,trxId:null,trxType:"approve"})},A=async e=&gt;{u.setItemProp(3,"show",!0),e.isCollateralized?b():v()},P=(e,t)=&gt;{setTimeout(()=&gt;{m&amp;&amp;y&amp;&amp;p.trxId&amp;&amp;a&amp;&amp;S({status:e,network:a,isFreeCollateral:!1===y.isCollateralized,nftAddress:m.contractAddress,nftId:m.nftId,hashTrx:null!=t?t:null,trxId:p.trxId})},"SUCCESS"===e?em.YZ:1)},L=async()=&gt;{"approve"===p.trxType&amp;&amp;(w(),m&amp;&amp;y&amp;&amp;p.trxId&amp;&amp;a&amp;&amp;await E({status:"CANCEL",network:a,isFreeCollateral:!1===y.isCollateralized,nftAddress:m.contractAddress,nftId:m.nftId,trxId:p.trxId,hashTrx:null}))};return(0,Z.useEffect)(()=&gt;{m&amp;&amp;a&amp;&amp;y&amp;&amp;(u.setItemProp(0,"type","completed"),u.setItemProp(1,"show",!0),C({network:a,nftAddress:m.contractAddress,nftId:m.nftId}))},[y]),(0,Z.useEffect)(()=&gt;{n||(null===t?(c(0),h(null),I()):c(1))},[n,t]),(0,Z.useEffect)(()=&gt;{3===o&amp;&amp;null===m&amp;&amp;c(2),ee.PK.set(o/3*100)},[o]),(0,l.jsxs)($.H,{title:"Lend",children:[(0,l.jsx)(ea.D,{hiddenFrom:"md",ta:"center",size:"2.35rem",mb:"xl",children:"Lend NFT"}),n?null:1===o?(0,l.jsx)(f,{onNextPressed:()=&gt;c(2)}):2===o?(0,l.jsx)(Q,{value:m,onNFTSelected:h,onNextPressed:()=&gt;c(3),onBackPressed:()=&gt;c(1)}):3===o&amp;&amp;null!==m?(0,l.jsx)(K,{selectedNFT:m,onLendPressed:k,onBackPressed:()=&gt;c(2),isLending:p.isLending}):(0,l.jsx)(q,{}),(0,l.jsx)(ej.Z,{data:d}),(0,l.jsx)(et.g,{onModalChanged:e=&gt;i(e),active:p.isLending,onConfirm:L,title:"There is an ongoing transaction",message:"approve"===p.trxType?"Are you sure? the current transaction will be canceled":"Are you sure? it will be done in the background."})]})}},52321:function(e,t,n){"use strict";n.d(t,{GX:function(){return o},IX:function(){return x},Kc:function(){return d},QP:function(){return c},_N:function(){return i},aA:function(){return u},eA:function(){return a},g9:function(){return s},ne:function(){return r},tU:function(){return l},wk:function(){return p},x4:function(){return m}});let l=[{label:"All NFTs",value:""},{label:"Collateralized",value:"collateralized"},{label:"Collateral-free",value:"free-collateral"}],a=l.map(e=&gt;e.value),r=a[0],i=[{label:"All Status",value:""},{label:"Available",value:"available"},{label:"Rented",value:"rented"}],s=i.map(e=&gt;e.value),o=s[0];[{label:"High to low price",value:"high-low"},{label:"Low to high price",value:"low-high"},{label:"Newest",value:"newest"},{label:"Oldest",value:"oldest"}].map(e=&gt;e.value)[0],[{label:"Highest Collateral",value:"highest-collateral"},{label:"Lowest Collateral",value:"lowest-collateral"}].map(e=&gt;e.value);let c=[{label:"All Networks",value:"all"},{label:"Ethereum",value:"ethereum"},{label:"Binance Smart Chain",value:"bsc"},{label:"Polygon",value:"polygon"},{label:"Klaytn",value:"klaytn"},{label:"Arbitrum",value:"arbitrum"}],d=c.map(e=&gt;e.value)[0],u=[{label:"Collectibles",value:"Collectibles"},{label:"Gaming",value:"Gaming"},{label:"Metaverse",value:"Metaverse"},{label:"Art",value:"Art"},{label:"Others",value:"Others"}],p=[{label:"All Categories",value:"all"},...u],x=p.map(e=&gt;e.value),m=x[0]},78639:function(e){e.exports={wrapper:"LendSteps_wrapper__mMJCB","back-button":"LendSteps_back-button__mlBfb","lend-actions":"LendSteps_lend-actions__GW5_6","content-wrapper":"LendSteps_content-wrapper__qx1m5","detail-nft_wrapper":"LendSteps_detail-nft_wrapper__kIihR","form-wrapper":"LendSteps_form-wrapper__FQB30","nft-image_wrapper":"LendSteps_nft-image_wrapper__SzoGm","nft-image_inner":"LendSteps_nft-image_inner__5iixb","nft-image":"LendSteps_nft-image__nAfYj","nft-header_collection-name":"LendSteps_nft-header_collection-name__nTxgE","nft-body_wrapper":"LendSteps_nft-body_wrapper__uER2x","nft-body_inner":"LendSteps_nft-body_inner__G_Lyu","nft-body_item":"LendSteps_nft-body_item__GjomC","input-wrapper":"LendSteps_input-wrapper__6U8Rx","collateral-input":"LendSteps_collateral-input__8uDDB"}}},function(e){e.O(0,[112,940,144,536,356,774,888,179],function(){return e(e.s=82838)}),_N_E=e.O()}]);</pre></body></html>