1import{Y as ye,j as e,ab as je,Z as be}from"./vendor-ui-BfO2VaBV.js";import{a as z}from"./vendor-redux-DAFPkm2K.js";import{j2 as Se,b as we,ja as Fe,E as De,G as ve,iJ as Ce,u as Ae,jx as G,t,e as Be,g as Ee,j8 as ke,Y as Te,n as o,B as l,p as f,r as y,a2 as Q,J as V,S as qe,j1 as Le,s as d,j9 as Pe,ag as H}from"./index-iXJSSkdU.js";import{u as Ie}from"./delegation.service-BCU0HQER.js";import{m as Ne,n as Ue}from"./transaction-8WZFJ3X5.js";import{c as $e,B as Re,a as J,h as M,C as We,n as ze}from"./Common.styled-DP4o8TVm.js";import{d as Ge}from"./styled-iQpoyO_w.js";import{g as Qe}from"./utils-KvcaFGqh.js";import{u as Ve}from"./useSpsValues-RYoRsz95.js";import"./vendor-blockchain-B33N8Jyr.js";import"./three-DYsWAOM3.js";import"./maps-BKggpbsI.js";import"./purchases.service-D8pcDxOy.js";import"./web3-WYqjMTYg.js";import"./bignumber-B1z4pYDt.js";import"./react-number-format.es-4hMs4u0_.js";import"./currency.service-DAk7tBfK.js";const i=d(l,{font:"normal normal normal 13px/15px Proxima Nova",color:"#FFEDA0",textTransform:"uppercase"}),O=d(ze,{background:"transparent linear-gradient(180deg, #00131C 0%, #00414A 100%) 0% 0% no-repeat padding-box",boxShadow:"inset 0px 0px 20px #000000BF",height:"32px",colorScheme:"dark"}),He=d(l,{font:"normal normal bold 16px/20px Proxima Nova",color:"#D9FFFF",textShadow:"0px 0px 10px #00FF9DCC",letterSpacing:"1.28px"}),Je=d(l,{font:"normal normal bold 18px/23px Proxima Nova",color:"#FFFFFF"}),Me=d(l,{border:"1px solid #786A2F",br:"8px",font:"normal normal normal 15px/20px Proxima Nova",color:"white",padding:"12px 16px"}),Oe=d("button",{all:"unset",background:"transparent linear-gradient(180deg, #023E41 0%, #142E2C 100%) 0% 0% no-repeat padding-box",boxShadow:"0px 3px 6px #00000072",borderRadius:6,font:"normal normal normal 14px/17px Proxima Nova",color:"#FFEDA0",border:"1px solid #142E2C",padding:"6px 11px",cursor:"pointer","&:hover":{background:"transparent linear-gradient(180deg, #008689 0%, #00666B 36%, #00B3B7 100%) 0% 0% no-repeat padding-box",border:"1px solid #FFFFFF",padding:"6px 11px"}}),ut=()=>{var k,T,q,L,P,I,N,U,$,R;const x=Se(),Y=we(),K=Ne(),Z=Ue(),[X]=Fe(),v=De(ve),ee=Ce(),{delegateType:n,player:c}=ee,[j,te]=z.useState(c!=null?c:null),{data:m}=Ae(),{currentData:s,isFetching:C}=Ie({player:v,targetPlayer:j},{skip:!j}),{isLoading:ae,loadingValues:{availableToDelegateOut:A}}=Ve(),b=+((T=(k=s==null?void 0:s.data)==null?void 0:k.amount)!=null?T:0),S=+((L=(q=s==null?void 0:s.data)==null?void 0:q.rentalDelegationAmount)!=null?L:0),ne=G(b,S),w=n==="delegate"?A:ne,se=(m==null?void 0:m.delegation_cooldown)||0,oe=Qe(m),B=(P=s==null?void 0:s.data)!=null&&P.lastDelegationDate?new Date((I=s==null?void 0:s.data)==null?void 0:I.lastDelegationDate):null,F=B?new Date(B.getTime()+se):null,u=n==="undelegate"&&F&&new Date<F,p=()=>Y("/sps/delegation"),re=[{text:"25%",times:.25},{text:"50%",times:.5},{text:"75%",times:.75},{text:t("delegation.max"),times:1}],le=Be().shape({quantity:ke().typeError(t("dec_management.err_invalid")).required(t("dec_management.err_invalid")).test("Is positive?",t("common.greater_than_0"),a=>a>0),player:Ee().required(t("transfer_token.err_player_required")).min(3,t("transfer_token.err_player_min")).max(50,t("transfer_token.err_player_max")).lowercase()}),ie={resolver:be(le),defaultValues:{player:c||""}},{register:E,handleSubmit:de,setValue:ce,control:pe,setError:h,clearErrors:ge,watch:xe,formState:{errors:D}}=ye(ie),me=+((N=xe("quantity"))!=null?N:0),ue=(n==="delegate"?Le:G)(b,me);z.useEffect(()=>{n!=="delegate"&&n!=="undelegate"&&p(),n==="undelegate"&&!c&&p()},[]);const he=a=>{const r=Pe(w,a);ce("quantity",H(r,!0)),ge("quantity")},_e=async a=>{var W;if(a.player===v){h("player",{message:t("delegation.delegate_to_self_error")});return}const r=+a.quantity;if(n==="delegate"&&r>w){h("quantity",{message:t("delegation.delegate_more_than_available_error")});return}if(n==="undelegate"&&r>w){h("quantity",{message:t("delegation.undelegate_more_error")});return}const _=await X(a.player).unwrap();if(!_||!_.exists){h("player",{message:t("transfer_token.err_player_not_found")});return}let g;n==="delegate"?g=await K({qty:r,to:a.player}):g=await Z({qty:r,from:a.player}),(W=g==null?void 0:g.data)!=null&&W.success&&p()},fe=a=>
1a===""?"":H(+a,!0);return e.jsxs(Ge,{children:[e.jsx(Te,{headerTitle:"".concat(n," SPS"),onGoBack:p,onGoBackTitle:"BACK",containerCss:{position:"relative"}}),e.jsx(o,{css:{justifyContent:"center"},children:e.jsxs(l,{css:{marginTop:60,width:520,maxWidth:"100%","@mdRev":{width:"90%"}},children:[e.jsxs(Me,{children:[n==="undelegate"&&t("delegation.undelegate_description"),n==="delegate"&&t("delegation.delegate_description"),n==="delegate"&&e.jsx(l,{css:{mt:"5px"},children:t("delegation.delegate_cooldown_description")})]}),e.jsxs($e,{css:{mt:"35px",borderBottom:"1px solid #786A2F"},children:[e.jsxs(Re,{css:{justifyContent:"left",alignItems:"center",flexWrap:"wrap",gap:"8px",minHeight:"56px",background:"linear-gradient(90deg, rgba(4, 122, 124, 0.75) 0%, rgba(0, 13, 15, 0.75) 100%) 0% 0% no-repeat padding-box padding-box transparent"},children:[e.jsx(f,{src:"".concat(window.config.SL_ASSETS_URL,"/ui_elements/sps_management/sps_icon_staked.svg"),css:{width:"26px"}}),n==="undelegate"&&e.jsx(J,{css:{ml:"2px",fontSize:"16px"},children:t("delegation.undelegate_title")}),n==="delegate"&&e.jsxs(e.Fragment,{children:[e.jsxs(J,{css:{ml:"2px",fontSize:"16px"},children:[t("delegation.available_for_delegation"),":"]}),e.jsx(y,{content:t("delegation.available_for_delegation_tooltip")}),e.jsx(He,{css:{ml:"auto"},children:ae?t("common.loading"):"".concat(x(A)," ").concat(t("sps_management.sps"))})]})]}),e.jsxs(l,{css:{padding:"25px 30px 30px","@mdRev":{padding:"20px 15px 30px"}},children:[e.jsxs(o,{css:{flexDirection:"column",gap:"6px",mb:"8px"},children:[e.jsx(i,{children:t("delegation.player_name")}),e.jsx(M,{type:"sps",css:{mt:"0"},children:e.jsx(O,{css:{width:"100%",br:"6px",textAlign:"left",pl:"10px"},type:"input","aria-label":"player name",...E("player",{onBlur:a=>te(a.target.value.toLowerCase())})})}),((U=D.player)==null?void 0:U.message)&&e.jsx(Q,{css:{fontSize:"12px"},children:($=D.player)==null?void 0:$.message})]}),e.jsxs(o,{css:{alignItems:"center"},children:[e.jsxs(i,{children:[t("delegation.currently_delegated"),":"]}),e.jsx(y,{content:t("delegation.currently_delegated_tooltip"),iconCss:{ml:"8px",mr:"8px"}}),e.jsx(i,{css:{color:"#FFB5B5"},children:C?e.jsx(f,{src:"".concat(window.config.SL_ASSETS_URL,"/loading.gif"),css:{height:"15px"},alt:"Loading"}):x(b)})]}),n==="undelegate"&&S>0&&e.jsxs(o,{css:{alignItems:"center",mt:"8px"},children:[e.jsxs(i,{children:[t("delegation.locked_by_rental"),":"]}),e.jsx(y,{content:t("delegation.locked_by_rental_tooltip"),iconCss:{ml:"8px",mr:"8px"}}),e.jsx(i,{css:{color:"#FFEDA0"},children:C?e.jsx(f,{src:"".concat(window.config.SL_ASSETS_URL,"/loading.gif"),css:{height:"15px"},alt:"Loading"}):x(S)})]}),e.jsxs(o,{css:{flexDirection:"column",gap:"6px",mt:"25px"},children:[e.jsx(i,{children:t("delegation.amount")}),e.jsx(o,{css:{gap:20},children:re.map(a=>e.jsx(Oe,{onClick:()=>he(a.times),children:a.text},a.text))}),e.jsxs(M,{type:"sps",css:{mt:"0"},children:[e.jsx(je,{render:({field:{onChange:a,value:r}})=>e.jsx(O,{value:r,type:"number",...E("quantity"),onChange:_=>a(fe(_.target.value))}),control:pe,name:"quantity"}),e.jsx(We,{css:{height:"32px"},type:"sps",children:t("sps_management.sps")}),e.jsx(l,{css:{position:"absolute",left:10,top:5},children:e.jsx(f,{src:"".concat(window.config.SL_ASSETS_URL,"/ui_elements/shop/cl/img_sps-shard_128.png"),alt:"sps",css:{width:19}})})]}),e.jsx(Q,{css:{fontSize:"12px"},children:(R=D.quantity)==null?void 0:R.message})]}),e.jsxs(o,{css:{flexDirection:"column",alignItems:"center",mt:"24px"},children:[e.jsxs(i,{css:{fontSize:"15px"},children:[t("delegation.new_delegation_amount"),":"]}),e.jsxs(Je,{css:{mt:"8px"},children:[x(ue)," ",t("sps_management.sps")]})]})]})]}),e.jsx(o,{css:{justifyContent:"center",marginTop:40},children:e.jsxs(o,{css:{gap:40,flexWrap:"wrap",justifyContent:"center","@mdRev":{gap:20}},children:[e.jsx(V,{color:"red",css:{width:140,fontWeight:"normal"},onClick:p,children:t("stake_unstake_page.cancel")}),e.jsx(y,{content:u?t("delegation.undelegate_disabled_tooltip",{daysTilUndelegateAllowed:oe,currentDelegateToPlayer:j,undelegationAvailableDate:F.toLocaleStr
1ing()}):null,children:e.jsx(qe,{children:e.jsx(V,{color:"green",css:{width:140,fontWeight:"normal",pointerEvents:u?"none":"auto"},onClick:de(_e),isDisabled:u,disabled:u,children:n})})})]})})]})})]})};export{ut as DelegateUndelegateSps,ut 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.