Files
pezkuwi-apps/page.b3a6c334b93477ff.js
T
github-actions[bot] 11f24d8db7 Updates
2026-01-30 08:16:06 +00:00

1423 lines
378 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use strict";(("undefined"!=typeof self?self:this).webpackChunk_pezkuwi_apps=("undefined"!=typeof self?self:this).webpackChunk_pezkuwi_apps||[]).push([[9907],{2456(e,s,t){t.d(s,{A:()=>ne});var a=t(31085),n=t(14041),r=t(18690),o=t(19428),i=t(1445),l=t(61020),c=t(97186),d=t(39444),u=t(54975),m=t(51524),h=t(37140);function p(){return(0,h.Bd)("app-assets")}var x=t(21327),g=t(33168),b=t(28138);const f=n.memo(function({accountId:e,assetId:s,className:t,minBalance:r,siFormat:[o,c]}){const{t:d}=p(),{api:u}=(0,l.g)(),[m,h]=(0,b.e)(),[x,g]=(0,n.useState)(),[f,j]=(0,n.useState)(null),[v,y]=(0,n.useState)(!0);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.$n,{icon:"paper-plane",label:d("send"),onClick:h}),m&&(0,a.jsxs)(i.aF,{className:t,header:d("transfer asset"),onClose:h,size:"large",children:[(0,a.jsxs)(i.aF.Content,{children:[(0,a.jsx)(i.aF.Columns,{hint:d("The account to transfer from. This account should have sufficient assets for this transfer."),children:(0,a.jsx)(i.B4,{defaultValue:e,isDisabled:!0,label:d("send from")})}),(0,a.jsx)(i.aF.Columns,{hint:d("The beneficiary will have access to the transferred asset when the transaction is included in a block."),children:(0,a.jsx)(i.B4,{label:d("send to address"),onChange:j,type:"allPlus"})}),(0,a.jsx)(i.aF.Columns,{hint:d("The amount of tokens to transfer to the account."),children:(0,a.jsx)(i.xg,{autoFocus:!0,label:d("amount to transfer"),onChange:g,siDecimals:o,siSymbol:c})}),(0,a.jsx)(i.aF.Columns,{hint:d("The minimum balance allowed for the asset."),children:(0,a.jsx)(i.xg,{defaultValue:r,isDisabled:!0,label:d("minimum balance"),siDecimals:o,siSymbol:c})}),(0,a.jsx)(i.aF.Columns,{hint:d("With the keep-alive option set, the account is protected against removal due to low balances."),children:(0,a.jsx)(i.lM,{className:"typeToggle",label:d(v?"Transfer with account keep-alive checks":"Normal transfer without keep-alive checks"),onChange:y,value:v})})]}),(0,a.jsx)(i.aF.Actions,{children:(0,a.jsx)(i.jX,{accountId:e,icon:"paper-plane",isDisabled:!f||!x,label:d("Send"),onStart:h,params:[s,f,x],tx:v?u.tx.assets.transferKeepAlive:u.tx.assets.transfer})})]})]})}),j=n.memo(function({account:{balance:e,isFrozen:s,reason:t,sufficient:n},accountId:r,assetId:o,minBalance:l,siFormat:c}){const{t:d}=p();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"address",children:(0,a.jsx)(i.y1,{value:r})}),(0,a.jsx)("td",{className:"start",children:d(s?.isTrue?"Yes":"No")}),(0,a.jsx)("td",{className:"start",children:n?n.isTrue?d("Yes"):d("No"):t?.toString()}),(0,a.jsx)("td",{className:"number all",children:(0,a.jsx)(g.A,{format:c,value:e})}),(0,a.jsx)("td",{className:"button",children:(0,a.jsx)(f,{accountId:r,assetId:o,minBalance:l,siFormat:c})})]})});var v=t(79129),y=t(55155);const C={transform:([[e],s])=>({accounts:e.map(([,e],t)=>{const a=s[t];return{account:(n=a,n.isSome||n.isNone?a.unwrapOr(null):a),accountId:e};var n}).filter(e=>!!e.account&&!e.account.balance.isZero()),assetId:e[0][0]}),withParamsTransform:!0},w=(0,y.F)("useBalances",function(e){const{api:s}=(0,l.g)(),{allAccounts:t}=(0,c.o)(),a=(0,n.useMemo)(()=>[t.map(s=>[e,s]).filter(e=>!!e[0])],[t,e]),r=(0,v.Gc)(a&&s.query.assets.account.multi,a,C);return r&&e&&r.assetId===e&&r.accounts||null}),k="0.5rem",S=i.I4.tr`
td {
border-top: ${e=>e.isFirstItem&&"0.375rem solid var(--bg-page)"};
border-radius: 0rem !important;
&:first-child {
padding-block: 1rem !important;
border-top-left-radius: ${e=>e.isFirstItem?k:"0rem"}!important;
border-bottom-left-radius: ${e=>e.isLastItem?k:"0rem"}!important;
}
&:last-child {
border-top-right-radius: ${e=>e.isFirstItem?k:"0rem"}!important;
border-bottom-right-radius: ${e=>e.isLastItem?k:"0rem"}!important;
}
}
`,N=({asset:{details:e,id:s,metadata:t},className:r,searchValue:o})=>{const i=w(s),l=(0,n.useMemo)(()=>t?[t.decimals.toNumber(),t.symbol.toUtf8().toUpperCase()]:[0,"NONE"],[t]),c=(0,n.useMemo)(()=>t.name.toUtf8().toLowerCase().includes(o)||(0,x.Z)(s).toString().replaceAll(",","").includes(o),[s,t.name,o]);return i?.length&&c?i.map(({account:n,accountId:o},c)=>(0,a.jsxs)(S,{className:`isExpanded ${r}`,isFirstItem:0===c,isLastItem:c===i.length-1,children:[(0,a.jsx)("td",{className:"all",children:0===c&&(0,a.jsxs)(a.Fragment,{children:[t.name.toUtf8()," (",(0,x.Z)(s),")"]})}),(0,a.jsx)(j,{account:n,accountId:o,assetId:s,minBalance:e.minBalance,siFormat:l},o)]},o)):(0,a.jsx)(a.Fragment,{})},A=i.I4.div`
input {
max-width: 250px !important;
}
table {
overflow: auto;
}
`,F=n.memo(function({className:e,infos:s=[]}){const{t}=p(),[{searchValue:r},o]=(0,n.useState)({searchValue:""}),l=(0,n.useRef)([[t("asset"),"start"],[t("accounts"),"start"],[t("frozen"),"start"],[t("sufficient"),"start"],[t("free balance"),"start"],[]]),c=(0,n.useCallback)(e=>{o({searchValue:e})},[]),d=(0,n.useMemo)(()=>s.filter(e=>!(!e.details||!e.metadata||e.details.supply.isZero())),[s]);return(0,a.jsxs)(A,{className:e,children:[(0,a.jsx)(i.pd,{"aria-label":t("Search by asset id or name"),className:"full isSmall",label:t("Search"),onChange:c,placeholder:t("Search by asset id or name"),value:r}),(0,a.jsx)(i.XI,{empty:t("No accounts with balances found for the asset"),header:l.current,children:d.map(e=>(0,a.jsx)(N,{asset:e,searchValue:r.toLowerCase()},e.id.toString()))})]})}),I=i.I4.td`
display: flex;
align-items: center;
gap: 0.6rem;
white-space: nowrap;
font-style: italic;
pre {
overflow: visible;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.ui--Expander-summary svg {
padding: 0.3rem 0.4rem;
border-radius: 0.25rem;
border: 1px solid var(--border-input);
}
`,E=n.memo(function({className:e,value:{details:s,location:t,metadata:r}}){const o=(0,n.useMemo)(()=>r?[r.decimals.toNumber(),r.symbol.toUtf8()]:[0,"---"],[r]);return(0,a.jsxs)("tr",{className:e,children:[(0,a.jsxs)(I,{children:[(0,a.jsx)(i.c6,{isLeft:!0,summary:JSON.stringify(t?.toJSON()).substring(0,40),children:(0,a.jsx)("pre",{children:JSON.stringify(t?.toJSON(),null,2)})}),(0,a.jsx)(i.i8,{value:JSON.stringify(t?.toJSON(),null,2)})]}),(0,a.jsx)("td",{className:"together",children:r?.name.toUtf8()}),(0,a.jsx)("td",{className:"address media--1000",children:s&&(0,a.jsx)(i.y1,{value:s.owner})}),(0,a.jsx)("td",{className:"address media--1300",children:s&&(0,a.jsx)(i.y1,{value:s.admin})}),(0,a.jsx)("td",{className:"address media--1600",children:s&&(0,a.jsx)(i.y1,{value:s.issuer})}),(0,a.jsx)("td",{className:"address media--1900",children:s&&(0,a.jsx)(i.y1,{value:s.freezer})}),(0,a.jsx)("td",{className:"number media--800",children:s&&(0,a.jsx)(g.A,{format:o,value:s.supply})}),(0,a.jsx)("td",{className:"number all",children:s?.accounts.toString()||"0"})]})}),T=n.memo(function({className:e,infos:s}){const{t}=p(),r=(0,n.useRef)([[t("foreign assets"),"start"],[],[t("owner"),"address media--1000"],[t("admin"),"address media--1300"],[t("issuer"),"address media--1600"],[t("freezer"),"address media--1900"],[t("supply"),"media--800"],[t("holders")]]);return(0,a.jsx)(i.XI,{className:e,empty:s&&t("No assets found"),header:r.current,children:s?.map(e=>(0,a.jsx)(E,{value:e},e.key))})}),D=n.memo(function({className:e,numAssets:s}){const{t}=p();return(0,a.jsx)(i.cp,{className:e,children:(0,a.jsx)(i.dS,{label:t("foreign assets"),children:(0,x.Z)(s)})})}),M=n.memo(function({className:e,foreignAssetInfos:s,locations:t}){return(0,a.jsxs)("div",{className:e,children:[(0,a.jsx)(D,{numAssets:t?.length}),(0,a.jsx)(T,{infos:s})]})});var B=t(11773),P=t(19348);const $=n.memo(function({assetIds:e,className:s="",defaultValue:t,onChange:r,openId:o}){const{t:c}=p(),{api:d}=(0,l.g)(),[u]=(0,n.useState)(()=>t),[h]=(0,n.useState)(()=>o),[x,g]=(0,n.useState)(null),[b,f]=(0,n.useState)(),[j,v]=(0,n.useState)(),[y,C]=(0,n.useState)(()=>t?.assetName),[w,k]=(0,n.useState)(()=>t?.assetSymbol),[S,N]=(0,n.useState)(),[A,F]=(0,n.useMemo)(()=>j&&w?[j.toNumber(),w.toUpperCase()]:[0,"NONE"],[j,w]),I=(0,n.useMemo)(()=>!!j&&j.lten(20),[j]),E=(0,n.useMemo)(()=>!!y&&y.length>=3&&y.length<=32,[y]),T=(0,n.useMemo)(()=>!!w&&w.length>=3&&w.length<=7,[w]),D=(0,n.useMemo)(()=>!!b&&b.gt(m.Yz)&&!e.some(e=>e.eq(b)),[b,e]);return(0,n.useEffect)(()=>{r(b&&y&&w&&j&&D&&E&&T&&I&&x&&S&&!S.isZero()?{accountId:x,assetDecimals:j,assetId:b,assetName:y,assetSymbol:w,minBalance:S}:null)},[d,x,j,b,e,y,w,D,E,T,I,S,r]),(0,a.jsxs)(i.aF.Content,{className:s,children:[(0,a.jsx)(i.aF.Columns,{hint:c("The account that is to be used to create this asset and setup the initial metadata."),children:(0,a.jsx)(i.B4,{defaultValue:u?.accountId,label:c("creator account"),onChange:g,type:"account"})}),(0,a.jsx)(i.aF.Columns,{hint:c("The descriptive name for this asset."),children:(0,a.jsx)(i.pd,{autoFocus:!0,defaultValue:u?.assetName,isError:!E,label:c("asset name"),onChange:C})}),(0,a.jsx)(i.aF.Columns,{hint:c("The symbol that will represent this asset."),children:(0,a.jsx)(i.pd,{defaultValue:u?.assetSymbol,isError:!T,label:c("asset symbol"),onChange:k})}),(0,a.jsx)(i.aF.Columns,{hint:c("The number of decimals for this token. Max allowed via the UI is set to 20."),children:(0,a.jsx)(i.YI,{defaultValue:u?.assetDecimals,isError:!I,label:c("asset decimals"),onChange:v})}),(0,a.jsx)(i.aF.Columns,{hint:c("The minimum balance for the asset. This is specified in the units and decimals as requested."),children:(0,a.jsx)(i.xg,{defaultValue:u?.minBalance,isZeroable:!1,label:c("minimum balance"),onChange:N,siDecimals:A,siSymbol:F})}),(0,a.jsx)(i.aF.Columns,{hint:c("The selected id for the asset. This should not match an already-existing asset id."),children:(0,a.jsx)(i.YI,{bitLength:128,defaultValue:u?.assetId||h,isError:!D,isZeroable:!1,label:c("asset id"),onChange:f})})]})}),L=n.memo(function({accountId:e,className:s="",defaultValue:t,onChange:r}){const{t:o}=p(),{api:c}=(0,l.g)(),[d]=(0,n.useState)(()=>t),[u,m]=(0,n.useState)(null),[h,x]=(0,n.useState)(null),[g,b]=(0,n.useState)(null);return(0,n.useEffect)(()=>{r(u&&h&&g?{adminId:u,freezerId:h,issuerId:g}:null)},[c,u,h,g,r]),(0,a.jsxs)(i.aF.Content,{className:s,children:[(0,a.jsx)(i.aF.Columns,{hint:o("The account that is to be used for ongoing admin on the token."),children:(0,a.jsx)(i.B4,{defaultValue:d?.adminId||e,label:o("admin account"),onChange:m,type:"account"})}),(0,a.jsx)(i.aF.Columns,{hint:o("The account that is to be used for issuing this token."),children:(0,a.jsx)(i.B4,{defaultValue:d?.issuerId||e,label:o("issuer account"),onChange:b,type:"account"})}),(0,a.jsx)(i.aF.Columns,{hint:o("The account that is to be used for performing freezing."),children:(0,a.jsx)(i.B4,{defaultValue:d?.freezerId||e,label:o("freezer account"),onChange:x,type:"account"})})]})}),V={type:"all"},R=n.memo(function({assetIds:e,className:s,onClose:t,openId:r}){const{t:o}=p(),{api:c}=(0,l.g)(),[d,u,m]=(0,B.l)(),[h,x]=(0,n.useState)(null),[g,b]=(0,n.useState)(null),[f,j]=(0,n.useMemo)(()=>h?[c.tx.assets.create(h.assetId,h.accountId,h.minBalance),c.tx.assets.setMetadata(h.assetId,h.assetName,h.assetSymbol,h.assetDecimals)]:[null,null],[c,h]),v=(0,n.useMemo)(()=>h&&g&&(g.adminId!==h.accountId||g.freezerId!==h.accountId||g.issuerId!==h.accountId)?c.tx.assets.setTeam(h.assetId,g.issuerId,g.adminId,g.freezerId):null,[c,h,g]),y=(0,n.useMemo)(()=>f&&j&&g&&(v?[f,j,v]:[f,j]),[f,j,g,v]),C=(0,P.e)(y,V);return(0,a.jsxs)(i.aF,{className:s,header:o("create asset {{step}}/{{steps}}",{replace:{step:d,steps:2}}),onClose:t,size:"large",children:[1===d&&(0,a.jsx)($,{assetIds:e,defaultValue:h,onChange:x,openId:r}),2===d&&h&&(0,a.jsx)(L,{accountId:h.accountId,defaultValue:g,onChange:b}),(0,a.jsxs)(i.aF.Actions,{children:[1===d&&(0,a.jsx)(i.$n,{icon:"step-forward",isDisabled:!h,label:o("Next"),onClick:u}),2===d&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.$n,{icon:"step-backward",label:o("Prev"),onClick:m}),(0,a.jsx)(i.jX,{accountId:h?.accountId,extrinsic:C,icon:"plus",label:o("Create"),onStart:t})]})]})]})}),z=n.memo(function({assetIds:e,className:s,openId:t}){const{t:n}=p(),{hasAccounts:r}=(0,c.o)(),[o,l]=(0,b.e)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.$n,{icon:"plus",isDisabled:!e||!r,label:n("Create"),onClick:l}),o&&e&&(0,a.jsx)(R,{assetIds:e,className:s,onClose:l,openId:t})]})}),H=n.memo(function({className:e,details:{issuer:s,minBalance:t},id:r,metadata:o,onClose:c}){const{t:d}=p(),{api:u}=(0,l.g)(),[m,h]=(0,n.useState)(),[x,g]=(0,n.useState)(null),b=(0,n.useMemo)(()=>m&&m.gte(t),[m,t]),[f,j]=(0,n.useMemo)(()=>[o.decimals.toNumber(),o.symbol.toUtf8().toUpperCase()],[o]);return(0,a.jsxs)(i.aF,{className:e,header:d("mint asset"),onClose:c,size:"large",children:[(0,a.jsxs)(i.aF.Content,{children:[(0,a.jsx)(i.aF.Columns,{hint:d("The recipient account for this minting operation."),children:(0,a.jsx)(i.B4,{defaultValue:s,isDisabled:!0,label:d("issuer account")})}),(0,a.jsx)(i.aF.Columns,{hint:d("The recipient account for this minting operation."),children:(0,a.jsx)(i.B4,{label:d("mint to address"),onChange:g,type:"allPlus"})}),(0,a.jsx)(i.aF.Columns,{hint:d("The amount of tokens to issue to the account."),children:(0,a.jsx)(i.xg,{autoFocus:!0,isError:!b,isZeroable:!1,label:d("amount to issue"),onChange:h,siDecimals:f,siSymbol:j})}),(0,a.jsx)(i.aF.Columns,{hint:d("The minimum balance allowed for the asset."),children:(0,a.jsx)(i.xg,{defaultValue:t,isDisabled:!0,label:d("minimum balance"),siDecimals:f,siSymbol:j})})]}),(0,a.jsx)(i.aF.Actions,{children:(0,a.jsx)(i.jX,{accountId:s,icon:"plus",isDisabled:!x||!b,label:d("Mint"),onStart:c,params:[r,x,m],tx:u.tx.assets.mint})})]})}),q=n.memo(function({className:e,details:s,id:t,metadata:n}){const{t:r}=p(),[o,l]=(0,b.e)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.$n,{icon:"plus",isDisabled:n.isFrozen.isTrue,label:r("Mint"),onClick:l}),o&&(0,a.jsx)(H,{className:e,details:s,id:t,metadata:n,onClose:l})]})}),O=n.memo(function({className:e,value:{details:s,id:t,isIssuerMe:r,metadata:o}}){const l=(0,n.useMemo)(()=>o?[o.decimals.toNumber(),o.symbol.toUtf8()]:[0,"---"],[o]);return(0,a.jsxs)("tr",{className:e,children:[(0,a.jsx)("td",{}),(0,a.jsxs)("td",{className:"together",children:[(0,a.jsx)("span",{style:{fontSize:18,marginRight:10},children:t.toString()}),o?.name.toUtf8()]}),(0,a.jsx)("td",{className:"address media--1000",children:s&&(0,a.jsx)(i.y1,{value:s.owner})}),(0,a.jsx)("td",{className:"address media--1300",children:s&&(0,a.jsx)(i.y1,{value:s.admin})}),(0,a.jsx)("td",{className:"address media--1600",children:s&&(0,a.jsx)(i.y1,{value:s.issuer})}),(0,a.jsx)("td",{className:"address media--1900",children:s&&(0,a.jsx)(i.y1,{value:s.freezer})}),(0,a.jsx)("td",{className:"number all",children:s&&(0,a.jsx)(g.A,{format:l,value:s.supply})}),(0,a.jsx)("td",{className:"button",children:s&&o&&r&&(0,a.jsx)(q,{details:s,id:t,metadata:o})})]})}),W=n.memo(function({className:e,infos:s}){const{t}=p(),r=(0,n.useRef)([[t("assets"),"start",2],[t("owner"),"address media--1000"],[t("admin"),"address media--1300"],[t("issuer"),"address media--1600"],[t("freezer"),"address media--1900"],[t("supply")],[]]);return(0,a.jsx)(i.XI,{className:e,empty:s&&t("No assets found"),header:r.current,children:s?.map(e=>(0,a.jsx)(O,{value:e},e.key))})}),U=(0,i.I4)(i.f7)`
.asset--query {
width: 20em;
}
`,G=n.memo(function({className:e="",onQuery:s}){const{t}=p(),[r,o]=(0,n.useState)(""),l=(0,n.useCallback)(e=>o(e),[]),c=(0,n.useCallback)(()=>{s&&s(r)},[r,s]);return(0,a.jsx)(U,{className:`${e} ui--FilterOverlay hasOwnMaxWidth`,children:(0,a.jsx)(i.pd,{className:"asset--query",onChange:l,onEnter:c,placeholder:t("asset id or name to query"),withLabel:!1,children:(0,a.jsx)(i.$n,{icon:"play",onClick:c})})})}),Y=n.memo(function({className:e,numAssets:s}){const{t}=p();return(0,a.jsx)(i.cp,{className:e,children:(0,a.jsx)(i.dS,{label:t("assets"),children:(0,x.Z)(s)})})}),X=n.memo(function({className:e,ids:s,infos:t,openId:r}){const[o,l]=(0,n.useState)(""),c=o?t?.filter(({key:e,metadata:s})=>e===o||s?.name.toUtf8().includes(o)):t;return(0,a.jsxs)("div",{className:e,children:[(0,a.jsx)(Y,{numAssets:s?.length}),(0,a.jsx)(G,{onQuery:l}),(0,a.jsx)(i.$n.Group,{children:(0,a.jsx)(z,{assetIds:s,openId:r})}),(0,a.jsx)(W,{infos:c})]})}),Z={isAdminMe:!1,isFreezerMe:!1,isIssuerMe:!1,isOwnerMe:!1},_={withParams:!0};function J(e,s){const t=s.toString();return e.some(e=>e===t)}const K=(0,y.F)("useForeignAssetInfos",function(e){const{api:s}=(0,l.g)(),{allAccounts:t}=(0,c.o)(),a=(0,n.useMemo)(()=>!!e?.length&&!!s.tx.foreignAssets?.setMetadata&&!!s.tx.foreignAssets?.transferKeepAlive,[s.tx.foreignAssets?.setMetadata,s.tx.foreignAssets?.transferKeepAlive,e?.length]),r=(0,v.Gc)(a&&s.query.foreignAssets.metadata.multi,[e],_),o=(0,v.Gc)(a&&s.query.foreignAssets.asset.multi,[e],_),[i,d]=(0,n.useState)();return(0,n.useEffect)(()=>{o&&r&&o[0][0].length===r[0][0].length&&d(o[0][0].map((e,s)=>function(e,s,t,a){const n=t.unwrapOr(null);return{...n?{isAdminMe:J(e,n.admin),isFreezerMe:J(e,n.freezer),isIssuerMe:J(e,n.issuer),isOwnerMe:J(e,n.owner)}:Z,details:n,key:String(s),location:s,metadata:a.isEmpty?null:a}}(t,e,o[1][s],r[1][s])))},[t,o,e,r]),i});var Q=t(13158);const ee=[],se={transform:e=>e.flatMap(({args:e})=>e)},te=(0,y.F)("useForeignAssetLocations",function(){const{api:e,isApiReady:s}=(0,l.g)();return(0,Q.S)(s&&e.query.foreignAssets?.asset,ee,se)||[]}),ae=[(0,o.HM)("statemint"),(0,o.HM)("statemine")],ne=n.memo(function({basePath:e,className:s}){const{t}=p(),{api:o}=(0,l.g)(),{hasAccounts:h}=(0,c.o)(),x=(0,d.Y)(),g=(0,u.j)(x),b=te(),f=K(b),j=(0,n.useRef)([{isRoot:!0,name:"overview",text:t("Overview")},{name:"foreignAssets",text:t("Foreign assets")},{name:"balances",text:t("Balances")}]),v=(0,n.useMemo)(()=>!!b.length,[b.length]),y=(0,n.useMemo)(()=>h&&g&&g.some(({details:e,metadata:s})=>!(!e||!s)),[h,g]),C=(0,n.useMemo)(()=>[!v&&"foreignAssets",!y&&"balances"].filter(e=>"string"==typeof e),[y,v]),w=(0,n.useMemo)(()=>function(e,s){if(!s?.length)return m.Uu;if(ae.includes(e))return s.sort((e,s)=>e.cmp(s))[s.length-1].add(m.Uu);const t=s.find((e,t)=>0===t?!e.eq(m.Uu):!e.sub(m.Uu).eq(s[t-1]));return t?t.add(m.Uu):s[s.length-1].add(m.Uu)}(o.genesisHash.toHex(),x?.filter(e=>/^\d{1,3}(,\d{3})*$/.test(e.toString()))),[o.genesisHash,x]);return(0,a.jsxs)("main",{className:s,children:[(0,a.jsx)(i.tU,{basePath:e,hidden:C,items:j.current}),(0,a.jsx)(r.BV,{children:(0,a.jsxs)(r.qh,{path:e,children:[(0,a.jsx)(r.qh,{element:(0,a.jsx)(F,{infos:g}),path:"balances"}),(0,a.jsx)(r.qh,{element:(0,a.jsx)(M,{foreignAssetInfos:f,locations:b}),path:"foreignAssets"}),(0,a.jsx)(r.qh,{element:(0,a.jsx)(X,{ids:x,infos:g,openId:w}),index:!0})]})})]})})},5939(e,s,t){t.d(s,{A:()=>i});var a=t(14041),n=t(55155),r=t(61020),o=t(79129);const i=(0,n.F)("useCounter",function(){const{api:e,isApiReady:s}=(0,r.g)(),t=(0,o.Gc)(s&&e.derive.alliance.proposalHashes);return(0,a.useMemo)(()=>t?.length||0,[t])})},9791(e,s,t){t.d(s,{A:()=>He});var a=t(31085),n=t(14041),r=t(1445),o=t(28138),i=t(63181),l=t(37140);function c(){return(0,l.Bd)("app-contracts")}const d=n.memo(function({className:e,isBusy:s,isContract:t,isError:n,onChange:o,onEnter:i,value:l=""}){const{t:d}=c();return(0,a.jsx)(r.pd,{className:e,isDisabled:s,isError:n,label:d(t?"contract name":"code bundle name"),onChange:o,onEnter:i,value:l})});var u=t(61020),m=t(79129),h=t(21327),p=t(43892),x=t(59385);const g=r.I4.div`
font: var(--font-mono);
font-weight: var(--font-weight-normal);
flex-grow: 1;
.ui--MessageSignature-mutates {
color: #ff8600;
margin-left: 0.5rem;
opacity: var(--opacity-light);
}
.ui--MessageSignature-name {
color: #2f8ddb;
font-weight: var(--font-weight-normal);
}
.ui--MessageSignature-type {
color: #21a2b2;
}
.ui--MessageSignature-returnType {
color: #ff8600;
}
`,b=n.memo(function({className:e,message:{args:s,isConstructor:t,isMutating:o,method:i,returnType:l},params:d=[],withTooltip:m=!1}){const{t:h}=c(),{api:p}=(0,u.g)();return(0,a.jsxs)(g,{className:e,children:[(0,a.jsx)("span",{className:"ui--MessageSignature-name",children:i})," ","(",s.map(({name:e,type:t},r)=>{return(0,a.jsxs)(n.Fragment,{children:[e,":"," ",(0,a.jsx)("span",{className:"ui--MessageSignature-type",children:d?.[r]?(0,a.jsx)("b",{children:(o=d[r].toString(),o.length>20?`${o.substring(0,10)}${o.substring(o.length-10)}`:o)}):(0,x.U6)(p.registry,t)}),r<s.length-1&&", "]},`${e}-args-${r}`);var o}),")",!t&&l&&(0,a.jsxs)(a.Fragment,{children:[":"," ",(0,a.jsx)("span",{className:"ui--MessageSignature-returnType",children:(0,x.U6)(p.registry,l)})]}),o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.In,{className:"ui--MessageSignature-mutates",icon:"database",tooltip:`mutates-${i}`}),m&&(0,a.jsx)(r.m_,{text:h("Mutates contract state"),trigger:`mutates-${i}`})]})]})});function f(e){let s=!1;return e.map(e=>e.trim()).filter(e=>e).filter((e,t)=>!(s||(t||e.startsWith("#"))&&(s=!0,1)))}const j=r.I4.div`
align-items: center;
border-radius: 0.25rem;
display: flex;
padding: 0.25rem 0.75rem 0.25rem 0;
&.disabled {
opacity: 1 !important;
background: #eee !important;
color: #555 !important;
}
.info {
flex: 1 1;
margin-left: 1.5rem;
.docs {
font-size: var(--font-size-small);
font-weight: var(--font-weight-normal);
}
}
.result {
min-width: 15rem;
}
&+& {
margin-top: 0.5rem;
}
`,v=n.memo(function({className:e="",index:s,lastResult:t,message:o,onSelect:i}){const{t:l}=c(),d=(0,n.useCallback)(()=>i&&i(s),[s,i]);return(0,a.jsxs)(j,{className:`${e} ${i?"":"exempt-hover"} ${o.isConstructor?"constructor":""}`,children:[i&&(o.isConstructor?(0,a.jsx)(r.$n,{className:"accessory",icon:"upload",label:l("deploy"),onClick:d}):(0,a.jsx)(r.$n,{className:"accessory",icon:"play",isDisabled:!o.isMutating&&!o.args.length&&t?.result.isOk,label:o.isMutating?l("exec"):l("read"),onClick:d})),(0,a.jsxs)("div",{className:"info",children:[(0,a.jsx)(b,{asConstructor:o.isConstructor,message:o,withTooltip:!0}),(0,a.jsx)("div",{className:"docs",children:o.docs.length?f(o.docs).map((e,s)=>(0,a.jsx)("div",{children:e},`${o.identifier}-docs-${s}`)):(0,a.jsxs)("i",{children:[" ",l("No documentation provided")," "]})})]}),t&&t.result.isOk&&t.output&&(0,a.jsx)(r.k7,{className:"result",isFull:!0,label:l("current value"),children:(0,p.A)("Text",t.output)})]},`${o.identifier}-${s}`)}),y="0x".padEnd(66,"0");function C(e){return e.map((e,s)=>[e,s]).sort((e,s)=>e[0].identifier.localeCompare(s[0].identifier)).sort((e,s)=>e[0].isMutating===s[0].isMutating?0:e[0].isMutating?-1:1)}const w=r.I4.div`
padding-bottom: 0.75rem !important;
&.isLabelled {
background: var(--bg-input);
box-sizing: border-box;
border: 1px solid var(--border-input);
border-radius: .28571429rem;
padding: 1rem 1rem 0.5rem;
width: 100%;
}
`,k=n.memo(function({className:e="",contract:s,contractAbi:{constructors:t,info:{source:o},messages:i},isLabelled:l,isWatching:d,onSelect:p,onSelectConstructor:x,trigger:g,withConstructors:b,withMessages:f,withWasm:j}){const{t:k}=c(),{api:S}=(0,u.g)(),N=(0,m.Gc)(s&&S.query.contracts.contractInfoOf,[s?.address]),[A,F]=(0,n.useState)(!1),[I,E]=(0,n.useState)([]),T=(0,n.useCallback)(e=>{d&&F(e)},[d]),D=(0,n.useCallback)(()=>{N&&s&&Promise.all(i.map(e=>e.isMutating||0!==e.args.length?Promise.resolve(void 0):s.query[e.method](y,{gasLimit:-1,value:0}).catch(s=>console.error(`contract.query.${e.method}:: ${s.message}`)).then(()=>{}))).then(E).catch(console.error)},[s,i,N]);(0,n.useEffect)(()=>{(A||g)&&N&&s&&D()},[D,s,A,N,g]);const M=(0,n.useCallback)((e,s)=>{},[]),B=(0,n.useCallback)(e=>p&&p(e,M),[M,p]);return(0,a.jsxs)(w,{className:`${e} ui--Messages ${l?"isLabelled":""}`,children:[b&&(0,a.jsx)(r.c6,{summary:k("Constructors ({{count}})",{replace:{count:t.length}}),children:C(t).map(([e,s])=>(0,a.jsx)(v,{index:s,message:e,onSelect:x},s))}),f&&(0,a.jsx)(r.c6,{onClick:T,summary:k("Messages ({{count}})",{replace:{count:i.length}}),children:C(i).map(([e,s])=>(0,a.jsx)(v,{index:s,lastResult:I[s],message:e,onSelect:B},s))}),j&&0!==o.wasm.length&&(0,a.jsx)("div",{children:k("{{size}} WASM bytes",{replace:{size:(0,h.Z)(o.wasm.length)}})})]})}),S=()=>{},N=n.memo(function({className:e,contractAbi:s,errorText:t,isDisabled:n,isError:o,isFull:i,isValid:l,label:d,onChange:u,onRemove:m=S,onSelectConstructor:h,withConstructors:p=!0,withLabel:x=!0,withMessages:g=!0,withWasm:b}){const{t:f}=c();return s&&l?(0,a.jsx)(r.ks,{className:e,label:d||f("contract ABI"),labelExtra:m&&(0,a.jsx)(r.AX,{icon:"trash",label:f("Remove ABI"),onClick:m}),withLabel:x,children:(0,a.jsx)(k,{contractAbi:s,isLabelled:x,onSelectConstructor:h,withConstructors:p,withMessages:g,withWasm:b})}):(0,a.jsx)("div",{className:e,children:(0,a.jsx)(r.bT,{isDisabled:n,isError:o,isFull:i,label:d||f("contract ABI"),onChange:u,placeholder:t||f("click to select or drag and drop a JSON file")})})});var A=t(27429),F=t(70020),I=t.n(F),E=t(51784),T=t(35038),D=t(76733);const M="code:";class B extends A.b{#e={};get hasCode(){return 0!==Object.keys(this.#e).length}getAllCode(){return Object.values(this.#e)}getCode(e){return this.#e[e]}saveCode(e,s){const t=((0,D.K)(e)?T.g.api.registry.createType("Hash",e):e).toHex(),a=this.getCode(t),n={...a?a.json:{},...s,codeHash:t,genesisHash:T.g.api.genesisHash.toHex(),whenCreated:a?.json.whenCreated||Date.now()},r=`${M}${n.codeHash}`;I().set(r,n),this.addCode(r,n)}forgetCode(e){this.removeCode(`${M}${e}`,e)}loadAll(e){try{const s=T.g.api.genesisHash.toHex();I().each((e,t)=>{e&&e.genesisHash===s&&t.startsWith(M)&&this.addCode(t,e)}),e&&e()}catch(e){console.error("Unable to load code",e)}}addCode(e,s){try{this.#e[s.codeHash]={contractAbi:s.abi?new E.l(s.abi,T.g.api.registry.getChainProperties()):void 0,json:s},this.emit("new-code")}catch(t){console.error(t),this.removeCode(e,s.codeHash)}}removeCode(e,s){try{delete this.#e[s],I().remove(e),this.emit("removed-code")}catch(e){console.error(e)}}}const P=new B;var $=t(55155),L=t(73108);function V(e,s){return{abi:e[0]||null,abiName:null,contractAbi:e[1]||null,errorText:null,isAbiError:!1,isAbiSupplied:!!e[1],isAbiValid:!s||!!e[1]}}const R={abi:null,abiName:null,contractAbi:null,errorText:null,isAbiError:!1,isAbiSupplied:!1,isAbiValid:!1},z=(0,$.F)("useAbi",function(e=[null,null],s=null,t=!1){const[a,r]=(0,n.useState)(()=>V(e,t));return(0,n.useEffect)(()=>r(s=>e[0]&&s.abi!==e[0]?V(e,t):s),[e,t]),{...a,onChangeAbi:(0,n.useCallback)((e,t)=>{const a=(0,L.F)(e);try{r({abi:a,abiName:t.replace(".contract","").replace(".json","").replace("_"," "),contractAbi:new E.l(a,T.g.api.registry.getChainProperties()),errorText:null,isAbiError:!1,isAbiSupplied:!0,isAbiValid:!0}),s&&P.saveCode(s,{abi:a})}catch(e){console.error(e),r({...R,errorText:e.message})}},[s]),onRemoveAbi:(0,n.useCallback)(()=>{r(R),s&&P.saveCode(s,{abi:null})},[s])}});var H=t(54143);const q=n.memo(function({codeHash:e,onChange:s}){const{api:t}=(0,u.g)(),{t:o}=c(),i=(0,m.Gc)((t.query.contracts||t.query.contract).pristineCode||(t.query.contracts||t.query.contract).codeStorage,[e]),[l,d]=(0,n.useMemo)(()=>{const t=!!e&&(0,H.qv)(e)&&66===e.length,a=!!i&&i.isSome,n=t&&a;return s(n),[t,n]},[e,i,s]);return d||!l?null:(0,a.jsx)(r.Mz,{type:"error",children:o(l?"Unable to find on-chain WASM code for the supplied codeHash":"The codeHash is not a valid hex hash")})}),O=n.memo(function({onClose:e}){const{t:s}=c(),[t,o]=(0,n.useState)(""),[l,u]=(0,n.useState)(!1),[m,h]=(0,n.useState)(null),{abi:p,contractAbi:x,errorText:g,isAbiError:b,isAbiSupplied:f,isAbiValid:j,onChangeAbi:v,onRemoveAbi:y}=z(),C=(0,n.useCallback)(()=>{t&&m&&(P.saveCode(t,{abi:p,name:m,tags:[]}),e())},[p,t,m,e]),w=!(0,i.k)(m)&&m.length>0,k=l&&w&&f&&j;return(0,a.jsxs)(r.aF,{header:s("Add an existing code hash"),onClose:e,children:[(0,a.jsxs)(r.aF.Content,{children:[(0,a.jsx)(r.pd,{autoFocus:!0,isError:t.length>0&&!l,label:s("code hash"),onChange:o,value:t}),(0,a.jsx)(q,{codeHash:t,onChange:u}),(0,a.jsx)(d,{isError:!w,onChange:h,value:m||void 0}),(0,a.jsx)(N,{contractAbi:x,errorText:g,isError:b||!b,isSupplied:f,isValid:j,onChange:v,onRemove:y})]}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.$n,{icon:"save",isDisabled:!k,label:s("Save"),onClick:C})})]})});var W=t(85199);const U="<unknown>",G=(0,r.I4)(W.A)`
.ui--CodeRow-icon {
margin-right: -0.5em;
background: #eee;
border-radius: 50%;
color: #666;
width: 26px;
height: 26px;
display: flex;
justify-content: center;
align-items: center;
}
`,Y=n.memo(function({buttons:e,children:s,className:t,code:{json:o},isInline:i,withTags:l}){const[c,d]=(0,n.useState)(o.name||U),[u,m]=(0,n.useState)(o.tags||[]),[h,p]=(0,n.useState)(o.codeHash||"0x");(0,n.useEffect)(()=>{d(o.name||U),m(o.tags||[]),p(o.codeHash||"0x")},[o]);const x=(0,n.useCallback)(()=>{c.trim()&&h&&P.saveCode(h,{name:c})},[h,c]),g=(0,n.useCallback)(()=>{h&&P.saveCode(h,{tags:u})},[h,u]);return(0,a.jsx)(G,{buttons:e,className:t,icon:(0,a.jsx)("div",{className:"ui--CodeRow-icon",children:(0,a.jsx)(r.In,{icon:"code"})}),isInline:i,name:c,onChangeName:d,onChangeTags:m,onSaveName:x,onSaveTags:g,tags:l?u:void 0,children:s})}),X=r.I4.tr`
.codeHash {
div {
display: inline;
&:first-child {
font-family: monospace;
margin-right: 0.5rem;
}
}
}
`,Z=n.memo(function({className:e,code:s,onShowDeploy:t}){const{t:i}=c(),{api:l}=(0,u.g)(),d=(0,m.Gc)(l.query.contracts.pristineCode||l.query.contracts.codeStorage,[s.json.codeHash]),[h,p]=(0,o.e)(),{contractAbi:x}=z([s.json.abi,s.contractAbi],s.json.codeHash,!0),g=(0,n.useCallback)(()=>t(s.json.codeHash,0),[s,t]),b=(0,n.useCallback)(e=>{t&&t(s.json.codeHash,e||0)},[s,t]),f=(0,n.useCallback)(()=>{try{P.forgetCode(s.json.codeHash)}catch(e){console.error(e)}finally{p()}},[s,p]);return(0,a.jsxs)(X,{className:e,children:[(0,a.jsx)("td",{className:"address top",children:(0,a.jsxs)(r.Zp,{children:[(0,a.jsx)(Y,{code:s,withTags:!1}),h&&(0,a.jsx)(r.EX,{mode:"code",onClose:p,onForget:f,children:(0,a.jsxs)(Y,{code:s||"",isInline:!0,children:[(0,a.jsx)("p",{children:i("You are about to remove this code from your list of available code hashes. Once completed, should you need to access it again, you will have to manually add the code hash again.")}),(0,a.jsx)("p",{children:i("This operation does not remove the uploaded code WASM and ABI from the chain, nor any deployed contracts. The forget operation only limits your access to the code on this browser.")})]})},"modal-forget-account")]})}),(0,a.jsx)("td",{className:"all top",children:x&&(0,a.jsx)(k,{contractAbi:x,onSelectConstructor:b,withConstructors:!0})}),(0,a.jsxs)("td",{className:"together codeHash",children:[(0,a.jsx)("div",{children:`${s.json.codeHash.slice(0,8)}${s.json.codeHash.slice(-6)}`}),(0,a.jsx)(r.i8,{value:s.json.codeHash})]}),(0,a.jsx)("td",{className:"start together",children:d&&(d.isSome?i("Available"):i("Not on-chain"))}),(0,a.jsxs)("td",{className:"button",children:[(0,a.jsx)(r.$n,{icon:"trash",onClick:p}),!x&&(0,a.jsx)(r.$n,{icon:"upload",label:i("deploy"),onClick:g})]})]})}),_=n.memo(function({onShowDeploy:e}){const{t:s}=c(),t=(0,n.useRef)([[s("code hashes"),"start"],[],[],[s("status"),"start"],[]]);return(0,a.jsx)(r.XI,{empty:s("No code hashes available"),header:t.current,children:P.getAllCode().map(s=>(0,a.jsx)(Z,{code:s,onShowDeploy:e},s.json.codeHash))})});var J=t(72286),K=t(18670),Q=t(11773),ee=t(41358),se=t(49919),te=t(44366),ae=t(770),ne=t(51524),re=t(3236),oe=t(29220),ie=t(98893);const le=n.memo(function({isDisabled:e,onChange:s,onEnter:t,params:r,registry:o}){const[i,l]=(0,n.useState)([]);(0,n.useEffect)(()=>{r&&l(r)},[r]);const c=(0,n.useCallback)(e=>s(e.map(({value:e})=>e)),[s]);return i.length?(0,a.jsx)(ie.Ay,{isDisabled:e,onChange:c,onEnter:t,params:i,registry:o}):null}),ce=n.memo(function({className:e,estimatedWeight:s,estimatedWeightV2:t,isCall:o,weight:{executionTime:i,isValid:l,isWeightV2:d,megaGas:u,megaRefTime:m,percentage:h,proofSize:p,setIsEmpty:x,setMegaGas:g,setMegaRefTime:b,setProofSize:f}}){const{t:j}=c(),[v,y]=(0,n.useState)(!0),C=(0,n.useMemo)(()=>s?s.div(ne.i5).iadd(ne.Uu):null,[s]),w=(0,n.useMemo)(()=>t?t.refTime.toBn().div(ne.i5).iadd(ne.Uu):null,[t]),k=(0,n.useMemo)(()=>t?t.proofSize.toBn():null,[t]);(0,n.useEffect)(()=>{v&&C&&g(C)},[C,g,v]),(0,n.useEffect)(()=>{v&&w&&b(w)},[w,b,v]),(0,n.useEffect)(()=>{v&&k&&f(k)},[k,f,v]),(0,n.useEffect)(()=>{x(v&&!!o)},[o,x,v]);const S=!!C&&v;return(0,a.jsx)("div",{className:e,children:d?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.YI,{defaultValue:w&&S?w.toString():void 0,isDisabled:S,isError:!l,isZeroable:o,label:!w||o&&v?j("max RefTime allowed (M)"):j("max RefTime allowed (M, {{estimatedRefTime}} estimated)",{replace:{estimatedMgRefTime:w.toString()}}),onChange:S?void 0:b,value:S?void 0:o&&v?ne.Yz:m,children:(t||o)&&(0,a.jsx)(r.lM,{label:j(o?"max read gas":"use estimated gas"),onChange:y,value:v})}),(0,a.jsx)(r.YI,{defaultValue:k&&S?k.toString():void 0,isDisabled:S,isError:!l,isZeroable:o,label:!k||o&&v?j("max ProofSize allowed"):j("max ProofSize allowed ({{estimatedProofSize}} estimated)",{replace:{estimatedProofSize:k.toString()}}),onChange:S?void 0:f,value:S?void 0:o&&v?ne.Yz:p}),(0,a.jsxs)("div",{className:"contracts--Input-meter",children:[j("{{executionTime}}s execution time",{replace:{executionTime:i.toFixed(3)}}),", ",j("{{percentage}}% of block weight",{replace:{percentage:h.toFixed(2)}})]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.YI,{defaultValue:C&&S?C.toString():void 0,isDisabled:S,isError:!l,isZeroable:o,label:!C||o&&v?j("max gas allowed (M)"):j("max gas allowed (M, {{estimatedMg}} estimated)",{replace:{estimatedMg:C.toString()}}),onChange:S?void 0:g,value:S?void 0:o&&v?ne.Yz:u,children:(s||o)&&(0,a.jsx)(r.lM,{label:j(o?"max read gas":"use estimated gas"),onChange:y,value:v})}),(0,a.jsxs)("div",{className:"contracts--Input-meter",children:[j("{{executionTime}}s execution time",{replace:{executionTime:i.toFixed(3)}}),", ",j("{{percentage}}% of block weight",{replace:{percentage:h.toFixed(2)}})]})]})})});var de=t(13648),ue=t(27010);const me=(0,$.F)("useWeight",function(){const{api:e}=(0,u.g)(),s=(0,de.y)(),t=!!e.registry.createType("Weight").proofSize,[a,r]=(0,n.useState)((0,ue.iO)(e.consts.system.blockWeights?e.consts.system.blockWeights.maxBlock:e.consts.system.maximumBlockWeight).v1Weight.div(ne.i5).div(ne.Xx)),[o,i]=(0,n.useState)(e.consts.system.blockWeights?e.consts.system.blockWeights.perClass.normal.maxExtrinsic.unwrapOrDefault().refTime.toBn().div(ne.i5).div(ne.Xx):ne.Yz),[l,c]=(0,n.useState)(e.consts.system.blockWeights?e.consts.system.blockWeights.perClass.normal.maxExtrinsic.unwrapOrDefault().proofSize.toBn():ne.Yz),[d,m]=(0,n.useState)(!1),h=(0,n.useCallback)(s=>r(s||(0,ue.iO)(e.consts.system.blockWeights?e.consts.system.blockWeights.maxBlock:e.consts.system.maximumBlockWeight).v1Weight.div(ne.i5).div(ne.Xx)),[e]),p=(0,n.useCallback)(s=>i(s||e.consts.system.blockWeights?e.consts.system.blockWeights.perClass.normal.maxExtrinsic.unwrapOrDefault().refTime.toBn().div(ne.i5).div(ne.Xx):ne.Yz),[e]),x=(0,n.useCallback)(s=>c(s||e.consts.system.blockWeights?e.consts.system.blockWeights.perClass.normal.maxExtrinsic.unwrapOrDefault().proofSize.toBn():ne.Yz),[e]);return(0,n.useMemo)(()=>{let n=0,r=0,i=ne.Yz,c=e.registry.createType("WeightV2",{proofSize:ne.Yz,refTime:ne.Yz}),u=!1;return a&&(i=a.mul(ne.i5),n=i.mul(s).div((0,ue.iO)(e.consts.system.blockWeights?e.consts.system.blockWeights.maxBlock:e.consts.system.maximumBlockWeight).v1Weight).toNumber(),r=n/s.toNumber()*100,n/=3e3,u=!a.isZero()&&r<65),t&&o&&l&&(c=e.registry.createType("WeightV2",{proofSize:l,refTime:o.mul(ne.i5)}),n=o.mul(ne.i5).mul(s).div(e.consts.system.blockWeights?e.consts.system.blockWeights.perClass.normal.maxExtrinsic.unwrapOrDefault().refTime.toBn():ne.Uu).toNumber(),r=n/s.toNumber()*100,n/=3e3,u=!o.isZero()),{executionTime:n,isEmpty:d,isValid:d||u,isWeightV2:t,megaGas:a||ne.Yz,megaRefTime:o||ne.Yz,percentage:r,proofSize:l||ne.Yz,setIsEmpty:m,setMegaGas:h,setMegaRefTime:p,setProofSize:x,weight:i,weightV2:c}},[e,s,d,t,a,o,l,m,h,p,x])}),he=n.memo(function({onClose:e}){const{t:s}=c(),{api:t}=(0,u.g)(),[o,l]=(0,K.C)(),[m,h,p]=(0,Q.l)(),[[x,g],f]=(0,n.useState)([null,null]),[j,v]=(0,n.useState)(0),[y,C,w]=(0,ee.W)(ne.Yz),[k,S]=(0,n.useState)([]),[[A,F],I]=(0,n.useState)([null,!1]),[E,T,D]=(0,se.N)(),{abiName:M,contractAbi:B,errorText:$,isAbiError:L,isAbiSupplied:V,isAbiValid:R,onChangeAbi:H,onRemoveAbi:q}=z(),O=me(),W=(0,n.useMemo)(()=>R&&F&&A&&B?new J.vZ(t,B,A):null,[t,B,R,F,A]),U=(0,n.useMemo)(()=>B?B.constructors.map((e,s)=>({info:e.identifier,key:e.identifier,text:(0,a.jsx)(b,{asConstructor:!0,message:e}),value:s})):[],[B]);(0,n.useEffect)(()=>{v(0)},[U]),(0,n.useEffect)(()=>{S([])},[B,j]),(0,n.useEffect)(()=>{I(B&&(0,re.H)(B.info.source.wasm)?[B.info.source.wasm,!0]:[null,!1])},[B]),(0,n.useEffect)(()=>{M&&D(M)},[M,D]),(0,n.useEffect)(()=>{(async function(){let e=null,s=null;try{if(W&&B?.constructors[j]?.method&&y&&o){const s=[o,B?.constructors[j].isPayable?t.registry.createType("Balance",y):t.registry.createType("Balance",ne.Yz),O.weightV2,null,{Upload:t.registry.createType("Raw",A)},B?.constructors[j]?.toU8a(k),""],a=await t.call.contractsApi.instantiate(...s);e=W.tx[B.constructors[j].method]({gasLimit:a.gasRequired,storageDepositLimit:a.storageDeposit.isCharge?a.storageDeposit.asCharge:null,value:B?.constructors[j].isPayable?y:void 0},...k)}}catch(e){s=e.message}f(()=>[e,s])})().catch(e=>console.error(e))},[o,A,t,W,B,j,y,k,O]);const G=(0,n.useCallback)((e,s)=>{I([e,(0,re.H)(e)]),D(s.replace(".wasm","").replace("_"," "))},[D]),Y=(0,n.useCallback)(e=>{e.blueprint&&P.saveCode(e.blueprint.codeHash,{abi:(0,oe.A)(e.blueprint.abi.json),name:E||"<>",tags:[]}),e.contract&&ae.AC.saveContract(e.contract.address.toString(),{contract:{abi:(0,oe.A)(e.contract.abi.json),genesisHash:t.genesisHash.toHex()},name:E||"<>",tags:[]})},[t,E]),X=!!o&&!(0,i.k)(E)&&T&&F&&V&&R&&!!x&&2===m,Z=L||!V;return(0,a.jsxs)(r.aF,{header:s("Upload & deploy code {{info}}",{replace:{info:`${m}/2`}}),onClose:e,children:[(0,a.jsxs)(r.aF.Content,{children:[1===m&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.B4,{isInput:!1,label:s("deployment account"),labelExtra:(0,a.jsx)(te.A,{label:s("transferable"),params:o}),onChange:l,type:"account",value:o}),(0,a.jsx)(N,{contractAbi:B,errorText:$,isError:Z,isSupplied:V,isValid:R,label:s("json for either ABI or .contract bundle"),onChange:H,onRemove:q,withWasm:!0}),!Z&&B&&(0,a.jsxs)(a.Fragment,{children:[!B.info.source.wasm.length&&(0,a.jsx)(r.bT,{isError:!F,label:s("compiled contract WASM"),onChange:G,placeholder:A&&!F&&s("The code is not recognized as being in valid WASM format")}),(0,a.jsx)(d,{isError:!T,onChange:D,value:E||void 0})]})]}),2===m&&B&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.ms,{isDisabled:B.constructors.length<=1,label:s("deployment constructor"),onChange:v,options:U,value:j}),(0,a.jsx)(le,{onChange:S,params:B.constructors[j].args,registry:B.registry}),B.constructors[j].isPayable&&(0,a.jsx)(r.xg,{isError:!C,isZeroable:!0,label:s("value"),onChange:w,value:y}),(0,a.jsx)(ce,{weight:O}),g&&(0,a.jsx)(r.o_,{content:g})]})]}),(0,a.jsxs)(r.aF.Actions,{children:[1===m?(0,a.jsx)(r.$n,{icon:"step-forward",isDisabled:!W||!B,label:s("Next"),onClick:h}):(0,a.jsx)(r.$n,{icon:"step-backward",label:s("Prev"),onClick:p}),(0,a.jsx)(r.jX,{accountId:o,extrinsic:x,icon:"upload",isDisabled:!X,label:s("Deploy"),onClick:e,onSuccess:Y})]})]})});var pe=t(22067);const xe={allCodes:[],codeTrigger:Date.now()},ge=(0,$.F)("useCodes",function(){const e=(0,pe.T)(),[s,t]=(0,n.useState)(xe);return(0,n.useEffect)(()=>{const s=()=>{e.current&&t({allCodes:P.getAllCode(),codeTrigger:Date.now()})};P.on("new-code",s),P.on("removed-code",s),P.loadAll(s)},[]),s});var be=t(58797);const fe={allContracts:[],hasContracts:!1,isContract:()=>!1},je=(0,$.F)("useContracts",function(){const e=(0,pe.T)(),[s,t]=(0,n.useState)(fe);return(0,n.useEffect)(()=>{const s=ae.AC.contracts.subject.subscribe(s=>{if(e.current){const e=s?Object.keys(s):[],a=0!==e.length,n=s=>e.includes(s);t({allContracts:e,hasContracts:a,isContract:n})}});return()=>{(0,be.d)(()=>s.unsubscribe())}},[]),s}),ve=n.memo(function({address:e,onChange:s}){const{t}=c(),{api:o}=(0,u.g)(),i=(0,m.Gc)(o.query.contracts.contractInfoOf,[e]),[l,d]=(0,n.useState)(!1),[h,p]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{try{ae.AC.decodeAddress(e||""),d(!0)}catch{d(!1)}},[e]),(0,n.useEffect)(()=>{p(!!i?.isSome)},[i]),(0,n.useEffect)(()=>{s(l&&h)},[l,h,s]),h||!l?null:(0,a.jsx)(r.Mz,{type:"error",children:t(l?"Unable to find deployed contract code at the specified address":"The value is not in a valid address format")})}),ye=n.memo(function({onClose:e}){const{t:s}=c(),{api:t}=(0,u.g)(),[o,i]=(0,n.useState)(null),[l,m]=(0,n.useState)(!1),[h,p,x]=(0,se.N)("New Contract"),{abi:g,contractAbi:b,errorText:f,isAbiError:j,isAbiSupplied:v,isAbiValid:y,onChangeAbi:C,onRemoveAbi:w}=z([null,null],null,!0),k=(0,n.useCallback)(()=>{const s={action:"create"};if(o&&g&&h)try{const a={contract:{abi:g,genesisHash:t.genesisHash.toHex()},name:h,tags:[]};ae.AC.saveContract(o,a),s.account=o,s.status=o?"success":"error",s.message="contract added",e()}catch(e){console.error(e),s.status="error",s.message=e.message}},[g,o,t,h,e]),S=l&&p&&y;return(0,a.jsxs)(r.aF,{header:s("Add an existing contract"),onClose:e,children:[(0,a.jsx)(r.aF.Content,{children:(0,a.jsxs)(r.J8,{defaultName:h,isValid:!0,value:o||null,children:[(0,a.jsx)(r.pd,{autoFocus:!0,isError:!l,label:s("contract address"),onChange:i,value:o||""}),(0,a.jsx)(ve,{address:o,onChange:m}),(0,a.jsx)(d,{isContract:!0,isError:!p,onChange:x,value:h||void 0}),(0,a.jsx)(N,{contractAbi:b,errorText:f,isError:j||!y,isSupplied:v,isValid:y,onChange:C,onRemove:w})]})}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.$n,{icon:"save",isDisabled:!S,label:s("Save"),onClick:k})})]})});var Ce=t(39573),we=t(95927),ke=t.n(we);const Se=r.I4.div`
align-items: center;
display: flex;
.output {
flex: 1 1;
margin: 0.25rem 0.5rem;
}
`,Ne=n.memo(function({className:e="",onClear:s,outcome:{from:t,message:n,output:o,params:i,result:l,when:c}}){return(0,a.jsxs)(Se,{className:e,children:[(0,a.jsx)(r._x,{value:t}),(0,a.jsx)(r.k7,{className:"output",isError:!l.isOk,isFull:!0,label:(0,a.jsx)(b,{message:n,params:i}),labelExtra:(0,a.jsxs)("span",{className:"date-time",children:[c.toLocaleDateString()," ",c.toLocaleTimeString()]}),value:(0,p.A)("Text",l.isOk?o:l)}),(0,a.jsx)(r.$n,{icon:"times",onClick:s})]})});var Ae=t(74809);const Fe=new(ke())(5e12).isub(ne.Uu),Ie=(0,r.I4)(r.aF)`
.rpc-toggle {
margin-top: 1rem;
display: flex;
justify-content: flex-end;
}
.clear-all {
float: right;
}
.outcomes {
margin-top: 1rem;
}
`,Ee=n.memo(function({className:e="",contract:s,messageIndex:t,onCallResult:i,onChangeMessage:l,onClose:d}){const{t:m}=c(),{api:h}=(0,u.g)(),p=s.abi.messages[t],[x,g]=(0,K.C)(),[f,j]=(0,n.useState)(null),[v,y]=(0,n.useState)(null),[C,w,k]=(0,ee.W)(ne.Yz),[S,N]=(0,n.useState)([]),[A,F]=(0,n.useState)(null),[I,E]=(0,n.useState)([]),[T,D]=(0,o.e)(),M=me(),B=(0,Ce.d)(C),P=(0,Ce.d)(I);(0,n.useEffect)(()=>{j(null),y(null),E([])},[s,t]),(0,n.useEffect)(()=>{(async function(){if(x&&C&&p.isMutating){const e=[x,s.address,p.isPayable?h.registry.createType("Balance",C):h.registry.createType("Balance",ne.Yz),M.weightV2,null,p.toU8a(I)],t=await h.call.contractsApi.call(...e);F(()=>{try{return s.tx[p.method]({gasLimit:t.gasRequired,storageDepositLimit:t.storageDeposit.isCharge?t.storageDeposit.asCharge:null,value:p.isPayable?C:0},...I)}catch{return null}})}})().catch(e=>console.error(e))},[h,x,s,p,C,M,I]),(0,n.useEffect)(()=>{x&&p&&P&&B&&s.query[p.method](x,{gasLimit:-1,storageDepositLimit:null,value:p.isPayable?B:0},...P).then(({gasRequired:e,result:s})=>{M.isWeightV2?y(s.isOk?h.registry.createType("WeightV2",e):null):j(s.isOk?e.refTime.toBn():null)}).catch(()=>{j(null),y(null)})},[h,x,s,p,P,B,M.isWeightV2]);const $=(0,n.useCallback)(()=>{x&&p&&C&&M&&s.query[p.method](x,{gasLimit:M.isWeightV2?M.weightV2:M.isEmpty?-1:M.weight,storageDepositLimit:null,value:p.isPayable?C:0},...I).then(e=>{N([{...e,from:x,message:p,params:I,when:new Date},...S]),i&&i(t,e)}).catch(e=>{console.error(e),i&&i(t)})},[x,s.query,p,t,i,S,I,C,M]),L=(0,n.useCallback)(e=>()=>N([...S.filter((s,t)=>t!==e)]),[S]),V=!!(x&&M.isValid&&w),R=T||!p.isMutating&&!p.isPayable;return(0,a.jsxs)(Ie,{className:`${e} app--contracts-Modal`,header:m("Call a contract"),onClose:d,children:[(0,a.jsxs)(r.aF.Content,{children:[(0,a.jsx)(r.B4,{isDisabled:!0,label:m("contract to use"),type:"contract",value:s.address}),(0,a.jsx)(r.B4,{defaultValue:x,label:m("call from account"),labelExtra:(0,a.jsx)(te.A,{label:m("transferable"),params:x}),onChange:g,type:"account",value:x}),null!==t&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.ms,{defaultValue:t,isError:null===p,label:m("message to send"),onChange:l,options:(z=s,z?.abi.messages.map((e,s)=>({key:e.identifier,text:(0,a.jsx)(b,{message:e}),value:s}))||[]),value:t}),(0,a.jsx)(le,{onChange:E,params:p?p.args:void 0,registry:s.abi.registry})]}),p.isPayable&&(0,a.jsx)(r.xg,{isError:!w,isZeroable:!0,label:m("value"),onChange:k,value:C}),(0,a.jsx)(ce,{estimatedWeight:p.isMutating?f:Fe,estimatedWeightV2:p.isMutating?v:h.registry.createType("WeightV2",{proofSize:new(ke())(1e6),refTIme:Fe}),isCall:!p.isMutating,weight:M}),p.isMutating&&(0,a.jsx)(r.lM,{className:"rpc-toggle",label:m("read contract only, no execution"),onChange:D,value:T}),S.length>0&&(0,a.jsx)(r.c6,{className:"outcomes",isOpen:!0,summary:m("Call results"),children:S.map((e,s)=>(0,a.jsx)(Ne,{onClear:L(s),outcome:e},`outcome-${s}`))})]}),(0,a.jsx)(r.aF.Actions,{children:R?(0,a.jsx)(r.$n,{icon:"sign-in-alt",isDisabled:!V,label:m("Read"),onClick:$}):(0,a.jsx)(r.jX,{accountId:x,extrinsic:A,icon:"sign-in-alt",isDisabled:!V||!A,label:m("Execute"),onStart:d})})]});var z});var Te=t(60750);function De(e){return e.unwrapOr(null)}const Me=r.I4.tr`
td.top a+a {
margin-left: 0.75rem;
}
`,Be=n.memo(function({className:e,contract:s,index:t,links:i,onCall:l}){const{t:d}=c(),{api:h}=(0,u.g)(),p=(0,m.Gc)(h.query.contracts.contractInfoOf,[s.address],{transform:De}),[x,g]=(0,o.e)(),b=(0,n.useCallback)((e,s)=>l(t,e,s),[t,l]),f=(0,n.useCallback)(()=>{const e={account:s.address,action:"forget"};try{ae.AC.forgetContract(s.address.toString()),e.status="success",e.message=d("address forgotten")}catch(s){e.status="error",e.message=s.message}g()},[s.address,d,g]);return(0,a.jsxs)(Me,{className:e,children:[(0,a.jsxs)("td",{className:"address top",children:[x&&(0,a.jsx)(r.EX,{address:s.address.toString(),mode:"contract",onClose:g,onForget:f},"modal-forget-contract"),(0,a.jsx)(r.ov,{value:s.address})]}),(0,a.jsx)("td",{className:"all top",children:(0,a.jsx)(k,{contract:s,contractAbi:s.abi,isWatching:!0,onSelect:b,trigger:i?.length,withMessages:!0})}),(0,a.jsx)("td",{className:"top",children:i?.map(({blockHash:e,blockNumber:s},t)=>(0,a.jsxs)("a",{href:`#/explorer/query/${e}`,children:["#",s]},`${t}-${s}`))}),(0,a.jsx)("td",{className:"number",children:(0,a.jsx)(r.lp,{address:s.address,withBalance:!0,withBalanceToggle:!0})}),(0,a.jsx)("td",{className:"start together",children:!(0,Te.b)(p)&&(p?p.type:d("Not on-chain"))}),(0,a.jsx)("td",{className:"button",children:(0,a.jsx)(r.$n,{icon:"trash",onClick:g})})]})});const Pe=n.memo(function({contracts:e}){const{t:s}=c(),{api:t}=(0,u.g)(),o=(0,m.Gc)(t.derive.chain.subscribeNewBlocks),[{contractIndex:i,messageIndex:l,onCallResult:d},p]=(0,n.useState)({contractIndex:0,messageIndex:0}),[x,g]=(0,n.useState)(!1),[b,f]=(0,n.useState)({}),j=(0,n.useRef)([[s("contracts"),"start"],[void 0,void 0,3],[s("status"),"start"],[]]);(0,n.useEffect)(()=>{if(o){const s=o.block.extrinsics.filter(({method:e})=>t.tx.contracts.call.is(e)).map(({args:s})=>{const t=e.find(e=>s[0].eq(e));return t?{blockHash:o.block.header.hash.toHex(),blockNumber:(0,h.Z)(o.block.header.number),contractId:t}:null}).filter(e=>!!e);s.length&&f(e=>(s.forEach(s=>{e[s.contractId]=[s].concat(e[s.contractId]||[]).slice(0,3)}),{...e}))}},[t,e,o]);const v=(0,n.useMemo)(()=>function(e,s=[]){return s.map(s=>function(e,s){if(s){const t=(0,Ae.fJ)(s);return t?new J.AP(e,t,s):null}return null}(e,s.toString())).filter(e=>!!e)}(t,e),[t,e]),y=(0,n.useCallback)(()=>g(e=>!e),[]),C=(0,n.useCallback)((e,s,t)=>{p({contractIndex:e,messageIndex:s,onCallResult:t}),g(!0)},[]),w=(0,n.useCallback)(e=>p(s=>({...s,messageIndex:e})),[]),k=v[i]||null;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.XI,{empty:s("No contracts available"),header:j.current,children:v.map((e,s)=>(0,a.jsx)(Be,{contract:e,index:s,links:b[e.address.toString()],onCall:C},e.address.toString()))}),x&&k&&(0,a.jsx)(Ee,{contract:k,messageIndex:l,onCallResult:d,onChangeMessage:w,onClose:y})]})});var $e=t(49141);const Le=n.memo(function({codeHash:e,constructorIndex:s=0,onClose:t,setConstructorIndex:o}){const{t:i}=c(),{api:l}=(0,u.g)(),[m,h]=(0,n.useState)(null),[p,x,g]=(0,ee.W)(null),[f,j,v]=(0,ee.W)(ne.Yz),[y,C]=(0,n.useState)([]),[w,k]=(0,n.useState)(()=>(0,$e.t)()),[S,A]=(0,n.useState)(!1),F=me();(0,n.useEffect)(()=>{C([])},[s]);const I=(0,n.useMemo)(()=>P.getCode(e),[e]),[E,T,D]=(0,se.N)(I?.json.name),{contractAbi:M,errorText:B,isAbiError:$,isAbiSupplied:L,isAbiValid:V,onChangeAbi:R,onRemoveAbi:q}=z([I?.json.abi,I?.contractAbi],e,!0),O=(0,n.useMemo)(()=>V&&e&&M?new J.ZC(l,M,e):null,[l,e,M,V]),W=(0,n.useMemo)(()=>M?M.constructors.map((e,s)=>({info:e.identifier,key:e.identifier,text:(0,a.jsx)(b,{asConstructor:!0,message:e}),value:s})):[],[M]);(0,n.useEffect)(()=>{f&&h(()=>{if(O&&M?.constructors[s]?.method)try{return O.tx[M.constructors[s].method]({gasLimit:F.isWeightV2?F.weightV2:F.weight,salt:S?w:null,storageDepositLimit:null,value:M?.constructors[s].isPayable?f:void 0},...y)}catch{return null}return null})},[O,M,s,f,y,w,F,S]);const U=(0,n.useCallback)(e=>{e.contract&&(ae.AC.saveContract(e.contract.address.toString(),{contract:{abi:(0,oe.A)(e.contract.abi.json),genesisHash:l.genesisHash.toHex()},name:E||void 0,tags:[]}),t&&t())},[l,E,t]),G=!S||w&&(!w.startsWith("0x")||(0,H.qv)(w)),Y=T&&j&&F.isValid&&x&&G;return(0,a.jsxs)(r.aF,{header:i("Deploy a contract"),onClose:t,children:[(0,a.jsxs)(r.aF.Content,{children:[(0,a.jsx)(r.B4,{isInput:!1,label:i("deployment account"),labelExtra:(0,a.jsx)(te.A,{label:i("transferable"),params:p}),onChange:g,type:"account",value:p}),(0,a.jsx)(d,{isContract:!0,isError:!T,onChange:D,value:E||""}),!L&&(0,a.jsx)(N,{contractAbi:M,errorText:B,isError:$,isSupplied:L,isValid:V,onChange:R,onRemove:q}),M&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.ms,{isDisabled:M.constructors.length<=1,label:i("deployment constructor"),onChange:o,options:W,value:s}),(0,a.jsx)(le,{onChange:C,params:M.constructors[s]?.args,registry:M.registry})]}),M?.constructors[s].isPayable&&(0,a.jsx)(r.xg,{isError:!j,isZeroable:!0,label:i("value"),onChange:v,value:f}),(0,a.jsx)(r.pd,{isDisabled:!S,label:i("unique deployment salt"),labelExtra:(0,a.jsx)(r.lM,{label:i("use deployment salt"),onChange:A,value:S}),onChange:k,placeholder:i("0x prefixed hex, e.g. 0x1234 or ascii data"),value:S?w:i("<none>")}),(0,a.jsx)(ce,{weight:F})]}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.jX,{accountId:p,extrinsic:m,icon:"upload",isDisabled:!Y||!m,label:i("Deploy"),onClick:t,onSuccess:U,withSpinner:!0})})]})}),Ve=n.memo(function({trigger:e}){const{t:s}=c(),{api:t}=(0,u.g)(),o=(0,m.Gc)(t.query.contracts.accountCounter),[i,l]=(0,n.useState)(0),[d,p]=(0,n.useState)(0);return(0,n.useEffect)(()=>{o&&t.query.contracts.contractInfoOf.keys().then(e=>l(e.length)).catch(console.error)},[t,o]),(0,n.useEffect)(()=>{(t.query.contracts.pristineCode||t.query.contracts.codeStorage).keys().then(e=>p(e.length)).catch(console.error)},[t,e]),(0,a.jsxs)(r.cp,{children:[(0,a.jsx)("section",{children:(0,a.jsx)(r.dS,{label:s("addresses"),children:(0,h.Z)(o)})}),(0,a.jsxs)("section",{children:[(0,a.jsx)(r.dS,{label:s("code hashes"),children:(0,h.Z)(d)}),(0,a.jsx)(r.dS,{label:s("contracts"),children:(0,h.Z)(i)})]})]})}),Re=r.I4.div`
.ui--Table td > article {
background: transparent;
border: none;
margin: 0;
padding: 0;
}
`,ze=n.memo(function({className:e=""}){const{t:s}=c(),{allCodes:t,codeTrigger:i}=ge(),{allContracts:l}=je(),[d,u]=(0,o.e)(),[m,h,p]=(0,o.e)(),[x,g]=(0,o.e)(),[b,f]=(0,o.e)(),[j,v]=(0,n.useState)(),[y,C]=(0,n.useState)(0),w=(0,n.useCallback)((e,s)=>{v(e||t?.[0]?.json.codeHash||void 0),C(s),h()},[t,h]),k=(0,n.useCallback)(()=>p(!1),[p]);return(0,a.jsxs)(Re,{className:e,children:[(0,a.jsx)(Ve,{trigger:i}),(0,a.jsxs)(r.$n.Group,{children:[(0,a.jsx)(r.$n,{icon:"plus",label:s("Upload & deploy code"),onClick:f}),(0,a.jsx)(r.$n,{icon:"plus",label:s("Add an existing code hash"),onClick:g}),(0,a.jsx)(r.$n,{icon:"plus",label:s("Add an existing contract"),onClick:u})]}),(0,a.jsx)(Pe,{contracts:l,updated:i}),(0,a.jsx)(_,{onShowDeploy:w,updated:i}),j&&m&&(0,a.jsx)(Le,{codeHash:j,constructorIndex:y,onClose:k,setConstructorIndex:C}),b&&(0,a.jsx)(he,{onClose:f}),x&&(0,a.jsx)(O,{onClose:g}),d&&(0,a.jsx)(ye,{onClose:u})]})}),He=n.memo(function({basePath:e,className:s=""}){const{t}=c(),o=(0,n.useRef)([{isRoot:!0,name:"contracts",text:t("Contracts")}]);return(0,a.jsxs)("main",{className:`${s} contracts--App`,children:[(0,a.jsx)(r.tU,{basePath:e,items:o.current}),(0,a.jsx)(ze,{})]})})},10608(e,s,t){t.d(s,{A:()=>M});var a=t(31085),n=t(14041),r=t(18690),o=t(1445),i=t(69496),l=t(28138),c=t(97670),d=t(88274),u=t(61020),m=t(79129),h=t(770),p=t(59540),x=t(84645),g=t(37140);function b(){return(0,g.Bd)("app-addresses")}const f=n.memo(function({onClose:e,onStatusChange:s}){const{t}=b(),{api:r,isEthereum:i}=(0,u.g)(),[{isNameValid:l,name:c},d]=(0,n.useState)({isNameValid:!1,name:""}),[{address:g,addressInput:f,isAddressExisting:j,isAddressValid:v},y]=(0,n.useState)({address:"",addressInput:"",isAddressExisting:!1,isAddressValid:!1,isPublicKey:!1}),C=(0,m.Gc)(!!g&&v&&r.derive.accounts.info,[g]),w=(0,n.useMemo)(()=>v&&l&&!!C?.accountId,[v,l,C]),k=(0,n.useCallback)(e=>{let s="",t=!0,a=!1,n=!1;try{if(i){const t=(0,p.V)(e);s=(0,x.w)(t),n=20===t.length}else{const t=h.AC.decodeAddress(e);s=h.AC.encodeAddress(t),n=32===t.length}if(!t){const e=h.AC.getAddress(s);if(e){const s=e.meta.name||c;a=!0,t=!0,d({isNameValid:!!(s||"").trim(),name:s})}}}catch{t=!1}y({address:t?s:"",addressInput:e,isAddressExisting:a,isAddressValid:t,isPublicKey:n})},[i,c]),S=(0,n.useCallback)(e=>d({isNameValid:!!e.trim(),name:e}),[]),N=(0,n.useCallback)(()=>{const a={action:"create"};if(w&&C?.accountId){try{const e=C.accountId.toString();h.AC.saveAddress(e,{genesisHash:h.AC.genesisHash,name:c.trim(),tags:[]}),a.account=e,a.status=e?"success":"error",a.message=t(j?"address edited":"address created"),o.B4.setLastValue("address",e)}catch(e){a.status="error",a.message=e.message}s(a),e()}},[C,j,w,c,e,s,t]);return(0,a.jsxs)(o.aF,{header:t("Add an address"),onClose:e,children:[(0,a.jsx)(o.aF.Content,{children:(0,a.jsxs)(o.J8,{defaultName:c,noDefaultNameOpacity:!0,value:v?C?.accountId?.toString():void 0,children:[(0,a.jsx)(o.pd,{autoFocus:!0,className:"full",isError:!v,label:t("address"),onChange:k,onEnter:N,placeholder:t("new address"),value:f}),(0,a.jsx)(o.pd,{className:"full",isError:!l,label:t("name"),onChange:S,onEnter:N,value:c})]})}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.$n,{icon:"save",isDisabled:!w,label:t("Save"),onClick:N})})]})});var j=t(99655),v=t(31706),y=t(30520),C=t(6404);const w={available:!1,bonded:!1,locked:!1,redeemable:!1,reserved:!1,total:!0,unlocking:!1,vested:!1},k={available:!0,bonded:!0,locked:!0,nonce:!0,redeemable:!0,reserved:!0,total:!1,unlocking:!0,vested:!0},S=n.memo(function({address:e,className:s="",filter:t,isFavorite:r,isVisible:i,toggleFavorite:c,toggleVisible:d}){const{t:m}=b(),p=(0,u.g)(),x=(0,v.q)(e),g=(0,y.y)(e),[f,S]=(0,n.useState)([]),[N,A]=(0,n.useState)(""),[F,I]=(0,n.useState)(null),[E,T]=(0,n.useState)(null),[D,M]=(0,n.useState)(!1),[B,P]=(0,n.useState)(!1),[$,L]=(0,l.e)(!1),V=(0,n.useCallback)(e=>S(e.sort()),[]);(0,n.useEffect)(()=>{const s=h.AC.getAddress(e);I(s||null),T(s?.meta.genesisHash||null)},[]),(0,n.useEffect)(()=>{let s=null;for(let t=0;null===s&&t<j.kS.length;t++)s=j.kS[t](e);if(s)A(s);else{const{identity:e,nickname:s}=x||{};(0,C.T)(p.apiIdentity.query.identity?.identityOf)?e?.display&&A(e.display):s&&A(s)}},[e,p,x]),(0,n.useEffect)(()=>{const s=h.AC.getAddress(e);V(s?.meta?.tags||[]),A(s?.meta?.name||"")},[V,e]),(0,n.useEffect)(()=>{const s=t.trim().toLowerCase();let a=!0;0!==s.length&&(a=h.AC.encodeAddress(e,0).toLowerCase().includes(s)||e.toLowerCase().includes(s)||f.reduce((e,t)=>e||t.toLowerCase().includes(s),N.toLowerCase().includes(s))),d(e,a)},[N,e,t,f,d]);const R=(0,n.useCallback)(s=>{T(s);const t=h.AC.getAddress(e);t&&h.AC.saveAddress(e,{...t.meta,genesisHash:s}),T(s)},[e]),z=(0,n.useCallback)(()=>M(!D),[D]),H=(0,n.useCallback)(()=>P(!B),[B]),q=(0,n.useCallback)(()=>{if(e){const s={account:e,action:"forget"};try{h.AC.forgetAddress(e),s.status="success",s.message=m("address forgotten")}catch(e){s.status="error",s.message=e.message}}},[e,m]);if(!i)return null;const O=(0,a.jsxs)(o.W1,{children:[(0,a.jsx)(o.W1.Item,{isDisabled:!1,label:m("Forget this address"),onClick:z}),!p.isDevelopment&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.W1.Divider,{}),(0,a.jsx)(o.rl,{className:"addresses--network-toggle",genesisHash:E,onChange:R})]})]});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("tr",{className:`${s} isExpanded isFirst packedBottom`,children:[(0,a.jsx)(o.XI.Column.Favorite,{address:e,isFavorite:r,toggle:c}),(0,a.jsxs)("td",{className:"address all",children:[(0,a.jsx)(o.y1,{value:e,withShortAddress:!0}),e&&F&&(0,a.jsxs)(a.Fragment,{children:[D&&(0,a.jsx)(o.EX,{address:F.address,mode:"address",onClose:z,onForget:q},"modal-forget-account"),B&&(0,a.jsx)(o.XU,{onClose:H,recipientId:e},"modal-transfer")]})]}),(0,a.jsx)("td",{className:"actions button",children:(0,a.jsxs)(o.$n.Group,{children:[((0,C.T)(p.api.tx.balances?.transferAllowDeath)||(0,C.T)(p.api.tx.balances?.transfer))&&(0,a.jsx)(o.$n,{className:"send-button",icon:"paper-plane",label:m("send"),onClick:H},"send"),(0,a.jsx)(o.zD,{value:O})]})}),(0,a.jsx)(o.XI.Column.Expand,{isExpanded:$,toggle:L})]}),(0,a.jsxs)("tr",{className:`${s} isExpanded ${$?"":"isLast"} packedTop`,children:[(0,a.jsx)("td",{}),(0,a.jsx)("td",{className:"balance all",colSpan:2,children:(0,a.jsx)(o.lp,{address:e,balancesAll:g,withBalance:w})}),(0,a.jsx)("td",{})]}),(0,a.jsxs)("tr",{className:`${s} ${$?"isExpanded isLast":"isCollapsed"} packedTop`,children:[(0,a.jsx)("td",{}),(0,a.jsxs)("td",{className:"balance columar",colSpan:2,children:[(0,a.jsx)(o.lp,{address:e,balancesAll:g,withBalance:k}),(0,a.jsx)(o.Yt,{size:"tiny",children:(0,a.jsx)(o.Yt.Column,{children:(0,a.jsx)("div",{"data-testid":"tags",children:(0,a.jsx)(o.YD,{value:f,withTitle:!0})})})}),(0,a.jsx)(o.Yt,{is100:!0,children:(0,a.jsx)(o.Yt.Column,{children:(0,a.jsx)(o.e9,{data:e,type:"address",withTitle:!0})})})]}),(0,a.jsx)("td",{})]})]})});var N=t(45060),A=t.n(N);const F=n.memo(function({sortedAddresses:e}){const{t:s}=b(),t=(0,n.useCallback)(()=>{const s=e?.map(({address:e,isFavorite:s})=>{const t=h.AC.getAddress(e);return{address:e,isFavorite:s,name:t?.meta.name||e}}),t=new Blob([JSON.stringify(s,null,2)],{type:"application/json; charset=utf-8"});A().saveAs(t,`batch_exported_address_book_${(new Date).getTime()}.json`)},[e]);return e?.length?(0,a.jsx)(o.$n,{icon:"file-export",label:s("Export"),onClick:t}):(0,a.jsx)(a.Fragment,{})});var I=t(61640);const E=n.memo(function({favorites:e,onStatusChange:s,toggleFavorite:t}){const{t:r}=b(),{api:i,isEthereum:l}=(0,u.g)(),c=(0,n.useRef)(null),d=(0,n.useCallback)((e,t="queued")=>{s?.({action:r("Import file"),message:e,status:t})},[s,r]),m=(0,n.useCallback)(({address:e,name:s})=>{let t="",a=!0,n=!1,r=!1,o=!!s.trim();try{if(l){const s=(0,p.V)(e);t=(0,x.w)(s),r=20===s.length}else{const s=I.Ay.decodeAddress(e);t=I.Ay.encodeAddress(s),r=32===s.length}const i=I.Ay.getAddress(t);if(i){const e=i.meta.name||s;n=!0,a=!0,o=!!(e||"").trim()}}catch{a=!1}return{address:t,isAddressExisting:n,isAddressValid:a,isNameValid:o,isPublicKey:r}},[l]),h=(0,n.useCallback)(async s=>{const{address:a,name:n}=s,r=await i.derive.accounts.info(a),{isAddressExisting:l,isAddressValid:c,isNameValid:d}=m(s);if(!(c&&d&&r?.accountId)||!r?.accountId||l)return!1;try{const a=r.accountId.toString();return I.Ay.saveAddress(a,{genesisHash:I.Ay.genesisHash,name:n.trim(),tags:[]}),o.B4.setLastValue("address",a),s.isFavorite&&!e.includes(a)&&t(a),!0}catch(e){return!1}},[i.derive.accounts,e,t,m]),g=(0,n.useCallback)(()=>{c.current&&(c.current.value="",c.current.click())},[]),f=(0,n.useCallback)(e=>{try{d(r("Importing"),"queued");const s=new FileReader,t=e.target.files;if(!t)return d(r("no file chosen"),"error");if(s.readAsText(t[0],"UTF-8"),!/(.json)$/i.test(e.target.value))return d(r("file error"),"error");s.onload=async e=>{try{const s=JSON.parse(e.target?.result);if(!Array.isArray(s))return d(r("file content error"),"error");const t=[];for(const e of s)e.name&&e.address&&t.push(e);let a=0;for(const e of t)try{const s=await h(e);a+=Number(s)}catch{}a>0?d(r("Success"),"success"):d(r("no account imported"),"eventWarn")}catch{d(r("file content error"),"error")}}}catch{d(r("file content error"),"error")}},[h,d,r]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{accept:"application/json",onChange:f,ref:c,style:{display:"none"},type:"file"}),(0,a.jsx)(o.$n,{icon:"file-import",label:r("Import"),onClick:g})]})}),T=o.I4.div`
.summary-box-contacts {
align-items: center;
}
`,D=n.memo(function({className:e="",onStatusChange:s}){const{t}=b(),{allAddresses:r}=(0,i._)(),[u,m]=(0,l.e)(!1),[h,p]=(0,c.r)("accounts:favorites"),[x,g]=(0,n.useState)(),[j,v]=(0,n.useState)(""),y=(0,d.O)(),C=(0,n.useRef)([[t("contacts"),"start",4]]);(0,n.useEffect)(()=>{g(r.map(e=>({address:e,isFavorite:h.includes(e),isVisible:!0})).sort((e,s)=>e.isFavorite===s.isFavorite?0:s.isFavorite?1:-1))},[r,h]);const w=(0,n.useCallback)((e,s)=>{g(t=>t?.map(t=>t.address===e?{...t,isVisible:s}:t).sort((e,s)=>e.isVisible===s.isVisible?0:s.isVisible?1:-1))},[]);return(0,a.jsxs)(T,{className:e,children:[u&&(0,a.jsx)(f,{onClose:m,onStatusChange:s}),(0,a.jsxs)(o.cp,{className:"summary-box-contacts",children:[(0,a.jsx)("section",{children:(0,a.jsx)(o.ZY,{className:"media--1000",filterOn:j,label:t("filter by name or tags"),setFilter:v})}),(0,a.jsxs)(o.$n.Group,{children:[(0,a.jsx)(E,{favorites:h,onStatusChange:s,toggleFavorite:p}),(0,a.jsx)(F,{sortedAddresses:x}),(0,a.jsx)(o.$n,{icon:"plus",label:t("Add contact"),onClick:m})]})]}),(0,a.jsx)(o.XI,{empty:y&&x&&t("no addresses saved yet, add any existing address"),header:C.current,isSplit:!0,children:y&&x?.map(({address:e,isFavorite:s,isVisible:t})=>(0,a.jsx)(S,{address:e,filter:j,isFavorite:s,isVisible:t,toggleFavorite:p,toggleVisible:w},e))})]})}),M=n.memo(function({basePath:e,onStatusChange:s}){const{t}=b(),i=(0,n.useRef)([{isRoot:!0,name:"contacts",text:t("My contacts")}]);return(0,a.jsxs)("main",{children:[(0,a.jsx)(o.tU,{basePath:e,items:i.current}),(0,a.jsx)(r.BV,{children:(0,a.jsx)(r.qh,{path:e,children:(0,a.jsx)(r.qh,{element:(0,a.jsx)(D,{onStatusChange:s}),index:!0})})})]})})},15423(e,s,t){t.d(s,{A:()=>X});var a=t(31085),n=t(14041),r=t(5750),o=t.n(r),i=t(37140),l=t(1445),c=t(2393),d=t(61020),u=t(79129),m=t(73108),h=t(92100),p=t(76506),x=t(97186),g=t(33168),b=t(51524);function f(){return(0,i.Bd)("app-claims")}var j=t(39942),v=t.n(j),y=t(35038),C=t(79876),w=t(66615),k=t(59540),S=t(11243),N=t(83448),A=t(64792);function F(e){const s=e.toLowerCase(),t=(0,A.sp)(s.substring(2)).substring(2);let a="0x";for(let e=0;e<40;e++)a=`${a}${parseInt(t[e],16)>7?s[e+2].toUpperCase():s[e+2]}`;return a}function I(e,{recovery:s,signature:t}){const a=function(e){const s=(0,C.j)(`Ethereum Signed Message:\n${e.length.toString()}${e}`),t=(0,A.H1)(s);return(0,w.e)(t)}(e),n=v().recover(a,t,s);return r=v().publicKeyConvert(n,!1).subarray(1),F(`0x${(0,A.sp)(r).slice(-40)}`);var r}function E(e,s){switch(e){case"Pezkuwi":case"Pezkuwi CC1":return function(e){if(!e)return;const s=e.isRegular?"https://statement.pezkuwichain.io/regular.html":"https://statement.pezkuwichain.io/saft.html";return{sentence:`I hereby agree to the terms of the statement whose SHA-256 multihash is ${e.isRegular?"Qmc1XYqT6S39WNp2UeiRUrZichUWUPpGEThDE6dAb3f6Ny":"QmXEkMahfhHJPzT3RjkXiZVFi77ZeVeuxtAjhojGRNYckz"}. (This may be found at the URL: ${s})`,url:s}}(s);default:return}}function T(e,s,t,a,n,r){return a?r||!n?{params:[t,a],tx:e.tx.claims.claim}:{params:[t,a,E(s,n)?.sentence],tx:e.tx.claims.claimAttest}:{}}const D="\nfont-size: var(--font-size-h3);\ndisplay: flex;\nflex-direction: column;\njustify-content: center;\nmin-height: 12rem;\nalign-items: center;\nmargin: 0 1rem;\n\nh3 {\n font-family: monospace;\n font-size: 1.5rem;\n max-width: 100%;\n margin: 0.5rem;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\nh2 {\n margin: 0.5rem 0 2rem;\n font-family: monospace;\n font-size: 2.5rem;\n font-weight: var(--font-weight-normal);\n}\n",M=l.I4.div`${D}`,B=n.memo(function({accountId:e,className:s="",ethereumAddress:t,ethereumSignature:r,isOldClaimProcess:o,onSuccess:i,statementKind:c}){const{t:u}=f(),{api:m,systemChain:h}=(0,d.g)(),[p,x]=(0,n.useState)(null),[j,v]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{t&&(v(!0),m.query.claims.claims(t).then(e=>{x(e.unwrapOr(b.Yz)),v(!1)}).catch(e=>{console.error(e),v(!1)}))},[m,t]),!t||j||!p)return null;const y=p.gt(b.Yz);return(0,a.jsx)(l.Zp,{isError:!y,isSuccess:y,children:(0,a.jsxs)(M,{className:s,children:[u("Your Ethereum account"),(0,a.jsx)("h2",{children:F(t.toString())}),y?(0,a.jsxs)(a.Fragment,{children:[u("has a valid claim for"),(0,a.jsx)("h2",{children:(0,a.jsx)(g.A,{value:p})}),(0,a.jsx)(l.$n.Group,{children:(0,a.jsx)(l.jX,{icon:"paper-plane",isUnsigned:!0,label:u("Claim"),onSuccess:i,...T(m,h,e,r,c,o)})})]}):(0,a.jsx)(a.Fragment,{children:u("does not appear to have a valid claim. Please double check that you have signed the transaction correctly on the correct ETH account.")})]})})});function P({statementUrl:e,systemChain:s}){const{t}=f();switch(s){case"Pezkuwi":case"Pezkuwi CC1":return e?(0,a.jsx)("iframe",{src:e}):null;default:return(0,a.jsx)("p",{children:t("Warning: we did not find any attest statement for {{chain}}",{replace:{chain:s}})})}}const $=l.I4.div`
.statement{
border: 1px solid #c2c2c2;
background: #f2f2f2;
height: 15rem;
padding: 1rem;
width: 100%;
margin: 1rem 0;
white-space: normal;
p {
color: var(--color-text) !important;
}
iframe {
border: 0;
height: 100%;
width: 100%;
}
}
.statementUrl{
margin-left: 0.3rem
}
`,L=n.memo(function({className:e,kind:s,systemChain:t}){const{t:n}=f(),r=E(t,s)?.url;return r?(0,a.jsxs)($,{className:e,children:[n("Please read these terms and conditions carefully. By submitting this statement, you are deemed to have accepted these Terms and Conditions. If you do not agree to these terms, please refrain from accessing or proceeding. You can also find them at:"),(0,a.jsx)("a",{className:"statementUrl",href:r,rel:"noopener noreferrer",target:"_blank",children:r}),(0,a.jsx)("div",{className:"statement",children:(0,a.jsx)(P,{statementUrl:r,systemChain:t})})]}):null}),V=l.I4.div`${D}`,R=n.memo(function({accountId:e,className:s,ethereumAddress:t,onSuccess:r,statementKind:o,systemChain:i}){const c=(0,x.o)(),{t:u}=f(),{api:m}=(0,d.g)(),[h,p]=(0,n.useState)(null),[j,v]=(0,n.useState)(!1);(0,n.useEffect)(()=>{t&&(v(!0),m.query.claims.claims(t).then(e=>{p(e.unwrapOr(b.Yz)),v(!1)}).catch(e=>{console.error(e),v(!1)}))},[m,t]);const y=(0,n.useMemo)(()=>E(i,o)?.sentence,[i,o]);if(j||!h)return null;const C=h.isZero();return C||!y?(0,a.jsx)(l.Zp,{isError:!0,children:(0,a.jsxs)(V,{className:s,children:[C&&(0,a.jsx)("p",{children:u("There is no on-chain claimable balance associated with the Ethereum account {{ethereumAddress}}",{replace:{ethereumAddress:t}})}),!y&&(0,a.jsx)("p",{children:u("There is no on-chain attestation statement associated with the Ethereum account {{ethereumAddress}}",{replace:{ethereumAddress:t}})})]})}):c.isAccount(e)?(0,a.jsx)(l.Zp,{isSuccess:!0,children:(0,a.jsxs)(V,{className:s,children:[(0,a.jsx)(L,{kind:o,systemChain:i}),(0,a.jsx)("h2",{children:(0,a.jsx)(g.A,{label:u("Account balance:"),value:h})}),(0,a.jsx)(l.$n.Group,{children:(0,a.jsx)(l.jX,{accountId:e,icon:"paper-plane",isDisabled:!y,label:u("I agree"),onSuccess:r,params:[y],tx:m.tx.claims.attest})})]})}):(0,a.jsx)(l.Zp,{isError:!0,children:(0,a.jsxs)(V,{className:s,children:[u("We found a pre-claim with this Pezkuwi address. However, attesting requires signing with this account. To continue with attesting, please add this account as an owned account first."),(0,a.jsx)("h2",{children:(0,a.jsx)(g.A,{label:u("Account balance:"),value:h})})]})})});var z=t(98586);const H=l.I4.div`
font-size: var(--font-size-h3);
display: flex;
flex-direction: column;
justify-content: center;
min-height: 8rem;
align-items: center;
margin: 0 1rem;
.ui--AddressMini-address {
max-width: 20rem;
}
`,q=n.memo(function({className:e}){const{t:s}=f(),t=(0,z.A)();return t.length?(0,a.jsx)(l.Zp,{isError:!0,children:(0,a.jsxs)(H,{className:e,children:[t.length>1?s("You need to sign an attestation for the following accounts:"):s("You need to sign an attestation for the following account:"),t.map(e=>(0,a.jsx)(l.ov,{value:e},e))]})}):null});var O;!function(e){e[e.Account=0]="Account",e[e.ETHAddress=1]="ETHAddress",e[e.Sign=2]="Sign",e[e.Claim=3]="Claim"}(O||(O={}));const W="PRECLAIMS_LOADING",U=l.I4.pre`
cursor: copy;
font: var(--font-mono);
border: 1px dashed #c2c2c2;
background: #f2f2f2;
padding: 1rem;
width: 100%;
margin: 1rem 0;
white-space: normal;
word-break: break-all;
`,G=l.I4.textarea`
font: var(--font-mono);
padding: 1rem;
border: 1px solid var(--border-input);
border-radius: 0.25rem;
margin: 1rem 0;
resize: none;
width: 100%;
&::placeholder {
color: rgba(0, 0, 0, 0.5);
}
&::-ms-input-placeholder {
color: rgba(0, 0, 0, 0.5);
}
&:-ms-input-placeholder {
color: rgba(0, 0, 0, 0.5);
}
`,Y={transform:e=>e.unwrapOr(null)},X=n.memo(function({basePath:e}){const[s,t]=(0,n.useState)(!1),[r,x]=(0,n.useState)(null),[g,b]=(0,n.useState)(null),[j,v]=(0,n.useState)(O.Account),[C,A]=(0,n.useState)(null),{api:F,systemChain:T}=(0,d.g)(),{t:D}=f(),[M,P]=(0,n.useState)(W),$=!!M&&M!==W,V=(0,n.useRef)([{isRoot:!0,name:"create",text:D("Claim tokens")}]);(0,n.useEffect)(()=>{if(C){if(v(O.Account),x(null),P(W),!F.query.claims||!F.query.claims.preclaims)return P(null);F.query.claims.preclaims(C).then(e=>{const s=e.unwrapOr(null)?.toString();x(s),P(s)}).catch(e=>{console.error(e),P(null)})}},[C,F.query.claims,F.query.claims.preclaims]);const z=!F.tx.claims.claimAttest;(0,n.useEffect)(()=>{s&&setTimeout(()=>{t(!1)},1e3)},[s]);const H=(0,n.useCallback)(()=>{v(O.Account)},[]),X=(0,n.useCallback)(()=>{v(O.Sign)},[]),Z=(0,n.useCallback)(()=>{v(O.Claim)},[]),_=(0,n.useCallback)(()=>{$?Z():r||z?X():v(O.ETHAddress)},[r,Z,X,$,z]),J=(0,n.useCallback)(e=>{const{value:s}=e.target,{ethereumAddress:t,signature:a}=function(e){try{const{msg:s,sig:t}=JSON.parse(e||"{}");if(!s||!t)throw new Error("Invalid signature object");const a=function(e){const s=(0,k.V)(e);(0,S.vA)(65===s.length,`Invalid signature length, expected 65 found ${s.length}`);let t=s[64];t<27&&(t+=27);const a=t-27;return(0,S.vA)(0===a||1===a,"Invalid signature v value"),{recovery:a,signature:(0,w.e)(s.slice(0,64))}}(t);return{error:null,ethereumAddress:y.g.registry.createType("EthereumAddress",I(s,a)),signature:y.g.registry.createType("EcdsaSignature",(0,N.z)(a.signature,new Uint8Array([a.recovery])))}}catch(e){return console.error(e),{error:e,ethereumAddress:null,signature:null}}}(s);x(t?.toString()),b(a)},[]),K=(0,n.useCallback)(e=>{x(e.trim())},[]),Q=(0,n.useCallback)(()=>{t(!0)},[]),ee=(0,u.Gc)(!$&&!z&&!!r&&F.query.claims.signing,[r],Y),se=E(T,ee)?.sentence||"",te=(0,m.F)(F.consts.claims.prefix.toU8a(!0)),ae=C?`${te}${(0,h.X)((0,p.F)(C),-1,!1)}${se}`:"";return(0,a.jsxs)("main",{children:[(0,a.jsx)(l.tU,{basePath:e,items:V.current}),!z&&(0,a.jsx)(q,{}),(0,a.jsx)("h1",{children:(0,a.jsxs)(i.x6,{children:["Claim your ",(0,a.jsx)("em",{children:c.A.abbr})," tokens"]})}),(0,a.jsxs)(l.Yt,{children:[(0,a.jsxs)(l.Yt.Column,{children:[(0,a.jsxs)(l.Zp,{withBottomMargin:!0,children:[(0,a.jsx)("h2",{children:D("1. Select your {{chain}} account",{replace:{chain:T}})}),(0,a.jsx)(l.B4,{defaultValue:C,label:D("claim to account"),onChange:A,type:"all"}),j===O.Account&&(0,a.jsx)(l.$n.Group,{children:(0,a.jsx)(l.$n,{icon:"sign-in-alt",isDisabled:M===W,label:D(M===W?"Loading":"Continue"),onClick:_})})]}),j>=O.ETHAddress&&!$&&!z&&(0,a.jsxs)(l.Zp,{withBottomMargin:!0,children:[(0,a.jsx)("h2",{children:D("2. Enter the ETH address from the sale.")}),(0,a.jsx)(l.pd,{autoFocus:!0,className:"full",label:D("Pre-sale ethereum address"),onChange:K,value:r||""}),j===O.ETHAddress&&(0,a.jsx)(l.$n.Group,{children:(0,a.jsx)(l.$n,{icon:"sign-in-alt",isDisabled:!r,label:D("Continue"),onClick:X})})]}),j>=O.Sign&&!$&&(0,a.jsxs)(l.Zp,{children:[(0,a.jsx)("h2",{children:D("{{step}}. Sign with your ETH address",{replace:{step:z?"2":"3"}})}),!z&&(0,a.jsx)(L,{kind:ee,systemChain:T}),(0,a.jsx)("div",{children:D("Copy the following string and sign it with the Ethereum account you used during the pre-sale in the wallet of your choice, using the string as the payload, and then paste the transaction signature object below:")}),(0,a.jsx)(o(),{onCopy:Q,text:ae,children:(0,a.jsx)(U,{"data-for":"tx-payload","data-tip":!0,children:ae})}),(0,a.jsx)(l.m_,{place:"right",text:D(s?"copied":"click to copy"),trigger:"tx-payload"}),(0,a.jsx)("div",{children:D("Paste the signed message into the field below. The placeholder text is there as a hint to what the message should look like:")}),(0,a.jsx)(G,{onChange:J,placeholder:`{\n "address": "0x ...",\n "msg": "${te}:...",\n "sig": "0x ...",\n "version": "2"\n}`,rows:10}),j===O.Sign&&(0,a.jsx)(l.$n.Group,{children:(0,a.jsx)(l.$n,{icon:"sign-in-alt",isDisabled:!C||!g,label:D("Confirm claim"),onClick:Z})})]})]}),(0,a.jsx)(l.Yt.Column,{children:C&&j>=O.Claim&&($?(0,a.jsx)(R,{accountId:C,ethereumAddress:r,onSuccess:H,statementKind:ee,systemChain:T}):(0,a.jsx)(B,{accountId:C,ethereumAddress:r,ethereumSignature:g,isOldClaimProcess:z,onSuccess:H,statementKind:ee}))})]})]})})},17722(e,s,t){t.d(s,{B:()=>n});var a=t(37140);function n(){return(0,a.Bd)("app-democracy")}},19956(e,s,t){t.d(s,{A:()=>J});var a=t(31085),n=t(14041),r=t(1445),o=t(61020),i=t(1810),l=t(57991),c=t(19444),d=t(35256),u=t(56780),m=t(26101),h=t(58359),p=t(54789),x=t(86832),g=t(95927),b=t.n(g);const f=(e,s,{blocksPerTimeslice:t,blocktimeMs:a}={blocksPerTimeslice:80,blocktimeMs:6e3})=>{if(!s||!e)return console.error("Invalid input: one or more inputs are missing"),null;const n=new(b())(Date.now());try{const o=new(b())(a),i=new(b())(t),l=new(b())(Number(e)).mul(i),c=new(b())(s),d=l.sub(c).mul(o),u=n.add(d);return{formattedDate:(r=new Date(u.toNumber()),`${r.getDate()} ${r.toLocaleString("default",{month:"short"})} ${r.getFullYear()}`),timestamp:u.toNumber()}}catch(e){return console.error("Error in calculation:",e),null}var r};function j(e,s,t,a,n,r,o={blocksPerTimeslice:0,blocktimeMs:0}){const i=a*o.blocksPerTimeslice;return e.map(e=>{const a={core:s,maskBits:e?.info?.maskBits,task:e?.info?.task,type:e?.type};if([x.qk["Bulk Coretime"],x.qk.Reservation,x.qk["On Demand"]].includes(e.type))a.start=n.beginDate,a.end=n.endDate,a.startTimeslice=n.begin,a.endBlock=n.end*o.blocksPerTimeslice;else if(e.type===x.qk.Lease){const s=Math.floor(e.lastBlock/r)*r,t=f(s,i,o);a.end=t?.formattedDate??null,a.endBlock=s*o.blocksPerTimeslice}return a.owner=t?.owner.toString(),a})}const v=e=>(e||[]).reduce((e,s)=>(e[Number(s.task)]=s,e),{}),y={config:null,coretimeConsts:null,currentRegion:{begin:null,beginDate:null,end:null,endDate:null},saleInfo:null,status:null},C=(0,n.createContext)(y),w=({api:e,children:s,isApiReady:t})=>{const r=(0,u.y)(),o=(0,m.$)(e,t),i=(0,h.P)(e,t),l=(0,p.j)(e,t),c=(0,n.useMemo)(()=>i?.regionBegin,[i]),d=(0,n.useMemo)(()=>i&&o&&i?.regionBegin-o?.regionLength,[i,o]),x=(0,n.useMemo)(()=>l&&r&&l.lastTimeslice*r.relay.blocksPerTimeslice,[l,r]),g=(0,n.useMemo)(()=>c&&x&&f(Number(c),x)?.formattedDate,[c,x]),b=(0,n.useMemo)(()=>d&&x&&f(Number(d),x)?.formattedDate,[d,x]),j=(0,n.useMemo)(()=>o&&i&&l&&d&&b&&c&&g&&r?{config:o,coretimeConsts:r,currentRegion:{begin:d,beginDate:b,end:c,endDate:g},saleInfo:i,status:l}:y,[d,c,b,g,o,i,l,r]);return(0,a.jsx)(C.Provider,{value:j,children:s})},k=()=>(0,n.useContext)(C);var S=t(37140);function N(){return(0,S.Bd)("app-broker")}var A=t(28138),F=t(3789);const I={[x.qk.Reservation]:"orange",[x.qk.Lease]:"blue",[x.qk["Bulk Coretime"]]:"pink",[x.qk["On Demand"]]:"green"},E=r.I4.td`
width: 150px;
vertical-align: top;
@media (max-width: 768px) {
/* Mobile */
${e=>"mobile"===e.hide||"both"===e.hide?"display: none;":""}
}
@media (min-width: 769px) and (max-width: 1024px) {
/* Tablet */
${e=>"tablet"===e.hide||"both"===e.hide?"display: none;":""}
}
`,T=({header:e,hide:s,value:t})=>(0,a.jsxs)(E,{hide:s,children:[(0,a.jsx)("h5",{style:{opacity:"0.6"},children:e}),(0,a.jsx)("p",{children:t||(0,a.jsx)(a.Fragment,{children:" "})})]}),D=n.memo(function({data:e}){return e.task?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(T,{header:"Task",value:e.task}),(0,a.jsx)(T,{header:"Blocks per timeslice",value:e.maskBits}),(0,a.jsx)(T,{header:"Start ts",hide:"both",value:e.startTimeslice}),(0,a.jsx)(T,{header:"Start date",hide:"both",value:e.start}),(0,a.jsx)(T,{header:"End date",hide:"both",value:e.end}),(0,a.jsx)(T,{header:"Last block (relay)",value:e.endBlock}),(0,a.jsxs)(E,{hide:"mobile",children:[(0,a.jsx)("h5",{style:{opacity:"0.6"},children:"type"}),"number"==typeof e.type&&e.type in x.qk&&(0,a.jsx)(r.vw,{color:I[e.type],label:Object.values(x.qk)[e.type]})]}),e.owner?(0,a.jsxs)(E,{hide:"mobile",children:[(0,a.jsx)("h5",{style:{opacity:"0.6"},children:"Owner"}),(0,a.jsx)(r.ov,{isPadded:!1,value:e.owner},e.owner)]}):(0,a.jsx)("td",{})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{style:{width:200},children:"no task"}),(0,a.jsx)("td",{colSpan:7})]})}),M=n.memo(function({isExpanded:e,workplanData:s}){return s?(0,a.jsx)(a.Fragment,{children:s&&(0,a.jsxs)("tr",{className:" "+(e?"isExpanded isLast":"isCollapsed"),children:[(0,a.jsx)(D,{data:s}),(0,a.jsx)("td",{})]},s.core)}):(0,a.jsxs)("tr",{className:" "+(e?"isExpanded isLast":"isCollapsed"),style:{minHeight:"100px"},children:[(0,a.jsxs)("td",{children:[" ",(0,a.jsx)(r.y$,{})," "]}),(0,a.jsx)("td",{colSpan:7})]})}),B=n.memo(function({api:e,config:s,core:t,workload:o,workplan:i}){const l=(0,u.y)(),[c,d]=(0,A.e)(!1),[m,h]=(0,n.useState)(),[p,x]=(0,n.useState)(),{currentRegion:g,status:b}=k(),v=(0,n.useMemo)(()=>b?.lastTimeslice??0,[b]),y=(0,F.N)(e),C=(0,n.useMemo)(()=>y?.find(e=>e.core===t&&e.start<=v&&e.end>v),[y,t,v]);(0,n.useEffect)(()=>{if(!(o?.length&&v>0))return h([{core:t}]);h(j(o,t,C,v,{begin:g.begin||0,beginDate:g.beginDate||"",end:g.end||0,endDate:g.endDate||""},s.regionLength,l?.relay))},[o,C,v,t,s,l,g]),(0,n.useEffect)(()=>{if(i?.length&&b&&l&&g.endDate){const e=g.end||0,a=e+s.regionLength,n=b.lastTimeslice*l?.relay.blocksPerTimeslice;x(j(i,t,C,b.lastTimeslice,{begin:e,beginDate:g.endDate,end:a,endDate:f(a,n)?.formattedDate??""},s.regionLength,l?.relay))}},[i,C,b,t,s,l,g]);const w=i?.length;return(0,a.jsxs)(a.Fragment,{children:[!!m&&(0,a.jsx)("tr",{className:"isExpanded isFirst "+(c?"":"isLast"),children:m.map(e=>(0,a.jsxs)(n.Fragment,{children:[(0,a.jsx)(D,{data:e}),(0,a.jsxs)("td",{style:{paddingRight:"2rem",textAlign:"right",verticalAlign:"top"},children:[(0,a.jsxs)("h5",{style:{opacity:"0.6"},children:["Workplan ",i?.length?`(${i?.length})`:""]}),!!w&&(0,a.jsx)(r.L3,{expanded:c,onClick:d}),!w&&"none"]})]},`${e.endBlock}${e.core}`))},t),c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{style:{fontWeight:700,paddingTop:"2rem",width:150},children:"workplans"}),(0,a.jsx)("td",{colSpan:8})]}),p?.map(e=>(0,a.jsx)(M,{isExpanded:c,workplanData:e},e.core))]})]})}),P=n.memo(function({api:e,config:s,core:t,workload:o,workplan:i}){const{t:l}=N(),c=(0,n.useRef)([[l("core")]]),d=[[(0,a.jsxs)("div",{children:[c.current," ",t," ",(0,a.jsx)("span",{})]},`header${t}`),"core",9,void 0]];return(0,a.jsx)(r.XI,{emptySpinner:!0,header:d,isSplit:!1,children:(0,a.jsx)(B,{api:e,config:s,core:t,workload:o,workplan:i},t)},t)}),$=n.memo(function({api:e,data:s}){const{config:t}=k();return(0,a.jsx)(a.Fragment,{children:t&&s?.map(s=>(0,a.jsx)(P,{api:e,config:t,core:s?.core,workload:s?.workload,workplan:s?.workplan},s?.core))})});var L=t(39573);const V=r.I4.div`
@media (max-width: 768px) {
max-width: 100%:
}
`,R=n.memo(function({data:e,onFilter:s}){const[t,o]=(0,n.useState)(-1),[i,l]=(0,n.useState)(""),c=(0,n.useMemo)(()=>e?.length?Array.from({length:e.length||0},(e,s)=>s):[],[e]),{t:d}=N(),u=(0,L.d)(i),m=(0,n.useMemo)(()=>c&&[{text:d("All active/available cores"),value:-1}].concat(c.map(e=>({text:`Core ${e}`,value:e})).filter(e=>!!e.text)),[c,d]);(0,n.useEffect)(()=>{if(!e)return;const a=((e,s,t)=>e?s.filter(({workload:s,workplan:t})=>!!s?.filter(({info:s})=>s.task===e).length||!!t?.filter(({info:s})=>s.task===e).length):-1===t?s:s.filter(e=>e.core===t))(u,e,t);s(a)},[e,t,u,s]);const h=(0,n.useCallback)(e=>{o(e),l("")},[]),p=(0,n.useCallback)(e=>{l(e),o(-1)},[]);return(0,a.jsxs)(V,{style:{display:"flex",flexDirection:"column",gap:"1rem",marginBottom:"1.5rem",maxWidth:"300px"},children:[(0,a.jsx)(r.ms,{className:"isSmall",label:d("selected core"),onChange:h,options:m,value:t}),(0,a.jsx)("div",{style:{minWidth:"150px"},children:(0,a.jsx)(r.pd,{className:"full isSmall",label:d("teyrchain id"),onChange:p,placeholder:d("teyrchain id"),value:i})})]})});var z=t(26689),H=t(51524),q=t(79129);const O=n.memo(function({children:e,className:s}){const{api:t}=(0,o.g)(),n=(0,q.Gc)(t.query.broker?.configuration),r=n?.toJSON()?.regionLength;return(0,a.jsxs)("div",{className:s,children:[r?.toString()||"-",e]})}),W=n.memo(function({children:e,className:s}){const{api:t,isApiReady:n}=(0,o.g)(),r=(0,p.j)(t,n);return(0,a.jsxs)("div",{className:s,children:[r?.lastTimeslice||"-",e]})}),U=n.memo(function({children:e,className:s}){const{api:t}=(0,o.g)(),n=t.consts.broker?.timeslicePeriod;return(0,a.jsxs)("div",{className:s,children:[n?.toString(),e]})}),G=r.I4.div`
display: flex;
flex-wrap: wrap;
gap: 1rem;
`,Y=r.I4.section`
display: flex;
gap: 1rem;
@media (max-width: 768px) {
flex-direction: column;
margin-bottom: 2rem
}
`,X=n.memo(function({coreCount:e,workloadInfos:s}){const{t}=N(),{api:i,apiEndpoint:l}=(0,o.g)(),c=l?.ui.color||z.q,{idles:d,pools:u,tasks:m}=n.useMemo(()=>function(e,s){if(!e||!s)return{idles:0,pools:0,tasks:0};const{pools:t,tasks:a}=s.reduce((e,{info:s})=>(s.isTask?e.tasks+=1:s.isPool&&(e.pools+=1),e),{pools:0,tasks:0});return{idles:Number(e)-(t+a),pools:t,tasks:a}}(e,s),[e,s]),{config:h,currentRegion:p,saleInfo:x,status:g}=k();return(0,a.jsxs)(r.cp,{children:[(0,a.jsxs)(Y,{style:{display:"flex"},children:[i.query.broker&&(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(G,{children:[(0,a.jsx)(r.dS,{label:t("timeslice (ts)"),children:(0,a.jsx)(W,{})}),(0,a.jsx)(r.dS,{label:t("block per ts"),children:(0,a.jsx)(U,{})}),(0,a.jsx)(r.dS,{label:t("region (ts)"),children:(0,a.jsx)(O,{})}),(0,a.jsx)(r.dS,{label:t("total cores"),children:e}),(0,a.jsx)(r.dS,{label:t("cores sold/offered"),children:(0,a.jsxs)("div",{children:[x?.coresSold," / ",x?.coresOffered]})}),(0,a.jsx)(r.dS,{label:t("cycle progress"),progress:{isBlurred:!1,total:new(b())(h?.regionLength||0),value:h?.regionLength&&p.end&&g&&new(b())(h?.regionLength-(p.end-g?.lastTimeslice))||H.Yz,withTime:!1}})]})}),(0,a.jsx)("div",{className:"media--1400",style:{marginLeft:"2rem"},children:(0,a.jsx)(r.Xb,{data:[{color:"#FFFFFF",label:"Idle",value:d},{color:"#04AA6D",label:"Pools",value:u},{color:c,label:"Tasks",value:m}]})})]}),(0,a.jsx)("section",{children:p.begin&&p.end&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.dS,{className:"media--1200",label:t("sale dates"),children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{style:{fontSize:"14px"},children:p.beginDate}),(0,a.jsx)("div",{style:{fontSize:"14px"},children:p.endDate})]})}),(0,a.jsx)(r.dS,{className:"media--1200",label:t("sale ts"),children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{style:{fontSize:"14px"},children:p.begin}),(0,a.jsx)("div",{style:{fontSize:"14px"},children:p.end})]})})]})})]})}),Z=(e,s,t)=>{return{...e,lastBlock:s[e?.info.task]?.until||0,maskBits:e.info.maskBits,task:e.info.task,type:(a=s[e.info.task],n=t[e.info.task],r=e.info.isPool,r?x.qk["On Demand"]:n?x.qk.Reservation:a?x.qk.Lease:x.qk["Bulk Coretime"])};var a,n,r},_=n.memo(function({className:e}){const{api:s,apiEndpoint:t,isApiReady:r}=(0,o.g)(),{currentRegion:u,status:m}=k(),[h,p]=(0,n.useState)([]),[x,g]=(0,n.useState)(),b=(0,i.E)(s,r),f=(0,l.d)(s,r),j=(0,c.a)(s,r),y=(0,d.O)(s,r),C=(0,n.useMemo)(()=>y?v(y):[],[y]),w=(0,n.useMemo)(()=>j?v(j):[],[j]);return(0,n.useEffect)(()=>{f&&b&&m?.coreCount&&p(((e,s,t,a,n)=>Array.from({length:e},(e,r)=>{var o;return{core:r,workload:t?.length?(o=t,o.filter(e=>e.core===r).map(e=>Z(e,a,n))):[],workplan:s?.length?(e=>e.filter(e=>e.core===r).map(e=>({...Z(e,a,n),timeslice:e.timeslice})))(s):[]}}))(Number(m?.coreCount),f,b,C,w))},[f,b,C,w,m]),(0,a.jsxs)("div",{className:e,children:[!!u.beginDate&&!!u.endDate&&(0,a.jsx)(X,{apiEndpoint:t,coreCount:m?.coreCount.toString()||"-",workloadInfos:b}),!!h?.length&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(R,{data:h,onFilter:g}),!!x&&(0,a.jsx)($,{api:s,data:x,isApiReady:r})]}),!h?.length&&(0,a.jsx)("p",{style:{marginLeft:"22px",marginTop:"3rem",opacity:.7},children:" No data currently available"})]})}),J=n.memo(function({basePath:e,className:s}){const{t}=N(),i=(0,n.useRef)(function(e){return[{isRoot:!0,name:"overview",text:e("Overview")}]}(t)),{api:l,isApiReady:c}=(0,o.g)();return(0,a.jsx)("main",{className:s,children:(0,a.jsxs)(w,{api:l,isApiReady:c,children:[(0,a.jsx)(r.tU,{basePath:e,items:i.current}),(0,a.jsx)(_,{})]})})})},20666(e,s,t){t.d(s,{A:()=>y});var a=t(31085),n=t(14041),r=t(1445),o=t(61020),i=t(96348),l=t(72026),c=t(17722),d=t(79129),u=t(81899);const m=n.memo(function({className:e="",value:s}){const{t}=(0,c.B)(),{api:n}=(0,o.g)(),r=(0,d.Gc)(n.derive.democracy.preimage,[s]);return r?.proposal?(0,a.jsx)(u.A,{className:e,withBorder:!0,withPadding:!0,children:(0,a.jsx)(l.A,{labelHash:t("proposal hash"),value:r.proposal,withHash:!0})}):null});var h=t(98893),p=t(39139);const x={params:[],values:[]},g={transform:e=>e.unwrapOr(null)},b=n.memo(function({className:e="",value:s}){const{t}=(0,c.B)(),{api:i}=(0,o.g)(),[l]=(0,n.useState)(()=>s.unwrap()),u=(0,d.Gc)(i.query.treasury.proposals,[l],g),[{params:m,values:b},f]=(0,n.useState)(x);return(0,n.useEffect)(()=>{u&&f({params:[{name:"proposal",type:(0,p.c)("TreasuryProposal")}],values:[{isValid:!0,value:u}]})},[u]),u?(0,a.jsx)("div",{className:e,children:(0,a.jsxs)(h.Ay,{isDisabled:!0,params:m,values:b,children:[(0,a.jsx)(r.B4,{defaultValue:u.beneficiary,isDisabled:!0,label:t("beneficiary")}),(0,a.jsx)(r.xg,{defaultValue:u.value,isDisabled:!0,label:t("payout")})]})}):null}),f=["externalPropose","externalProposeDefault","externalProposeMajority","fastTrack"],j=["approveProposal","rejectProposal"],v=r.I4.td`
.shortHash {
+ div {
margin-left: 0.5rem;
}
}
`,y=n.memo(function({className:e="",imageHash:s,isCollective:t,proposal:n}){const{t:r}=(0,c.B)(),{api:d}=(0,o.g)(),u=(0,i.I2)(s),h=t||d.query.democracy?.preimages?n:u?.proposal;if(!h){const t=s.toString();return(0,a.jsx)("td",{className:`${e} all hash`,children:(0,a.jsx)("div",{className:"shortHash",children:t})})}const{method:p,section:x}=h.registry.findMetaCall(h.callIndex),g="treasury"===x&&j.includes(p),y="democracy"===x&&f.includes(p);return(0,a.jsx)(v,{className:`${e} all`,children:(0,a.jsxs)(l.A,{labelHash:r("proposal hash"),value:h,withHash:!g&&!y,children:[y&&(0,a.jsx)(m,{value:h.args[0]}),g&&(0,a.jsx)(b,{value:h.args[0]})]})})})},24736(e,s,t){t.d(s,{A:()=>o});var a=t(31085),n=t(14041),r=t(42909);const o=n.memo(function({basePath:e,className:s}){return(0,a.jsx)(r.A,{basePath:e,className:s,palletColl:"fellowshipCollective",palletPoll:"fellowshipReferenda"})})},30868(e,s,t){t.d(s,{A:()=>o});var a=t(31085),n=t(14041),r=t(42909);const o=n.memo(function({basePath:e,className:s}){return(0,a.jsx)(r.A,{basePath:e,className:s,palletColl:"ambassadorCollective",palletPoll:"ambassadorReferenda"})})},31539(e,s,t){t.d(s,{A:()=>n});var a=t(66530);const n=(0,t(55155).F)("useCounter",function(){return(0,a.r)("fellowshipReferenda")})},32125(e,s,t){t.d(s,{A:()=>l});var a=t(55155),n=t(97186),r=t(61020),o=t(79129);const i={transform:e=>e.filter(({votes:e})=>!!e).length},l=(0,a.F)("useCounter",function(){const{hasAccounts:e}=(0,n.o)(),{api:s,isApiReady:t}=(0,r.g)();return(0,o.Gc)(t&&e&&s.derive.council?.proposals,void 0,i)||0})},33202(e,s,t){t.d(s,{A:()=>y});var a=t(31085),n=t(14041),r=t(1445),o=t(59233),i=t(26577),l=t(21327);const c=n.memo(function({className:e,info:{accountId:s,deposit:t,isInvulnerable:o,lastBlock:c},lastBlock:d}){const u=(0,n.useMemo)(()=>c?(0,l.Z)(c):d,[c,d]);return(0,a.jsxs)("tr",{className:e,children:[(0,a.jsx)("td",{className:"badge number",children:o&&(0,a.jsx)(r.Ex,{color:"green",icon:"shield"})}),(0,a.jsx)("td",{className:"address all",children:(0,a.jsx)(r.y1,{value:s})}),(0,a.jsx)(r.XI.Column.Balance,{value:t}),(0,a.jsx)("td",{className:"number",children:(0,a.jsx)(i.A,{params:s})}),(0,a.jsx)("td",{className:"number",children:u})]})});var d=t(61020),u=t(79129),m=t(37140);function h(){return(0,m.Bd)("app-collator")}const p=n.memo(function({className:e}){const{t:s}=h(),{api:t}=(0,d.g)(),n=(0,u.Gc)(t.query.collatorSelection.desiredCandidates);return(0,a.jsx)(r.cp,{className:e,children:(0,a.jsx)("section",{children:n&&(0,a.jsx)(r.dS,{label:s("desired"),children:(0,l.Z)(n)})})})});var x=t(55155);const g={transform:e=>e.map(e=>({accountId:e.toString(),isInvulnerable:!0}))},b={transform:e=>Array.isArray(e)?e.map(({deposit:e,who:s})=>({accountId:s.toString(),deposit:e,isInvulnerable:!1})):e.strings.map(e=>({accountId:e,isInvulnerable:!1}))},f={transform:([[e],s])=>e.reduce((e,t,a)=>({...e,[t]:s[a]}),{}),withParamsTransform:!0},j=(0,x.F)("useCollatorImpl",function(){const{api:e}=(0,d.g)(),[s,t]=(0,n.useState)(),a=(0,n.useMemo)(()=>s?.map(({accountId:e})=>e),[s]),r=e.query.collatorSelection.candidates||e.query.collatorSelection.candidateList,o=(0,u.Gc)(e.query.collatorSelection.invulnerables,[],g),i=(0,u.Gc)(r,[],b),l=(0,u.Gc)(a&&e.query.collatorSelection.lastAuthoredBlock?.multi,[a],f);return(0,n.useEffect)(()=>o&&i&&t(()=>[...o,...i]),[i,o]),(0,n.useEffect)(()=>l&&t(e=>e&&function(e,s){let t=!1;const a=e.map(e=>!s[e.accountId]||e.lastBlock&&s[e.accountId].eq(e.lastBlock)?e:(t=!0,{...e,lastBlock:s[e.accountId]}));return t?a:e}(e,l)),[l]),s}),v=n.memo(function({className:e}){const{t:s}=h(),t=j(),{byAuthor:i}=(0,o.$)(),l=(0,n.useRef)([[s("collators"),"start",2],[s("deposit"),"number"],[s("balance"),"number"],[s("last #"),"number"]]);return(0,a.jsxs)("div",{className:e,children:[(0,a.jsx)(p,{}),(0,a.jsx)(r.XI,{empty:t&&s("No running collators"),header:l.current,children:t?.map(e=>(0,a.jsx)(c,{info:e,lastBlock:i[e.accountId]},e.accountId))})]})}),y=n.memo(function({basePath:e,className:s}){const{t}=h(),o=(0,n.useRef)([{isRoot:!0,name:"index",text:t("Overview")}]);return(0,a.jsxs)("main",{className:s,children:[(0,a.jsx)(r.tU,{basePath:e,items:o.current}),(0,a.jsx)(v,{})]})})},34202(e,s,t){t.d(s,{A:()=>b});var a=t(31085),n=t(14041),r=t(1445),o=t(61020),i=t(2899),l=t(44366),c=t(95927),d=t.n(c),u=t(51524),m=t(76733),h=t(9799),p=t(17722);const x=(0,h.X)(""),g=(0,r.I4)(r.aF)`
.toggleImminent {
margin: 0.5rem 0;
text-align: right;
}
`,b=n.memo(function({className:e="",imageHash:s,isImminent:t=!1,onClose:c}){const{t:b}=(0,p.B)(),{api:f,apiDefaultTxSudo:j}=(0,o.g)(),[v,y]=(0,n.useState)(null),[{encodedHash:C,encodedProposal:w,storageFee:k},S]=(0,n.useState)({encodedHash:x,encodedProposal:"",storageFee:null}),[N,A]=(0,n.useState)();(0,n.useEffect)(()=>{const e=N?.method.toHex()||"",s=f.consts.democracy.preimageByteDeposit?f.consts.democracy.preimageByteDeposit.mul(e?new(d())((e.length-2)/2):u.Yz):null;S({encodedHash:(0,h.X)(e),encodedProposal:e,storageFee:s})},[f,N]);const F=(0,n.useMemo)(()=>!s||((0,m.K)(s)?s===C:s.eq(C)),[C,s]);return(0,a.jsxs)(g,{className:e,header:b("Submit preimage"),onClose:c,size:"large",children:[(0,a.jsxs)(r.aF.Content,{children:[(0,a.jsx)(r.aF.Columns,{hint:b("This account will pay the fees for the preimage, based on the size thereof."),children:(0,a.jsx)(r.B4,{label:b("send from account"),labelExtra:(0,a.jsx)(l.A,{label:(0,a.jsx)("span",{className:"label",children:b("transferable")}),params:v}),onChange:y,type:"account"})}),(0,a.jsxs)(r.aF.Columns,{hint:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{children:b("The image (proposal) will be stored on-chain against the hash of the contents.")}),(0,a.jsx)("p",{children:b("When submitting a proposal the hash needs to be known. Proposals can be submitted with hash-only, but upon dispatch the preimage needs to be available.")})]}),children:[(0,a.jsx)(i.A,{defaultValue:j,label:b("propose"),onChange:A}),(0,a.jsx)(r.jC,{label:b("preimage hash"),value:C,withCopy:!0})]}),!t&&k&&(0,a.jsx)(r.aF.Columns,{hint:b("The calculated storage costs based on the size and the per-bytes fee."),children:(0,a.jsx)(r.xg,{defaultValue:k,isDisabled:!0,label:b("calculated storage fee")})})]}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.jX,{accountId:v,icon:"plus",isDisabled:!(N&&v&&F&&w),label:b("Submit preimage"),onStart:c,params:[w],tx:t?f.tx.democracy.noteImminentPreimage:f.tx.democracy.notePreimage})})]})})},41435(e,s,t){t.d(s,{A:()=>M});var a=t(31085),n=t(14041),r=t(1445),o=t(61020),i=t(28138),l=t(72721),c=t(61640),d=t(71971),u=t(33404);const m={children:"Storage",color:"blue",size:"tiny"},h=[{value:"rpcNetworkAuthoring",text:"Get authoring information",label:{color:"pink",children:"RPC",size:"tiny"},code:"// Returns all pending extrinsics, potentially grouped by sender\nconst unsub = await api.rpc.author.pendingExtrinsics((extrinsics) => {\n if(extrinsics.length === 0){\n console.log('No pending extrinsics');\n return;\n }\n console.log(extrinsics);\n});"},{value:"rpcListenToHead",text:"Listen to new Head",label:{color:"pink",children:"RPC",size:"tiny"},code:"// subscribe to new headers, printing the full info for 5 Blocks\nlet count = 0;\nconst unsub = await api.rpc.chain.subscribeNewHeads((header) => {\n console.log(`#${header.number}:`, header);\n\n if (++count === 5) {\n console.log('5 headers retrieved, unsubscribing');\n unsub();\n }\n});"},{value:"rpcQueryState",text:"Get state metadata",label:{color:"pink",children:"RPC",size:"tiny"},code:"// retrieve and log the complete metadata of your node\nconst metadata = await api.rpc.state.getMetadata();\n\nconsole.log('version: ' + metadata.version);\nconsole.log('formatted: ' + JSON.stringify(metadata.asLatest.toHuman(), null, 2));\n"},{value:"rpcSystemInfo",text:"Get system information",label:{color:"pink",children:"RPC",size:"tiny"},code:"// Retrieve the chain & node information via rpc calls\nconst [chain, nodeName, nodeVersion, properties] = await Promise.all([\n api.rpc.system.chain(),\n api.rpc.system.name(),\n api.rpc.system.version(),\n api.rpc.system.properties()\n]);\nconsole.log('You are connected to chain ' + chain)\nconsole.log('You are using: ' + nodeName + ' v' + nodeVersion);\n\nif (properties.size > 0) {\n console.log('Node specific properties:');\n properties.forEach((value, key) => {\n console.log(key, value);\n });\n} else {\n console.log('No specific chain properties found.');\n}"},{code:"// Get chain state information\n// Make our basic chain state / storage queries, all in one go\n\nconst [now, minimumValidatorCount, validators] = await Promise.all([\n api.query.timestamp.now(),\n api.query.staking.minimumValidatorCount(),\n api.query.session.validators()\n]);\n\nconsole.log('The current date is: ' + now);\nconsole.log('The minimum validator count: ' + minimumValidatorCount);\n\nif (validators && validators.length > 0) {\n // Retrieve the balances for all validators\n console.log('Validators');\n\n const validatorBalances = await Promise.all(\n validators.map((authorityId) => api.query.system.account(authorityId))\n );\n\n validators.forEach((authorityId, index) => {\n console.log('Validator: ' + authorityId.toString() )\n console.log('AccountData: ' + validatorBalances[index].toHuman() );\n });\n}\n",label:m,text:"Get chain state information",value:"storageGetInfo"},{code:"// Subscribe to system events via storage\napi.query.system.events((events) => {\n console.log('----- Received ' + events.length + ' event(s): -----');\n // loop through the Vec<EventRecord>\n events.forEach((record) => {\n // extract the phase, event and the event types\n const { event, phase } = record;\n const types = event.typeDef;\n // show what we are busy with\n console.log(event.section + ':' + event.method + '::' + 'phase=' + phase.toString());\n console.log(event.meta.docs.toString());\n // loop through each of the parameters, displaying the type and data\n event.data.forEach((data, index) => {\n console.log(types[index].type + ';' + data.toString());\n });\n });\n});",label:m,text:"Listen to system events",value:"storageSystemEvents"},{code:"// You may leave this example running and make a transfer\n// of any value from or to Alice address in the 'Transfer' App\nconst ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';\n\n// Retrieve the initial data\nlet [, { free: previous }] = await api.query.system.account(ALICE);\n\nconsole.log('ALICE has a balance of ' + previous);\n\n// Subscribe and listen to balance changes\napi.query.system.account(ALICE, ([, { free }]) => {\n // Calculate the delta\n const change = free.sub(previous);\n // Only display positive value changes (Since we are pulling 'previous' above already,\n // the initial balance change will also be zero)\n if (!change.isZero()) {\n previous = free;\n console.log('New transaction of: '+ change);\n }\n});",label:m,text:"Listen to balance changes",value:"storageListenToBalanceChange"},{code:"// You may leave this example running and make a transfer\n// of any value from or to Alice/Bob address in the 'Transfer' App\nconst ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';\nconst BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';\n\nconsole.log('Tracking balances for:', [ALICE, BOB])\n\n// Subscribe and listen to several balance changes\napi.query.system.account.multi([ALICE, BOB], (info) => {\n console.log('Change detected, new balances: ', info)\n});",label:m,text:"Listen to multiple balances changes",value:"storageListenToMultipleBalancesChange"},{code:"// This example set shows how to make queries at a point\nconst ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';\n\n// retrieve the balance, once-off at the latest block\nconst { data: { free } } = await api.query.system.account(ALICE);\n\nconsole.log('Alice has a current balance of', free.toHuman());\n\n// retrieve balance updates with an optional value callback\nconst balanceUnsub = await api.query.system.account(ALICE, ({ data: { free } }) => {\n console.log('Alice has an updated balance of', free.toHuman());\n});\n\n// retrieve the balance at a block hash in the past\nconst header = await api.rpc.chain.getHeader();\nconst prevHash = await api.rpc.chain.getBlockHash(header.number.unwrap().subn(42));\nconst { data: { free: prev } } = await api.query.system.account.at(prevHash, ALICE);\n\nconsole.log('Alice had a balance of', prev.toHuman(), '(42 blocks ago)');\n\n// useful in some situations - the value hash and storage entry size\nconst currHash = await api.query.system.account.hash(ALICE);\nconst currSize = await api.query.system.account.size(ALICE);\n\nconsole.log('Alice account entry has a value hash of', currHash, 'with a size of', currSize);",label:m,text:"Retrieve historic query data",value:"storageRetrieveInfoOnQueryKeys"},{code:"// this example shows how to retrieve the hex representation of a storage key\n\nconst ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';\n\n// show the key for an entry without arguments\nconsole.log(api.query.timestamp.now.key());\n\n// show the key for a map entry (single argument)\nconsole.log(api.query.system.account.key(ALICE));\n\n// show the key prefix for a map\nconsole.log(api.query.system.account.keyPrefix());\n\n// show the key for a double map\nconsole.log(api.query.staking.erasStakers.key(0, ALICE));\n\n// show the key prefix for a doublemap\nconsole.log(api.query.staking.erasStakers.keyPrefix());\n",label:m,text:"Get underlying storage key hex values",value:"storageKeys"},{value:"constsStakingParameters",text:"Get staking parameters",label:{color:"green",children:"Consts",size:"tiny"},code:"// Get SRML staking parameters as consts\n// 'parameter_types' were added to bizinikiwi with spec_version: 101.\n// This example will throw an error if used with versions before that.\n\nconst bondingDuration = api.consts.staking.bondingDuration;\nconst sessionsPerEra = api.consts.staking.sessionsPerEra;\n\nconsole.log('Staking bonding duration: ' + bondingDuration);\nconsole.log('Staking sessions per era: ' + sessionsPerEra);"},{value:"extrinsicMakeTransfer",text:"Make transfer and listen to events",label:{color:"grey",children:"Extrinsics",size:"tiny"},code:"// Make a transfer from Alice to Bob and listen to system events.\n// You need to be connected to a development chain for this example to work.\nconst ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';\nconst BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';\n\n// Get a random number between 1 and 100000\nconst randomAmount = Math.floor((Math.random() * 100000) + 1);\n\n// Create a extrinsic, transferring randomAmount units to Bob.\nconst transfer = api.tx.balances.transferAllowDeath(BOB, randomAmount);\n\n// Sign and Send the transaction\nawait transfer.signAndSend(ALICE, ({ events = [], status }) => {\n if (status.isInBlock) {\n console.log('Successful transfer of ' + randomAmount + ' with hash ' + status.asInBlock.toHex());\n } else {\n console.log('Status of transfer: ' + status.type);\n }\n\n events.forEach(({ phase, event: { data, method, section } }) => {\n console.log(phase.toString() + ' : ' + section + '.' + method + ' ' + data.toString());\n });\n});"}];var p=t(37140);function x(){return(0,p.Bd)("app-js")}const g=n.memo(function({className:e="",isCustomExample:s,isRunning:t,removeSnippet:o,runJs:i,saveSnippet:l,stopJs:c}){const{t:d}=x(),[u,m]=(0,n.useState)(""),h=(0,n.useCallback)(e=>m(e),[]),p=(0,n.useCallback)(()=>{m("")},[]),g=(0,n.useCallback)(()=>{l(u),p()},[p,l,u]);return(0,a.jsxs)(r.$n.Group,{className:`${e} action-button`,children:[s?(0,a.jsx)(r.$n,{icon:"trash",onClick:o}):(0,a.jsx)(r.zD,{className:"popup-local",onCloseAction:p,value:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.pd,{autoFocus:!0,maxLength:50,min:1,onChange:h,onEnter:g,placeholder:d("Name your example"),value:u,withLabel:!1}),(0,a.jsx)(r.$n,{icon:"save",isDisabled:!u.length,label:d("Save snippet to local storage"),onClick:g})]}),children:(0,a.jsx)(r.$n,{icon:"save",isReadOnly:!1})}),t?(0,a.jsx)(r.$n,{icon:"times",onClick:c}):(0,a.jsx)(r.$n,{className:"play-button",icon:"play",onClick:i})]})}),b="pezkuwi-app-js-examples",f="pezkuwi-app-js-selected",j={children:"Custom",color:"orange",size:"tiny"};var v=t(63724),y=t(60750),C=t(63181);const w=e=>(0,v.b)(e)?e.stack?e.stack:e.toString():(0,y.b)(e)?"undefined":(0,C.k)(e)?"null":Array.isArray(e)?`[${e.map(w).join(", ")}]`:e instanceof Map?`{${[...e.entries()].map(([e,s])=>`${e.toString()}: ${w(s)}`).join(", ")}}`:e.toString(),k=({args:e,type:s},t)=>{try{return(0,a.jsx)("div",{className:`js--Log ${s}`,children:e.map(w).join(" ")},t)}catch(e){return(0,a.jsxs)("div",{className:`js--Log ${s} error`,children:["Internal error: ",e.stack||e.message]},t)}},S=r.I4.article`
background-color: #4e4e4e;
color: #ffffff;
display: flex;
flex-direction: column;
flex-grow: 1;
font: var(--font-mono);
font-variant-ligatures: common-ligatures;
line-height: 18px;
padding: 50px 10px 10px;
position: relative;
width: 40%;
.logs-wrapper {
display: flex;
flex: 1;
min-height: 0;
}
.logs-container {
flex: 1;
overflow: auto;
}
.logs-content {
height: auto;
}
.js--Log {
animation: fadein 0.2s;
margin: 0 0 5px 0;
word-break: break-all;
&.error {
color: #f88;
}
}
`,N=n.memo(function({children:e,className:s="",logs:t}){return(0,a.jsxs)(S,{className:`${s} container`,children:[(0,a.jsx)("div",{className:"logs-wrapper",children:(0,a.jsx)("div",{className:"logs-container",children:(0,a.jsx)("pre",{className:"logs-content",children:t.map(k)})})}),e]})}),A=["atob","btoa"],F={Atomics:null,Bluetooth:null,Clipboard:null,Document:null,Function:null,Location:null,ServiceWorker:null,SharedWorker:null,USB:null,global:null,window:null},I=JSON.parse(JSON.stringify(h));let E=!1;const T=r.I4.main`
display: flex;
flex-direction: column;
height: 100vh;
position: relative;
article {
p:last-child {
margin-bottom: 0;
}
}
.js--Selection {
margin-bottom: 1rem;
}
.js--Content {
align-content: stretch;
align-items: stretch;
display: flex;
height: 100%;
justify-content: space-between;
margin-bottom: 0;
}
.js--Dropdown {
position: relative;
z-index: 200;
.dropdown .menu > .item {
display: flex;
flex-direction: row-reverse;
justify-content: space-between;
}
}
.js--Editor,
.js--Output {
min-width: 200px;
.action-button {
margin: 0;
position: absolute;
right: 0.5rem;
top: 0.5rem;
z-index: 100;
}
}
.js--Editor {
flex-grow: 1;
overflow: auto;
padding: 0;
position: relative;
resize: horizontal;
width: 60%;
textarea {
outline: 0;
}
.codeflask {
background: transparent;
}
.codeflask--has-line-numbers {
z-index: 0;
}
.codeflask--has-line-numbers .codeflask__flatten {
font-size: 12px;
line-height: 18px;
min-width: calc(100% - 40px);
padding-top: 50px;
width: auto;
}
.codeflask__lines {
background: #f2f2f2;
line-height: 18px;
padding-top: 50px;
z-index: 100;
}
&::after {
bottom: 0;
content: '↔';
cursor: col-resize;
font-size: 20px;
height: 20px;
line-height: 18px;
position: absolute;
right: 0;
width: 22px;
z-index: 1;
}
}
.ui.popup.popup-local {
display: flex;
flex: 1 1 100%;
max-width: 300px;
}
.warnOverlay {
left: 0;
position: absolute;
right: 0;
top: -0.25rem;
z-index: 202;
article p:first-child {
padding-top: 1rem;
}
.ui--Button-Group {
margin-bottom: 0;
}
}
`,D=n.memo(function({basePath:e,className:s=""}){const{t}=x(),m=(0,o.g)(),h=(0,n.useRef)(null),p=(0,n.useRef)(null),[v,y]=(0,n.useState)(""),[C,w]=(0,n.useState)(!1),[k,S]=(0,n.useState)(!1),[D,M]=(0,i.e)(!0),[B,P]=(0,n.useState)([]),[$,L]=(0,n.useState)([]),[V,R]=(0,n.useState)([]),[z,H]=(0,n.useState)(I[0]),q=(0,n.useRef)([{isRoot:!0,name:"playground",text:t("Console")}]);(0,n.useEffect)(()=>{E||(I.forEach(e=>{e.code=`${function(e){const s=`api, hashing, ${e?"keyring, ":""}types, util`;return`// All code is wrapped within an async closure,\n// allowing access to ${s}.\n// (async ({ ${s} }) => {\n// ... any user code is executed here ...\n// })();\n\n`}(m.isDevelopment)}${e.code}`}),E=!0);const e={examples:localStorage.getItem(b),selectedValue:localStorage.getItem(f)},s=e.examples?JSON.parse(e.examples):[],t=[...s,...I],a=t.find(s=>s.value===e.selectedValue);P(s),w(a&&"custom"===a.type||!1),R(t),H(a||I[0])},[]),(0,n.useEffect)(()=>{y(z.code)},[z]);const O=(0,n.useCallback)(()=>L([]),[]),W=(0,n.useCallback)((e,s)=>{$.push({args:s,type:e}),L($.slice(0))},[$]),U=(0,n.useCallback)(()=>{h.current&&(h.current.api.disconnect().catch(console.error),h.current=null),S(!1)},[]),G=(0,n.useCallback)(()=>{(async function(){S(!0),O(),h.current=function({api:e,isDevelopment:s},t,a){return{...Object.keys(window).filter(e=>!e.includes("-")&&!A.includes(e)).reduce((e,s)=>(e[s]=null,e),{...F}),api:e.clone(),console:{error:(...e)=>a("error",e),log:(...e)=>a("log",e)},hashing:u,keyring:s?c.Ay.keyring:null,setIsRunning:t,types:l,uiKeyring:s?c.Ay:null,util:d,window}}(m,S,W),await h.current.api.isReady;try{if(!p.current?.contentWindow)throw new Error("No window found to run code");{const e=p.current.contentWindow.document;e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),p.current.contentWindow.injected=h.current;const s=`\n (async ({ ${Object.keys(p.current.contentWindow.injected).sort().slice(1).join(", ")} }) => {\n try {\n ${v}\n } catch (error) {\n console.error(error);\n } finally {\n if (typeof setIsRunning === 'function') {\n setIsRunning(false);\n } \n }\n })(injected);\n `,t=e.createElement("script");t.innerText=new Function("injected",s).bind({},p.current.contentWindow.injected)(),p.current.contentWindow.document.body.appendChild(t)}}catch(e){h.current&&h.current.console.error(e),S(!1)}})().catch(console.error)},[O,W,m,v]),Y=(0,n.useCallback)(e=>{if(U(),e.length){const s=V.find(s=>s.value===e);s&&(localStorage.setItem(f,e),O(),w("custom"===s.type),H(s))}},[O,U,V]),X=(0,n.useCallback)(()=>{const e=B.filter(e=>e.value!==z.value),s=[...e,...I];P(e),w("custom"===s[0].type),R(s),Y(s[0].value),localStorage.setItem(b,JSON.stringify(e))},[Y,B,z.value]),Z=(0,n.useCallback)(e=>{const s={code:v,label:j,text:e,type:"custom",value:`custom-${Date.now()}`},t=[s,...B,...I];localStorage.setItem(b,JSON.stringify([s,...B])),P([s,...B]),w(!0),R(t),H(s)},[v,B]),_="custom"===z.type?z.text:void 0;return(0,a.jsxs)(T,{className:`${s} js--App`,children:[(0,a.jsx)(r.tU,{basePath:e,items:q.current}),(0,a.jsx)("section",{className:"js--Selection",children:(0,a.jsx)(r.ms,{className:"js--Dropdown",isFull:!0,label:t("Select example"),onChange:Y,options:V,value:z.value})}),(0,a.jsxs)("section",{className:"js--Content",children:[(0,a.jsxs)("article",{className:"container js--Editor",children:[(0,a.jsx)(g,{isCustomExample:C,isRunning:k,removeSnippet:X,runJs:G,saveSnippet:Z,snippetName:_,stopJs:U}),(0,a.jsx)("iframe",{ref:p,sandbox:"allow-scripts allow-same-origin",style:{display:"none"}}),(0,a.jsx)(r.KE,{code:v,onEdit:y})]}),(0,a.jsx)(N,{className:"js--Output",logs:$,children:(0,a.jsx)(r.$n,{className:"action-button",icon:"eraser",onClick:O})})]}),D&&(0,a.jsx)("div",{className:"warnOverlay",children:(0,a.jsxs)("article",{className:"warning centered",children:[(0,a.jsx)("p",{children:t("This is a developer tool that allows you to execute selected snippets in a limited context.")}),(0,a.jsx)("p",{children:t("Never execute JS snippets from untrusted sources.")}),(0,a.jsx)("p",{children:t("Unless you are a developer with insight into what the specific script does to your environment (based on reading the code being executed) generally the advice would be to not use this environment.")}),(0,a.jsx)(r.$n.Group,{children:(0,a.jsx)(r.$n,{icon:"times",label:t("Close"),onClick:M})})]})})]})}),M=n.memo(function(e){return(0,a.jsx)(D,{...e})})},43754(e,s,t){t.d(s,{A:()=>d});var a=t(31085),n=t(14041),r=t(1445),o=t(61020),i=t(28138),l=t(17722),c=t(34202);const d=n.memo(function({imageHash:e,isImminent:s}){const{t}=(0,l.B)(),{api:n}=(0,o.g)(),[d,u]=(0,i.e)();return n.tx.democracy.notePreimage?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.$n,{icon:"plus",label:t("Image"),onClick:u}),d&&(0,a.jsx)(c.A,{imageHash:e,isImminent:s,onClose:u})]}):null})},49161(e,s,t){t.d(s,{A:()=>O});var a=t(31085),n=t(14041),r=t(18690),o=t(75621),i=t(1445),l=t(61020),c=t(79129),d=t(24067),u=t(37140);function m(){return(0,u.Bd)("app-alliance")}var h=t(23780);const p=n.memo(function({className:e,value:{cid:{codec:s,hash_:{code:t},version:n},ipfs:r}}){const o=(0,h.I)(r);return(0,a.jsxs)("tr",{className:e,children:[(0,a.jsx)("td",{className:"start all",children:o&&(0,a.jsx)("a",{href:o.ipfsUrl,rel:"noopener noreferrer",target:"_blank",children:o.ipfsHash})}),(0,a.jsx)("td",{className:"number",children:n.type}),(0,a.jsxs)("td",{className:"number",children:["0x",s.toString(16)]}),(0,a.jsxs)("td",{className:"number",children:["0x",t.toString(16)]})]})}),x=n.memo(function({accouncements:e,className:s}){const{t}=m(),r=(0,n.useRef)([[t("announcements"),"start"],[t("version"),"number"],[t("codec"),"number"],[t("code"),"number"]]);return(0,a.jsx)("div",{className:s,children:(0,a.jsx)(i.XI,{empty:e&&t("No announcements"),header:r.current,children:e?.map(e=>(0,a.jsx)(p,{value:e},e.key))})})});var g=t(28138),b=t(40941),f=t(97186);const j=n.memo(function({className:e,members:s,onClose:t,unscrupulous:{accounts:r}}){const{t:o}=m(),{api:c}=(0,l.g)(),{allAccounts:d}=(0,f.o)(),[u,h]=(0,n.useState)(null),p=(0,n.useMemo)(()=>d.filter(e=>!s.some(({accountId:s})=>s===e)&&!r.some(s=>s===e)),[r,d,s]);return(0,a.jsxs)(i.aF,{className:e,header:o("Join alliance"),onClose:t,size:"large",children:[(0,a.jsxs)(i.aF.Content,{children:[(0,a.jsx)(i.aF.Columns,{hint:o("This account will be submitted to join the aliance. It will be allocated one of the alliance roles upon joining, starting with Ally."),children:(0,a.jsx)(i.B4,{filter:p,label:o("alliance account"),onChange:h,type:"account"})}),(0,a.jsx)(i.aF.Columns,{hint:o("The bond will be reserved for the duration of your alliance membership."),children:(0,a.jsx)(i.xg,{defaultValue:c.consts.alliance.allyDeposit,isDisabled:!0,label:o("alliance deposit")})})]}),(0,a.jsx)(i.aF.Actions,{children:(0,a.jsx)(i.jX,{accountId:u,onStart:t,tx:c.tx.alliance.joinAlliance})})]})});var v=t(51999),y=t(55155);const C=(0,y.F)("useMemberInfo",function(e){const{api:s}=(0,l.g)(),t=(0,c.Gc)(s.query.alliance.upForKicking,[e]),a=(0,c.Gc)(s.query.alliance.retiringMembers,[e]),r=(0,c.Gc)(s.query.alliance.depositOf,[e]);return(0,n.useMemo)(()=>r&&{accountId:e,deposit:r.unwrapOr(null),isUpForKicking:t&&t.isTrue,retiringAt:a?.unwrapOr(null)},[e,r,a,t])}),w=n.memo(function({bestNumber:e,className:s,info:{accountId:t,role:r},isPrime:o,isVoter:c}){const{t:d}=m(),{api:u}=(0,l.g)(),{allAccounts:h}=(0,f.o)(),p=C(t),{queueExtrinsic:x}=(0,v.x)(),g=!!u.tx.alliance.giveRetirementNotice,b=(0,n.useMemo)(()=>h.includes(t),[h,t]),j=(0,n.useCallback)(()=>x({accountId:t,extrinsic:u.tx.alliance.retire()}),[t,u,x]),y=(0,n.useCallback)(()=>x({accountId:t,extrinsic:u.tx.alliance.giveRetirementNotice()}),[t,u,x]);return(0,a.jsxs)("tr",{className:s,children:[(0,a.jsxs)("td",{className:"address all relative",children:[(0,a.jsx)(i.y1,{value:t}),(0,a.jsx)("div",{className:"absolute",children:p?.isRetiringAt&&(0,a.jsx)(i.vw,{color:"yellow",hover:d("Is retiring"),label:d("retirting")})||p?.isUpForKicking&&(0,a.jsx)(i.vw,{color:"red",hover:d("Up for kicking"),label:d("kicking")})||o&&(0,a.jsx)(i.vw,{color:"green",hover:d("Current prime member, default voting"),label:d("prime voter")})||c&&(0,a.jsx)(i.vw,{color:"green",hover:d("Allowed to vote on motions"),label:d("voter")})})]}),(0,a.jsx)("td",{className:"number",children:r}),(0,a.jsx)("td",{className:"button",children:b&&(0,a.jsx)(i.zD,{value:(0,a.jsxs)(i.W1,{children:[g&&(0,a.jsx)(i.W1.Item,{isDisabled:!!p?.isRetiringAt,label:d("Announce retirement"),onClick:y}),(0,a.jsx)(i.W1.Item,{isDisabled:!!p&&(p.isUpForKicking||!!g&&(!e||!p.isRetiringAt||p.isRetiringAt.lt(e))),label:d("Retire"),onClick:j})]})},"settings")})]})});var k=t(21327);const S=n.memo(function({className:e,members:s,rule:t}){const{t:n}=m(),r=(0,h.I)(t?.cid?.ipfs);return(0,a.jsxs)(i.cp,{className:e,children:[(0,a.jsx)(i.dS,{label:n("rule"),children:t?t.hasRule?r?(0,a.jsx)("a",{href:r.ipfsUrl,rel:"noopener noreferrer",target:"_blank",children:r.ipfsShort}):n("yes"):n("no"):(0,a.jsx)("span",{className:"--tmp",children:n("no")})}),(0,a.jsx)(i.dS,{label:n("members"),children:s?(0,k.Z)(s.length):(0,a.jsx)("span",{className:"--tmp",children:"99"})})]})}),N=n.memo(function({className:e,members:s,prime:t,rule:r,unscrupulous:o,voters:l}){const{t:c}=m(),[d,u]=(0,g.e)(),h=(0,b.x)(),p=(0,n.useRef)([[c("members"),"start",3]]);return(0,a.jsxs)("div",{className:e,children:[(0,a.jsx)(S,{members:s,rule:r}),(0,a.jsxs)(i.$n.Group,{children:[(0,a.jsx)(i.$n,{icon:"add",isDisabled:!s||!o,label:c("Join"),onClick:u}),s&&o&&d&&(0,a.jsx)(j,{members:s,onClose:u,unscrupulous:o})]}),(0,a.jsx)(i.XI,{empty:s&&c("No members"),header:p.current,isSplit:!0,maxColumns:2,children:s?.map(e=>(0,a.jsx)(w,{bestNumber:h,info:e,isPrime:t===e.accountId,isVoter:!!l&&l.includes(e.accountId)},e.accountId))})]})}),A=n.memo(function({className:e,value:s}){return(0,a.jsx)("tr",{className:e,children:(0,a.jsx)("td",{className:"address all",children:(0,a.jsx)(i.y1,{value:s})})})}),F=n.memo(function({className:e,value:s}){return(0,a.jsx)("tr",{className:e,children:(0,a.jsx)("td",{className:"start all",children:s})})}),I=n.memo(function({className:e,unscrupulous:s}){const{t}=m(),r=(0,n.useRef)([[t("accounts"),"start"]]),o=(0,n.useRef)([[t("websites"),"start"]]);return(0,a.jsxs)("div",{className:e,children:[(0,a.jsx)(i.XI,{empty:s?.accounts&&t("No accounts"),header:r.current,children:s?.accounts.map(e=>(0,a.jsx)(A,{value:e},e))}),(0,a.jsx)(i.XI,{empty:s?.websites&&t("No websites"),header:o.current,children:s?.websites.map(e=>(0,a.jsx)(F,{value:e},e))})]})});var E=t(94135);function T(e){return{cid:e,ipfs:(0,E.c)(e),key:e.toHex()}}const D={transform:e=>e.map(T)},M=(0,y.F)("useAnnouncements",function(){const{api:e}=(0,l.g)();return(0,c.Gc)(e.query.alliance.announcements,[],D)}),B=["Retiring","Ally","Fellow"],P=(0,y.F)("useMembers",function(){const{api:e}=(0,l.g)(),[s,t]=(0,n.useState)(),a=(0,c.Gc)(e.query.alliance.members,[B[0]]),r=(0,c.Gc)(e.query.alliance.members,[B[1]]),o=(0,c.Gc)(e.query.alliance.members,[B[2]]);return(0,n.useEffect)(()=>{a&&r&&o&&t((e=[])=>function(e,...s){const t=[];for(let a=0;a<B.length;a++){const n=B[a],r=s[a];for(let s=0,a=r.length;s<a;s++){const a=r[s].toString(),o=e.find(e=>e.accountId===a&&e.role===n);t.push(o||{accountId:a,role:n})}}return t.reverse()}(e,a,r,o))},[a,r,o]),s}),$={transform:e=>e.isSome?{cid:T(e.unwrap()),hasRule:!0}:{cid:null,hasRule:!1}},L=(0,y.F)("useRule",function(){const{api:e}=(0,l.g)();return(0,c.Gc)(e.query.alliance.rule,[],$)});function V(e){return e.map(e=>e.toString())}const R={transform:e=>V(e)},z={transform:e=>V(e.filter(e=>e.isAscii))},H=(0,y.F)("useUnscrupulous",function(){const{api:e}=(0,l.g)(),s=(0,c.Gc)(e.query.alliance.unscrupulousAccounts,[],R),t=(0,c.Gc)(e.query.alliance.unscrupulousWebsites,[],z);return(0,n.useMemo)(()=>s&&t&&{accounts:s,websites:t},[s,t])}),q=2/3,O=n.memo(function({basePath:e,className:s}){const{t}=m(),{api:u}=(0,l.g)(),h=(0,c.Gc)(u.derive.alliance.proposalHashes),{isMember:p,members:g,prime:b}=(0,d.r)("alliance"),f=M(),j=P(),v=L(),y=H(),C=(0,n.useCallback)(e=>"alliance"===e,[]),w=(0,n.useMemo)(()=>[{isRoot:!0,name:"overview",text:t("Overview")},{name:"motions",text:t("Motions ({{count}})",{replace:{count:h?.length||0}})},{name:"announcements",text:t("Announcements ({{count}})",{replace:{count:f?.length||0}})},{name:"unscrupulous",text:t("Unscrupulous")}],[f,h,t]);return(0,a.jsxs)("main",{className:s,children:[(0,a.jsx)(i.tU,{basePath:e,items:w}),(0,a.jsx)(r.BV,{children:(0,a.jsxs)(r.qh,{path:e,children:[(0,a.jsx)(r.qh,{element:(0,a.jsx)(x,{accouncements:f}),path:"announcements"}),(0,a.jsx)(r.qh,{element:(0,a.jsx)(o.A,{defaultProposal:u.tx.alliance.addUnscrupulousItems,defaultThreshold:q,filter:C,isMember:p,members:g,prime:b,proposalHashes:h,type:"alliance"}),path:"motions"}),(0,a.jsx)(r.qh,{element:(0,a.jsx)(I,{unscrupulous:y}),path:"unscrupulous"}),(0,a.jsx)(r.qh,{element:(0,a.jsx)(N,{isVoter:p,members:j,prime:b,rule:v,unscrupulous:y,voters:g}),index:!0})]})})]})})},51482(e,s,t){t.d(s,{A:()=>jt});var a=t(31085),n=t(14041),r=t(18690),o=t(1445),i=t(97186),l=t(73408),c=t(74809),d=t(61020),u=t(8575),m=t(28138),h=t(97670),p=t(40043),x=t(48204),g=t(88274),b=t(770),f=t(49723),j=t(51524),v=t(6404),y=t(43778),C=t(11773),w=t(92100),k=t(54143),S=t(58797),N=t(30396),A=t(56393),F=t(2001),I=t(34119),E=t(49141),T=t(32066),D=t(37140);function M(){return(0,D.Bd)("app-accounts")}var B=t(45060),P=t.n(B),$=t(2926);function L(e,s,t){const r=s.filter(e=>!!e);return r.length?(0,a.jsxs)(n.Fragment,{children:[(0,a.jsx)(o.W1.Divider,{}),t&&(0,a.jsx)(o.W1.Header,{children:t}),r]},e):null}function V({json:e,pair:s}){P().saveAs(new Blob([JSON.stringify(e)],{type:"application/json; charset=utf-8"}),`${s.address}.json`)}function R(e,s){const t={action:"create",message:s,status:"success"};try{const s=e(),a=s.pair.address;t.account=a,"web"===(0,$.uc)()&&V(s),V(s),o.B4.setLastValue("account",a)}catch(e){t.status="error",t.message=e.message}return t}const z=["parent","name","date","balances"];function H({onChange:e,onEnter:s}){const{t}=M(),[{isPass1Valid:r,password1:i},l]=(0,n.useState)({isPass1Valid:!1,password1:""}),[{isPass2Valid:c,password2:d},u]=(0,n.useState)({isPass2Valid:!1,password2:""});(0,n.useEffect)(()=>e(i,r&&c),[i,e,r,c]);const m=(0,n.useCallback)(e=>{l({isPass1Valid:b.AC.isPassValid(e),password1:e}),u({isPass2Valid:b.AC.isPassValid(d)&&d===e,password2:d})},[d]),h=(0,n.useCallback)(e=>u({isPass2Valid:b.AC.isPassValid(e)&&e===i,password2:e}),[i]);return(0,a.jsxs)(o.aF.Columns,{hint:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{children:t("The password and password confirmation for this account. This is required to authenticate any transactions made and to encrypt the keypair.")}),(0,a.jsx)("p",{children:t("Ensure you are using a strong password for proper account protection.")})]}),children:[(0,a.jsx)(o._2,{className:"full",isError:!r,label:t("password"),onChange:m,onEnter:s,value:i}),(0,a.jsx)(o._2,{className:"full",isError:!c,label:t("password (repeat)"),onChange:h,onEnter:s,value:d}),(0,a.jsx)(o.Xh,{value:i})]})}const q=n.memo(({name:{isNameValid:e,name:s},onCommit:t,setName:r,setPassword:i})=>{const{t:l}=M(),c=(0,n.useCallback)(e=>r({isNameValid:!!e.trim(),name:e}),[r]),d=(0,n.useCallback)((e,s)=>i({isPasswordValid:s,password:e}),[i]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.aF.Columns,{hint:l("The name for this account and how it will appear under your addresses. With an on-chain identity, it can be made available to others."),children:(0,a.jsx)(o.pd,{className:"full",isError:!e,label:l("name"),onChange:c,onEnter:t,placeholder:l("new account"),value:s})}),(0,a.jsx)(H,{onChange:d,onEnter:t})]})}),O=n.memo(function({address:e,derivePath:s,name:t,pairType:n,seed:r}){const{t:i}=M(),l=r?.split(" "),c=(0,k.qv)(r)?`${r.slice(10)}${r.slice(-8)}`:l?.map((e,s)=>s%3?"…":e).join(" ");return(0,a.jsx)(o.aF.Content,{children:(0,a.jsxs)(o.aF.Columns,{hint:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{children:i('We will provide you with a generated backup file after your account is created. As long as you have access to your account you can always download this file later by clicking on "Backup" button from the Accounts section.')}),(0,a.jsx)("p",{children:i("Please make sure to save this file in a secure location as it is required, together with your password, to restore your account.")})]}),children:[e&&t&&(0,a.jsx)(o.J8,{defaultName:t,isInline:!0,noDefaultNameOpacity:!0,value:e}),c&&(0,a.jsx)(o.jC,{label:i("partial seed"),value:c}),(0,a.jsx)(o.jC,{label:i("keypair type"),value:n}),(0,a.jsx)(o.jC,{label:i("derivation path"),value:s||i("<none provided>")})]})})}),W="m/44'/60'/0'/0/0",U=n.memo(function({className:e,derivePath:s,deriveValidation:t,onChange:r,seedType:i}){const{t:l}=M(),[c,d]=(0,n.useState)(0),[u,h]=(0,n.useState)(j.Yz),[p]=(0,n.useState)(()=>new Array(10).fill(0).map((e,s)=>({key:s,text:l("Address index {{index}}",{replace:{index:s}}),value:s}))),[x,g]=(0,m.e)(),[b,f]=(0,m.e)(),v=(0,n.useRef)({INVALID_DERIVATION_PATH:l("This is an invalid derivation path."),PASSWORD_IGNORED:l("Password are ignored for hex seed"),SOFT_NOT_ALLOWED:l("Soft derivation paths are not allowed on ed25519"),WARNING_SLASH_PASSWORD:l('Your password contains at least one "/" character. Disregard this warning if it is intended.')});return(0,n.useEffect)(()=>{r(`m/44'/60'/0'/0/${b?Number(u):c}`)},[u,r,b,c]),(0,a.jsxs)(o.aF.Columns,{className:e,hint:l("raw"===i?"The derivation path is only relevant when deriving keys from a mnemonic.":"The derivation path allows you to create different accounts from the same base mnemonic."),children:["bip"===i?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"saveToggle",children:(0,a.jsx)(o.Sc,{label:(0,a.jsx)(a.Fragment,{children:l("Use custom address index")}),onChange:f,value:b})}),b?(0,a.jsx)(o.YI,{isDecimal:!1,label:l("Custom index"),onChange:h,value:u}):(0,a.jsx)(o.ms,{label:l("address index"),onChange:d,options:p,value:c}),(0,a.jsx)("div",{className:"saveToggle",children:(0,a.jsx)(o.Sc,{label:(0,a.jsx)(a.Fragment,{children:l("Use custom derivation path")}),onChange:g,value:x})}),x?(0,a.jsx)(o.pd,{isError:!!t?.error,label:l("secret derivation path"),onChange:r,placeholder:W,tabIndex:-1,value:s}):null]}):(0,a.jsx)(o.WM,{content:l("The derivation path is only relevant when deriving keys from a mnemonic.")}),t?.error&&(0,a.jsx)(o.o_,{content:v.current[t.error]||t.error}),t?.warning&&(0,a.jsx)(o.WM,{content:v.current[t.warning]})]})});var G=t(25102),Y=t(23254);const X=o.I4.article`
.box {
padding: 0 0.5rem;
}
`,Z=n.memo(function({children:e,className:s="",type:t}){return(0,a.jsx)(X,{className:`${s} ${t} centered`,children:(0,a.jsx)("div",{className:"box",children:e})})}),_=(0,Y.F)(20),J=n.memo(function({className:e,onClose:s}){const{t}=M(),{api:r}=(0,d.g)(),{getLedger:i}=(0,u.L)(),[l,c]=(0,n.useState)(0),[m,h]=(0,n.useState)(0),[p,x]=(0,n.useState)(null),[{isNameValid:g,name:j},v]=(0,n.useState)({isNameValid:!1,name:""}),[y,C]=(0,n.useState)(!1),w=(0,n.useRef)(_.map(e=>({text:t("Account type {{index}}",{replace:{index:e}}),value:e}))),k=(0,n.useRef)(_.map(e=>({text:t("Address index {{index}}",{replace:{index:e}}),value:e}))),S=(0,n.useCallback)(e=>v({isNameValid:!!e.trim(),name:e}),[]),N=(0,n.useCallback)(()=>{x(null),C(!0),async function(e,s,t,a,n,r){let o;const i=f.W.get().ledgerApp;o="migration"===i||"generic"===i?(await s().getAddress(r,!1,a,n)).address:(await s().getAddress(!1,a,n)).address,b.AC.addHardware(o,"ledger",{accountOffset:a,addressOffset:n,genesisHash:e.genesisHash.toHex(),name:t||`ledger ${a}/${n}`})}(r,i,j,l,m,r.consts.system.ss58Prefix.toNumber()).then(()=>s()).catch(e=>{console.error(e),C(!1),x(e)})},[l,m,r,i,j,s]);return(0,a.jsxs)(o.aF,{className:e,header:t("Add account via Ledger"),onClose:s,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:t("The name for this account as it will appear under your accounts."),children:(0,a.jsx)(o.pd,{autoFocus:!0,className:"full",isError:!g,label:t("name"),onChange:S,placeholder:t("account name"),value:j})}),(0,a.jsx)(o.aF.Columns,{hint:t("The account type that you wish to create. This is the top-level derivation."),children:(0,a.jsx)(o.ms,{label:t("account type"),onChange:c,options:w.current,value:l})}),(0,a.jsxs)(o.aF.Columns,{hint:t("The address index on the account that you wish to add. This is the second-level derivation."),children:[(0,a.jsx)(o.ms,{label:t("address index"),onChange:h,options:k.current,value:m}),p&&(0,a.jsx)(o.o_,{content:p.message})]})]}),(0,a.jsx)(Z,{type:"warning",children:(0,a.jsx)("p",{children:`You are using the Ledger ${f.W.ledgerApp.toUpperCase()} App. If you would like to switch it, please go the "manage ledger app" in the settings.`})}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.$n,{icon:"plus",isBusy:y,isDisabled:!g,label:t("Save"),onClick:N})})]})}),K=G.Kx.filter(({hasLedgerSupport:e})=>e),Q=n.memo(function({className:e,onChange:s,seedType:t}){const{t:r}=M(),[i,l]=(0,n.useState)(0),[c,d]=(0,n.useState)(0),[u,m]=(0,n.useState)("pezkuwi"),h=(0,n.useRef)(K.map(({displayName:e,network:s})=>({text:e,value:s}))),p=(0,n.useRef)(_.map(e=>({text:r("Account type {{index}}",{replace:{index:e}}),value:e}))),x=(0,n.useRef)(_.map(e=>({text:r("Address index {{index}}",{replace:{index:e}}),value:e})));return(0,n.useEffect)(()=>{const e=K.find(({network:e})=>e===u);s(`m/44'/${e?.slip44}'/${i}'/0'/${c}'`)},[i,c,u,s]),(0,a.jsx)(o.aF.Columns,{className:e,hint:r("The derivation will be constructed from the values you specify."),children:"bip"===t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.ms,{label:r("Ledger app type (originated from)"),onChange:m,options:h.current,value:u}),(0,a.jsx)(o.ms,{label:r("account type"),onChange:l,options:p.current,value:i}),(0,a.jsx)(o.ms,{label:r("address index"),onChange:d,options:x.current,value:c})]}):(0,a.jsx)(o.o_,{content:r("Derivation for Ledger-type accounts are only available on mnemonic seeds.")})})}),ee=navigator.userAgent.toLowerCase().indexOf(" electron/")>-1,se=n.memo(function(){const{t:e}=M();return ee?null:(0,a.jsx)(o.WM,{content:(0,a.jsxs)(a.Fragment,{children:[e("Consider storing your account in a signer such as a browser extension, hardware device, QR-capable phone wallet (non-connected) or desktop application for optimal account security.")," ",e("Future versions of the web-only interface will drop support for non-external accounts, much like the IPFS version.")]})})});function te(e,s,t){return"ed25519-ledger"===t?(0,w.X)((0,N.i)(e,s).secretKey.slice(0,32)):"ethereum"===t?`${e}/${s}`:`${e}${s}`}function ae(e,s,t){return b.AC.createFromUri(te(e,s,t),{},"ed25519-ledger"===t?"ed25519":t).address}function ne(e,s,t,a="sr25519"){const n=function(e,s){switch(s){case"bip":return(0,I.a)();case"dev":return y.G;default:return e||(0,w.X)((0,E.a)())}}(e,t);return{address:ae(n,s,a),derivePath:s,deriveValidation:void 0,isSeedValid:!0,pairType:a,seed:n,seedType:t}}function re(e,s,t,a){let n=null,r=function(e,s,t,a){try{const{password:n,path:r}=(0,A.E)("ethereum"===a?`${e}/${t}`:`${e}${t}`);let o={};return n?.includes("/")&&(o={warning:"WARNING_SLASH_PASSWORD"}),"ed25519"===a&&r.some(({isSoft:e})=>e)?{...o,error:"SOFT_NOT_ALLOWED"}:"raw"===s&&n?{...o,error:"PASSWORD_IGNORED"}:"ethereum"!==a||(0,F.o)(t)?o:{...o,error:"INVALID_DERIVATION_PATH"}}catch(e){return{error:e.message}}}(e,t,s,a),o=!1;if("raw"===t)o=function(e){return e.length>0&&e.length<=32||function(e){return(0,k.qv)(e)&&66===e.length}(e)}(e);else{const s=e.split(" ");"ed25519-ledger"===a&&25===s.length?(s.pop(),o=(0,T.F)(s.join(" "))):o=(0,T.F)(e)}if(!r?.error&&o)try{n=ae(e,s,a)}catch(e){console.error(e),r={error:e.message?e.message:e.toString()},o=!1}return{address:n,derivePath:s,deriveValidation:r,isSeedValid:o,pairType:a,seed:e,seedType:t}}const oe=(0,o.I4)(o.aF)`
.accounts--Creator-advanced {
margin-top: 1rem;
overflow: visible;
}
.ui--CopyButton.copyMoved {
position: absolute;
right: 9.25rem;
top: 1.15rem;
}
&& .TextAreaWithDropdown {
textarea {
width: 80%;
}
.ui.buttons {
width: 20%;
}
}
.saveToggle {
text-align: right;
.ui--Checkbox {
margin: 0.8rem 0;
> label {
font-weight: var(--font-weight-normal);
}
}
}
`,ie=n.memo(function({className:e="",onClose:s,onStatusChange:t,seed:r,type:i}){const{t:l}=M(),{api:c,isDevelopment:m,isEthereum:h}=(0,d.g)(),{isLedgerEnabled:p}=(0,u.L)(),[{address:x,derivePath:g,deriveValidation:j,isSeedValid:v,pairType:y,seed:w,seedType:k},N]=(0,n.useState)(()=>ne(r,h?W:"",r?"raw":"bip",h?"ethereum":i)),[A,F]=(0,n.useState)(!1),[I,E,T]=(0,C.l)(),[D,B]=(0,n.useState)(!1),[{isNameValid:P,name:$},L]=(0,n.useState)(()=>({isNameValid:!1,name:""})),[{isPasswordValid:V,password:z},H]=(0,n.useState)(()=>({isPasswordValid:!1,password:""})),G=!!x&&A&&!j?.error&&v,Y=P&&V,X=G&&Y,Z=(0,n.useRef)({INVALID_DERIVATION_PATH:l("This is an invalid derivation path."),PASSWORD_IGNORED:l("Password are ignored for hex seed"),SOFT_NOT_ALLOWED:l("Soft derivation paths are not allowed on ed25519"),WARNING_SLASH_PASSWORD:l('Your password contains at least one "/" character. Disregard this warning if it is intended.')}),_=(0,n.useRef)((m?[{text:l("Development"),value:"dev"}]:[]).concat({text:l("Mnemonic"),value:"bip"},h?{text:l("Private Key"),value:"raw"}:{text:l("Raw seed"),value:"raw"})),J=(0,n.useCallback)(e=>N(re(w,e,k,y)),[y,w,k]),K=(0,n.useCallback)(e=>N(re(e,g,k,y)),[g,y,k]),ee=(0,n.useCallback)(e=>N(re(w,h?W:"",k,e)),[w,k,h]),ae=(0,n.useCallback)(e=>{e!==k&&N(ne(null,g,e,y))},[g,y,k]),ie=(0,n.useCallback)(()=>F(!A),[A]),le=(0,n.useCallback)(()=>{X&&(B(!0),(0,S.d)(()=>{const e={genesisHash:m?void 0:c.genesisHash.toHex(),isHardware:!1,name:$.trim()},a=function(e,s,t,{genesisHash:a,name:n,tags:r=[]},o,i){return R(()=>b.AC.addUri(te(e,s,t),o,{genesisHash:a,isHardware:!1,name:n,tags:r},"ed25519-ledger"===t?"ed25519":t),i)}(w,g,y,e,z,l("created account"));t(a),B(!1),s()}))},[c,g,m,X,$,s,t,y,z,w,l]);return(0,a.jsxs)(oe,{className:e,header:l("Add an account via seed {{step}}/{{STEPS_COUNT}}",{replace:{STEPS_COUNT:3,step:I}}),onClose:s,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{children:(0,a.jsx)(o.J8,{defaultName:$,fullLength:!0,isEditableName:!1,noDefaultNameOpacity:!0,value:v&&x||null})}),1===I&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.aF.Columns,{hint:l("The secret seed value for this account. Ensure that you keep this in a safe place, with access to the seed you can re-create the account."),children:(0,a.jsxs)(o.fs,{isError:!v,isReadOnly:"dev"===k,label:l("bip"===k?"mnemonic seed":"dev"===k?"development seed":h?"ethereum private key":"seed (hex or string)"),onChange:K,seed:w,withLabel:!0,children:[(0,a.jsx)(o.i8,{className:"copyMoved",type:"bip"===k?l("mnemonic"):"raw"===k?h?l("private key"):"seed":l("raw seed"),value:w}),(0,a.jsx)(o.ms,{defaultValue:k,isButton:!0,onChange:ae,options:_.current})]})}),(0,a.jsxs)(o.c6,{className:"accounts--Creator-advanced",isPadded:!0,summary:l("Advanced creation options"),children:["ethereum"!==y&&(0,a.jsx)(o.aF.Columns,{hint:l("If you are moving accounts between applications, ensure that you use the correct type."),children:(0,a.jsx)(o.ms,{defaultValue:y,label:l("keypair crypto type"),onChange:ee,options:h?f.W.availableCryptosEth:p?f.W.availableCryptosLedger:f.W.availableCryptos,tabIndex:-1})}),"ed25519-ledger"===y?(0,a.jsx)(Q,{onChange:J,seedType:k}):"ethereum"===y?(0,a.jsx)(U,{derivePath:g,deriveValidation:j,onChange:J,seed:w,seedType:k}):(0,a.jsxs)(o.aF.Columns,{hint:l("The derivation path allows you to create different accounts from the same base mnemonic."),children:[(0,a.jsx)(o.pd,{isDisabled:"raw"===k,isError:!!j?.error,label:l("secret derivation path"),onChange:J,placeholder:l("raw"===k?"sr25519"===y?"//hard/soft":"//hard":"sr25519"===y?"//hard/soft///password":"//hard///password"),tabIndex:-1,value:g}),j?.error&&(0,a.jsx)(o.o_,{content:Z.current[j.error]||j.error}),j?.warning&&(0,a.jsx)(o.WM,{content:Z.current[j.warning]})]})]}),(0,a.jsxs)(o.aF.Columns,{children:[(0,a.jsx)(se,{}),(0,a.jsx)("div",{className:"saveToggle",children:(0,a.jsx)(o.Sc,{label:(0,a.jsx)(a.Fragment,{children:l("I have saved my mnemonic seed safely")}),onChange:ie,value:A})})]})]}),2===I&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(q,{name:{isNameValid:P,name:$},onCommit:le,setName:L,setPassword:H}),";",(0,a.jsx)(o.aF.Columns,{children:(0,a.jsx)(se,{})})]}),3===I&&x&&(0,a.jsx)(O,{derivePath:g,isBusy:D,pairType:"ed25519-ledger"===y?"ed25519":y,seed:w})]}),(0,a.jsxs)(o.aF.Actions,{children:[1===I&&(0,a.jsx)(o.$n,{activeOnEnter:!0,icon:"step-forward",isDisabled:!G,label:l("Next"),onClick:E}),2===I&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.$n,{icon:"step-backward",label:l("Prev"),onClick:T}),(0,a.jsx)(o.$n,{activeOnEnter:!0,icon:"step-forward",isDisabled:!Y,label:l("Next"),onClick:E})]}),3===I&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.$n,{icon:"step-backward",label:l("Prev"),onClick:T}),(0,a.jsx)(o.$n,{activeOnEnter:!0,icon:"plus",isBusy:D,label:l("Save"),onClick:le})]})]})]})}),le=["accounts","multisig","qr"],ce=({accounts:e,allPassword:s,setAllPassword:t})=>{const{t:r}=M(),i=(0,n.useCallback)((e,s)=>{t(t=>[...t.filter(s=>s.account!==e),{account:e,isPassTouched:!0,password:s}])},[t]);return e.map(e=>{const{isPassTouched:t,password:n}=s.find(s=>s.account===e)||{isPassTouched:!1,password:""},l=b.AC.isPassValid(n);return(0,a.jsxs)(ue,{children:[(0,a.jsx)(o.J8,{isInline:!0,value:e}),(0,a.jsx)(o._2,{autoFocus:!0,isError:t&&!l,label:r("password"),onChange:s=>i(e,s),value:n})]},e)})},de=o.I4.div`
display: flex;
flex-direction: column;
gap: 1.5rem;
margin-top: 1.5rem;
padding-inline: 2rem;
label, .ui--Icon {
font-size: 1rem;
font-weight: 500;
}
section > div > label {
text-transform: capitalize;
}
`,ue=o.I4.div`
width: 100%;
display: flex;
gap: 1rem;
margin-top: 1.5rem;
padding-inline: 2rem;
div:nth-child(2) {
width: 100%;
label {
font-size: var(--font-size-label);
}
}
`,me=n.memo(function({accountsByGroup:e,className:s,onClose:t,onStatusChange:r}){const{t:i}=M(),[l,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)([]),[m,h]=(0,n.useState)([]),p=(0,n.useCallback)(e=>{d.includes(e)?u(d.filter(s=>s!==e)):u([...d,e])},[d]),x=(0,n.useCallback)(()=>{c(!0),(0,S.d)(()=>{const s={action:"export"};try{let t=[];d.forEach(s=>{t=[...t,...e[s]]});const a=t.map(s=>{const t=b.AC.getPair(s);return e.accounts.includes(s)?b.AC.backupAccount(t,m.find(e=>e.account===s)?.password||""):t}),n=new Blob([JSON.stringify(a,null,2)],{type:"application/json; charset=utf-8"});P().saveAs(n,`batch_exported_accounts_${(new Date).getTime()}.json`),s.status="success",s.message=i("accounts exported")}catch(e){s.status="error",s.message=e.message,console.error(e)}c(!1),r(s),"error"!==s.status&&t()})},[e,m,t,r,d,i]);return(0,a.jsxs)(o.aF,{className:s,header:i("export all accounts"),onClose:t,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.WM,{content:i("You can batch export accounts, but only for in-browser, QR, and multisig types."),withIcon:!1}),(0,a.jsx)(de,{children:Object.keys(e).filter(s=>le.includes(s)&&e[s].length>0).map(s=>{const t=d.includes(s);return(0,a.jsxs)("section",{children:[(0,a.jsx)(o.Sc,{label:`${"accounts"===s?"in-browser":s} accounts (${e[s].length})`,onChange:()=>p(s),value:t}),"accounts"===s&&t&&(0,a.jsx)(ce,{accounts:e[s],allPassword:m,setAllPassword:h})]},s)})})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.$n,{icon:"sync",isBusy:l,isDisabled:!d.length,label:i("Export"),onClick:x})})]})});var he=t(73108),pe=t(11243);const xe=["application/json","text/plain"],ge=n.memo(function({className:e="",onClose:s,onStatusChange:t}){const{t:r}=M(),{api:i,isDevelopment:l,isEthereum:c}=(0,d.g)(),[u,m]=(0,n.useState)(!1),[h,p]=(0,n.useState)(null),[x,g]=(0,n.useState)(null),[{isPassValid:f,password:j},v]=(0,n.useState)({isPassValid:!1,password:""}),y=(0,n.useMemo)(()=>l?null:i.genesisHash.toHex(),[i,l]),C=(0,n.useMemo)(()=>!!h?.meta.genesisHash&&h.meta.genesisHash!==y,[y,h]),w=(0,n.useCallback)(e=>p(function(e,s,t,a){try{const s=b.AC.createFromJson(JSON.parse((0,he.F)(e)),{genesisHash:a});return t?(0,pe.vA)("ethereum"===s.type,"JSON File does not contain an ethereum type key pair"):(0,pe.vA)("ethereum"!==s.type,"JSON contains an ethereum keytype, this is not available on this network"),s}catch(e){console.error(e),s(e.message?e.message:e.toString())}return null}(e,g,c,y)),[y,c]),k=(0,n.useCallback)(e=>v({isPassValid:b.AC.isPassValid(e),password:e}),[]),N=(0,n.useCallback)(()=>{h&&(m(!0),(0,S.d)(()=>{const e={action:"restore"};try{b.AC.addPair(h,j),e.status="success",e.account=h.address,e.message=r("account restored"),o.B4.setLastValue("account",h.address)}catch(s){v(e=>({...e,isPassValid:!1})),e.status="error",e.message=s.message,console.error(s)}m(!1),t(e),"error"!==e.status&&s()}))},[s,t,h,j,r]);return(0,a.jsxs)(o.aF,{className:e,header:r("Add via backup file"),onClose:s,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{children:(0,a.jsx)(o.J8,{defaultName:h?.meta.name||null,noDefaultNameOpacity:!0,value:h?.address||null})}),(0,a.jsx)(o.aF.Columns,{hint:r("Supply a backed-up JSON file, encrypted with your account-specific password."),children:(0,a.jsx)(o.bT,{accept:xe,className:"full",isError:!h,label:r("backup file"),onChange:w,withLabel:!0})}),(0,a.jsx)(o.aF.Columns,{hint:r("The password previously used to encrypt this account."),children:(0,a.jsx)(o._2,{autoFocus:!0,className:"full",isError:!f,label:r("password"),onChange:k,onEnter:N,value:j})}),(0,a.jsxs)(o.aF.Columns,{children:[x&&(0,a.jsx)(o.o_,{content:x}),C&&(0,a.jsx)(o.WM,{content:r('The network from which this account was originally generated is different than the network you are currently connected to. Once imported ensure you toggle the "allow on any network" option for the account to keep it visible on the current network.')}),(0,a.jsx)(se,{})]})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.$n,{icon:"sync",isBusy:u,isDisabled:!h||!f,label:r("Restore"),onClick:N})})]})});var be=t(61640);const fe=["application/json"];function je(e){return!(e.meta.isInjected||e.meta.isHardware||e.meta.isMultisig||!e.encoded||!e.encoding)}const ve=({allPassword:e,pairs:s,setAllPassword:t})=>{const{t:r}=M(),i=(0,n.useCallback)((e,s)=>{t(t=>[...t.filter(s=>s.account!==e),{account:e,isPassTouched:!0,password:s}])},[t]);return s.map(s=>{const{address:t}=s,{isPassTouched:n,password:l}=e.find(e=>e.account===t)||{isPassTouched:!1,password:""},c=be.Ay.isPassValid(l);return je(s)&&(0,a.jsxs)(ye,{children:[(0,a.jsx)(o.J8,{defaultName:s?.meta.name||null,noDefaultNameOpacity:!0,value:s?.address||null}),(0,a.jsx)(o._2,{autoFocus:!0,isError:n&&!c,label:r("password"),onChange:e=>i(t,e),value:l})]},t)})},ye=o.I4.div`
width: 100%;
display: flex;
gap: 1rem;
margin-top: 1.5rem;
padding-inline: 2rem;
div:nth-child(2) {width: 100%;}
`,Ce=n.memo(function({className:e,onClose:s,onStatusChange:t}){const{t:r}=M(),[i,l]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[u,m]=(0,n.useState)(null),[h,p]=(0,n.useState)([]),x=(0,n.useCallback)(e=>{const s=(0,he.F)(e);m(function(e,s){s(null);try{const s=JSON.parse(e);if(!Array.isArray(s))throw new Error("Invalid format: File content should be an array");for(const e of s)if("string"!=typeof e.address||"object"!=typeof e.meta||null===e.meta)throw new Error('Invalid format: Each item must have a string "address" and an object "meta"');return!0}catch(e){return console.error(e),s(e.message?e.message:e.toString()),!1}}(s,d)?JSON.parse(s):null)},[]),g=(0,n.useCallback)(()=>{l(!0),(0,S.d)(()=>{const e={action:"import"};try{u?.forEach(e=>{if(je(e)){const s=be.Ay.createFromJson(e),t=h.find(s=>s.account===e.address)?.password||"";be.Ay.addPair(s,t)}else be.Ay.addExternal(e.address,e.meta)}),e.status="success",e.message=r("all accounts imported")}catch(s){e.status="error",e.message=s.message,console.error(s)}l(!1),t(e),"error"!==e.status&&s()})},[h,u,s,t,r]);return(0,a.jsxs)(o.aF,{className:e,header:r("import all accounts"),onClose:s,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:r("Supply a backed-up JSON file"),children:(0,a.jsx)(o.bT,{accept:fe,className:"full",isError:!u,label:r("backup file"),onChange:x,withLabel:!0})}),u&&u.some(je)&&(0,a.jsx)(o.aF.Columns,{hint:r("Provide password for browser accounts"),children:(0,a.jsx)(ve,{allPassword:h,pairs:u,setAllPassword:p})}),(0,a.jsx)(o.aF.Columns,{children:c&&(0,a.jsx)(o.o_,{content:c})})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.$n,{icon:"sync",isBusy:i,isDisabled:!u||!!c,label:r("Import"),onClick:g})})]})}),we=n.memo(function({className:e="",onClose:s,onStatusChange:t}){const{t:r}=M(),[{isNameValid:i,name:l},c]=(0,n.useState)({isNameValid:!1,name:""}),[d,u]=(0,n.useState)(null),m=(0,n.useCallback)(()=>{if(!d)return;const e={name:l.trim()},a=function(e,{name:s}){const t={action:"create"};try{b.AC.addExternal(e,{isLocal:!0,name:s,tags:["local"]}),t.account=e,t.status="success",t.message="Local account created."}catch(e){t.status="error",t.message=e.message}return t}(d,e);t(a),s()},[d,l,s,t]),h=(0,n.useCallback)(e=>c({isNameValid:e.trim().length>=3,name:e}),[]),p=i&&!!d;return(0,a.jsxs)(o.aF,{className:e,header:r("Add a mock account to chopsticks"),onClose:s,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:r("Any address, this can override other accounts"),children:(0,a.jsx)(o.J9,{autoFocus:!0,label:r("address"),onChange:u,placeholder:r("e.g. 5Gg3...")})}),(0,a.jsx)(o.aF.Columns,{hint:r("The name for this account"),children:(0,a.jsx)(o.pd,{className:"full",isError:!i,label:r("name"),onChange:h,placeholder:r("local account name")})})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.$n,{icon:"plus",isDisabled:!p,label:r("Add"),onClick:m})})]})});var ke=t(95927),Se=t.n(ke),Ne=t(90258),Ae=t(40349),Fe=t(55155);function Ie(e,s,t){return s.reduce((e,s)=>(s===t||e.includes(s)||e.push(s),e),e)}const Ee=(0,Fe.F)("useKnownAddresses",function(e){const{accounts:{allAccounts:s},addresses:{allAddresses:t}}=(0,Ae.j)();return(0,n.useMemo)(()=>Ie(Ie([],s,e),t,e),[s,t,e])}),Te=new(Se())(2),De=["application/json"],Me=(0,o.I4)(o.aF)`
.signaturesFileToggle {
width: 100%;
text-align: right;
}
`,Be=n.memo(function({className:e="",onClose:s,onStatusChange:t}){const{api:r,isDevelopment:i}=(0,d.g)(),{t:l}=M(),c=Ee(),[{isNameValid:u,name:m},h]=(0,n.useState)({isNameValid:!1,name:""}),[{isUploadedFileValid:p,uploadedFileError:x,uploadedSignatories:g},f]=(0,n.useState)({isUploadedFileValid:!0,uploadedFileError:"",uploadedSignatories:[]}),[j,v]=(0,n.useState)([""]),[y,C]=(0,n.useState)(!1),[{isThresholdValid:w,threshold:k},S]=(0,n.useState)({isThresholdValid:!0,threshold:Te}),N=(0,n.useCallback)(()=>{const e={genesisHash:i?void 0:r.genesisHash.toHex(),name:m.trim()},a=function(e,s,{genesisHash:t,name:a,tags:n=[]},r){const o={action:"create"};try{const i=b.AC.addMultisig(e,s,{genesisHash:t,name:a,tags:n}),{address:l}=i.pair;o.account=l,o.status="success",o.message=r}catch(e){o.status="error",o.message=e.message,console.error(e)}return o}(j,k,e,l("created multisig"));t(a),s()},[r.genesisHash,i,m,s,t,j,l,k]),A=(0,n.useCallback)(e=>h({isNameValid:e.trim().length>=3,name:e}),[]),F=(0,n.useCallback)(e=>e&&S({isThresholdValid:e.gte(Te)&&e.lten(j.length),threshold:e}),[j]),I=(0,n.useCallback)(e=>{const s=function(e){let s,t="";try{s=JSON.parse((0,he.F)(e)),(0,pe.vA)(Array.isArray(s)&&!!s.length,"JSON file should contain an array of signatories"),s=s.filter(e=>(0,Ne.j)(e)),s=[...new Set(s)],(0,pe.vA)(s.length<=100,"Maximum you can have 100 signatories")}catch(e){s=[],t=e.message?e.message:e.toString()}return{isUploadedFileValid:!t,uploadedFileError:t,uploadedSignatories:s}}(e);f(s),(s.isUploadedFileValid||g.length)&&v(s.uploadedSignatories.length?s.uploadedSignatories:[""])},[g]),E=(0,n.useCallback)(()=>{f({isUploadedFileValid:p,uploadedFileError:x,uploadedSignatories:[]})},[x,p]),T=(0,n.useCallback)(e=>{E(),v(e)},[E]),D=u&&w;return(0,a.jsxs)(Me,{className:e,header:l("Add multisig"),onClose:s,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{children:(0,a.jsx)(o.lM,{className:"signaturesFileToggle",label:l("Upload JSON file with signatories"),onChange:C,value:y})}),!y&&(0,a.jsx)(o.aF.Columns,{hint:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{children:l("The signatories has the ability to create transactions using the multisig and approve transactions sent by others.Once the threshold is reached with approvals, the multisig transaction is enacted on-chain.")}),(0,a.jsx)("p",{children:l("Since the multisig function like any other account, once created it is available for selection anywhere accounts are used and needs to be funded before use.")})]}),children:(0,a.jsx)(o.ur,{available:c,availableLabel:l("available signatories"),maxCount:100,onChange:T,valueLabel:l("selected signatories")})}),y&&(0,a.jsxs)(o.aF.Columns,{hint:l("Supply a JSON file with the list of signatories."),children:[(0,a.jsx)(o.bT,{accept:De,className:"full",clearContent:!g.length&&p,isError:!p,label:l("upload signatories list"),onChange:I,withLabel:!0}),!!g.length&&(0,a.jsx)(o.ks,{label:l("found signatories"),labelExtra:(0,a.jsx)(o.AX,{icon:"sync",label:l("Reset"),onClick:E}),children:(0,a.jsx)("div",{className:"ui--Static ui dropdown selection",children:g.map(e=>(0,a.jsx)("div",{children:(0,a.jsx)(o.ov,{value:e,withSidebar:!1})},e))})}),x&&(0,a.jsx)(o.o_,{content:x})]}),(0,a.jsx)(o.aF.Columns,{hint:l("The threshold for approval should be less or equal to the number of signatories for this multisig."),children:(0,a.jsx)(o.YI,{isError:!w,label:l("threshold"),onChange:F,value:k})}),(0,a.jsx)(o.aF.Columns,{hint:l("The name is for unique identification of the account in your owner lists."),children:(0,a.jsx)(o.pd,{autoFocus:!0,className:"full",isError:!u,label:l("name"),onChange:A,placeholder:l("multisig name")})})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.$n,{icon:"plus",isDisabled:!D,label:l("Create"),onClick:N})})]})});var Pe=t(22067);function $e(e,s,t,a=j.Yz){const n=s.toString();return{address:n,delay:a,isOwned:e.includes(n),type:t}}const Le=(0,Fe.F)("useProxies",function(e){const{api:s}=(0,d.g)(),{allAccounts:t}=(0,i.o)(),a=(0,Pe.T)(),[r,o]=(0,n.useState)(null);return(0,n.useEffect)(()=>{o(null),e&&s.query.proxy?.proxies(e).then(([e])=>{const n=3===s.tx.proxy.addProxy.meta.args.length?e.map(({delay:e,delegate:s,proxyType:a})=>$e(t,s,a,e)):e.map(([e,s])=>$e(t,e,s)),r=n.filter(({isOwned:e})=>e);a.current&&o({isEmpty:0===r.length,owned:r,proxies:n})}).catch(console.error)},[t,s,e,a]),r}),Ve=n.memo(function({className:e="",onClose:s,onStatusChange:t}){const{api:r,isDevelopment:i}=(0,d.g)(),{t:l}=M(),[{isNameValid:c,name:u},m]=(0,n.useState)({isNameValid:!1,name:""}),[h,p]=(0,n.useState)(null),x=Le(h),g=(0,n.useCallback)(()=>{if(h){const e={genesisHash:i?void 0:r.genesisHash.toHex(),name:u.trim()},a=function(e,{genesisHash:s,name:t,tags:a=[]},n){const r={action:"create"};try{b.AC.addExternal(e,{genesisHash:s,isProxied:!0,name:t,tags:a}),r.account=e,r.status="success",r.message=n}catch(e){r.status="error",r.message=e.message}return r}(h,e,l("added proxy"));t(a),s()}},[r.genesisHash,i,u,s,t,h,l]),f=(0,n.useCallback)(e=>m({isNameValid:e.trim().length>=3,name:e}),[]),j=c&&!!h&&x&&!x.isEmpty;return(0,a.jsxs)(o.aF,{className:e,header:l("Add proxied account"),onClose:s,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:l("The address that has previously setup a proxy to one of the accounts that you control."),children:(0,a.jsx)(o.J9,{autoFocus:!0,isError:!x||x.isEmpty,label:l("proxied account"),onChange:p,placeholder:l("address being proxied")})}),(0,a.jsx)(o.aF.Columns,{hint:l("The name is for unique identification of the account in your owner lists."),children:(0,a.jsx)(o.pd,{className:"full",isError:!c,label:l("name"),onChange:f,placeholder:l("proxied name")})})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.$n,{icon:"plus",isDisabled:!j,label:l("Add"),onClick:g})})]})}),Re=(0,o.I4)(o.aF)`
.qr-wrapper {
margin: 0 auto;
max-width: 30rem;
}
`,ze=n.memo(function({className:e="",onClose:s,onStatusChange:t}){const{t:r}=M(),{api:i,isEthereum:c}=(0,d.g)(),{isIpfs:u}=(0,l.c)(),[{isNameValid:m,name:h},p]=(0,n.useState)({isNameValid:!1,name:""}),[{address:x,isAddress:g,scanned:f,warning:j},v]=(0,n.useState)({address:"",isAddress:!1,scanned:null}),[{isPasswordValid:y,password:C},w]=(0,n.useState)({isPasswordValid:!1,password:""}),k=!!x&&m&&(g||y),S=(0,n.useMemo)(()=>!!f&&!!f.genesisHash&&!i.genesisHash.eq(f.genesisHash),[f,i]),N=(0,n.useCallback)(e=>p({isNameValid:!!e.trim(),name:e}),[]),A=(0,n.useCallback)((e,s)=>w({isPasswordValid:s,password:e}),[]),F=(0,n.useCallback)(e=>{v({address:e.isAddress?e.content:b.AC.createFromUri(e.content,{},"sr25519").address,isAddress:e.isAddress,scanned:e}),e.name&&N(e.name)},[N]),I=(0,n.useCallback)(e=>{v({address:"",isAddress:!1,scanned:null,warning:e.message})},[]),E=(0,n.useCallback)(()=>{if(!f||!k)return;const{content:e,isAddress:a}=f,n={genesisHash:f.genesisHash||i.genesisHash.toHex(),name:h.trim()},l=a?c?b.AC.addExternal(e).pair.address:b.AC.addExternal(e,n).pair.address:b.AC.addUri(e,C,n,"sr25519").pair.address;o.B4.setLastValue("account",l),t({account:l,action:"create",message:r("created account"),status:"success"}),s()},[i,k,h,s,t,C,f,c,r]);return(0,a.jsxs)(Re,{className:e,header:r("Add account via Qr"),onClose:s,size:"large",children:[(0,a.jsx)(o.aF.Content,{children:f?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.aF.Columns,{children:(0,a.jsx)(o.J8,{defaultName:h,noDefaultNameOpacity:!0,value:f.content})}),(0,a.jsxs)(o.aF.Columns,{hint:r("The local name for this account. Changing this does not affect your on-line identity, so this is only used to indicate the name of the account locally."),children:[(0,a.jsx)(o.pd,{autoFocus:!0,className:"full",isError:!m,label:r("name"),onChange:N,onEnter:E,value:h}),S&&(0,a.jsx)(o.WM,{content:r("The genesisHash for the scanned account does not match the genesisHash of the connected chain. The account will not be usable on this chain.")})]}),!g&&(0,a.jsx)(H,{onChange:A,onEnter:E})]}):(0,a.jsxs)(o.aF.Columns,{hint:r("Provide the account QR from the module/external application for scanning. Once detected as valid, you will be taken to the next step to add the account to your list."),children:[(0,a.jsx)("div",{className:"qr-wrapper",children:(0,a.jsx)(o.FK,{isEthereum:c,onError:I,onScan:F})}),j&&(0,a.jsx)(o.WM,{content:j})]})}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.$n,{icon:"plus",isDisabled:!f||!k||!g&&u,label:r("Save"),onClick:E})})]})});var He=t(50905),qe=t(51999),Oe=t(69956),We=t(40941),Ue=t(30520),Ge=t(8698),Ye=t(36109),Xe=t(79129),Ze=t(58430),_e=t(21327),Je=t(848);const Ke=n.memo(function({address:e,onClose:s}){const{t}=M(),[r,i]=(0,n.useState)(!1),[{isPassTouched:l,password:c},d]=(0,n.useState)({isPassTouched:!1,password:""}),[u,m]=(0,n.useState)(!1),h=!u&&b.AC.isPassValid(c),p=(0,n.useCallback)(e=>{m(!1),d({isPassTouched:!0,password:e})},[]),x=(0,n.useCallback)(()=>{i(!0),(0,S.d)(()=>{try{const s=e&&b.AC.getPair(e),t=s&&b.AC.backupAccount(s,c),a=new Blob([JSON.stringify(t)],{type:"application/json; charset=utf-8"});P().saveAs(a,`${e}.json`)}catch(e){return m(!0),i(!1),void console.error(e)}i(!1),s()})},[e,s,c]);return(0,a.jsxs)(o.aF,{className:"app--accounts-Modal",header:t("Backup account"),onClose:s,children:[(0,a.jsx)(o.aF.Content,{children:(0,a.jsxs)(o.J8,{isInline:!0,value:e,children:[(0,a.jsx)("p",{children:t('An encrypted backup file will be created once you have pressed the "Download" button. This can be used to re-import your account on any other machine.')}),(0,a.jsx)("p",{children:t("Save this backup file in a secure location. Additionally, the password associated with this account is needed together with this backup file in order to restore your account.")}),(0,a.jsx)("div",{children:(0,a.jsx)(o._2,{autoFocus:!0,isError:l&&!h,label:t("password"),onChange:p,onEnter:x,tabIndex:0,value:c})})]})}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.$n,{icon:"download",isBusy:r,isDisabled:!h,label:t("Download"),onClick:x})})]})}),Qe=n.memo(function({address:e,className:s="",onClose:t}){const{t:r}=M(),[i,l]=(0,n.useState)(!1),[c,d]=(0,n.useState)({isValid:!1,password:""}),[u,m]=(0,n.useState)({isValid:!1,password:""}),[{isOldValid:h,oldPass:p},x]=(0,n.useState)({isOldValid:!1,oldPass:""}),g=(0,n.useCallback)(e=>d({isValid:b.AC.isPassValid(e),password:e}),[]),f=(0,n.useCallback)(e=>m({isValid:b.AC.isPassValid(e)&&c.password===e,password:e}),[c]),j=(0,n.useCallback)(e=>x({isOldValid:b.AC.isPassValid(e),oldPass:e}),[]),v=(0,n.useCallback)(()=>{const s=e&&b.AC.getPair(e);s&&(l(!0),(0,S.d)(()=>{try{s.isLocked||s.lock(),s.decodePkcs8(p)}catch{return x(e=>({...e,isOldValid:!1})),void l(!1)}try{b.AC.encryptAccount(s,c.password)}catch{return m(e=>({...e,isValid:!1})),void l(!1)}l(!1),t()}))},[e,c,p,t]);return(0,a.jsxs)(o.aF,{className:`${s} app--accounts-Modal`,header:r("Change account password"),onClose:t,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.J8,{isInline:!0,value:e}),(0,a.jsx)(o.aF.Columns,{hint:r("The existing account password as specified when this account was created or when it was last changed."),children:(0,a.jsx)(o._2,{autoFocus:!0,isError:!h,label:r("your current password"),onChange:j,tabIndex:1,value:p})}),(0,a.jsxs)(o.aF.Columns,{hint:r("This will apply to any future use of this account as stored on this browser. Ensure that you securely store this new password and that it is strong and unique to the account."),children:[(0,a.jsx)(o._2,{isError:!c.isValid,label:r("your new password"),onChange:g,onEnter:v,tabIndex:2,value:c.password}),(0,a.jsx)(o._2,{isError:!u.isValid,label:r("password (repeat)"),onChange:f,onEnter:v,tabIndex:2,value:u.password}),(0,a.jsx)(o.Xh,{value:c.password})]})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.$n,{icon:"sign-in-alt",isBusy:i,isDisabled:!c.isValid||!u.isValid||!h,label:r("Change"),onClick:v})})]})});var es=t(26577);const ss=n.memo(function({amount:e,delegatingAccount:s,onError:t}){const{t:r}=M(),{api:i}=(0,d.g)(),l=(0,Xe.Gc)(i.derive.balances?.all,[s]),[{error:c,warning:u},m]=(0,n.useState)({error:null,warning:null});return(0,n.useEffect)(()=>{if(l?.freeBalance&&e?.gt(j.Yz)){let s=null;e.gte(l.freeBalance)&&(s=r("The maximum amount you can delegate is the amount of funds available on the delegating account.")),m(e=>{const a=e.error!==s?s:e.error,n=e.warning;return t(a||n?{error:a,warning:n}:null),{error:a,warning:n}})}},[i,t,e,r,l]),c?(0,a.jsx)(o.o_,{content:c}):u?(0,a.jsx)(o.WM,{content:u}):null}),ts=n.memo(function({onClose:e,previousAmount:s,previousConviction:t,previousDelegatedAccount:r,previousDelegatingAccount:i}){const{t:l}=M(),{api:c}=(0,d.g)(),[u,m]=(0,n.useState)(null),[h]=(0,n.useState)(),[p,x]=(0,n.useState)(s),[g,b]=(0,n.useState)(i||null),[f,v]=(0,n.useState)(r||null),y=void 0===t?0:t.toNumber(),[C,w]=(0,n.useState)(y),k=p?.toString()!==s?.toString()||f!==r||g!==i||C!==t?.toNumber();return(0,a.jsxs)(o.aF,{className:"staking--Delegate",header:l(r?"democracy vote delegation":"delegate democracy vote"),onClose:e,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsxs)(o.aF.Columns,{hint:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{children:l("Any democracy vote performed by the delegated account will result in an additional vote from the delegating account")}),(0,a.jsx)("p",{children:l("If the delegated account is currently voting in a referendum, the delegating vote and conviction will be added.")})]}),children:[(0,a.jsx)(o.B4,{label:l("delegating account"),onChange:b,type:"account",value:g}),(0,a.jsx)(o.B4,{label:l("delegated account"),onChange:v,type:"allPlus",value:f})]}),(0,a.jsxs)(o.aF.Columns,{hint:l("The amount to allocate and the conviction that will be applied to all votes made on a referendum."),children:[(0,a.jsx)(o.xg,{autoFocus:!0,isError:!!u?.error,isZeroable:!1,label:l("delegating amount"),labelExtra:(0,a.jsx)(es.A,{label:(0,a.jsx)("span",{className:"label",children:l("balance")}),params:g}),maxValue:h,onChange:x,value:p}),(0,a.jsx)(ss,{amount:p,delegatingAccount:g,onError:m}),(0,a.jsx)(o.GC,{label:l("conviction"),onChange:w,value:C,voteLockingPeriod:c.consts.democracy.voteLockingPeriod||c.consts.democracy.enactmentPeriod})]})]}),(0,a.jsxs)(o.aF.Actions,{children:[r&&(0,a.jsx)(o.jX,{accountId:g,icon:"trash-alt",label:l("Undelegate"),onStart:e,tx:c.tx.democracy.undelegate}),(0,a.jsx)(o.jX,{accountId:g,icon:"sign-in-alt",isDisabled:!p?.gt(j.Yz)||!!u?.error||!k,label:l(r?"Save delegation":"Delegate"),onStart:e,params:[f,C,p],tx:c.tx.democracy.delegate})]})]})});var as=t(39573),ns=t(88929);const rs=n.memo(function({className:e="",from:s,onClose:t}){const{t:r}=M(),{api:i,isDevelopment:l}=(0,d.g)(),{queueAction:c}=(0,qe.x)(),[u]=(0,n.useState)(()=>b.AC.getPair(s)),[h,p]=(0,n.useState)(!1),[{isNameValid:x,name:g},f]=(0,n.useState)({isNameValid:!1,name:""}),[{isPasswordValid:j,password:v},y]=(0,n.useState)({isPasswordValid:!1,password:""}),[{address:C,deriveError:w},k]=(0,n.useState)({address:null,deriveError:null}),[N,A]=(0,m.e)(),[{isLocked:F,lockedError:I},E]=(0,n.useState)({isLocked:u.isLocked,lockedError:null}),[{isRootValid:T,rootPass:D},B]=(0,n.useState)({isRootValid:!1,rootPass:""}),[P,$]=(0,n.useState)(""),L=(0,as.d)(P),V=!!C&&!w&&x&&j;(0,n.useEffect)(()=>{E({isLocked:u.isLocked,lockedError:null})},[u]),(0,n.useEffect)(()=>{!F&&k(()=>{let e=null;const s=function(e,s){if(e.includes("///"))return"Password paths are not supported on keys derived from others";try{const{path:t}=(0,ns._)(e);if("ed25519"===s&&t.some(({isSoft:e})=>e))return"Soft derivation paths are not allowed on ed25519"}catch(e){return console.error(e),e.message}return null}(L,u.type);return s||(e=u.derive(L).address),{address:e,deriveError:s}})},[L,F,u]);const z=(0,n.useCallback)(e=>{B({isRootValid:!!e,rootPass:e}),E(({isLocked:e})=>({isLocked:e,lockedError:null}))},[]),H=(0,n.useCallback)(()=>{p(!0),(0,S.d)(()=>{try{u.decodePkcs8(D),E({isLocked:u.isLocked,lockedError:null})}catch(e){console.error(e),E({isLocked:!0,lockedError:e.message})}p(!1)})},[D,u]),W=(0,n.useCallback)(()=>{V&&(p(!0),(0,S.d)(()=>{const e=function(e,s,t,a,n,r){return R(()=>{const n=e.derive(s);return n.setMeta({...n.meta,genesisHash:r,name:t,parentAddress:e.address,tags:[]}),b.AC.addPair(n,a||"")},n)}(u,P,g,v,r("created account"),l?void 0:i.genesisHash.toHex());c(e),p(!1),t()}))},[i,l,V,g,t,v,c,u,P,r]),U=(0,a.jsx)(o.B4,{isDisabled:!0,label:r("derive root account"),value:s});return(0,a.jsxs)(o.aF,{className:e,header:r("Derive account from pair"),onClose:t,children:[C&&N?(0,a.jsx)(O,{address:C,derivePath:P,isBusy:h,name:g,pairType:u.type}):(0,a.jsxs)(o.aF.Content,{children:[F&&(0,a.jsxs)(a.Fragment,{children:[U,(0,a.jsx)(o._2,{autoFocus:!0,isError:!!I,label:r("password"),onChange:z,value:D})]}),!F&&(0,a.jsxs)(o.J8,{defaultName:g,noDefaultNameOpacity:!0,value:w?"":C,children:[U,(0,a.jsx)(o.pd,{autoFocus:!0,label:r("derivation path"),onChange:$,placeholder:r("//hard/soft")}),w&&(0,a.jsx)(o.o_,{content:w}),(0,a.jsx)(q,{name:{isNameValid:x,name:g},onCommit:W,setName:f,setPassword:y}),";"]})]}),(0,a.jsx)(o.aF.Actions,{children:F?(0,a.jsx)(o.$n,{icon:"lock",isBusy:h,isDisabled:!T,label:r("Unlock"),onClick:H}):N?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.$n,{icon:"step-backward",label:r("Prev"),onClick:A}),(0,a.jsx)(o.$n,{icon:"plus",isBusy:h,label:r("Save"),onClick:W})]}):(0,a.jsx)(o.$n,{icon:"step-forward",isDisabled:!V,label:r("Next"),onClick:A})})]})});var os=t(86832);const is=[" ","\t"];function ls(e,s,t){e&&e.isRaw&&(s&&s(!0),t((0,he.F)(e.asRaw.toU8a(!0))))}function cs(e,s,t,a,n,r,o=is,i=is){return!e||!!s&&s.length>=t&&a.reduce((e,t)=>e&&s.includes(t),!0)&&(!r.length||r.some(e=>s.startsWith(e)))&&!n.some(e=>s.includes(e))&&!o.some(e=>s.startsWith(e))&&!i.some(e=>s.endsWith(e))}const ds=n.memo(function({address:e,className:s="",onClose:t}){const{t:r}=M(),{apiIdentity:i,enableIdentity:l,specName:u}=(0,d.g)(),m=(0,Xe.Gc)(i.query.identity.identityOf,[e]),[{okAll:h,okDiscord:p,okDisplay:x,okEmail:g,okGithub:b,okLegal:f,okMatrix:j,okRiot:v,okTwitter:y,okWeb:C},w]=(0,n.useState)({okAll:!1}),[k,S]=(0,n.useState)({}),[N,A]=(0,n.useState)({}),[F,I]=(0,n.useState)(!1),[E,T]=(0,n.useState)(!1),[D,B]=(0,n.useState)(!1),[P,$]=(0,n.useState)(!1),[L,V]=(0,n.useState)(!1),[R,z]=(0,n.useState)(!1),[H,q]=(0,n.useState)(!1),[O,W]=(0,n.useState)(!1),[U,G]=(0,n.useState)(()=>((0,c.y)(e).name||"").replace(/\(.*\)/,"").trim()),[Y,X]=(0,n.useState)(""),[Z,_]=(0,n.useState)(""),[J,K]=(0,n.useState)(""),[Q,ee]=(0,n.useState)(""),[se,te]=(0,n.useState)(""),[ae,ne]=(0,n.useState)(""),[re,oe]=(0,n.useState)(""),[ie,le]=(0,n.useState)(""),[ce,de]=(0,n.useState)(!1),[ue,me]=(0,n.useState)(!u.includes("people-")),[pe,xe]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{if(m&&m.isSome){const e=m.unwrap(),s=Array.isArray(e)?e[0].info:e.info;if(pe){ls(s.display,null,G),ls(s.email,I,X),ls(s.legal,T,_),ls(s.riot,B,K),ls(s.twitter,z,ne),ls(s.matrix,$,ee),ls(s.github,V,te),ls(s.web,W,le);const e=ue?function(e,s,t,a,n){const r=e.registry.createType("Data",e.registry.createType("Data",{Raw:t})),o=e.registry.createType("Data",""),i=s.additional.find(e=>e[0].eq(r))?.[1]||o;return i&&i.isRaw&&ls(i,a,n),i}(i,s,os.Gh,q,oe):function(e,s,t){return e.discord&&!e.discord.isNone&&(s&&s(!0),t((0,he.F)(e.discord.asRaw.toU8a(!0)))),e.discord}(s,q,oe);(ue?[s.display,s.email,s.legal,s.riot,s.twitter,e,s.web]:[s.display,s.email,s.github,s.legal,s.matrix,s.twitter,e,s.web]).some(e=>!(!e||!e.isRaw||(de(!0),0)))}else s.riot?me(!0):me(!1),xe(!0)}},[m,i,ue,pe]),(0,n.useEffect)(()=>{const e=cs(!0,U,1,[],[],[]),s=cs(F,Y,3,["@"],is,[]),t=cs(E,Z,1,[],[],[]),a=cs(P,Q,6,[":"],is,["@","~"]),n=cs(D,J,6,[":"],is,["@","~"]),r=cs(R,ae,3,[],is,["@"]),o=cs(H,re,3,[],is,[]),i=cs(L,se,3,[],is,[]),l=cs(O,ie,8,["."],is,["https://","http://"]);w({okAll:e&&s&&t&&n&&r&&o&&l,okDiscord:o,okDisplay:e,okEmail:s,okGithub:i,okLegal:t,okMatrix:a,okRiot:n,okTwitter:r,okWeb:l}),ue?S({additional:[o&&H?[{raw:os.Gh},{raw:re}]:null].filter(e=>!!e),display:{[e?"raw":"none"]:U||null},email:{[s&&F?"raw":"none"]:s&&F?Y:null},legal:{[t&&E?"raw":"none"]:t&&E?Z:null},riot:{[n&&D?"raw":"none"]:n&&D?J:null},twitter:{[r&&R?"raw":"none"]:r&&R?ae:null},web:{[l&&O?"raw":"none"]:l&&O?ie:null}}):A({discord:{[o&&H?"raw":"none"]:o&&H?re:null},display:{[e?"raw":"none"]:U||null},email:{[s&&F?"raw":"none"]:s&&F?Y:null},github:{[i&&L?"raw":"none"]:i&&L?se:null},legal:{[t&&E?"raw":"none"]:t&&E?Z:null},matrix:{[a&&P?"raw":"none"]:a&&P?Q:null},twitter:{[r&&R?"raw":"none"]:r&&R?ae:null},web:{[l&&O?"raw":"none"]:l&&O?ie:null}})},[F,E,D,R,H,O,P,L,U,Y,Z,J,ae,re,ie,Q,se,ue]),(0,a.jsxs)(o.aF,{className:s,header:r("Register identity"),onClose:t,children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.pd,{autoFocus:!0,isError:!x,label:r("display name"),maxLength:32,onChange:G,placeholder:r("My On-Chain Name"),value:U}),(0,a.jsx)(o.pd,{isDisabled:!E,isError:!f,label:r("legal name"),labelExtra:(0,a.jsx)(o.lM,{label:r("include field"),onChange:T,value:E}),maxLength:32,onChange:_,placeholder:r("Full Legal Name"),value:E?Z:"<none>"}),(0,a.jsx)(o.pd,{isDisabled:!F,isError:!g,label:r("email"),labelExtra:(0,a.jsx)(o.lM,{label:r("include field"),onChange:I,value:F}),maxLength:32,onChange:X,placeholder:r("somebody@example.com"),value:F?Y:"<none>"}),(0,a.jsx)(o.pd,{isDisabled:!O,isError:!C,label:r("web"),labelExtra:(0,a.jsx)(o.lM,{label:r("include field"),onChange:W,value:O}),maxLength:32,onChange:le,placeholder:r("https://example.com"),value:O?ie:"<none>"}),(0,a.jsx)(o.pd,{isDisabled:!R,isError:!y,label:r("twitter"),labelExtra:(0,a.jsx)(o.lM,{label:r("include field"),onChange:z,value:R}),onChange:ne,placeholder:r("@YourTwitterName"),value:R?ae:"<none>"}),(0,a.jsx)(o.pd,{isDisabled:!H,isError:!p,label:r("discord"),labelExtra:(0,a.jsx)(o.lM,{label:r("include field"),onChange:q,value:H}),onChange:oe,placeholder:r("YourDiscordHandle"),value:H?re:"<none>"}),ue?(0,a.jsx)(o.pd,{isDisabled:!D,isError:!v,label:r("riot name"),labelExtra:(0,a.jsx)(o.lM,{label:r("include field"),onChange:B,value:D}),maxLength:32,onChange:K,placeholder:r("@yourname:matrix.org"),value:D?J:"<none>"}):(0,a.jsx)(o.pd,{isDisabled:!P,isError:!j,label:r("matrix name"),labelExtra:(0,a.jsx)(o.lM,{label:r("include field"),onChange:$,value:P}),maxLength:32,onChange:ee,placeholder:r("@yourname:matrix.org"),value:P?Q:"<none>"}),ue?(0,a.jsx)("div",{}):(0,a.jsx)(o.pd,{isDisabled:!L,isError:!b,label:r("Github name"),labelExtra:(0,a.jsx)(o.lM,{label:r("include field"),onChange:V,value:L}),maxLength:32,onChange:te,placeholder:r("YourGithubHandle"),value:L?se:"<none>"}),(0,a.jsx)(o.xg,{defaultValue:i.consts.identity?.basicDeposit,isDisabled:!0,label:r("total deposit")})]}),(0,a.jsxs)(o.aF.Actions,{children:[(0,a.jsx)(o.jX,{accountId:e,icon:"trash-alt",isDisabled:!l||!ce,label:r("Clear Identity"),onStart:t,tx:i.tx.identity.clearIdentity}),(0,a.jsx)(o.jX,{accountId:e,isDisabled:!l||!h,label:r("Set Identity"),onStart:t,params:[ue?k:N],tx:i.tx.identity.setIdentity})]})]})});var us=t(58792);const ms=n.memo(function({address:e,index:s,name:t,setAddress:r,setName:i,t:l}){const c=(0,n.useCallback)(e=>r(s,e||""),[s,r]),d=(0,n.useCallback)(e=>i(s,e||""),[s,i]);return(0,a.jsxs)(o.Yt,{children:[(0,a.jsx)(o.Yt.Column,{children:(0,a.jsx)(o.B4,{defaultValue:e,label:l("address {{index}}",{replace:{index:s+1}}),onChange:c})}),(0,a.jsx)(o.Yt.Column,{children:(0,a.jsx)(o.pd,{defaultValue:t,isError:!t,isFull:!0,label:l("sub name"),onChange:d})})]})}),hs={withParams:!0},ps=n.memo(function({address:e,className:s,onClose:t}){const{t:r}=M(),{apiIdentity:l,enableIdentity:c}=(0,d.g)(),{allAccounts:u}=(0,i.o)(),m=(0,us.s)(e),h=(0,Xe.Gc)(m&&0!==m.length&&l.query.identity.superOf.multi,[m],hs),[p,x]=(0,n.useState)();(0,n.useEffect)(()=>{h?x(function([[e],s]){return e.reduce((e,t,a)=>{const n=s[a];if(n.isSome){const[,s]=n.unwrap();s.isRaw&&e.push([t,(0,he.F)(s.asRaw)])}return e},[])}(h)):m&&!m.length&&x([])},[u,m,h]);const g=(0,n.useCallback)(()=>x(e=>e?.concat([[u[0],""]])),[u]),b=(0,n.useCallback)(()=>x(e=>e?.slice(0,e.length-1)),[]),f=(0,n.useCallback)((e,s)=>x(t=>(t||[]).map(([t,a],n)=>[e===n?s:t,a])),[]),j=(0,n.useCallback)((e,s)=>x(t=>(t||[]).map(([t,a],n)=>[t,e===n?s:a])),[]);return(0,a.jsxs)(o.aF,{className:s,header:r("Register sub-identities"),onClose:t,size:"large",children:[(0,a.jsx)(o.aF.Content,{children:p?(0,a.jsxs)("div",{children:[p.length?p.map(([e,s],t)=>(0,a.jsx)(ms,{address:e,index:t,name:s,setAddress:f,setName:j,t:r},t)):(0,a.jsx)("article",{children:r("No sub identities set.")}),(0,a.jsxs)(o.$n.Group,{children:[(0,a.jsx)(o.$n,{icon:"plus",label:r("Add sub"),onClick:g}),(0,a.jsx)(o.$n,{icon:"minus",isDisabled:0===p.length,label:r("Remove sub"),onClick:b})]})]}):(0,a.jsx)(o.y$,{label:r("Retrieving sub-identities")})}),(0,a.jsx)(o.aF.Actions,{children:p&&(0,a.jsx)(o.jX,{accountId:e,isDisabled:!c||p.some(([e,s])=>!e||!s),label:r("Set Subs"),onStart:t,params:[p.map(([e,s])=>[e,{raw:s}])],tx:l.tx.identity.setSubs})})]})});var xs=t(27010),gs=t(7643);const bs={callData:null,callError:null,callInfo:null},fs=(0,o.I4)(o.aF)`
.tipToggle {
width: fit-content;
float: right;
text-align: right;
}
`,js=n.memo(function({className:e="",onClose:s,ongoing:t,threshold:r=0,who:l=[]}){const{t:c}=M(),{api:u}=(0,d.g)(),{allAccounts:m}=(0,i.o)(),[h,p]=(0,n.useState)(""),[{callData:x,callError:g,callInfo:b},f]=(0,n.useState)(bs),{encodedCallLength:j,weight:v}=(0,xs.wj)(x),[y,C]=(0,n.useState)(()=>t[0][0].toHex()),[{isMultiCall:w,multisig:S},N]=(0,n.useState)(()=>({isMultiCall:!1,multisig:null})),[A,F]=(0,n.useState)(!0),[I,E]=(0,n.useState)([]),[T,D]=(0,n.useState)(null),[B,P]=(0,n.useState)([]),[$,L]=(0,n.useState)("aye"),[V,R]=(0,n.useState)(null),z=(0,n.useRef)([{text:c("Approve this call hash"),value:"aye"},{text:c("Cancel this call hash"),value:"nay"}]),H=(0,n.useMemo)(()=>t.map(([e])=>({text:e.toHex(),value:e.toHex()})),[t]);(0,n.useEffect)(()=>{const[,e]=t.find(([e])=>e.eq(y))||[null,null];N({isMultiCall:!!e&&e.approvals.length+1>=r,multisig:e}),p(""),f(bs)},[y,t,r]),(0,n.useEffect)(()=>{E(l.map(e=>u.createType("AccountId",e)).filter(e=>!T||!e.eq(T)))},[u,T,l]),(0,n.useEffect)(()=>{const e=S&&S.approvals.length>=r;P(l.map(e=>u.createType("AccountId",e).toString()).filter(s=>m.some(e=>e===s)&&S&&("nay"===$?S.depositor.eq(s):e||!S.approvals.some(e=>e.eq(s)))))},[u,m,S,r,$,l]),(0,n.useEffect)(()=>{if(h)try{(0,pe.vA)((0,k.qv)(h),"Hex call data required");const e=u.createType("Call",h);(0,pe.vA)(e.hash.eq(y),"Call data does not match the existing call hash");const s=u.registry.findMetaCall(e.callIndex);f({callData:e,callError:null,callInfo:s})}catch(e){f({callData:null,callError:e.message,callInfo:null})}else f(bs)},[u,h,y]),(0,n.useEffect)(()=>{const e=u.tx.multisig||u.tx.utility;R(()=>y&&S?"aye"===$?w&&A?x?5===e.asMulti.meta.args.length?e.asMulti(r,I,S.when,x.toHex(),v):6===e.asMulti.meta.args.length?e.asMulti(r,I,S.when,x.toHex(),!1,v):e.asMulti(r,I,S.when,x):null:5===e.approveAsMulti.meta.args.length?e.approveAsMulti(r,I,S.when,y,v):e.approveAsMulti(r,I,S.when,y):e.cancelAsMulti(r,I,S.when,y):null)},[u,x,y,A,w,I,S,r,$,v]);const q="aye"===$;return(0,a.jsxs)(fs,{className:e,header:c("Pending call hashes"),onClose:s,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:c("The call hash from the list of available and unapproved calls."),children:(0,a.jsx)(o.ms,{label:c("pending hashes {{count}}",{replace:{count:`(${H.length})`}}),onChange:C,options:H,value:y})}),S&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.aF.Columns,{hint:c("The creator for this multisig call"),children:(0,a.jsx)(o.B4,{defaultValue:S.depositor,isDisabled:!0,label:c("depositor")})}),(0,a.jsx)(o.aF.Columns,{hint:c("The current approvals applied to this multisig"),children:(0,a.jsx)(o.c6,{isPadded:!0,summary:c("Existing approvals ({{approvals}}/{{threshold}})",{replace:{approvals:S.approvals.length,threshold:r}}),children:S.approvals.map(e=>(0,a.jsx)(o.ov,{isPadded:!1,value:e},pe.vA.toString()))})})]}),(0,a.jsx)(o.aF.Columns,{hint:c("The operation type to apply. For approvals both non-final and final approvals are supported."),children:(0,a.jsx)(o.ms,{label:c("approval type"),onChange:L,options:z.current,value:$})}),0!==B.length&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.aF.Columns,{hint:c("For approvals outstanding approvers will be shown, for hashes that should be cancelled the first approver is required."),children:(0,a.jsx)(o.B4,{filter:B,label:c("signatory"),onChange:D})}),"aye"===$&&w&&(0,a.jsxs)(a.Fragment,{children:[A&&(0,a.jsxs)(o.aF.Columns,{hint:c("The call data for this transaction matching the hash. Once sent, the multisig will be executed against this."),children:[(0,a.jsx)(o.pd,{autoFocus:!0,isError:!h||!!g,label:c("call data for final approval"),onChange:p,value:h}),x&&b&&(0,a.jsx)("div",{style:{marginTop:8},children:(0,a.jsx)(o.c6,{isPadded:!0,summary:`${b.section}.${b.method}`,summaryMeta:b.meta,children:(0,a.jsx)(gs.A,{className:"details",value:x})})}),g&&(0,a.jsx)(o.o_,{content:g})]}),(0,a.jsx)(o.aF.Columns,{hint:c("Swap to a non-executing approval type, with subsequent calls providing the actual call data."),children:(0,a.jsx)(o.lM,{className:"tipToggle",label:c(w?"Multisig message with call (for final approval)":"Multisig approval with hash (non-final approval)"),onChange:F,value:A})})]})]})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.jX,{accountId:T,extrinsic:V,icon:q?"check":"times",isDisabled:!V||q&&(!B.length||!!x&&!j),label:q?"Approve":"Reject",onStart:s})})]})});var vs=t(19348);const ys={type:"all"},Cs=[[],j.Yz];function ws(e,s,t,a=0){return 2===e.tx.proxy.removeProxy.meta.args.length?e.tx.proxy.removeProxy(s,t):e.tx.proxy.removeProxy(s,t,a)}function ks({index:e,onRemove:s,typeOpts:t,value:[r,i]}){const{t:l}=M(),c=(0,n.useCallback)(()=>{r&&s(r,i,e)},[r,e,s,i]);return(0,a.jsxs)("div",{className:"proxy-container",children:[(0,a.jsxs)("div",{className:"input-column",children:[(0,a.jsx)(o.B4,{defaultValue:r,isDisabled:!0,label:l("proxy account")}),(0,a.jsx)(o.ms,{isDisabled:!0,label:"type",options:t,value:i.toNumber()})]}),(0,a.jsx)("div",{className:"buttons-column",children:(0,a.jsx)(o.$n,{icon:"times",onClick:c})})]})}function Ss({index:e,onChangeAccount:s,onChangeType:t,onRemove:r,proxiedAccount:i,typeOpts:l,value:[c,d]}){const{t:u}=M(),m=(0,n.useCallback)(t=>s(e,t),[e,s]),h=(0,n.useCallback)(s=>t(e,s),[e,t]),p=(0,n.useCallback)(()=>r(e),[e,r]);return(0,a.jsxs)("div",{className:"proxy-container",children:[(0,a.jsxs)("div",{className:"input-column",children:[(0,a.jsx)(o.B4,{isError:!c,label:u("proxy account"),onChange:m,type:"allPlus",value:c}),c&&c.eq(i)&&(0,a.jsx)(o.o_,{content:u("You should not setup proxies to act as a self-proxy.")}),(0,a.jsx)(o.ms,{label:"type",onChange:h,options:l,value:d.toNumber()})]}),(0,a.jsx)("div",{className:"buttons-column",children:(0,a.jsx)(o.$n,{icon:"times",onClick:p})})]},`addedProxy-${e}`)}function Ns(e,s=0){const t=e.registry.lookup.names.filter(e=>e.endsWith("RuntimeProxyType"));return e.createType(t.length?t[0]:"ProxyType",s)}const As=(0,o.I4)(o.aF)`
.proxy-container {
display: grid;
grid-column-gap: 0.5rem;
grid-template-columns: minmax(0, 1fr) auto;
margin-bottom: 1rem;
.input-column {
grid-column: 1;
}
.buttons-column {
grid-column: 2;
padding-top: 0.3rem;
}
}
`,Fs=n.memo(function({className:e,onClose:s,previousProxy:[t]=Cs,proxiedAccount:r}){const{t:i}=M(),{api:l}=(0,d.g)(),[c,u]=(0,n.useState)([]),[m,h]=(0,n.useState)([]),[p,x]=(0,n.useState)(null),[g,b]=(0,n.useState)(()=>t.map(({delegate:e,proxyType:s})=>[e,s])),[f,j]=(0,n.useState)([]),v=(0,vs.e)(p,ys),y=(0,n.useMemo)(()=>l.consts.proxy.proxyDepositFactor.muln(c.length+m.length).iadd(l.consts.proxy.proxyDepositBase),[l,c,m]),C=(0,n.useRef)(function(e){return Ns(e).defKeys.map((e,s)=>({text:e,value:s})).filter(({text:e})=>!e.startsWith("__Unused"))}(l));(0,n.useEffect)(()=>{h(f.filter(e=>!!e[0]).map(([e,s])=>function(e,s,t,a=0){return 2===e.tx.proxy.addProxy.meta.args.length?e.tx.proxy.addProxy(s,t):e.tx.proxy.addProxy(s,t,a)}(l,e,s)))},[l,f]),(0,n.useEffect)(()=>{x(()=>[...c,...m])},[c,m]);const w=(0,n.useCallback)(()=>j(e=>[...e,[e.length?e[e.length-1][0]:g.length?g[g.length-1][0]:l.createType("AccountId",r),Ns(l)]]),[l,g,r]),k=(0,n.useCallback)(e=>j(s=>s.filter((s,t)=>t!==e)),[]),S=(0,n.useCallback)((e,s,t)=>{b(e=>e.filter((e,s)=>s!==t)),u(t=>[...t,ws(l,e,s)])},[l]),N=(0,n.useCallback)((e,s)=>j(t=>{const a=[...t];return a[e][0]=s?l.createType("AccountId",s):null,a}),[l]),A=(0,n.useCallback)((e,s)=>j(t=>{const a=[...t];return a[e][1]=Ns(l,s),a}),[l]),F=f.some(([e])=>e&&e.eq(r));return(0,a.jsxs)(As,{className:e,header:i("Proxy overview"),onClose:s,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:i("Any account set as proxy will be able to perform actions in place of the proxied account"),children:(0,a.jsx)(o.B4,{isDisabled:!0,label:i("proxied account"),type:"account",value:r})}),(0,a.jsxs)(o.aF.Columns,{hint:i("If you add several proxy accounts for the same proxy type (e.g 2 accounts set as proxy for Governance), then any of those 2 accounts will be able to perform governance actions on behalf of the proxied account"),children:[g.map((e,s)=>(0,a.jsx)(ks,{index:s,onRemove:S,typeOpts:C.current,value:e},`${e.toString()}-${s}`)),f.map((e,s)=>(0,a.jsx)(Ss,{index:s,onChangeAccount:N,onChangeType:A,onRemove:k,proxiedAccount:r,typeOpts:C.current,value:e},`${e.toString()}-${s}`)),(0,a.jsx)(o.$n.Group,{children:(0,a.jsx)(o.$n,{icon:"plus",label:i("Add proxy"),onClick:w})})]}),(0,a.jsx)(o.aF.Columns,{hint:i("A deposit paid by the proxied account that can not be used while the proxy is in existence. The deposit is returned when the proxy is destroyed. The amount reserved is based on the base deposit and number of proxies"),children:(0,a.jsx)(o.xg,{defaultValue:y,isDisabled:!0,label:i("reserved balance")})}),(0,a.jsx)(o.aF.Columns,{children:(0,a.jsx)(o.x,{})})]}),(0,a.jsxs)(o.aF.Actions,{children:[0!==t.length&&(0,a.jsx)(o.jX,{accountId:r,icon:"trash-alt",label:i("Clear all"),onStart:s,tx:l.tx.proxy.removeProxies}),(0,a.jsx)(o.jX,{accountId:r,extrinsic:v,icon:"sign-in-alt",isDisabled:F||!c.length&&!m.length,onStart:s})]})]})}),Is=n.memo(function({address:e,className:s="",onClose:t}){const{t:r}=M(),{api:i}=(0,d.g)(),[l,c]=(0,n.useState)(null);return(0,a.jsxs)(o.aF,{className:s,header:r("Initiate account recovery"),onClose:t,children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.B4,{isDisabled:!0,label:r("the account to recover to"),value:e}),(0,a.jsx)(o.B4,{label:r("recover this account"),onChange:c,type:"allPlus"})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.jX,{accountId:e,icon:"recycle",isDisabled:!l||l===e,label:r("Start recovery"),onStart:t,params:[l],tx:i.tx.recovery.initiateRecovery})})]})});var Es=t(36628);const Ts=n.memo(function({address:e,className:s="",onClose:t}){const{t:r}=M(),{api:i}=(0,d.g)(),l=Ee(e),[c,u]=(0,n.useState)(),[m,h]=(0,n.useState)([]),[p,x]=(0,n.useState)(),g=!c,b=!m.length,f=!p||!p.gtn(0)||p.gtn(m.length);return(0,a.jsxs)(o.aF,{className:s,header:r("Setup account as recoverable"),onClose:t,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:r("The recoverable account is protected against the loss of seed/access by a social process."),children:(0,a.jsx)(o.B4,{isDisabled:!0,label:r("the account to make recoverable"),value:e})}),(0,a.jsx)(o.aF.Columns,{hint:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{children:r("These are trusted individuals that can verify and approve any recovery actions. With recovery, once the threshold is reached, the funds associated with the account can be moved to a new destination.")}),(0,a.jsx)("p",{children:r("The helpers should be able to verify, via an off-chain mechanism, that the account owner indeed wishes to recover access and as such provide any approvals. In the cases of malicious recovery procedures, they will have the power to stop it.")})]}),children:(0,a.jsx)(o.ur,{available:l,availableLabel:r("available social recovery helpers"),maxCount:16,onChange:h,valueLabel:r("trusted social recovery helpers")})}),(0,a.jsxs)(o.aF.Columns,{hint:r("The threshold for approvals and the delay is the protection associated with the account. The delay should be such that any colluding recovery attempts does have a window to stop."),children:[(0,a.jsx)(o.YI,{isError:f,label:r("recovery threshold"),onChange:x}),(0,a.jsx)(o.YI,{isError:g,isZeroable:!0,label:r("recovery block delay"),onChange:u})]})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.jX,{accountId:e,icon:"share-alt",isDisabled:b||f||g,label:r("Make recoverable"),onStart:t,params:[(0,Es.f)(m),p,c],tx:i.tx.recovery.createRecovery})})]})}),Ds=n.memo(function({accountDelegating:e,onClose:s}){const{t}=M(),{api:n}=(0,d.g)();return(0,a.jsxs)(o.aF,{className:"staking--Undelegate",header:t("Undelegate"),onClose:s,size:"large",children:[(0,a.jsx)(o.aF.Content,{children:(0,a.jsx)(o.aF.Columns,{hint:t("You will remove any delegation made by this account"),children:(0,a.jsx)(o.B4,{defaultValue:e,isDisabled:!0,label:t("delegating account")})})}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.jX,{accountId:e,icon:"sign-in-alt",label:t("Undelegate"),onStart:s,tx:n.tx.democracy.undelegate})})]})});var Ms=t(15816),Bs=t(97301);const Ps=(0,Fe.F)("useMultisigApprovals",function(e){const{events:s}=(0,Ms.s)(),{api:t}=(0,d.g)(),[a,r]=(0,n.useState)(),[o,i]=(0,Bs.R)(1),l=(0,Pe.T)(),c=(0,n.useRef)("");return(0,n.useEffect)(()=>{const t=s.filter(({record:{event:{data:s,section:t}}})=>"multisig"===t&&s.some(s=>"AccountId"===s.toRawType()&&s.eq(e)));if(t.length){const e=JSON.stringify(t.map(e=>e.key));e!==c.current&&(c.current=e,i())}},[e,s,i]),(0,n.useEffect)(()=>{o&&t.query.multisig?.multisigs&&t.query.multisig?.multisigs.entries(e).then(e=>{l.current&&r(e.filter(([,e])=>e.isSome).map(([e,s])=>[e.args[1],s.unwrap()]))}).catch(console.error)},[e,t,l,o]),a}),$s={available:!1,bonded:!1,locked:!1,redeemable:!1,reserved:!1,total:!0,unlocking:!1,vested:!1},Ls={available:!0,bonded:!0,locked:!0,nonce:!0,redeemable:!0,reserved:!0,total:!1,unlocking:!0,vested:!0};function Vs(e){return e?.unlocking?e.unlocking.filter(({remainingEras:e,value:s})=>s.gt(j.Yz)&&e.gt(j.Yz)).map(e=>e.value).reduce((e,s)=>e.iadd(s),new(Se())(0)):j.Yz}function Rs(e,s,t){return e.tx.utility&&t.length?e.tx.utility.batch(t.map(s=>e.tx.democracy.removeVote(s)).concat(e.tx.democracy.unlock(s))):null}function zs(e,s,t,a="convictionVoting"){if(!e.tx.utility||!t.length)return null;const n=t.map(([s,t])=>e.tx[a].removeVote(s,t));return t.reduce((e,[s])=>(e.find(e=>e.eq(s))||e.push(s),e),[]).forEach(t=>{n.push(e.tx[a].unlock(t,s))}),e.tx.utility.batch(n)}const Hs={transform:e=>e.unwrapOr(null)},qs=o.I4.tr`
.devBadge {
opacity: var(--opacity-light);
}
`,Os=n.memo(function({account:{address:e,meta:s},className:t="",delegation:r,filter:i,isFavorite:l,onStatusChange:c,proxy:h,setBalance:p,toggleFavorite:x}){const{t:g}=M(),[y,C]=(0,m.e)(!1),{queueExtrinsic:w}=(0,qe.x)(),{api:k,apiIdentity:S,enableIdentity:N,isDevelopment:A,isEthereum:F}=(0,d.g)(),{getLedger:I}=(0,u.L)(),{ahApi:E,isRelayChain:T,rcApi:D}=(0,Oe.Y)(),B=(0,We.m)(),$=(0,Ue.y)(e),V=(0,Ge.e)(e),R=T?void 0:V,z=(0,Ye.X)(e),H=(0,Xe.Gc)(D?.derive.chain.bestNumber),q=R&&D?H:void 0,O=(0,Xe.Gc)(k.derive.democracy?.locks,[e]),W=(0,Xe.Gc)(k.query.recovery?.recoverable,[e],Hs),U=Ps(e),G=Le(e),{flags:{isDevelopment:Y,isEditable:X,isEthereum:Z,isExternal:_,isHardware:J,isInjected:K,isMultisig:Q,isProxied:ee},genesisHash:se,identity:te,name:ae,onSetGenesisHash:ne,tags:re}=(0,Ze.T)(e),oe=(0,He.A)("referenda","convictionVoting",e),[{democracyUnlockTx:ie},le]=(0,n.useState)({democracyUnlockTx:null,ids:[]}),[{referendaUnlockTx:ce},de]=(0,n.useState)({ids:[],referendaUnlockTx:null}),[ue,me]=(0,n.useState)(null),[he,pe]=(0,m.e)(),[xe,ge]=(0,m.e)(),[be,fe]=(0,m.e)(),[je,ve]=(0,m.e)(),[ye,Ce]=(0,m.e)(),[we,ke]=(0,m.e)(),[Se,Ne]=(0,m.e)(),[Ae,Fe]=(0,m.e)(),[Ie,Ee]=(0,m.e)(),[Te,De]=(0,m.e)(),[Me,Be]=(0,m.e)(),[Pe,$e]=(0,m.e)(),[Ve,Re]=(0,m.e)();(0,n.useEffect)(()=>{$&&p(e,{bonded:z?.stakingLedger.active?.unwrap()||j.Yz,locked:$.lockedBalance,redeemable:z?.redeemable||j.Yz,total:$.freeBalance.add($.reservedBalance),transferable:$.transferable||$.availableBalance,unbonding:Vs(z)})},[e,$,p,z]),(0,n.useEffect)(()=>{const e=T&&E?E:k;R&&e.tx.vesting?.vest?me(()=>R.vestingLocked.isZero()?null:e.tx.vesting.vest()):me(null)},[e,E,k,T,R]),(0,n.useEffect)(()=>{B&&O&&le(s=>{const t=O.filter(({isFinished:e,unlockAt:s})=>e&&B.gt(s)).map(({referendumId:e})=>e);return JSON.stringify(s.ids)===JSON.stringify(t)?s:{democracyUnlockTx:Rs(k,e,t),ids:t}})},[e,k,B,O]),(0,n.useEffect)(()=>{B&&oe&&de(s=>{const t=oe.filter(({endBlock:e})=>e.gt(j.Yz)&&B.gt(e)).map(({classId:e,refId:s})=>[e,s]);return JSON.stringify(s.ids)===JSON.stringify(t)?s:{ids:t,referendaUnlockTx:zs(k,e,t)}})},[e,k,B,oe]);const ze=(0,n.useMemo)(()=>function(e,s,t){if(0===e.length)return!0;const a=e.toLowerCase();return t.reduce((e,s)=>e||s.toLowerCase().includes(a),s.toLowerCase().includes(a))}(i,ae,re),[ae,i,re]),es=(0,n.useCallback)(()=>{if(!e)return;const s={account:e,action:"forget"};try{b.AC.forgetAccount(e),s.status="success",s.message=g("account forgotten")}catch(e){s.status="error",s.message=e.message}},[e,g]),ss=(0,n.useCallback)(()=>{try{if(!Q)throw new Error("not a multisig account");if(!s.who)throw new Error("signatories not found");const t=s.who,a=new Blob([JSON.stringify(t,null,2)],{type:"application/json; charset=utf-8"});P().saveAs(a,`${ae}_${e}_${(new Date).getTime()}.json`)}catch(s){const t={account:e,action:"export",message:s.message,status:"error"};c(t)}},[ae,e,Q,s.who,c]),as=(0,n.useCallback)(()=>ie&&w({accountId:e,extrinsic:ie}),[e,ie,w]),ns=(0,n.useCallback)(()=>ce&&w({accountId:e,extrinsic:ce}),[e,ce,w]),os=(0,n.useCallback)(()=>ue&&w({accountId:e,extrinsic:ue}),[e,w,ue]),is=(0,n.useCallback)(()=>{(async function(e,s,t){const a=f.W.get().ledgerApp,n=e();"migration"===a||"generic"===a?await n.getAddress(t,!0,s.accountOffset||0,s.addressOffset||0):await n.getAddress(!0,s.accountOffset||0,s.addressOffset||0)})(I,s,k.consts.system.ss58Prefix.toNumber()).catch(e=>{console.error(`ledger: ${e.message}`)})},[I,s,k.consts.system.ss58Prefix]),ls=(0,n.useMemo)(()=>[L("identityGroup",[(0,v.T)(S.tx.identity?.setIdentity)&&N&&!J&&(0,a.jsx)(o.W1.Item,{icon:"link",label:g("Set on-chain identity"),onClick:ve},"identityMain"),(0,v.T)(S.tx.identity?.setSubs)&&N&&te?.display&&!J&&(0,a.jsx)(o.W1.Item,{icon:"vector-square",label:g("Set on-chain sub-identities"),onClick:Ce},"identitySub"),(0,v.T)(k.tx.democracy?.unlock)&&ie&&(0,a.jsx)(o.W1.Item,{icon:"broom",label:g("Clear expired democracy locks"),onClick:as},"clearDemocracy"),(0,v.T)(k.tx.convictionVoting?.unlock)&&ce&&(0,a.jsx)(o.W1.Item,{icon:"broom",label:g("Clear expired referenda locks"),onClick:ns},"clearReferenda"),(0,v.T)(k.tx.vesting?.vest)&&ue&&(0,a.jsx)(o.W1.Item,{icon:"unlock",label:g("Unlock vested amount"),onClick:os},"vestingVest")],g("Identity")),L("deriveGroup",[!(Z||_||J||K||Q||F)&&(0,a.jsx)(o.W1.Item,{icon:"download",label:g("Derive account via derivation path"),onClick:ge},"deriveAccount"),J&&(0,a.jsx)(o.W1.Item,{icon:"eye",label:g("Show address on hardware device"),onClick:is},"showHwAddress")],g("Derive")),L("backupGroup",[!(_||J||K||Q||Y)&&(0,a.jsx)(o.W1.Item,{icon:"database",label:g("Create a backup file for this account"),onClick:pe},"backupJson"),!(K||Y)&&Q&&(0,a.jsx)(o.W1.Item,{icon:"database",label:g("Export JSON file with signatories"),onClick:ss},"backupJson"),!(_||J||K||Q||Y)&&(0,a.jsx)(o.W1.Item,{icon:"edit",label:g("Change this account's password"),onClick:Fe},"changePassword"),!(K||Y)&&(0,a.jsx)(o.W1.Item,{icon:"trash-alt",label:g("Forget this account"),onClick:fe},"forgetAccount")],g("Backup")),(0,v.T)(k.tx.recovery?.createRecovery)&&L("reoveryGroup",[!W&&(0,a.jsx)(o.W1.Item,{icon:"redo",label:g("Make recoverable"),onClick:De},"makeRecoverable"),(0,a.jsx)(o.W1.Item,{icon:"screwdriver",label:g("Initiate recovery for another"),onClick:Ee},"initRecovery")],g("Recovery")),(0,v.T)(k.tx.multisig?.asMulti)&&Q&&L("multisigGroup",[(0,a.jsx)(o.W1.Item,{icon:"file-signature",isDisabled:!U?.length,label:g("Multisig approvals"),onClick:ke},"multisigApprovals")],g("Multisig")),(0,v.T)(k.query.democracy?.votingOf)&&r?.accountDelegated&&L("undelegateGroup",[(0,a.jsx)(o.W1.Item,{icon:"user-edit",label:g("Change democracy delegation"),onClick:$e},"changeDelegate"),(0,a.jsx)(o.W1.Item,{icon:"user-minus",label:g("Undelegate"),onClick:Re},"undelegate")],g("Undelegate")),L("delegateGroup",[(0,v.T)(k.query.democracy?.votingOf)&&!r?.accountDelegated&&(0,a.jsx)(o.W1.Item,{icon:"user-plus",label:g("Delegate democracy votes"),onClick:$e},"delegate"),(0,v.T)(k.query.proxy?.proxies)&&(0,a.jsx)(o.W1.Item,{icon:"sitemap",label:h?.[0].length?g("Manage proxies"):g("Add proxy"),onClick:Ne},"proxy-overview")],g("Delegate")),X&&!A&&L("genesisGroup",[(0,a.jsx)(o.rl,{className:"accounts--network-toggle",genesisHash:se,onChange:ne},"chainlock")])].filter(e=>e),[as,ns,is,os,ss,k,S.tx.identity,N,r,ie,se,te,Y,A,F,X,Z,_,J,K,Q,U,ne,h,ce,W,g,pe,$e,ge,fe,ve,Ce,ke,Fe,Ne,Ee,De,Re,ue]);return ze?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(qs,{className:`${t} isExpanded isFirst packedBottom`,children:[(0,a.jsx)(o.XI.Column.Favorite,{address:e,isFavorite:l,toggle:x}),(0,a.jsxs)("td",{className:"address all relative",children:[(0,a.jsx)(o.y1,{parentAddress:s.parentAddress,value:e,withShortAddress:!0}),he&&(0,a.jsx)(Ke,{address:e,onClose:pe},"modal-backup-account"),Pe&&(0,a.jsx)(ts,{onClose:$e,previousAmount:r?.amount,previousConviction:r?.conviction,previousDelegatedAccount:r?.accountDelegated,previousDelegatingAccount:e},"modal-delegate"),xe&&(0,a.jsx)(rs,{from:e,onClose:ge},"modal-derive-account"),be&&(0,a.jsx)(o.EX,{address:e,onClose:fe,onForget:es},"modal-forget-account"),je&&(0,a.jsx)(ds,{address:e,onClose:ve},"modal-identity-main"),ye&&(0,a.jsx)(ps,{address:e,onClose:Ce},"modal-identity-sub"),Ae&&(0,a.jsx)(Qe,{address:e,onClose:Fe},"modal-change-pass"),Me&&(0,a.jsx)(o.XU,{onClose:Be,senderId:e},"modal-transfer"),Se&&(0,a.jsx)(Fs,{onClose:Ne,previousProxy:h,proxiedAccount:e},"modal-proxy-overview"),Q&&we&&U&&0!==U.length&&(0,a.jsx)(js,{address:e,onClose:ke,ongoing:U,threshold:s.threshold,who:s.who},"multisig-approve"),Ie&&(0,a.jsx)(Is,{address:e,onClose:Ee},"recover-account"),Te&&(0,a.jsx)(Ts,{address:e,onClose:De},"recover-setup"),Ve&&(0,a.jsx)(Ds,{accountDelegating:e,onClose:Re},"modal-delegate"),(0,a.jsxs)("div",{className:"absolute",children:[s.genesisHash?(0,a.jsx)(o.Ex,{color:"transparent"}):Y?(0,a.jsx)(o.Ex,{className:"warning",hover:g("This is a development account derived from the known development seed. Do not use for any funds on a non-development network."),icon:"wrench"}):(0,a.jsx)(o.Ex,{className:"warning",hover:(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{children:g('This account is available on all networks. It is recommended to link to a specific network via the account options ("only this network" option) to limit availability. For accounts from an extension, set the network on the extension.')}),(0,a.jsx)("p",{children:g("This does not send any transaction, rather it only sets the genesis in the account JSON.")})]}),icon:"exclamation-triangle"}),W&&(0,a.jsx)(o.Ex,{className:"recovery",hover:(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{children:g("This account is recoverable, with the following friends:")}),(0,a.jsx)("div",{children:W.friends.map((e,s)=>(0,a.jsx)(o.y1,{value:e},s))}),(0,a.jsx)("table",{children:(0,a.jsxs)("tbody",{children:[(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{children:g("threshold")}),(0,a.jsx)("td",{children:(0,_e.Z)(W.threshold)})]}),(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{children:g("delay")}),(0,a.jsx)("td",{children:(0,_e.Z)(W.delayPeriod)})]}),(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{children:g("deposit")}),(0,a.jsx)("td",{children:(0,Je.Q)(W.deposit)})]})]})})]}),icon:"redo"}),ee&&G?.isEmpty&&(0,a.jsx)(o.Ex,{className:"important",hover:g("Proxied account has no owned proxies"),icon:"sitemap",info:"0"}),Q&&U&&0!==U.length&&(0,a.jsx)(o.Ex,{className:"important",color:"purple",hover:g("Multisig approvals pending"),hoverAction:g("View pending approvals"),icon:"file-signature",onClick:ke}),r?.accountDelegated&&(0,a.jsx)(o.Ex,{className:"information",hover:g("This account has a governance delegation"),hoverAction:g("Manage delegation"),icon:"calendar-check",onClick:$e}),h&&0!==h[0].length&&k.tx.utility&&(0,a.jsx)(o.Ex,{className:"information",hover:1===h[0].length?g("This account has a proxy set"):g("This account has {{proxyNumber}} proxies set",{replace:{proxyNumber:h[0].length}}),hoverAction:g("Manage proxies"),icon:"sitemap",onClick:Ne})]})]}),(0,a.jsx)("td",{className:"actions button",children:(0,a.jsxs)(o.$n.Group,{children:[((0,v.T)(k.tx.balances?.transferAllowDeath)||(0,v.T)(k.tx.balances?.transfer))&&(0,a.jsx)(o.$n,{className:"send-button",icon:"paper-plane",label:g("send"),onClick:Be}),(0,a.jsx)(o.zD,{isDisabled:!ls.length,value:(0,a.jsx)(o.W1,{children:ls})})]})}),(0,a.jsx)(o.XI.Column.Expand,{isExpanded:y,toggle:C})]}),(0,a.jsxs)(qs,{className:`${t} isExpanded ${y?"":"isLast"} packedTop`,children:[(0,a.jsx)("td",{}),(0,a.jsx)("td",{className:"balance all",colSpan:2,children:(0,a.jsx)(o.lp,{address:e,balancesAll:$,vestingBestNumber:q,vestingInfo:R,withBalance:$s})}),(0,a.jsx)("td",{})]}),(0,a.jsxs)(qs,{className:`${t} ${y?"isExpanded isLast":"isCollapsed"} packedTop`,children:[(0,a.jsx)("td",{}),(0,a.jsxs)("td",{className:"balance columar",colSpan:2,children:[(0,a.jsx)(o.lp,{address:e,balancesAll:$,convictionLocks:oe,vestingBestNumber:q,vestingInfo:R,withBalance:Ls}),(0,a.jsxs)(o.Yt,{size:"tiny",children:[(0,a.jsx)(o.Yt.Column,{children:(0,a.jsx)("div",{"data-testid":"tags",children:(0,a.jsx)(o.YD,{value:re,withTitle:!0})})}),(0,a.jsxs)(o.Yt.Column,{children:[(0,a.jsx)("h5",{children:g("account type")}),(0,a.jsx)(o.SY,{accountId:e})]})]}),(0,a.jsx)(o.Yt,{is100:!0,children:(0,a.jsx)(o.Yt.Column,{children:(0,a.jsx)(o.e9,{data:e,type:"address",withTitle:!0})})})]}),(0,a.jsx)("td",{})]})]}):null}),Ws=(0,o.I4)(Z)`
border: 1px solid #ffc107;
font-size: 1rem !important;
`,Us=n.memo(()=>{const{t:e}=M(),{ahEndPoints:s,isRelayChain:t}=(0,Oe.Y)(),r=(0,n.useMemo)(()=>s[Math.floor(Math.random()*s.length)],[s]);return t?(0,a.jsx)(Ws,{type:"warning",children:(0,a.jsxs)("p",{children:[e("After Asset Hub migration, all funds have been moved to Asset Hub. Please switch to the "),(0,a.jsx)("a",{href:`${window.location.origin}${window.location.pathname}?rpc=${r}#/accounts`,rel:"noopener noreferrer",target:"_blank",children:e("Asset Hub chain")}),e(" to view your balances and details."),(0,a.jsx)("br",{}),e("For more information about Asset Hub migration, check the "),(0,a.jsx)("a",{href:"https://support.pezkuwichain.io/support/solutions/articles/65000190561#What-would-happen-after-the-migration?",rel:"noopener noreferrer",target:"_blank",children:"details here"}),"."]})}):null});var Gs=t(74831);const Ys=n.memo(function(){const e=(0,Gs.A)(),{t:s}=M();return e?(0,a.jsx)(Z,{type:"error",children:(0,a.jsxs)("p",{children:[s("You have {{claimCount}} accounts that need attestations. Use the Claim Tokens app on the navigation bar to complete the process. Until you do, your balances for those accounts will not be reflected.",{replace:{claimCount:e}})," ",(0,a.jsx)("a",{href:"#/claims",children:s("Claim tokens...")})]})}):null});var Xs=t(24661),Zs=t(36583),_s=t(28783),Js=t(41042),Ks=t(27900),Qs=t(67954);const et=(0,Xs.o0)(),st=et&&et.name||null,tt=st&&Object.keys(_s.s).includes(st),at=(0,Ks.QR)(n.memo(function(){const{t:e}=M(),{hasInjectedAccounts:s}=(0,d.g)(),t=(0,Zs.A)(),r=(0,n.useRef)(e("Since some extensions, such as the pezkuwi-js extension, protects you against all community reported phishing sites, there are valid reasons to use them for additional protection, even if you are not storing accounts in it."));return tt&&st?Js.el?s?t?(0,a.jsxs)(Z,{type:"warning",children:[(0,a.jsxs)("p",{children:[1===t?e("You have 1 extension that needs to be updated with the latest chain properties in order to display the correct information for the chain you are connected to and to use a Ledger device."):e("You have {{upgradableCount}} extensions that need to be updated with the latest chain properties in order to display the correct information for the chain you are connected to and to use a Ledger device.",{replace:{upgradableCount:t}}),e(" This update includes chain metadata and chain properties.")]}),(0,a.jsx)("p",{children:(0,a.jsxs)(D.x6,{children:["Visit your ",(0,a.jsx)("a",{href:"#/settings/metadata",children:"settings page"})," to apply the updates to the injected extensions."]},"extensionUpgrade")})]}):null:(0,a.jsxs)(Z,{type:"warning",children:[(0,a.jsx)("p",{children:e("One or more extensions are detected in your browser, however no accounts has been injected.")}),(0,a.jsx)("p",{children:e("Ensure that the extension has accounts, some accounts are visible globally and available for this chain and that you gave the application permission to access accounts from the extension to use them.")}),(0,a.jsx)("p",{children:r.current})]}):(0,a.jsxs)(Z,{type:"warning",children:[(0,a.jsx)("p",{children:e("It is recommended that you create/store your accounts securely and externally from the app. On {{yourBrowser}} the following browser extensions are available for use -",{replace:{yourBrowser:(0,Qs.g)(st)}})}),(0,a.jsx)("ul",{children:_s.s[st].map(({desc:s,link:t,name:n})=>(0,a.jsxs)("li",{children:[(0,a.jsx)("a",{href:t,rel:"noopener noreferrer",target:"_blank",children:n})," (",e(s),")"]},n))}),(0,a.jsxs)("p",{children:[e("Accounts injected from any of these extensions will appear in this application and be available for use. The above list is updated as more extensions with external signing capability become available.")," ",(0,a.jsx)("a",{href:"https://github.com/pezkuwi-js/extension",rel:"noopener noreferrer",target:"_blank",children:e("Learn more...")})]}),(0,a.jsx)("p",{children:r.current})]}):null}));var nt=t(33168);const rt=n.memo(function({balance:e,className:s}){const{t}=M();return(0,a.jsxs)(o.cp,{className:s,children:[(0,a.jsx)(o.dS,{label:t("total balance"),children:(0,a.jsx)(nt.A,{className:e?"":"--tmp",value:e?.total||1})}),(0,a.jsx)(o.dS,{className:"media--900",label:t("total transferable"),children:(0,a.jsx)(nt.A,{className:e?"":"--tmp",value:e?.transferable||1})}),(0,a.jsx)(o.dS,{label:t("total locked"),children:(0,a.jsx)(nt.A,{className:e?"":"--tmp",value:e?.locked||1})}),e?.bonded.gtn(0)&&(0,a.jsx)(o.dS,{className:"media--1100",label:t("bonded"),children:(0,a.jsx)(nt.A,{value:e.bonded})}),e?.redeemable.gtn(0)&&(0,a.jsx)(o.dS,{className:"media--1500",label:t("redeemable"),children:(0,a.jsx)(nt.A,{value:e.redeemable})}),e?.unbonding.gtn(0)&&(0,a.jsx)(o.dS,{className:"media--1300",label:t("unbonding"),children:(0,a.jsx)(nt.A,{value:e.unbonding})})]})}),ot={sortBy:"date",sortFromMax:!0},it=["accounts","injected","qr","hardware","proxied","multisig","testing","chopsticks"],lt=o.I4.div`
.ui--Dropdown {
width: 15rem;
}
.header-box {
.dropdown-section {
display: flex;
flex-direction: row;
align-items: center;
}
.ui--Button-Group {
margin-left: auto;
}
}
`,ct=n.memo(function({className:e="",onStatusChange:s}){const{t}=M(),{api:r,fork:y,isElectron:C}=(0,d.g)(),{allAccounts:w,hasAccounts:k}=(0,i.o)(),{isIpfs:S}=(0,l.c)(),{isLedgerEnabled:N}=(0,u.L)(),[A,F]=(0,m.e)(),[I,E]=(0,m.e)(),[T,D]=(0,m.e)(),[B,P]=(0,m.e)(),[$,L]=(0,m.e)(),[V,R]=(0,m.e)(),[H,q]=(0,m.e)(),[O,W]=(0,m.e)(),[U,G]=(0,m.e)(),[Y,X]=(0,h.r)("accounts:favorites"),[Z,_]=(0,n.useState)({accounts:{}}),[K,Q]=(0,n.useState)(""),[ee,se]=(0,n.useState)([]),[{sortBy:te,sortFromMax:ae},ne]=(0,n.useState)(ot),re=(0,p.B)(),oe=(0,x.U)(),le=(0,g.O)(),ce=(0,n.useCallback)(e=>ne(({sortFromMax:s})=>({sortBy:e,sortFromMax:s})),[]),de=(0,n.useCallback)(()=>ne(({sortBy:e,sortFromMax:s})=>({sortBy:e,sortFromMax:!s})),[]),ue=(0,n.useRef)(z.map(e=>({text:e,value:e}))),he=(0,n.useCallback)((e,s)=>_(({accounts:t})=>{t[e]=s;const a=e=>Object.values(t).reduce((s,t)=>s.add(t[e]),j.Yz);return{accounts:t,summary:{bonded:a("bonded"),locked:a("locked"),redeemable:a("redeemable"),total:a("total"),transferable:a("transferable"),unbonding:a("unbonding")}}}),[]),pe=(0,n.useMemo)(()=>C||!S&&"on"===f.W.get().storage,[C,S]),xe=(0,n.useMemo)(()=>Object.fromEntries(Y.map(e=>[e,!0])),[Y]),be=(0,n.useMemo)(()=>(0,v.T)((r.tx.multisig||r.tx.utility)?.approveAsMulti),[r]),fe=(0,n.useMemo)(()=>(0,v.T)(r.tx.proxy?.addProxy),[r]),je=(0,n.useMemo)(()=>w.map((e,s)=>{const t=re?.[s]?.isDelegating&&re[s]?.asDelegating,a=t&&{accountDelegated:t.target.toString(),amount:t.balance,conviction:t.conviction}||void 0;return{account:b.AC.getAccount(e),address:e,delegation:a,isFavorite:xe[e??""]??!1}}).filter(e=>!!e.account).reduce((e,s)=>(e[s.address]=s,e),{}),[w,xe,re]),ve=(0,n.useMemo)(()=>{const e={accounts:[[(0,a.jsxs)(a.Fragment,{children:[t("accounts"),(0,a.jsx)("div",{className:"sub",children:t("all locally stored accounts")})]})]],chopsticks:[[(0,a.jsxs)(a.Fragment,{children:[t("chopsticks"),(0,a.jsx)("div",{className:"sub",children:t("local accounts added via chopsticks fork")})]})]],hardware:[[(0,a.jsxs)(a.Fragment,{children:[t("hardware"),(0,a.jsx)("div",{className:"sub",children:t("accounts managed via hardware devices")})]})]],injected:[[(0,a.jsxs)(a.Fragment,{children:[t("extension"),(0,a.jsx)("div",{className:"sub",children:t("accounts available via browser extensions")})]})]],multisig:[[(0,a.jsxs)(a.Fragment,{children:[t("multisig"),(0,a.jsx)("div",{className:"sub",children:t("on-chain multisig accounts")})]})]],proxied:[[(0,a.jsxs)(a.Fragment,{children:[t("proxied"),(0,a.jsx)("div",{className:"sub",children:t("on-chain proxied accounts")})]})]],qr:[[(0,a.jsxs)(a.Fragment,{children:[t("via qr"),(0,a.jsx)("div",{className:"sub",children:t("accounts available via mobile devices")})]})]],testing:[[(0,a.jsxs)(a.Fragment,{children:[t("development"),(0,a.jsx)("div",{className:"sub",children:t("accounts derived via development seeds")})]})]]};return Object.values(e).forEach(e=>{e[0][1]="start",e[0][2]=4}),e},[t]),ye=(0,n.useMemo)(()=>function(e){const s={accounts:[],chopsticks:[],hardware:[],injected:[],multisig:[],proxied:[],qr:[],testing:[]};for(let t=0,a=e.length;t<a;t++){const{account:a,address:n}=e[t],r=(0,c.$)(n);a?.meta.isHardware?s.hardware.push(n):a?.meta.isTesting?s.testing.push(n):"injected"===r?s.injected.push(n):"multisig"===r?s.multisig.push(n):"proxied"===r?s.proxied.push(n):"chopsticks"===r?s.chopsticks.push(n):"qr"===r?s.qr.push(n):s.accounts.push(n)}return s}(ee),[ee]),ke=(0,n.useMemo)(()=>Object.values(je).reduce((e,{account:t,address:n,delegation:r,isFavorite:o},i)=>(e[n]=(0,a.jsx)(Os,{account:t,delegation:r,filter:K,isFavorite:o,onStatusChange:s,proxy:oe?.[i],setBalance:he,toggleFavorite:X},n),e),{}),[je,K,oe,he,X,s]),Se=(0,n.useMemo)(()=>it.reduce((e,s)=>{const t=ye[s];return t.length&&(e[s]=t.map(e=>ke[e])),e},{}),[ye,ke]);return(0,n.useEffect)(()=>{se(e=>[...e.map(e=>je[e.address]).filter(e=>!!e),...Object.keys(je).filter(s=>!e.find(e=>s===e.address)).map(e=>je[e])])},[je]),(0,n.useEffect)(()=>{se(e=>function(e,s,t,a,n){return[...e].sort(function(e,s,t,a){function n(e,s){const t=a?1:-1;return(a,n)=>t*s(e(a),e(n))}switch(t){case"parent":return n(function s(t){if(t){const a=t.account?.meta.parentAddress||"";return s(e[a])+t.address}return""},(e,s)=>e.localeCompare(s));case"name":return n(e=>(0,c.y)(e.address).name??"",(e,s)=>e.localeCompare(s));case"date":return n(e=>e.account?.meta.whenCreated??0,(e,s)=>e-s);case"balances":return n(e=>s[e.address]?.total??j.Yz,(e,s)=>e.cmp(s))}}(s,t,a,n)).sort((e,s)=>e.isFavorite===s.isFavorite?0:s.isFavorite?1:-1)}(e,je,Z.accounts,te,ae))},[je,Z,te,ae]),(0,a.jsxs)(lt,{className:e,children:[A&&(0,a.jsx)(ie,{onClose:F,onStatusChange:s}),I&&(0,a.jsx)(ge,{onClose:E,onStatusChange:s}),T&&(0,a.jsx)(J,{onClose:D}),V&&(0,a.jsx)(we,{onClose:R,onStatusChange:s}),B&&(0,a.jsx)(Be,{onClose:P,onStatusChange:s}),$&&(0,a.jsx)(Ve,{onClose:L,onStatusChange:s}),H&&(0,a.jsx)(ze,{onClose:q,onStatusChange:s}),O&&(0,a.jsx)(me,{accountsByGroup:ye,onClose:W,onStatusChange:s}),U&&(0,a.jsx)(Ce,{onClose:G,onStatusChange:s}),(0,a.jsx)(Us,{}),(0,a.jsx)(at,{}),(0,a.jsx)(Ys,{}),(0,a.jsx)(rt,{balance:Z.summary}),(0,a.jsxs)(o.cp,{className:"header-box",children:[(0,a.jsxs)("section",{className:"dropdown-section media--1300","data-testid":"sort-by-section",children:[(0,a.jsx)(o.mi,{className:"media--1500",defaultValue:te,label:t("sort by"),onChange:ce,onClick:de,options:ue.current,sortDirection:ae?"ascending":"descending"}),(0,a.jsx)(o.ZY,{filterOn:K,label:t("filter by name or tags"),setFilter:Q})]}),(0,a.jsxs)(o.$n.Group,{children:[pe&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.$n,{icon:"plus",label:t("Account"),onClick:F}),(0,a.jsx)(o.$n,{icon:"sync",label:t("From JSON"),onClick:E})]}),(0,a.jsx)(o.$n,{icon:"file-import",label:t("Import"),onClick:G}),(0,a.jsx)(o.$n,{icon:"file-export",label:t("Export"),onClick:W}),(0,a.jsx)(o.$n,{icon:"qrcode",label:t("From Qr"),onClick:q}),N&&(0,a.jsx)(o.$n,{icon:"project-diagram",label:t("From Ledger"),onClick:D}),k&&(0,a.jsxs)(a.Fragment,{children:[be&&(0,a.jsx)(o.$n,{icon:"plus",label:t("Multisig"),onClick:P}),fe&&(0,a.jsx)(o.$n,{icon:"plus",label:t("Proxied"),onClick:L})]}),y&&(0,a.jsx)(o.$n,{icon:"plus",label:t("Local"),onClick:R})]})]}),le&&ee.length?it.map(e=>Se[e]&&(0,a.jsx)(o.XI,{empty:t("No accounts"),header:ve[e],isSplit:!0,children:Se[e]},e)):(0,a.jsx)(o.XI,{empty:le&&ee&&t("You don't have any accounts. Some features are currently hidden and will only become available once you have accounts."),header:ve.accounts})]})});var dt=t(82686),ut=t(84227),mt=t(48998);const ht=o.I4.tr`
text-align: center;
&:hover {
background: #f9f8f7;
}
.vanity--Match-addr {
font-size: 1.1rem;
.no {
color: inherit;
}
.yes {
color: red;
}
}
.vanity--Match-buttons,
.vanity--Match-data,
.vanity--Match-icon {
display: inline-block;
vertical-align: middle;
}
.vanity--Match-item {
display: inline-block;
font: var(--font-mono);
margin: 0 auto;
padding: 0.5em;
position: relative;
}
.vanity--Match-seed {
opacity: 0.45;
padding: 0 1rem;
}
`,pt=n.memo(function({address:e,className:s="",count:t,offset:r,onCreateToggle:i,onRemove:l,seed:c}){const{t:d}=M(),u=(0,n.useMemo)(()=>(0,w.X)(c),[c]),m=(0,n.useCallback)(()=>i(u),[u,i]),h=(0,n.useCallback)(()=>l(e),[e,l]);return(0,a.jsxs)(ht,{className:s,children:[(0,a.jsx)("td",{className:"number",colSpan:2,children:(0,a.jsx)(o._x,{className:"vanity--Match-icon",value:e})}),(0,a.jsx)("td",{className:"address all",children:(0,a.jsxs)("div",{className:"vanity--Match-addr",children:[(0,a.jsx)("span",{className:"no",children:e.slice(0,r)}),(0,a.jsx)("span",{className:"yes",children:e.slice(r,t+r)}),(0,a.jsx)("span",{className:"no",children:e.slice(t+r)})]})}),(0,a.jsx)("td",{className:"hash",children:u}),(0,a.jsxs)("td",{className:"button",children:[(0,a.jsx)(o.$n,{icon:"plus",label:d("Save"),onClick:m}),(0,a.jsx)(o.$n,{icon:"times",onClick:h})]})]})}),xt=[{text:"No",value:!1},{text:"Yes",value:!0}],gt=o.I4.div`
.vanity--App-matches {
overflow-x: auto;
padding: 1em 0;
}
.vanity--App-stats {
padding: 1em 0 0 0;
opacity: 0.45;
text-align: center;
}
`,bt=n.memo(function({className:e="",onStatusChange:s}){const{t}=M(),{api:r,isEthereum:i}=(0,d.g)(),l=(0,n.useRef)([]),c=(0,n.useRef)(!1),u=(0,Pe.T)(),[m,h]=(0,n.useState)(null),[{elapsed:p,isRunning:x,keyCount:g,matches:b},j]=(0,n.useState)({elapsed:0,isRunning:!1,keyCount:-1,keyTime:0,matches:[],startAt:0}),[{isMatchValid:v,match:y},C]=(0,n.useState)({isMatchValid:!0,match:"Some"}),[w,k]=(0,n.useState)("ed25519"),[N,A]=(0,n.useState)(!0),F=(0,n.useCallback)(()=>h(null),[]),I=(0,n.useCallback)(()=>{const e=l.current;l.current=[],0!==e.length&&u.current&&j(({isRunning:s,keyCount:t,keyTime:a,matches:n,startAt:r})=>{let o=t,i=a;const l=e.reduce((e,{elapsed:s,found:t})=>(o+=t.length,i+=s,e.concat(t)),n);return{elapsed:Date.now()-r,isRunning:s,keyCount:o,keyTime:i,matches:l.sort(mt.A).slice(0,25),startAt:r}})},[u]),E=(0,n.useCallback)(()=>{if(!c.current)return I();(0,S.d)(()=>{u.current&&(25===l.current.length&&I(),l.current.push((0,dt.A)({match:y,runs:10,ss58Format:r.registry.chainSS58||0,type:w,withCase:N,withHex:!0})),E())})},[I,r,y,u,c,w,N]),T=(0,n.useCallback)(e=>C({isMatchValid:ut.A.test(e)&&0!==e.length&&e.length<31,match:e}),[]),D=(0,n.useCallback)(e=>j(s=>({...s,matches:s.matches.filter(s=>s.address!==e)})),[]),B=(0,n.useCallback)(()=>j(({elapsed:e,isRunning:s,keyCount:t,keyTime:a,matches:n,startAt:r})=>({elapsed:e,isRunning:!s,keyCount:s?t:0,keyTime:s?a:0,matches:n,startAt:s?r:Date.now()})),[]);(0,n.useEffect)(()=>{c.current=x,x&&E()},[E,x]);const P=(0,n.useMemo)(()=>[[t("matches"),"start",2],[t("Evaluated {{count}} keys in {{elapsed}}s ({{avg}} keys/s)",{replace:{avg:(g/(p/1e3)).toFixed(3),count:g,elapsed:(p/1e3).toFixed(2)}}),"start --digits"],[t("secret"),"start"],[]],[p,g,t]);return(0,a.jsxs)(gt,{className:e,children:[(0,a.jsxs)("div",{className:"ui--row",children:[(0,a.jsx)(o.pd,{autoFocus:!0,className:"medium",isDisabled:x,isError:!v,label:t("Search for"),onChange:T,onEnter:B,value:y}),(0,a.jsx)(o.ms,{className:"medium",isDisabled:x,label:t("case sensitive"),onChange:A,options:xt,value:N})]}),(0,a.jsx)("div",{className:"ui--row",children:(0,a.jsx)(o.ms,{className:"medium",defaultValue:w,label:t("keypair crypto type"),onChange:k,options:i?f.W.availableCryptosEth:f.W.availableCryptos})}),(0,a.jsx)(o.$n.Group,{children:(0,a.jsx)(o.$n,{icon:x?"stop":"sign-in-alt",isDisabled:!v,label:t(x?"Stop generation":"Start generation"),onClick:B})}),0!==b.length&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("article",{className:"warning centered",children:t('Ensure that you utilized the "Save" functionality before using a generated address to receive funds. Without saving the address and the associated seed any funds sent to it will be lost.')}),(0,a.jsx)(o.XI,{className:"vanity--App-matches",empty:t("No matches found"),header:P,children:b.map(e=>(0,n.createElement)(pt,{...e,key:e.address,onCreateToggle:h,onRemove:D}))})]}),m&&(0,a.jsx)(ie,{onClose:F,onStatusChange:s,seed:m,type:w})]})}),ft=["vanity"],jt=n.memo(function({basePath:e,onStatusChange:s}){const{t}=M(),{hasAccounts:c}=(0,i.o)(),{isIpfs:d}=(0,l.c)(),u=(0,n.useRef)([{isRoot:!0,name:"overview",text:t("My accounts")},{name:"vanity",text:t("Vanity generator")}]);return(0,a.jsxs)("main",{className:"accounts--App",children:[(0,a.jsx)(o.tU,{basePath:e,hidden:c&&!d?void 0:ft,items:u.current}),(0,a.jsx)(r.BV,{children:(0,a.jsxs)(r.qh,{path:e,children:[(0,a.jsx)(r.qh,{element:(0,a.jsx)(bt,{onStatusChange:s}),path:"vanity"}),(0,a.jsx)(r.qh,{element:(0,a.jsx)(ct,{onStatusChange:s}),index:!0})]})})]})})},52262(e,s,t){t.d(s,{A:()=>rs});var a=t(31085),n=t(14041),r=t(18690),o=t(1445),i=t(61020),l=t(59233),c=t(15816),d=t(6404),u=t(52362),m=t(21327);const h={aspectRatio:6,maintainAspectRatio:!0},p=o.I4.div`
background: var(--bg-table);
border: 1px solid var(--border-table);
border-radius: 0.25rem;
margin-bottom: 1rem;
padding: 1rem 1.5rem;
`,x=n.memo(function({className:e,colors:s,legends:t,options:n,title:r,value:{labels:i,values:l}}){return(0,a.jsx)(p,{className:e,children:(0,a.jsx)(o.t1.Line,{colors:s,labels:i,legends:t,options:n||h,title:r,values:l})})});var g=t(68300);const b={aspectRatio:6,maintainAspectRatio:!0,scales:{y:{beginAtZero:!0}}},f=["#00448c","#008c44","#acacac"],j=["#008c8c","#00448c","#8c4400","#acacac"],v=o.I4.div`
.container {
background: var(--bg-table);
border: 1px solid var(--border-table);
border-radius: 0.25rem;
padding: 1rem 1.5rem;
}
.container+.container {
margin-top: 1rem;
}
`,y=n.memo(function({className:e}){const{t:s}=(0,g.B)(),t=(0,u.n)(),{bytesLegend:r,requestsLegend:i}=(0,n.useMemo)(()=>({bytesLegend:[s("sent"),s("recv"),s("average")],errorsLegend:[s("errors")],requestsLegend:[s("total"),s("requests"),s("subscriptions"),s("average")]}),[s]),{bytesChart:l,requestsChart:c}=(0,n.useMemo)(()=>function(e){const s={labels:[],values:[[],[],[]]},t={labels:[],values:[[]]},a={labels:[],values:[[],[],[],[]]},n=e.reduce((e,{stats:{active:{requests:s,subscriptions:t}}})=>e+s+t,0);let{bytesRecv:r,bytesSent:o,errors:i}=e[0].stats.total,l=0;for(let c=1;c<e.length;c++){const{stats:{active:{requests:d,subscriptions:u},total:{bytesRecv:m,bytesSent:h,errors:p}},when:x}=e[c],g=new Date(x).toLocaleTimeString();s.labels.push(g),s.values[0].push(h-o),s.values[1].push(m-r),t.labels.push(g),t.values[0].push(p-i),a.labels.push(g),a.values[0].push(d+u),a.values[1].push(d),a.values[2].push(u),a.values[3].push(n/e.length),l+=m-r,i=p,r=m,o=h}const c=l/(e.length-1);for(let t=1;t<e.length;t++)s.values[2].push(c);return{bytesChart:s,errorsChart:t,requestsChart:a}}(t),[t]),d=t[t.length-1],h=d&&t.length>3,p=(0,a.jsx)("span",{className:"--tmp",children:"99"}),y=(0,a.jsx)("span",{className:"--tmp",children:"1,000kB"});return(0,a.jsxs)(v,{className:e,children:[(0,a.jsxs)(o.cp,{children:[(0,a.jsxs)("section",{children:[(0,a.jsx)(o.dS,{label:s("sent"),children:h?(0,a.jsxs)(a.Fragment,{children:[(0,m.Z)(d.stats.total.bytesSent/1024),"kB"]}):y}),(0,a.jsx)(o.dS,{label:s("recv"),children:h?(0,a.jsxs)(a.Fragment,{children:[(0,m.Z)(d.stats.total.bytesRecv/1024),"kB"]}):y})]}),(0,a.jsxs)("section",{children:[(0,a.jsx)(o.dS,{label:s("total req"),children:h?(0,a.jsx)(a.Fragment,{children:(0,m.Z)(d.stats.total.requests)}):p}),(0,a.jsx)(o.dS,{label:s("total sub"),children:h?(0,a.jsx)(a.Fragment,{children:(0,m.Z)(d.stats.total.subscriptions)}):p})]})]}),(0,a.jsxs)(o.pq,{isActive:h,children:[(0,a.jsx)(x,{colors:j,legends:i,options:b,title:s("requests made"),value:c}),(0,a.jsx)(x,{colors:f,legends:r,options:b,title:s("bytes transferred"),value:l})]})]})});var C=t(40941),w=t(54143);function k(e){return{isValid:(0,w.qv)(e,256)||/^\d+$/.test(e),value:e}}const S=(0,o.I4)(o.f7)`
.explorer--query {
width: 20em;
}
`,N=n.memo(function({className:e="",value:s}){const{t}=(0,g.B)(),[{isValid:r,value:i},l]=(0,n.useState)(()=>k(s||"")),c=(0,n.useCallback)(e=>l(k(e)),[]),d=(0,n.useCallback)(()=>{r&&0!==i.length&&(window.location.hash=`/explorer/query/${i}`)},[r,i]);return(0,a.jsx)(S,{className:`${e} ui--FilterOverlay hasOwnMaxWidth`,children:(0,a.jsx)(o.pd,{className:"explorer--query",defaultValue:s,isError:!r&&0!==i.length,onChange:c,onEnter:d,placeholder:t("block hash or number to query"),withLabel:!1,children:(0,a.jsx)(o.$n,{icon:"play",onClick:d})})})});var A=t(73657),F=t(22067),I=t(27010),E=t(16880),T=t(97186),D=t(28138),M=t(92165),B=t(27539);const P=n.memo(function({className:e="",value:{event:s}}){const t=`${s.section}.${s.method}`;return(0,a.jsx)(o.c6,{className:e,isLeft:!0,summary:t,summaryMeta:s.meta,children:s.data.length?(0,a.jsx)(B.A,{className:"details",eventName:t,value:s,withExpander:!0}):null})}),$=new Map,L=o.I4.section`
position: relative;
.ui--Toggle {
position: absolute;
top: 1.4rem;
right: 1rem;
z-index: 999;
}
`,V=n.memo(function({className:e="",emptyLabel:s,error:t,eventClassName:r,events:l,label:c,showToggle:d=!1}){const{t:u}=(0,g.B)(),{api:h}=(0,i.g)(),{allAccounts:p}=(0,T.o)(),[x,b]=(0,D.e)(),[f,j]=(0,n.useState)([]),v=(0,n.useMemo)(()=>[[c||u("recent events"),"start"]],[c,u]);return(0,n.useEffect)(()=>{(async()=>{if(l&&x)for(const e of l){const{blockHash:s,record:t}=e;if(!s)continue;let a=$.get(s);if(!a){const[{author:e},t]=await Promise.all([await h.derive.chain.getHeader(s),await h.rpc.chain.getBlock(s)]);if(a={author:e,extrinsics:t.block.extrinsics},$.set(s,a),$.size>200){const e=$.keys().next().value;e&&$.delete(e)}}const{author:n,extrinsics:r}=a;(0,M.d)(t,r,n,p)&&j(s=>(s??[]).some(s=>s.key===e.key)?s:[e,...s??[]])}})().catch(console.error)},[p,h.derive.chain,h.rpc.chain,l,x]),(0,a.jsxs)(L,{children:[(0,a.jsx)(o.XI,{className:e,empty:s||u("No events available"),header:v,children:t?(0,a.jsx)("tr",{className:r,children:(0,a.jsx)("td",{children:(0,a.jsx)(o.o_,{content:u("Unable to decode the block events. {{error}}",{replace:{error:t.message}})})})},"error"):(x?f:l)?.map(e=>function(e,{blockHash:s,blockNumber:t,indexes:n,key:r,record:o}){return(0,a.jsx)("tr",{className:e,children:(0,a.jsxs)("td",{className:"overflow relative",children:[(0,a.jsx)(P,{value:o}),t&&(0,a.jsxs)("div",{className:"absolute --digits",children:[1!==n.length&&(0,a.jsxs)("span",{children:[(0,m.Z)(n.length),"x "]}),(0,a.jsxs)(A.N_,{to:`/explorer/query/${s||""}`,children:[(0,m.Z)(t),"-",n[0].toString().padStart(2,"0")]})]})]})},r)}(r,e))}),d&&(0,a.jsx)(o.lM,{label:u("Show my events"),onChange:b,value:x})]})});var R=t(72026),z=t(95927),H=t.n(z);const q=new(H())(1e4),O=o.I4.tr`
.explorer--BlockByHash-event+.explorer--BlockByHash-event {
margin-top: 0.75rem;
}
.explorer--BlockByHash-nonce {
font-size: var(--font-size-small);
margin-left: 2.25rem;
margin-top: -0.5rem;
opacity: var(--opacity-light);
text-align: left;
}
.explorer--BlockByHash-unsigned {
opacity: var(--opacity-light);
font-weight: var(--font-weight-normal);
}
a.isDecoded {
display: block;
margin-top: 0.25rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
`,W=n.memo(function({blockNumber:e,className:s="",events:t,index:r,maxBlockWeight:i,value:l,withLink:c}){const{t:d}=(0,g.B)(),u=(0,n.useMemo)(()=>c?`#/extrinsics/decode/${l.toHex()}`:null,[l,c]),{method:h,section:p}=(0,n.useMemo)(()=>l.registry.findMetaCall(l.callIndex),[l]),x=(0,n.useMemo)(()=>"timestamp"===p&&"set"===h?new Date(l.args[0].unwrap().toNumber()):void 0,[h,p,l]),b=(0,n.useMemo)(()=>{if(l.isSigned){const s=function({era:e},s){if(s&&e.isMortalEra){const t=e.asMortalEra;return[t.birth(s.toNumber()),t.death(s.toNumber())]}return null}(l,e);return s?d("mortal, valid from #{{startAt}} to #{{endsAt}}",{replace:{endsAt:(0,m.Z)(s[1]),startAt:(0,m.Z)(s[0])}}):d("immortal")}},[e,d,l]),[,f,j,v]=(0,n.useMemo)(()=>function(e,s,t){const a=s?s.filter(({record:{phase:s}})=>s.isApplyExtrinsic&&s.asApplyExtrinsic.eq(e)):[],n=a.find(({record:{event:{method:e,section:s}}})=>"system"===s&&["ExtrinsicFailed","ExtrinsicSuccess"].includes(e)),r=n?"ExtrinsicSuccess"===n.record.event.method?n.record.event.data[0]:n.record.event.data[1]:void 0,o=r&&(0,I.iO)(r.weight);return[r,o?.v1Weight,o&&t?o.v1Weight.mul(q).div(t).toNumber()/100:0,a]}(r,t,i),[r,t,i]);return(0,a.jsxs)(O,{className:s,children:[(0,a.jsxs)("td",{className:"top",colSpan:2,children:[(0,a.jsx)(R.A,{className:"details",mortality:b,tip:l.tip?.toBn(),value:l,withHash:!0,withSignature:!0}),u&&(0,a.jsx)("a",{className:"isDecoded",href:u,rel:"noreferrer",children:u})]}),(0,a.jsx)("td",{className:"top media--1000",colSpan:2,children:v.map(({key:e,record:s})=>(0,a.jsx)(P,{className:"explorer--BlockByHash-event",value:s},e))}),(0,a.jsx)("td",{className:"top number media--1400",children:f&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(a.Fragment,{children:(0,m.Z)(f)}),(0,a.jsxs)("div",{children:[j.toFixed(2),"%"]})]})}),(0,a.jsx)("td",{className:"top media--1200",children:l.isSigned?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.ov,{value:l.signer}),(0,a.jsxs)("div",{className:"explorer--BlockByHash-nonce",children:[d("index")," ",(0,m.Z)(l.nonce)]}),(0,a.jsx)(o.e9,{data:l.hash.toHex(),type:"extrinsic"})]}):x?x.toLocaleString():null})]},`extrinsic:${r}`)}),U=({onToggleUserEvents:e,showOnlyUserEvents:s})=>{const{t}=(0,g.B)();return(0,a.jsx)(G,{children:(0,a.jsx)(o.lM,{label:t("Show my events"),onChange:e,value:s})})},G=o.I4.div`
.ui--Toggle {
label{
font-size: var(--font-size-base);
}
}
`,Y=n.memo(function({blockNumber:e,className:s="",events:t,label:r,maxBlockWeight:i,value:l,withLink:c}){const{t:d}=(0,g.B)(),{allAccounts:u}=(0,T.o)(),[m,h]=(0,D.e)(),p=(0,n.useMemo)(()=>[[r||d("extrinsics"),"start",2],[d("events"),"start media--1000",2],[d("weight"),"media--1400"],[(0,a.jsx)(U,{onToggleUserEvents:h,showOnlyUserEvents:m},"eventsToggle"),"end media--1000"]],[r,h,m,d]),x=(0,n.useMemo)(()=>m?t?.filter(e=>(0,M.d)(e.record,l,void 0,u)):t,[u,t,m,l]);return(0,a.jsx)(o.XI,{className:s,empty:d("No extrinsics available"),header:p,isFixed:!0,children:l?.map((s,t)=>(0,a.jsx)(W,{blockNumber:e,events:x,index:t,maxBlockWeight:i,value:s,withLink:c},`extrinsic:${t}`))})});var X=t(98893),Z=t(39139);function _(e){const s=e.Types.map(e=>({type:(0,Z.c)(e)})),t=e.toArray().map(e=>({isValid:!0,value:e}));return(0,a.jsx)(X.Ay,{isDisabled:!0,params:s,values:t,withExpander:!0})}const J=n.memo(function({value:e}){const{t:s}=(0,g.B)(),t=(0,n.useRef)([[s("justifications"),"start"]]),r=e.unwrapOr(null);return r?(0,a.jsx)(o.XI,{empty:s("No justifications available"),header:t.current,children:r?.map((e,s)=>(0,a.jsx)("tr",{children:(0,a.jsx)("td",{className:"overflow",children:(0,a.jsx)(o.c6,{summary:e[0].toString(),children:_(e)})})},`justification:${s}`))}):null});var K=t(96328),Q=t(30905),ee=t(5853),se=t(26679);function te(e){return e.value instanceof K._?function(e){const s=Object.entries(e.Type).map(([e,s])=>({name:e,type:(0,Z.c)(s)})),t=e.toArray().map(e=>({isValid:!0,value:e}));return(0,a.jsx)(X.Ay,{isDisabled:!0,params:s,values:t,withExpander:!0})}(e.value):e.value instanceof Q.r?function(e){const s=e.Types.map(e=>({type:(0,Z.c)(e)})),t=e.toArray().map(e=>({isValid:!0,value:e}));return(0,a.jsx)(X.Ay,{isDisabled:!0,params:s,values:t,withExpander:!0})}(e.value):e.value instanceof ee.l?function(e){const s=(0,Z.c)(e.Type),t=e.toArray().map(e=>({isValid:!0,value:e})),n=t.map((e,t)=>({name:`${t}`,type:s}));return(0,a.jsx)(X.Ay,{isDisabled:!0,params:n,values:t,withExpander:!0})}(e.value):e.value instanceof se.d?(s=e.value,(0,a.jsx)(X.Ay,{isDisabled:!0,params:[{type:(0,Z.c)("Bytes")}],values:[{isValid:!0,value:s}],withExpander:!0})):(0,a.jsx)("div",{children:e.value.toString().split(",").join(", ")});var s}const ae=n.memo(function({value:e}){const{t:s}=(0,g.B)(),t=(0,n.useRef)([[s("logs"),"start"]]);return(0,a.jsx)(o.XI,{empty:s("No logs available"),header:t.current,children:e?.map((e,s)=>(0,a.jsx)("tr",{children:(0,a.jsx)("td",{className:"overflow",children:(0,a.jsx)(o.c6,{isLeft:!0,summary:e.type.toString(),children:te(e)})})},`log:${s}`))})});var ne=t(33168),re=t(51524);const oe=n.memo(function({blockWeight:e,events:s,maxBlockWeight:t,maxProofSize:r,signedBlock:l}){const{t:c}=(0,g.B)(),{api:d}=(0,i.g)(),[u,h,p,x]=(0,n.useMemo)(()=>{const t=function(e){return e?e.reduce(([e,s,t,a],{record:{event:{data:n,method:r,section:o}}})=>{const i=(0,I.iO)(("ExtrinsicSuccess"===r?n[0]:n[1])?.weight).v2Weight.proofSize;return["balances"===o&&"Deposit"===r?e.iadd(n[1]):e,"balances"===o&&"Transfer"===r?s.iadd(n[2]):s,"system"===o&&["ExtrinsicFailed","ExtrinsicSuccess"].includes(r)?t.iadd((0,I.iO)(("ExtrinsicSuccess"===r?n[0]:n[1])?.weight).v1Weight):t,"system"===o&&["ExtrinsicFailed","ExtrinsicSuccess"].includes(r)?a.iadd((0,E.f)(i)?i:i.toBn()):a]},[new(H())(0),new(H())(0),new(H())(0),new(H())(0)]):[]}(s),{totalProofSize:a,totalRefTime:n}=function(e){const s=new(H())(0),t=new(H())(0);return["normal","operational","mandatory"].forEach(a=>{s.iadd(e?.[a].refTime.toBn()??new(H())(0)),t.iadd(e?.[a].proofSize.toBn()??new(H())(0))}),{totalProofSize:t,totalRefTime:s}}(e);return e&&(t[2]=n,t[3]=a),t},[e,s]);return(0,a.jsxs)(o.cp,{children:[(0,a.jsx)("section",{children:d.query.balances&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.dS,{label:c("deposits"),children:(0,a.jsx)(ne.A,{className:u?"":"--tmp",value:u||re.Uu})}),(0,a.jsx)(o.dS,{className:"media--1000",label:c("transfers"),children:(0,a.jsx)(ne.A,{className:h?"":"--tmp",value:h||re.Uu})})]})}),(0,a.jsxs)("section",{children:[(0,a.jsx)(o.dS,{label:c("ref time"),progress:{hideValue:!0,isBlurred:!(t&&p),total:t&&p?t:re.iz,value:t&&p?p:re.u_},children:p?(0,m.Z)(p):(0,a.jsx)("span",{className:"--tmp",children:"999,999,999"})}),r&&x&&(0,a.jsx)(o.dS,{label:c("proof size"),progress:{hideValue:!0,isBlurred:!1,total:r,value:x},children:(0,m.Z)(x)})]}),(0,a.jsxs)("section",{className:"media--900",children:[(0,a.jsx)(o.dS,{label:c("event count"),children:s?(0,m.Z)(s.length):(0,a.jsx)("span",{className:"--tmp",children:"99"})}),(0,a.jsx)(o.dS,{label:c("extrinsic count"),children:l?(0,m.Z)(l.block.extrinsics.length):(0,a.jsx)("span",{className:"--tmp",children:"99"})})]})]})}),ie=[["...","start",6]],le=(0,o.I4)(o.XI)`
.inline-hash-copy {
align-items: center;
display: inline-flex;
gap: 0.25em;
width: 100%;
a {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
`,ce=n.memo(function({className:e="",error:s,value:t}){const{t:r}=(0,g.B)(),{api:l}=(0,i.g)(),c=(0,F.T)(),[{blockWeight:d,events:u,getBlock:h,getHeader:p,nextBlockHash:x,runtimeVersion:b},f]=(0,n.useState)({}),[j,v]=(0,n.useState)(s),[y,C]=(0,n.useState)(),[w,k]=(0,n.useMemo)(()=>[!!b&&l.runtimeVersion.specName.eq(b.specName)&&l.runtimeVersion.specVersion.eq(b.specVersion),l.consts.system.blockWeights&&l.consts.system.blockWeights.maxBlock&&(0,I.iO)(l.consts.system.blockWeights.maxBlock).v2Weight],[l,b]);(0,n.useEffect)(()=>{s&&v(s)},[s]);const S=(0,n.useMemo)(()=>u?.filter(({record:{phase:e}})=>!e.isApplyExtrinsic),[u]);(0,n.useEffect)(()=>{t&&Promise.all([l.at(t).then(e=>Promise.all([Promise.resolve(e.runtimeVersion),e.query.system.events().catch(e=>(c.current&&C(e),null)),e.query.system.blockWeight().catch(()=>null)])),l.rpc.chain.getBlock(t),l.derive.chain.getHeader(t)]).then(e=>{c.current&&f(function([[e,s,t],a,n]){return{blockWeight:t,events:s?.map((e,s)=>({indexes:[s],key:`${Date.now()}-${s}-${e.hash.toHex()}`,record:e})),getBlock:a,getHeader:n,runtimeVersion:e}}(e))}).catch(e=>{c.current&&v(e)})},[l,c,t]),(0,n.useEffect)(()=>{if(!c.current||!p?.number)return;const e=p.number.unwrap().addn(1);let s;return l.rpc.chain.getBlockHash(e).then(t=>{t.isEmpty?l.derive.chain.subscribeNewHeads(t=>{c.current&&t.number.unwrap().eq(e)&&(f(e=>({...e,nextBlockHash:t.hash})),s&&s())}).then(e=>{s=e}).catch(e=>{c.current&&v(e)}):f(e=>({...e,nextBlockHash:t}))}).catch(e=>{c.current&&v(e)}),()=>{s&&s()}},[l,p?.number,c]);const N=(0,n.useMemo)(()=>p?[[(0,m.Z)(p.number.unwrap()),"start --digits",1],[r("hash"),"start"],[r("parent"),"start"],[r("next"),"start"],[r("extrinsics"),"start media--1300"],[r("state"),"start media--1200"],[b?`${b.specName.toString()}/${b.specVersion.toString()}`:void 0,"media--1000"]]:ie,[p,b,r]),T=p?.number.unwrap(),D=p?.parentHash.toHex(),M=!p?.parentHash.isEmpty;return(0,a.jsxs)("div",{className:e,children:[(0,a.jsx)(oe,{blockWeight:d,events:u,maxBlockWeight:k.refTime.toBn(),maxProofSize:(0,E.f)(k.proofSize)?k.proofSize:k.proofSize.toBn(),signedBlock:h}),(0,a.jsx)(le,{header:N,children:j?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:6,children:(0,a.jsx)(o.o_,{content:r("Unable to retrieve the specified block details. {{error}}",{replace:{error:j.message}})})})}):h&&p&&!h.isEmpty&&!p.isEmpty&&(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"address",children:p.author&&(0,a.jsx)(o.y1,{value:p.author})}),(0,a.jsx)("td",{className:"hash overflow",children:p.hash.toHex()}),(0,a.jsx)("td",{className:"hash overflow",children:M?(0,a.jsxs)("span",{className:"inline-hash-copy",children:[(0,a.jsx)(A.N_,{to:`/explorer/query/${D||""}`,children:D}),(0,a.jsx)(o.i8,{value:D})]}):D}),(0,a.jsx)("td",{className:"hash overflow",children:x?(0,a.jsxs)("span",{className:"inline-hash-copy",children:[(0,a.jsx)(A.N_,{to:`/explorer/query/${x.toHex()}`,children:x.toHex()}),(0,a.jsx)(o.i8,{value:x.toHex()})]}):r("Waiting for next block...")}),(0,a.jsx)("td",{className:"hash overflow media--1300",children:p.extrinsicsRoot.toHex()}),(0,a.jsx)("td",{className:"hash overflow media--1200",children:p.stateRoot.toHex()}),(0,a.jsx)("td",{className:"media--1000",children:t&&(0,a.jsx)(o.e9,{data:t,type:"block"})})]})}),h&&p&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{blockNumber:T,events:u,maxBlockWeight:k.refTime.toBn(),value:h.block.extrinsics,withLink:w}),(0,a.jsxs)(o.Yt,{children:[(0,a.jsx)(o.Yt.Column,{children:(0,a.jsx)(V,{error:y,eventClassName:"explorer--BlockByHash-block",events:S,label:r("system events")})}),(0,a.jsxs)(o.Yt.Column,{children:[(0,a.jsx)(ae,{value:p.digest.logs}),(0,a.jsx)(J,{value:h.justifications})]})]})]})]})}),de=n.memo(function({value:e}){const{api:s}=(0,i.g)(),[t,r]=(0,n.useState)(null),o=(0,F.T)(),[l,c]=(0,n.useState)(null);return(0,n.useEffect)(()=>{s.rpc.chain.getBlockHash(e).then(e=>{o.current&&r(e)}).catch(e=>{console.error(1),o.current&&c(e)})},[s,o,e]),(0,a.jsx)(ce,{error:l,value:t?t.toHex():null})}),ue=n.memo(function(){const e=(0,C.x)(),{value:s}=(0,r.g)(),[t,o]=(0,n.useState)(s);if((0,n.useEffect)(()=>{o(t=>s&&s!==t?s:!t&&e?e.toString():t)},[e,s]),!t)return null;const i=(0,w.qv)(t)?ce:de;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N,{}),(0,a.jsx)(i,{value:t},t)]})});var me=t(58797),he=t(79129),pe=t(55155);const xe={details:[],isLoaded:!1,maxItems:50,stdDev:0,timeAvg:0,timeMax:0,timeMin:0};function ge(e){const s=e.sort((e,s)=>e.block.number-s.block.number).filter(({block:s},t)=>0===t||s.number>e[t-1].block.number);for(let e=0;e<s.length-1;e++){const t=s[e],a=s[e+1];if(t.now===a.now)continue;const n=a.now-t.now;if(n<0){a.delay=0;continue}let r=e+1;for(;r<s.length&&s[r].now===a.now;)r++;const o=s[r-1].block.number-t.block.number;if(o<=0){a.delay=n;continue}const i=n/o;for(let t=e+1;t<r;t++)s[t].delay=i}return s.slice(-50)}function be(e,{block:s,events:t}){const a=function({extrinsics:e}){return e.find(({method:{method:e,section:s}})=>"set"===e&&"timestamp"===s)}(s);return a?[...e,{block:{bytes:s.encodedLength,number:s.header.number.toNumber()},delay:0,events:{count:t.length,system:t.filter(({phase:e})=>!e.isApplyExtrinsic).length},extrinsics:{bytes:s.extrinsics.reduce((e,s)=>e+s.encodedLength,0),count:s.extrinsics.length},now:a.args[0].toNumber(),parentHash:s.header.parentHash}]:e}function fe(e,s){return s.reduce((e,s)=>be(e,s),e)}async function je(e,s){return s.length?(await Promise.all(s.map(s=>e.derive.chain.getBlockByNumber(s)))).filter(e=>!!e):[]}const ve=(0,pe.F)("useLatency",function(){const{api:e}=(0,i.g)(),[s,t]=(0,n.useState)([]),a=(0,he.Gc)(e.derive.chain.subscribeNewBlocks),r=(0,n.useRef)(!1);return(0,n.useEffect)(()=>{a&&(t(e=>ge(be(e,a))),r.current||(r.current=!0,async function(e,{block:{header:s}}){const t=[];let a=s.number.toNumber();for(let e=1;a>0&&e<=50;e++)t.push(--a);return je(e,t)}(e,a).then(e=>t(s=>ge(fe(s,e)))).catch(console.error)))},[e,a]),(0,n.useEffect)(()=>{if(s.length<=2)return;const a=s.findIndex(({block:e},t)=>t!==s.length-1&&s[t+1].block.number-e.number>1);-1!==a&&async function(e,{block:{number:s}},{block:{number:t}}){const a=[];for(let e=s+1;e<t;e++)a.push(e);return je(e,a)}(e,s[a],s[a+1]).then(e=>t(s=>ge(fe(s,e)))).catch(console.error)},[e,s]),(0,n.useMemo)(()=>{const e=s.map(({delay:e})=>e).filter(e=>e);if(!e.length)return xe;const t=e.reduce((e,s)=>e+s,0)/e.length,a=Math.sqrt(e.reduce((e,s)=>e+Math.pow(t-s,2),0)/e.length);return{details:s,isLoaded:50===s.length,maxItems:50,stdDev:a,timeAvg:t,timeMax:Math.max(...e),timeMin:Math.min(...e)}},[s])}),ye=["times","blocks","extrinsics","events"],Ce={blocks:["#008c8c","#acacac"],events:["#00448c","#8c0044","#acacac"],extrinsics:["#448c00","#acacac"],times:["#8c8c00","#acacac"]};function we(e,s=1e3){return(0,a.jsxs)("span",{className:"--digits",children:[`${(e/s).toFixed(3)}`,(0,a.jsx)("span",{className:"postfix",children:" s"})]})}const ke=o.I4.div`
.container {
background: var(--bg-table);
border: 1px solid var(--border-table);
border-radius: 0.25rem;
padding: 1rem 1.5rem;
}
.container+.container {
margin-top: 1rem;
}
span.--digits {
.postfix {
font-size: var(--font-percent-tiny);
}
}
`,Se=n.memo(function({className:e}){const{t:s}=(0,g.B)(),{details:t,isLoaded:r,maxItems:i,stdDev:l,timeAvg:c,timeMax:d,timeMin:u}=ve(),[h,p]=(0,n.useState)(()=>new Array(ye.length).fill(!1));(0,n.useEffect)(()=>{if(r){const e=h.findIndex(e=>!e);-1!==e&&(0,me.d)(()=>p(h.map((s,t)=>t===e||s)))}},[r,h]);const b=(0,n.useMemo)(()=>function(e,s){const t={labels:[],values:[[],[]]},a={labels:[],values:[[],[],[]]},n={labels:[],values:[[],[]]},r={labels:[],values:[[],[]]},o=e.reduce((e,{events:{count:s}})=>e+s,0),i=e.reduce((e,{extrinsics:{count:s}})=>e+s,0),l=e.reduce((e,{block:{bytes:s}})=>e+s,0);for(let s=0,r=e.length;s<r;s++){const r=(0,m.Z)(e[s].block.number);t.labels.push(r),t.values[0].push(e[s].block.bytes),t.values[1].push(l/e.length),a.labels.push(r),a.values[0].push(e[s].events.count),a.values[1].push(e[s].events.system),a.values[2].push(o/e.length),n.labels.push(r),n.values[0].push(e[s].extrinsics.count),n.values[1].push(i/e.length)}const c=e.filter(({delay:e})=>e),d=s*c.length;for(let e=0,s=c.length;e<s;e++)r.labels.push((0,m.Z)(c[e].block.number)),r.values[0].push(c[e].delay/1e3),r.values[1].push(d/c.length/1e3);return{blockLast:r.values[0][r.values[0].length-1],blocks:t,events:a,extrinsics:n,times:r}}(t,c),[t,c]),[f,j]=(0,n.useMemo)(()=>[{blocks:[s("bytes"),s("average")],events:[s("events"),s("system"),s("average")],extrinsics:[s("extrinsics"),s("average")],times:[s("blocktime"),s("average")]},{blocks:s("blocksize (last {{n}} blocks)",{replace:{n:i}}),events:s("events (last {{n}} blocks)",{replace:{n:i}}),extrinsics:s("extrinsics (last {{n}} blocks)",{replace:{n:i}}),times:s("blocktimes (last {{n}} blocks)",{replace:{n:i}})}],[i,s]),v=(0,a.jsxs)("span",{className:"--tmp --digits",children:["0.000 ",(0,a.jsx)("span",{className:"postfix",children:"s"})]});return(0,a.jsxs)(ke,{className:e,children:[(0,a.jsxs)(o.cp,{children:[(0,a.jsxs)("section",{children:[(0,a.jsx)(o.dS,{label:s("avg"),children:r?we(c):v}),(0,a.jsx)(o.dS,{className:"media--1000",label:s("std dev"),children:r?we(l):v})]}),(0,a.jsxs)("section",{children:[(0,a.jsx)(o.dS,{label:s("min"),children:r?we(u):v}),(0,a.jsx)(o.dS,{label:s("max"),children:r?we(d):v})]}),(0,a.jsx)(o.dS,{label:s("last"),children:r?we(b.blockLast,1):v})]}),(0,a.jsx)(o.pq,{isActive:r,children:ye.map(e=>(0,a.jsx)(x,{colors:Ce[e],legends:f[e],title:j[e],value:b[e]},e))})]})});var Ne=t(51661);const Ae=(0,o.I4)(o.XI)`
overflow-x: auto;
td.roles {
max-width: 9ch;
width: 9ch;
}
td.bestNumber {
max-width: 11ch;
width: 11ch;
}
`,Fe=n.memo(function({className:e="",peers:s}){const{t}=(0,g.B)(),r=(0,n.useRef)([[t("connected peers"),"start",2],[t("best hash"),"start"],[t("best #"),"number"]]),o=(0,n.useMemo)(()=>s&&function(e){return e.map(({bestHash:e,bestNumber:s,peerId:t,roles:a})=>({bestHash:e.toHex(),bestNumber:s,peerId:t.toString(),roles:(0,Ne.Oy)(a)})).sort((e,s)=>e.peerId.localeCompare(s.peerId)).sort((e,s)=>e.roles.localeCompare(s.roles)).sort((e,s)=>s.bestNumber.cmp(e.bestNumber))}(s),[s]);return(0,a.jsx)(Ae,{className:e,empty:t("no peers connected"),header:r.current,children:o?.map(({bestHash:e,bestNumber:s,peerId:t,roles:n})=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"roles",children:n}),(0,a.jsx)("td",{className:"hash overflow",children:t}),(0,a.jsx)("td",{className:"hash overflow",children:e}),(0,a.jsx)("td",{className:"number bestNumber",children:(0,m.Z)(s)})]},t))})});var Ie=t(11683),Ee=t(60078);const Te={extrinsics:null,health:null,peers:null},De=n.memo(function({info:{extrinsics:e,health:s,peers:t}=Te,nextRefresh:r}){const{t:i}=(0,g.B)(),[l,c]=(0,n.useState)(re.Yz);return(0,n.useEffect)(()=>{if(t){const e=t.sort((e,s)=>s.bestNumber.cmp(e.bestNumber))[0];c(e?e.bestNumber:re.Yz)}},[t]),(0,a.jsxs)(o.cp,{children:[(0,a.jsxs)("section",{children:[(0,a.jsx)(o.dS,{label:i("refresh in"),children:(0,a.jsx)(Ie.A,{value:r})}),s&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.dS,{className:"media--800",label:i("total peers"),children:(0,m.Z)(s.peers)}),(0,a.jsx)(o.dS,{className:"media--800",label:i("syncing"),children:s.isSyncing.valueOf()?i("yes"):i("no")})]})]}),e&&e.length>0&&(0,a.jsx)("section",{className:"media--1200",children:(0,a.jsx)(o.dS,{label:i("queued tx"),children:e.length})}),(0,a.jsxs)("section",{children:[l?.gtn(0)&&(0,a.jsx)(o.dS,{label:i("peer best"),children:(0,m.Z)(l)}),(0,a.jsx)(o.dS,{label:i("our best"),children:(0,a.jsx)(Ee.A,{})})]})]})}),Me=n.memo(function(){const{t:e}=(0,g.B)(),{api:s}=(0,i.g)(),[t,r]=(0,n.useState)({}),[o,l]=(0,n.useState)(()=>Date.now());return(0,n.useEffect)(()=>{const e=()=>{l(Date.now()+9900),async function(e){try{const[s,t,a,n]=await Promise.all([e.derive.chain.bestNumber(),e.rpc.system.health().catch(()=>null),e.rpc.system.peers().catch(()=>null),e.rpc.author.pendingExtrinsics().catch(()=>null)]);return{blockNumber:s,extrinsics:n,health:t,peers:a}}catch{return{}}}(s).then(r).catch(console.error)};e();const t=window.setInterval(e,9900);return()=>{window.clearInterval(t)}},[]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(De,{info:t,nextRefresh:o}),(0,a.jsx)(Fe,{peers:t.peers}),(0,a.jsx)(Y,{blockNumber:t.blockNumber,label:e("pending extrinsics"),value:t.extrinsics,withLink:!0})]})});function Be(e){return Math.max(1,e.reduce((e,{hdr:{width:s}})=>e+s,0))}function Pe(e){return e.reduce((e,{arr:s,hdr:t})=>(t.height=t.isEmpty?0:1+Pe(s),Math.max(e,t.height)),0)}function $e({hdr:{author:e,hash:s,isEmpty:t,isFinalized:a,parent:n,width:r}}){return{author:e,hash:s,isEmpty:t,isFinalized:a,parent:n,width:r}}function Le(e){return e.length?Le(e.reduce((e,{arr:s})=>e.concat(...s),[])).concat({bn:e.reduce((e,{hdr:{bn:s}})=>e||s,""),cols:e.map($e)}):[]}function Ve(e,s,t,a,n=!1){return{author:a,bn:e,hash:s,height:0,isEmpty:n,isFinalized:!1,parent:t,width:0}}function Re(){return{arr:[],hdr:Ve(""," "," ",null,!0)}}function ze(e){e.some(({arr:e})=>0!==e.length)&&(e.filter(({arr:e})=>0===e.length).forEach(({arr:e})=>e.push(Re())),ze(e.reduce((e,{arr:s})=>e.concat(...s),[])))}function He(e){return!(!e[0]||e[0].isEmpty)&&e.reduce((e,s,t)=>(0===t||!!s.isEmpty)&&e,!0)}function qe({author:e,hash:s,isEmpty:t,isFinalized:n,parent:r,width:i},l){return(0,a.jsx)("td",{className:`header ${t?"isEmpty":""} ${n?"isFinalized":"isNotFinal"}`,colSpan:i,children:t?(0,a.jsx)("div",{className:"empty"}):(0,a.jsxs)(a.Fragment,{children:[e&&(0,a.jsx)(o._x,{className:"author",size:28,value:e}),(0,a.jsxs)("div",{className:"contents",children:[(0,a.jsx)("div",{className:"hash",children:s}),(0,a.jsx)("div",{className:"parent",children:r})]})]})},`${s}:${l}:${i}`)}function Oe(e){const s=e.length-1;let t=!1;return e.map(({bn:n,cols:r},o)=>{if(0!==o&&o!==s&&He(r)){if(t)return null;if(He(e[o-1].cols))return t=!0,(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{},"blockNumber"),(0,a.jsx)("td",{className:"header isLink",colSpan:r[0].width,children:(0,a.jsx)("div",{className:"link",children:"⋮"})})]},n)}return t=!1,(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{children:`#${n}`},"blockNumber"),r.map(qe)]},n)})}const We=o.I4.div`
margin-bottom: 1.5rem;
table {
border-collapse: separate;
border-spacing: 0.25rem;
font: var(--font-mono);
td {
padding: 0.25rem 0.5rem;
text-align: center;
.author,
.contents {
display: inline-block;
vertical-align: middle;
}
.author {
margin-right: 0.25rem;
}
.contents {
.hash, .parent {
margin: 0 auto;
max-width: 6rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.parent {
font-size: var(--font-size-small);
line-height: 0.75rem;
max-width: 4.5rem;
}
}
&.blockNumber {
font-size: 1.25rem;
}
&.header {
background: #fff;
border: 1px solid #e6e6e6;
border-radius: 0.25rem;
&.isEmpty {
background: transparent;
border-color: transparent;
}
&.isFinalized {
background: rgba(0, 255, 0, 0.1);
}
&.isNotFinal {
color: rgba(0,0,0);
}
&.isLink {
background: transparent;
border-color: transparent;
line-height: 1rem;
padding: 0;
}
&.isMissing {
background: rgba(255, 0, 0, 0.05);
}
}
}
}
`,Ue=n.memo(function({className:e}){const{t:s}=(0,g.B)(),{api:t}=(0,i.g)(),[r,l]=(0,n.useState)(null),c=(0,n.useRef)(new Map([["root",[]]])),d=(0,n.useRef)({numBlocks:0,numForks:0}),u=(0,n.useRef)(new Map),h=(0,n.useRef)(""),p=(0,n.useCallback)(e=>{const s=u.current.get(e);s&&!s.isFinalized&&(s.isFinalized=!0,p(s.parent))},[]),x=(0,n.useCallback)((e,s)=>((c.current.get(e.hash)||[]).map(e=>u.current.get(e)).filter(e=>!!e).forEach(e=>{s.push({arr:x(e,[]),hdr:e})}),e.height=Pe(s),e.width=Be(s),s.sort((e,s)=>e.hdr.width>s.hdr.width||e.hdr.height>s.hdr.height||e.hdr.isFinalized?-1:e.hdr.width<s.hdr.width||e.hdr.height<s.hdr.height||s.hdr.isFinalized?1:0),s),[]),b=(0,n.useCallback)(()=>{const e=Re();return(c.current.get("root")||[]).forEach(s=>{const t=u.current.get(s);t&&e.arr.push({arr:[],hdr:{...t}})}),e.arr.forEach(({arr:e,hdr:s})=>{x(s,e)}),ze(e.arr),e.hdr.height=Pe(e.arr),e.hdr.width=Be(e.arr),e},[x]),f=(0,n.useCallback)(e=>{p(e.hash.toHex())},[p]),j=(0,n.useCallback)(e=>{const s=(0,m.Z)(e.number),a=e.hash.toHex(),n=e.parentHash.toHex();let r=!1;if(h.current||(h.current=s),!u.current.has(a)){if(h.current===s&&c.current.get("root").push(a),u.current.set(a,Ve(s,a,n,null)),c.current.has(n)?(r=!0,c.current.get(n).push(a)):c.current.set(n,[a]),!u.current.has(n)&&h.current!==s)return console.warn(`Retrieving missing header ${e.parentHash.toHex()}`),void t.rpc.chain.getHeader(e.parentHash).then(j).catch(console.error);d.current.numBlocks++,r&&d.current.numForks++,l(b())}},[t,b]);return(0,n.useEffect)(()=>{let e=null,s=null;return(async()=>{e=await t.rpc.chain.subscribeFinalizedHeads(f),s=await t.rpc.chain.subscribeNewHeads(j)})().catch(console.error),()=>{e&&e(),s&&s()}},[t,f,j]),r?(0,a.jsxs)(We,{className:e,children:[(0,a.jsx)(o.cp,{children:(0,a.jsxs)("section",{children:[(0,a.jsx)(o.dS,{label:s("blocks"),children:(0,m.Z)(d.current.numBlocks)}),(0,a.jsx)(o.dS,{label:s("forks"),children:(0,m.Z)(d.current.numForks)})]})}),(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Oe(Le(r.arr))})})]}):null});function Ge(e,s="s",t=!1){const[n,r]=e.toFixed().split(".");return t&&r?.trim()?.length>0?(0,a.jsxs)(a.Fragment,{children:[n,".",r," ",(0,a.jsxs)("span",{className:"timeUnit",children:[s," ago"]})]}):(0,a.jsxs)(a.Fragment,{children:[n," ",(0,a.jsxs)("span",{className:"timeUnit",children:[s," ago"]})]})}const Ye="0.5rem",Xe=o.I4.tr`
.blockTime {
text-align: right;
font-style: italic;
white-space: nowrap;
min-width: 6rem;
}
td {
border-top: ${e=>e.isFirstItem&&"0.375rem solid var(--bg-page)"};
border-radius: 0rem !important;
&:first-child {
border-top-left-radius: ${e=>e.isFirstItem?Ye:"0rem"}!important;
border-bottom-left-radius: ${e=>e.isLastItem?Ye:"0rem"}!important;
}
&:last-child {
border-top-right-radius: ${e=>e.isFirstItem?Ye:"0rem"}!important;
border-bottom-right-radius: ${e=>e.isLastItem?Ye:"0rem"}!important;
}
.timeUnit {
font-size: var(--font-percent-small);
}
}
`,Ze=n.memo(function({headers:e}){return(0,a.jsx)(a.Fragment,{children:e.map((s,t)=>{const n=s.hash.toHex();return(0,a.jsxs)(Xe,{className:"isExpanded",isFirstItem:0===t,isLastItem:t===e.length-1,children:[(0,a.jsx)("td",{className:"number",children:(0,a.jsx)("h4",{className:"--digits",children:(0,a.jsx)(A.N_,{to:`/explorer/query/${n}`,children:(0,m.Z)(s.number)})})}),(0,a.jsx)("td",{className:"all hash overflow",children:n}),(0,a.jsx)("td",{className:"address",children:s.author&&(0,a.jsx)(o.y1,{value:s.author})}),(0,a.jsx)("td",{className:"--digits blockTime",children:(r=(Date.now()-s.timestamp.toNumber())/1e3,r<60?Ge(r,"secs",r<15):r<3600?Ge(r/60,"mins"):Ge(r/3600,"hrs"))},Date.now())]},s.number.toString());var r})})}),_e=n.memo(function({headers:e}){const{t:s}=(0,g.B)(),t=(0,n.useRef)([[s("recent blocks"),"start",4]]),r=(0,n.useMemo)(()=>e.reduce((e,s)=>{const t=s.timestamp.toString();return e[t]||(e[t]=[]),e[t].push(s),e},{}),[e]);return(0,a.jsx)(o.XI,{empty:s("No blocks available"),header:t.current,children:Object.entries(r).map(([e,s])=>(0,a.jsx)(Ze,{headers:s.filter(e=>!!e)},e))})});var Je=t(22462),Ke=t(69832),Qe=t(85016),es=t(1290),ss=t(7851),ts=t(84596);const as=n.memo(function({eventCount:e,headers:s}){const{t}=(0,g.B)(),{api:n}=(0,i.g)();return(0,a.jsxs)(o.cp,{children:[(0,a.jsxs)("section",{children:[n.query.timestamp&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.dS,{label:t("last block"),children:(0,a.jsx)(Je.A,{},s.at(0)?.hash.toHex())}),(0,a.jsx)(o.dS,{className:"media--800",label:t("slot"),children:(0,a.jsx)(Ke.A,{value:re.Uu})})]}),n.query.balances&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.dS,{className:"media--800",label:t("total issuance"),children:(0,a.jsx)(Qe.A,{})}),!!n.query.balances.inactiveIssuance&&(0,a.jsx)(o.dS,{className:"media--1300",label:t("inactive issuance"),children:(0,a.jsx)(es.A,{})})]})]}),(0,a.jsx)("section",{className:"media--1100",children:(0,a.jsx)(ts.A,{withEra:!1})}),(0,a.jsxs)("section",{children:[(0,a.jsx)(o.dS,{className:"media--1400",label:t("last events"),children:(0,m.Z)(e)}),n.query.grandpa&&(0,a.jsx)(o.dS,{label:t("finalized"),children:(0,a.jsx)(ss.A,{})}),(0,a.jsx)(o.dS,{label:t("best"),children:(0,a.jsx)(Ee.A,{})})]})]})}),ns=n.memo(function({eventCount:e,events:s,headers:t}){return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N,{}),(0,a.jsx)(as,{eventCount:e,headers:t}),(0,a.jsxs)(o.Yt,{children:[(0,a.jsx)(o.Yt.Column,{children:(0,a.jsx)(_e,{headers:t})}),(0,a.jsx)(o.Yt.Column,{children:(0,a.jsx)(V,{events:s,showToggle:!0})})]})]})}),rs=n.memo(function({basePath:e,className:s}){const{t}=(0,g.B)(),{api:u}=(0,i.g)(),{lastHeaders:m}=(0,l.$)(),{eventCount:h,events:p}=(0,c.s)(),x=(0,n.useRef)(function(e){return[{isRoot:!0,name:"chain",text:e("Chain info")},{hasParams:!0,name:"query",text:e("Block details")},{name:"latency",text:e("Latency")},{name:"forks",text:e("Forks")},{name:"node",text:e("Node info")},{name:"api",text:e("API stats")}]}(t)),b=(0,n.useMemo)(()=>(0,d.T)(u.query.babe?.authorities)?[]:["forks"],[u]);return(0,a.jsxs)("main",{className:s,children:[(0,a.jsx)(o.tU,{basePath:e,hidden:b,items:x.current}),(0,a.jsx)(r.BV,{children:(0,a.jsxs)(r.qh,{path:e,children:[(0,a.jsx)(r.qh,{element:(0,a.jsx)(y,{}),path:"api"}),(0,a.jsx)(r.qh,{element:(0,a.jsx)(Ue,{}),path:"forks"}),(0,a.jsx)(r.qh,{element:(0,a.jsx)(Se,{}),path:"latency"}),(0,a.jsx)(r.qh,{element:(0,a.jsx)(Me,{}),path:"node"}),(0,a.jsx)(r.qh,{element:(0,a.jsx)(ue,{}),path:"query/:value?"}),(0,a.jsx)(r.qh,{element:(0,a.jsx)(ns,{eventCount:h,events:p,headers:m}),index:!0})]})})]})})},54668(e,s,t){t.d(s,{A:()=>r});var a=t(55155),n=t(97186);const r=(0,a.F)("useCounter",function(){const{hasAccounts:e}=(0,n.o)();return e?null:"!"})},60086(e,s,t){t.d(s,{A:()=>E});var a=t(31085),n=t(14041),r=t(18690),o=t(1445),i=t(61020),l=t(97186),c=t(22067),d=t(55155);const u=(0,d.F)("useProxies",function(){const{api:e}=(0,i.g)(),{allAccounts:s}=(0,l.o)(),t=(0,c.T)(),[a,r]=(0,n.useState)({});return(0,n.useEffect)(()=>{s.length&&e.query.proxy.proxies.multi(s).then(e=>t.current&&r(e.map(([e],t)=>[s[t],e.map(({delegate:e})=>e.toString())]).filter(([,e])=>e.length).reduce((e,[s,t])=>({...e,[s]:t}),{}))).catch(console.error)},[s,e,t]),a});var m=t(28138),h=t(44366),p=t(51524),x=t(37140);function g(){return(0,x.Bd)("app-gilt")}const b=n.memo(function({className:e,isDisabled:s,proxies:t}){const{t:r}=g(),{api:l}=(0,i.g)(),[c,d]=(0,m.e)(),[u,x]=(0,n.useState)(null),[b,f]=(0,n.useState)(null),[j,v]=(0,n.useState)(),[y,C]=(0,n.useState)(),w=(0,n.useMemo)(()=>u&&j&&y?l.tx.proxy.proxy(u,null,l.tx.gilt.placeBid(j,y)):null,[l,u,j,y]),k=Object.keys(t),S=!j||j.isZero()||j.lt(l.consts.gilt.minFreeze),N=!y||!y.gte(p.Uu)||y.gt(l.consts.gilt.queueCount);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.$n,{icon:"plus",isDisabled:!k.length||s,label:r("Submit Bid"),onClick:d}),c&&(0,a.jsxs)(o.aF,{className:e,header:r("submit gilt bid"),onClose:d,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsxs)(o.aF.Columns,{hint:r("This account will make the bid for the gilt and pay all associated fees."),children:[(0,a.jsx)(o.B4,{filter:k,label:r("use proxied account"),labelExtra:(0,a.jsx)(h.A,{label:(0,a.jsx)("span",{className:"label",children:r("transferable")}),params:u}),onChange:x,type:"account"}),u&&(0,a.jsx)(o.B4,{filter:t[u],label:r("send via proxy"),onChange:f,type:"account"})]}),(0,a.jsxs)(o.aF.Columns,{hint:r("The amount you wish to lock for the duration. It needs to be more than the gilt minimum."),children:[(0,a.jsx)(o.xg,{autoFocus:!0,defaultValue:l.consts.gilt.minFreeze,isError:S,isZeroable:!1,label:r("bid amount"),onChange:v}),(0,a.jsx)(o.xg,{defaultValue:l.consts.gilt.minFreeze,isDisabled:!0,label:r("minimum freeze amount")})]}),(0,a.jsxs)(o.aF.Columns,{hint:r("The number of periods this bid is to be freezed for, less than the maximum period"),children:[(0,a.jsx)(o.YI,{defaultValue:p.Uu,isError:N,isZeroable:!1,label:r("lock periods"),onChange:C}),(0,a.jsx)(o.YI,{defaultValue:l.consts.gilt.queueCount,isDisabled:!0,label:r("maximum lock periods")})]})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.jX,{accountId:b,extrinsic:w,icon:"check",isDisabled:S||N||!u,label:r("Bid"),onStart:d})})]})]})});var f=t(33168),j=t(21327);const v=n.memo(function({className:e,value:{balance:s,index:t,numItems:n}}){return(0,a.jsxs)("tr",{className:e,children:[(0,a.jsx)(o.XI.Column.Id,{value:t}),(0,a.jsx)("td",{className:"number all",children:(0,j.Z)(n)}),(0,a.jsx)("td",{className:"all",children:(0,a.jsx)(f.A,{value:s})})]})}),y=n.memo(function({className:e,queueTotals:s}){const{t}=g(),r=(0,n.useRef)([[t("queues"),"start"],[t("participants"),"number"],[t("balance"),"number"]]);return(0,a.jsx)(o.XI,{className:e,empty:s&&t("No active gilt queues found."),header:r.current,children:s?.map(e=>(0,a.jsx)(v,{value:e},e.index))})});var C=t(40941),w=t(95927);const k=new(t.n(w)())(1e4),S=n.memo(function({activeTotal:e,className:s,isDisabled:t}){const{t:n}=g(),{api:r}=(0,i.g)(),l=(0,C.x)();return(0,a.jsxs)(o.cp,{className:s,children:[(0,a.jsxs)("section",{children:[(0,a.jsx)(o.dS,{label:n("active"),children:n(t?"no":"yes")}),e&&(0,a.jsx)(o.dS,{label:n("index"),children:(0,j.Z)(e.index)})]}),e&&(0,a.jsxs)("section",{children:[(0,a.jsxs)(o.dS,{label:n("proportion"),children:[(e.proportion.mul(k).imul(p.cM).div(p.ik).toNumber()/1e4).toFixed(2),"%"]}),(0,a.jsxs)(o.dS,{label:n("target"),children:[(e.target.mul(k).imul(p.cM).div(p.ik).toNumber()/1e4).toFixed(2),"%"]})]}),(0,a.jsx)("section",{children:l&&(0,a.jsx)(o.dS,{label:n("intake"),progress:{total:r.consts.gilt.intakePeriod,value:l.mod(r.consts.gilt.intakePeriod),withTime:!0}})})]})});var N=t(87497);const A={defaultValue:{},transform:([e,s])=>({activeIndex:e.index.isZero()?null:e.index.sub(p.Uu),activeTotal:e,queueTotals:s.map(([e,s],t)=>({balance:s,index:t+1,numItems:e})).filter(({balance:e})=>!e.isZero())})},F=(0,d.F)("useInfo",function(){const{api:e}=(0,i.g)(),s=(0,N.x)([e.query.gilt.activeTotal,e.query.gilt.queueTotals],A);return(0,n.useMemo)(()=>({info:s}),[s])}),I=n.memo(function({className:e}){const s=u(),{info:t}=F(),r=(0,n.useMemo)(()=>!t?.activeTotal||t.activeTotal.target.isZero(),[t]);return(0,a.jsxs)("div",{className:e,children:[(0,a.jsx)(S,{activeTotal:t?.activeTotal,isDisabled:r}),(0,a.jsx)(o.$n.Group,{children:(0,a.jsx)(b,{isDisabled:r,proxies:s})}),(0,a.jsx)(y,{queueTotals:t?.queueTotals})]})}),E=n.memo(function({basePath:e,className:s}){const{t}=g(),i=(0,n.useRef)([{isRoot:!0,name:"overview",text:t("Overview")}]);return(0,a.jsxs)("main",{className:s,children:[(0,a.jsx)(o.tU,{basePath:e,items:i.current}),(0,a.jsx)(r.BV,{children:(0,a.jsx)(r.qh,{path:e,children:(0,a.jsx)(r.qh,{element:(0,a.jsx)(I,{}),index:!0})})})]})})},61014(e,s,t){t.d(s,{A:()=>K});var a=t(31085),n=t(14041),r=t(18690),o=t(1445),i=t(61020),l=t(79129),c=t(24067),d=t(37140);function u(){return(0,d.Bd)("app-council")}var m=t(20666),h=t(97186),p=t(32123),x=t(8525),g=t(69832),b=t(21327),f=t(28138),j=t(27010),v=t(54979);const y=n.memo(function({hasFailed:e,hash:s,idNumber:t,proposal:r}){const{t:l}=u(),{api:c}=(0,i.g)(),[d,m]=(0,f.e)(),[h,p]=(0,n.useState)(null),{encodedCallLength:g,weight:b}=(0,j.wj)(r),y=(0,x.L)("council");return y?(0,a.jsxs)(a.Fragment,{children:[d&&(0,a.jsxs)(o.aF,{header:l("Close proposal"),onClose:m,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:l("The proposal that will be affected. Once closed for the current voting round, it would need to be re-submitted to council for a subsequent voting round."),children:(0,a.jsx)(v.A,{idNumber:t,proposal:r})}),(0,a.jsx)(o.aF.Columns,{hint:l("The council account that will apply the close for the current round."),children:(0,a.jsx)(o.B4,{label:l("close from account"),onChange:p,type:"account"})})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.jX,{accountId:h,isDisabled:!e&&!g,onStart:m,params:4===c.tx[y].close.meta.args.length?e?[s,t,0,0]:[s,t,b,g]:[s,t],tx:c.tx[y].closeOperational||c.tx[y].close})})]}),(0,a.jsx)(o.$n,{icon:"times",label:l("Close"),onClick:m})]}):null}),C=n.memo(function({isAye:e,members:s,threshold:t,votes:r}){const{t:i}=u(),l=(0,n.useMemo)(()=>{const a=t.toNumber(),n=e?a:s?.length?s.length-a+1:0;return`${r.length}${n?`/${n}`:""}`},[e,s,t,r]),c=(0,n.useCallback)(()=>r?.map(e=>(0,a.jsx)(o.ov,{value:e,withBalance:!1},e.toString())),[r]);return l&&r.length?(0,a.jsx)(o.PW,{renderChildren:c,summary:i(e?"Aye {{count}}":"Nay {{count}}",{replace:{count:l}})}):null}),w=n.memo(function({hash:e,idNumber:s,isDisabled:t,members:r,prime:l,proposal:c}){const{t:d}=u(),{api:m}=(0,i.g)(),{hasAccounts:p}=(0,h.o)(),[g,b]=(0,f.e)(),[j,y]=(0,n.useState)(null),C=(0,x.L)("council");if(!p||!C)return null;const w=l?.toString()===j;return(0,a.jsxs)(a.Fragment,{children:[g&&(0,a.jsxs)(o.aF,{header:d("Vote on proposal"),onClose:b,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:d("The proposal that is being voted on. It will pass when the threshold is reached."),children:(0,a.jsx)(v.A,{idNumber:s,proposal:c})}),(0,a.jsxs)(o.aF.Columns,{hint:d("The council account for this vote. The selection is filtered by the current members."),children:[(0,a.jsx)(o.g1,{filter:r,onChange:y}),w&&(0,a.jsx)(o.WM,{content:d("You are voting with this collective's prime account. The vote will be the default outcome in case of any abstentions.")})]})]}),(0,a.jsxs)(o.aF.Actions,{children:[(0,a.jsx)(o.jX,{accountId:j,icon:"ban",isDisabled:t,label:d("Vote Nay"),onStart:b,params:[e,s,!1],tx:m.tx[C].vote}),(0,a.jsx)(o.jX,{accountId:j,icon:"check-to-slot",isDisabled:t,label:d("Vote Aye"),onStart:b,params:[e,s,!0],tx:m.tx[C].vote})]})]}),(0,a.jsx)(o.$n,{icon:"check-to-slot",isDisabled:t,label:d("Vote"),onClick:b})]})}),k=n.memo(function({className:e="",isMember:s,members:t,motion:{hash:r,proposal:i,votes:l},prime:c}){const{allAccounts:d}=(0,h.o)(),{hasFailed:u,isCloseable:f,isVoteable:j,remainingBlocks:v}=(0,p.N)(l,t.length,"council"),k=(0,x.L)("council"),{hasVoted:S,hasVotedAye:N}=(0,n.useMemo)(()=>{if(l){const e=d.some(e=>l.ayes.some(s=>s.eq(e))),s=d.some(e=>l.nays.some(s=>s.eq(e)));return{hasVoted:e||s,hasVotedAye:e,hasVotedNay:s}}return{hasVoted:!1,hasVotedAye:!1,hasVotedNay:!1}},[d,l]);if(!l||!k)return null;const{ayes:A,end:F,index:I,nays:E,threshold:T}=l;return(0,a.jsxs)("tr",{className:e,children:[(0,a.jsx)(o.XI.Column.Id,{value:I}),(0,a.jsx)(m.A,{imageHash:r,isCollective:!0,proposal:i}),(0,a.jsx)("td",{className:"number together",children:(0,b.Z)(T)}),(0,a.jsx)("td",{className:"number together",children:v&&F&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(g.A,{value:v}),"#",(0,b.Z)(F)]})}),(0,a.jsxs)("td",{className:"expand",children:[(0,a.jsx)(C,{isAye:!0,members:t,threshold:T,votes:A}),(0,a.jsx)(C,{members:t,threshold:T,votes:E})]}),(0,a.jsxs)("td",{className:"button",children:[j&&!f&&(0,a.jsx)(w,{hash:r,idNumber:I,isDisabled:!s,members:t,prime:c,proposal:i}),f&&(0,a.jsx)(y,{hasFailed:u,hash:r,idNumber:I,proposal:i})]}),(0,a.jsx)("td",{className:"badge",children:s&&(0,a.jsx)(o.In,{color:S?N?"green":"red":"gray",icon:"asterisk"})}),(0,a.jsx)("td",{className:"links",children:(0,a.jsx)(o.e9,{data:I,hash:r.toString(),type:"council"})})]})});var S=t(69312),N=t(96348),A=t(51524),F=t(6404),I=t(54143);const E=n.memo(function({className:e="",isMember:s,members:t}){const{t:r}=u(),{api:l}=(0,i.g)(),[c,d]=(0,f.e)(),[m,h]=(0,n.useState)(null),[{proposal:p,proposalLength:g},b]=(0,n.useState)({proposalLength:0}),[{hash:j,isHashValid:v},y]=(0,n.useState)({isHashValid:!1}),[{imageLen:C,imageLenDefault:w,isImageLenValid:k},E]=(0,n.useState)({imageLen:A.Yz,isImageLenValid:!1}),T=(0,x.L)("council"),D=(0,N.I2)(j),M=Math.min(t.length,Math.ceil((t.length||0)*(0,S.sR)(l))),B=(0,n.useMemo)(()=>(0,F.T)(l.tx.preimage?.notePreimage)&&!(0,F.T)(l.tx.democracy?.notePreimage),[l]),P=(0,n.useCallback)(e=>y({hash:e,isHashValid:(0,I.qv)(e,256)}),[]),$=(0,n.useCallback)(e=>{e&&E(s=>({imageLen:e,imageLenDefault:s.imageLenDefault,isImageLenValid:!e.isZero()}))},[]);return(0,n.useEffect)(()=>{D?.proposalLength&&E(e=>({imageLen:e.imageLen,imageLenDefault:D.proposalLength,isImageLenValid:e.isImageLenValid}))},[D]),(0,n.useEffect)(()=>{if(v&&j){const e=B?D&&l.tx.democracy.externalProposeMajority({Lookup:{hash:D.proposalHash,len:D.proposalLength||C}}):l.tx.democracy.externalProposeMajority(j);if(e)return b({proposal:e,proposalLength:e.encodedLength||0})}b({proposal:null,proposalLength:0})},[l,j,B,v,C,D]),T?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.$n,{icon:"plus",isDisabled:!s,label:r("Propose external"),onClick:d}),c&&(0,a.jsxs)(o.aF,{className:e,header:r("Propose external (majority)"),onClose:d,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:r("The council account for the proposal. The selection is filtered by the current members."),children:(0,a.jsx)(o.B4,{filter:t,label:r("propose from account"),onChange:h,type:"account",withLabel:!0})}),(0,a.jsxs)(o.aF.Columns,{hint:r("The hash of the proposal image, either already submitted or valid for the specific call."),children:[(0,a.jsx)(o.pd,{autoFocus:!0,isError:!v,label:r("preimage hash"),onChange:P,value:j}),B&&(0,a.jsx)(o.YI,{defaultValue:w,isDisabled:!!D?.proposalLength&&!D?.proposalLength.isZero()&&v&&k,isError:!k,label:r("preimage length"),onChange:$,value:C},"inputLength")]})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.jX,{accountId:m,icon:"plus",isDisabled:!M||!t.includes(m||"")||!p||B&&!k,label:r("Propose"),onStart:d,params:3===l.tx[T].propose.meta.args.length?[M,p,g]:[M,p],tx:l.tx[T].propose})})]})]}):null});var T=t(2899),D=t(95927),M=t.n(D);const B=n.memo(function({isMember:e,members:s}){const{t}=u(),{api:r,apiDefaultTxSudo:l}=(0,i.g)(),[c,d]=(0,f.e)(),[m,h]=(0,n.useState)(null),[{proposal:p,proposalLength:g},b]=(0,n.useState)({proposalLength:0}),[{isThresholdValid:j,threshold:v},y]=(0,n.useState)({isThresholdValid:!1}),C=(0,x.L)("council");(0,n.useEffect)(()=>{s&&y({isThresholdValid:0!==s.length,threshold:new(M())(Math.min(s.length,Math.ceil(s.length*(0,S.sR)(r))))})},[r,s]);const w=(0,n.useCallback)(e=>b({proposal:e,proposalLength:e?.encodedLength||0}),[]),k=(0,n.useCallback)(e=>y({isThresholdValid:!!e?.gtn(0),threshold:e}),[]);return C?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.$n,{icon:"plus",isDisabled:!e,label:t("Propose motion"),onClick:d}),c&&(0,a.jsxs)(o.aF,{header:t("Propose a council motion"),onClose:d,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:t("The council account for the proposal. The selection is filtered by the current members."),children:(0,a.jsx)(o.B4,{filter:s,label:t("propose from account"),onChange:h,type:"account",withLabel:!0})}),(0,a.jsx)(o.aF.Columns,{hint:t("The desired threshold. Here set to a default of 50%+1, as applicable for general proposals."),children:(0,a.jsx)(o.YI,{className:"medium",isError:!v||v.eqn(0)||v.gtn(s.length),label:t("threshold"),onChange:k,placeholder:t("Positive number between 1 and {{memberCount}}",{replace:{memberCount:s.length}}),value:v||A.Yz})}),(0,a.jsx)(o.aF.Columns,{hint:t("The actual proposal to make, based on the selected call and parameters thereof."),children:(0,a.jsx)(T.A,{defaultValue:l,label:t("proposal"),onChange:w})})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.jX,{accountId:m,isDisabled:!p||!j,label:t("Propose"),onStart:d,params:3===r.tx[C].propose.meta.args.length?[v,p,g]:[v,p],tx:r.tx[C].propose})})]})]}):null});var P=t(5668);const $=n.memo(function({className:e="",isMember:s,members:t}){const{t:r}=u(),{api:l}=(0,i.g)(),c=(0,P.e)(),[d,m]=(0,f.e)(),[h,p]=(0,n.useState)(null),[{proposal:g,proposalLength:b},j]=(0,n.useState)({proposal:null,proposalLength:0}),[v,y]=(0,n.useState)(0),C=(0,x.L)("council"),w=Math.ceil((t.length||0)*(0,S.lq)(l)),k=(0,n.useMemo)(()=>(c||[]).map(([e,s])=>({text:r("era {{era}}, {{count}} slashes",{replace:{count:s.length,era:e.toNumber()}}),value:e.toNumber()})),[c,r]);return(0,n.useEffect)(()=>{const e=v&&c?.find(([e])=>e.eqn(v)),s=e?l.tx.staking.cancelDeferredSlash(e[0],e[1].map((e,s)=>s)):null;j({proposal:s,proposalLength:s?.encodedLength||0})},[l,v,c]),C&&l.tx.staking?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.$n,{icon:"sync",isDisabled:!s||!c.length,label:r("Cancel slashes"),onClick:m}),d&&(0,a.jsxs)(o.aF,{className:e,header:r("Revert pending slashes"),onClose:m,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:r("The council account for the proposal. The selection is filtered by the current members."),children:(0,a.jsx)(o.B4,{filter:t,label:r("propose from account"),onChange:p,type:"account",withLabel:!0})}),(0,a.jsx)(o.aF.Columns,{hint:r("The specific eras on which there are unapplied slashes. For each era a separate proposal is to be made."),children:k.length?(0,a.jsx)(o.ms,{defaultValue:k[0].value,label:r("the era to cancel for"),onChange:y,options:k}):(0,a.jsx)(o.pd,{isDisabled:!0,label:r("the era to cancel for"),value:r("no unapplied slashes found")})})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.jX,{accountId:h,icon:"sync",isDisabled:!w||!t.includes(h||"")||!g,label:r("Revert"),onStart:m,params:3===l.tx[C].propose.meta.args.length?[w,g,b]:[w,g],tx:l.tx[C].propose})})]})]}):null}),L=n.memo(function({className:e="",motions:s,prime:t}){const{t:r}=u(),{isMember:i,members:l}=(0,c.r)("council"),d=(0,n.useRef)([[r("motions"),"start",2],[r("threshold")],[r("voting end")],[r("votes"),"expand"],[],[void 0,"badge"],[]]);return(0,a.jsxs)("div",{className:e,children:[(0,a.jsxs)(o.$n.Group,{children:[(0,a.jsx)(B,{isMember:i,members:l}),(0,a.jsx)(E,{isMember:i,members:l}),(0,a.jsx)($,{isMember:i,members:l})]}),(0,a.jsx)(o.XI,{empty:s&&r("No council motions"),header:d.current,children:s?.map(e=>(0,a.jsx)(k,{isMember:i,members:l,motion:e,prime:t},e.hash.toHex()))})]})});var V=t(40941);const R=(0,t(55155).F)("useModuleElections",function(){const{api:e}=(0,i.g)();return(0,n.useMemo)(()=>e.tx.phragmenElection?"phragmenElection":e.tx.electionsPhragmen?"electionsPhragmen":e.tx.elections?"elections":null,[e])});var z=t(33168);const H=n.memo(function({balance:e,voters:s}){const t=(0,n.useCallback)(()=>s?.map(e=>(0,a.jsx)(o.ov,{value:e,withLockedVote:!0},e.toString())),[s]);return(0,a.jsx)("tr",{className:"isExpanded isLast packedTop",children:(0,a.jsx)("td",{className:"expand all",colSpan:2,children:(0,a.jsx)(o.PW,{renderChildren:t,summary:(0,a.jsx)(z.A,{className:e&&s?"":"--tmp",value:e})})})})}),q=n.memo(function({address:e,balance:s,className:t="",hasElections:n,isPrime:r,voters:i}){const{t:l}=u();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("tr",{className:`${t} isExpanded isFirst ${n?"":"isLast"}`,children:[(0,a.jsxs)("td",{className:"address all relative",children:[(0,a.jsx)(o.y1,{value:e}),r&&(0,a.jsx)(o.vw,{className:"absolute",color:"green",label:l("prime")})]}),(0,a.jsx)("td",{className:"number",children:i&&(0,b.Z)(i.length)})]}),n&&(0,a.jsx)(H,{balance:s,voters:i})]})}),O=n.memo(function({allVotes:e={},electionsInfo:s,hasElections:t}){const{t:r}=u(),i=(0,n.useRef)([[r("candidates"),"start",2]]),l=(0,n.useRef)([[r("runners up"),"start",2]]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.XI,{empty:s&&r("No runners up found"),header:l.current,isSplit:!0,children:s?.runnersUp.map(([s,n])=>(0,a.jsx)(q,{address:s,balance:n,hasElections:t,voters:e[s.toString()]},s.toString()))}),(0,a.jsx)(o.XI,{empty:s&&r("No candidates found"),header:i.current,isSplit:!0,children:s?.candidates.map(s=>(0,a.jsx)(q,{address:s,hasElections:!1,voters:e[s.toString()]},s.toString()))})]})}),W=n.memo(function({allVotes:e={},className:s="",electionsInfo:t,hasElections:r,prime:i}){const{t:l}=u(),c=(0,n.useRef)([[l("members"),"start",2]]);return(0,a.jsx)(o.XI,{className:s,empty:t&&l("No members found"),header:c.current,isSplit:!0,children:t?.members.map(([s,t])=>(0,a.jsx)(q,{address:s,balance:t,hasElections:r,isPrime:i?.eq(s),voters:e[s.toString()]},s.toString()))})});var U=t(60569);const G=n.memo(function({electionsInfo:e}){const{api:s}=(0,i.g)(),{t}=u(),[r,l]=(0,n.useState)(null),{isOpen:c,onClose:d,onOpen:m}=(0,U.h)(),h=R();return h?(0,a.jsxs)(a.Fragment,{children:[c&&(0,a.jsxs)(o.aF,{header:t("Submit your council candidacy"),onClose:d,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:t("This account will appear in the list of candidates. With enough votes in an election, it will become either a runner-up or a council member."),children:(0,a.jsx)(o.B4,{label:t("candidate account"),onChange:l,type:"account"})}),s.consts[h]&&(0,a.jsx)(o.aF.Columns,{hint:t("The bond will be reserved for the duration of your candidacy and membership."),children:(0,a.jsx)(o.xg,{defaultValue:s.consts[h]?.candidacyBond,isDisabled:!0,label:t("candidacy bond")})})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.jX,{accountId:r,isDisabled:!e,onStart:d,params:1===s.tx[h].submitCandidacy.meta.args.length?[e?.candidates.length]:[],tx:s.tx[h].submitCandidacy})})]}),(0,a.jsx)(o.$n,{icon:"plus",isDisabled:!e,label:t("Submit candidacy"),onClick:m})]}):null}),Y=n.memo(function({bestNumber:e,className:s="",electionsInfo:t,hasElections:n}){const{t:r}=u();return(0,a.jsxs)(o.cp,{className:s,children:[(0,a.jsxs)("section",{children:[(0,a.jsx)(o.dS,{label:r("seats"),children:t?(0,a.jsxs)(a.Fragment,{children:[(0,b.Z)(t.members.length),t.desiredSeats&&(0,a.jsxs)(a.Fragment,{children:[" / ",(0,b.Z)(t.desiredSeats)]})]}):(0,a.jsx)("span",{className:"--tmp",children:"99"})}),n&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.dS,{label:r("runners up"),children:t?(0,a.jsxs)(a.Fragment,{children:[(0,b.Z)(t.runnersUp.length),t.desiredRunnersUp&&(0,a.jsxs)(a.Fragment,{children:[" / ",(0,b.Z)(t.desiredRunnersUp)]})]}):(0,a.jsx)("span",{className:"--tmp",children:"99 / 99"})}),(0,a.jsx)(o.dS,{label:r("candidates"),children:t?(0,b.Z)(t.candidateCount):(0,a.jsx)("span",{className:"--tmp",children:"99"})})]})]}),t?.voteCount&&(0,a.jsx)("section",{children:(0,a.jsxs)(o.dS,{label:r("voting round"),children:["#",(0,b.Z)(t.voteCount)]})}),t&&e&&t.termDuration&&t.termDuration.gt(A.Yz)&&(0,a.jsx)("section",{children:(0,a.jsx)(o.dS,{label:r("term progress"),progress:{total:t&&e?t.termDuration:A.iz,value:t&&e?e.mod(t.termDuration):A.u_,withTime:!0}})})]})}),X=n.memo(function({electionsInfo:e}){const{t:s}=u(),{api:t}=(0,i.g)(),[r,l]=(0,f.e)(),[c,d]=(0,n.useState)(null),[m,h]=(0,n.useState)([]),[p,x]=(0,n.useState)([]),[g,b]=(0,n.useState)([]),[j,v]=(0,n.useState)(A.Yz),y=R();(0,n.useEffect)(()=>{if(e){const{candidates:s,members:t,runnersUp:a}=e;h(t.map(([e])=>e.toString()).concat(a.map(([e])=>e.toString())).concat(s.map(e=>e.toString())))}},[e]),(0,n.useEffect)(()=>{c&&t.derive.council.votesOf(c).then(({votes:e})=>{x(e.map(e=>e.toString()).filter(e=>m.includes(e)))}).catch(console.error)},[t,c,m]);const C=(0,n.useMemo)(()=>{const e=t.consts.elections||t.consts.phragmenElection||t.consts.electionsPhragmen;return e&&e.votingBondBase&&e.votingBondBase.add(e.votingBondFactor.muln(g.length))},[t,g]);return y?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.$n,{icon:"check-to-slot",isDisabled:0===m.length,label:s("Vote"),onClick:l}),r&&(0,a.jsxs)(o.aF,{header:s("Vote for current candidates"),onClose:l,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:s("The vote will be recorded for the selected account."),children:(0,a.jsx)(o.B4,{label:s("voting account"),onChange:d,type:"account"})}),(0,a.jsx)(o.aF.Columns,{hint:s("The value associated with this vote. The amount will be locked (not available for transfer) and used in all subsequent elections."),children:(0,a.jsx)(o.mB,{accountId:c,onChange:v})}),(0,a.jsx)(o.aF.Columns,{hint:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{children:s("The votes for the members, runner-ups and candidates. These should be ordered based on your priority.")}),(0,a.jsx)("p",{children:s("In calculating the election outcome, this prioritized vote ordering will be used to determine the final score for the candidates.")})]}),children:(0,a.jsx)(o.ur,{available:m,availableLabel:s("council candidates"),defaultValue:p,maxCount:16,onChange:b,valueLabel:s("my ordered votes")})}),C&&(0,a.jsx)(o.aF.Columns,{hint:s("The amount will be reserved for the duration of your vote"),children:(0,a.jsx)(o.xg,{defaultValue:C,isDisabled:!0,label:s("voting bond")})})]}),(0,a.jsxs)(o.aF.Actions,{children:[(0,a.jsx)(o.jX,{accountId:c,icon:"trash-alt",isDisabled:!p.length,label:s("Unvote all"),onStart:l,tx:t.tx[y].removeVoter}),(0,a.jsx)(o.jX,{accountId:c,isDisabled:!c||0===g.length||j.lten(0),label:s("Vote"),onStart:l,params:[g,j],tx:t.tx[y].vote})]})]})]}):null}),Z={transform:e=>e.reduce((e,[s,{votes:t}])=>(t.forEach(t=>{const a=t.toString();e[a]||(e[a]=[]),e[a].push(s)}),e),{})},_=n.memo(function({className:e="",prime:s}){const{api:t}=(0,i.g)(),n=(0,V.x)(),r=(0,l.Gc)(t.derive.elections.info),c=(0,l.Gc)(t.derive.council.votes,void 0,Z),d=R(),u=!!d;return(0,a.jsxs)("div",{className:e,children:[(0,a.jsx)(Y,{bestNumber:n,electionsInfo:r,hasElections:!!d}),u&&(0,a.jsxs)(o.$n.Group,{children:[(0,a.jsx)(X,{electionsInfo:r}),(0,a.jsx)(G,{electionsInfo:r})]}),(0,a.jsx)(W,{allVotes:c,electionsInfo:r,hasElections:u,prime:s}),u&&(0,a.jsx)(O,{allVotes:c,electionsInfo:r,hasElections:u})]})});var J=t(32125);const K=n.memo(function({basePath:e,className:s}){const{t}=u(),{api:c}=(0,i.g)(),{pathname:d}=(0,r.zy)(),m=(0,J.A)(),h=(0,l.Gc)(c.derive.council.prime),p=(0,l.Gc)(c.derive.council.proposals),x=(0,n.useMemo)(()=>[{isRoot:!0,name:"overview",text:t("Overview")},{count:m,name:"motions",text:t("Motions")}],[m,t]);return(0,a.jsxs)("main",{className:s,children:[(0,a.jsx)(o.tU,{basePath:e,items:x}),(0,a.jsx)(r.BV,{children:(0,a.jsx)(r.qh,{path:e,children:(0,a.jsx)(r.qh,{element:(0,a.jsx)(L,{motions:p,prime:h}),path:"motions"})})}),(0,a.jsx)(_,{className:[e,`${e}/candidates`].includes(d)?"":"--hidden",prime:h})]})})},63057(e,s,t){t.d(s,{A:()=>i});var a=t(14041),n=t(55155),r=t(61020),o=t(79129);const i=(0,n.F)("useCounter",function(){const{api:e,isApiReady:s}=(0,r.g)(),t=(0,o.Gc)(s&&e.derive.bounties?.bounties);return(0,a.useMemo)(()=>t?.length||0,[t])})},68300(e,s,t){t.d(s,{B:()=>n});var a=t(37140);function n(){return(0,a.Bd)("app-explorer")}},70464(e,s,t){t.d(s,{A:()=>S});var a=t(31085),n=t(14041),r=t(18690),o=t(1445),i=t(61020),l=t(7643),c=t(11243),d=t(54143),u=t(83448),m=t(17080),h=t(36730),p=t(92100),x=t(37140);function g(){return(0,x.Bd)("app-extrinsics")}const b=(0,o.I4)(o.Yt)`
.ui--Column:last-child .ui--Labelled {
padding-left: 0.5rem;
label {
left: 2.05rem; /* 3.55 - 1.5 (diff from padding above) */
}
}
`,f=n.memo(function({className:e,extrinsic:s,isCall:t,payload:r,withData:i=!0,withHash:l=!0}){const{t:c}=g(),[d,u,m]=(0,n.useMemo)(()=>function(e,s,t){if(!s)return["0x","0x",null];const a=s.method.toU8a();let n=e?s.method.inspect():s.inspect();if(t){const e=n;n=t.inspect(),n.inner?.map((s,t)=>(0===t&&(s.inner=e.inner,s.outer=void 0),s))}return[(0,p.X)(a),s.registry.hash(a).toHex(),n]}(t,s,r),[s,t,r]);return m?(0,a.jsxs)(b,{className:e,isPadded:!1,children:[(0,a.jsxs)(o.Yt.Column,{children:[i&&(0,a.jsx)(o.k7,{isDisabled:!0,isTrimmed:!0,label:c("encoded call data"),value:d,withCopy:!0}),l&&(0,a.jsx)(o.k7,{isDisabled:!0,label:c("encoded call hash"),value:u,withCopy:!0})]}),(0,a.jsx)(o.Yt.Column,{children:(0,a.jsx)(o.Rx,{hex:d,inspect:m,label:c("encoding details")})})]}):null}),j={decoded:null,extrinsicCall:null,extrinsicError:null,extrinsicFn:null,extrinsicHex:null,extrinsicKey:"none",extrinsicPayload:null,isCall:!0},v=o.I4.div`
.ui--Call--toplevel {
margin-top: 0;
}
.ui--Call > .ui--Params.withBorder {
padding-left: 2rem;
}
`,y=n.memo(function({className:e,defaultValue:s,setLast:t}){const{encoded:p}=(0,r.g)(),[x]=(0,n.useState)(()=>s||p),{t:b}=g(),{api:y}=(0,i.g)(),[{decoded:C,extrinsicCall:w,extrinsicError:k,extrinsicFn:S,extrinsicKey:N,extrinsicPayload:A,isCall:F},I]=(0,n.useState)(j),E=(0,n.useCallback)(e=>{try{let s;(0,c.vA)((0,d.qv)(e),"Expected a hex-encoded call");let a=null,n=null,r=!1;try{const t=y.tx(e);(0,c.vA)(t.toHex()===e,"Cannot decode data as extrinsic, length mismatch"),n=t,s=y.createType("Call",n.method)}catch{try{s=y.createType("Call",e);const t=s.toHex();if(t===e)r=!0;else{if(!e.startsWith(t))throw new Error("Unable to decode data as Call, length mismatch in supplied data");{const t=(0,u.z)((0,m.R)(s.encodedLength),e);a=y.createType("ExtrinsicPayload",t),(0,c.vA)((0,h.f)(a.toU8a(),t),"Unable to decode data as un-prefixed ExtrinsicPayload"),s=y.createType("Call",a.method.toHex())}}}catch{a=y.createType("ExtrinsicPayload",e),(0,c.vA)(a.toHex()===e,"Unable to decode input data as Call, Extrinsic or ExtrinsicPayload"),s=y.createType("Call",a.method.toHex())}}const{method:o,section:i}=y.registry.findMetaCall(s.callIndex),l=y.tx[i][o],p=s.callIndex.toString();n||(n=l(...s.args)),I({...j,decoded:n,extrinsicCall:s,extrinsicFn:l,extrinsicHex:e,extrinsicKey:p,extrinsicPayload:a,isCall:r}),t({call:s,fn:l,hex:e})}catch(e){I({...j,extrinsicError:e.message}),t(null)}},[y,t]);return(0,a.jsxs)(v,{className:e,children:[(0,a.jsx)(o.pd,{defaultValue:x,isError:!S,label:b("hex-encoded call"),onChange:E,placeholder:b("0x...")}),k&&(0,a.jsx)(o.o_,{content:k}),S&&w&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.CI,{defaultValue:S,isDisabled:!0,label:b("decoded call")},`extrinsicKey:${N}`),(0,a.jsx)(l.A,{className:"details",value:w})]}),(0,a.jsx)(f,{extrinsic:C,isCall:F,payload:A,withData:!1})]})});var C=t(2899),w=t(26577);const k=n.memo(function({className:e,defaultValue:s}){const{t}=g(),{apiDefaultTxSudo:r}=(0,i.g)(),[l,c]=(0,n.useState)(null),[d,u]=(0,n.useState)(null),[m,h]=(0,n.useState)(null),[{defaultArgs:p,defaultFn:x}]=(0,n.useState)(()=>function(e,s){return e?{defaultArgs:e.call.args.map(e=>({isValid:!0,value:e})),defaultFn:e.fn}:{defaultFn:s}}(s,r)),b=(0,n.useCallback)(e=>h(()=>e||null),[]),j=(0,n.useCallback)(e=>u(e?e.message:null),[]);return(0,a.jsxs)("div",{className:e,children:[(0,a.jsx)(o.B4,{label:t("using the selected account"),labelExtra:(0,a.jsx)(w.A,{label:(0,a.jsx)("label",{children:t("free balance")}),params:l}),onChange:c,type:"account"}),(0,a.jsx)(C.A,{defaultArgs:p,defaultValue:x,label:t("submit the following extrinsic"),onChange:b,onError:j}),(0,a.jsx)(f,{extrinsic:m,isCall:!0}),d&&!m&&(0,a.jsx)(o.o_,{content:d}),(0,a.jsxs)(o.$n.Group,{children:[(0,a.jsx)(o.jX,{extrinsic:m,icon:"sign-in-alt",isUnsigned:!0,label:t("Submit Unsigned"),withSpinner:!0}),(0,a.jsx)(o.jX,{accountId:l,extrinsic:m,icon:"sign-in-alt",label:t("Submit Transaction")})]})]})}),S=n.memo(function({basePath:e}){const{t:s}=g(),[t,i]=(0,n.useState)(null),l=(0,n.useRef)(function(e){return[{isRoot:!0,name:"create",text:e("Submission")},{hasParams:!0,name:"decode",text:e("Decode")}]}(s));return(0,a.jsxs)("main",{className:"extrinsics--App",children:[(0,a.jsx)(o.tU,{basePath:e,items:l.current}),(0,a.jsx)(r.BV,{children:(0,a.jsxs)(r.qh,{path:e,children:[(0,a.jsx)(r.qh,{element:(0,a.jsx)(y,{defaultValue:t?.hex,setLast:i}),path:"decode/:encoded?"}),(0,a.jsx)(r.qh,{element:(0,a.jsx)(k,{defaultValue:t}),index:!0})]})})]})})},74831(e,s,t){t.d(s,{A:()=>r});var a=t(55155),n=t(98586);const r=(0,a.F)("useCounter",function(){return(0,n.A)().length})},76604(e,s,t){t.d(s,{A:()=>U});var a=t(31085),n=t(14041),r=t(1445);const o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i=["January","February","March","April","May","June","July","August","September","October","November","December"];var l=t(76733),c=t(21327),d=t(37140);function u(){return(0,d.Bd)("app-calendar")}function m(e){const s=new Date(e);return s.setHours(0),s.setMinutes(0),s.setSeconds(0),s.setMilliseconds(0),s}function h(e,s=1){const t=e.getMonth();return 11===t?new Date(e.getFullYear()+1,0,s):new Date(e.getFullYear(),t+1,s)}function p(e,s){const t=m(e);t.setDate(1);const a=h(t),n=m(s),r=h(t,0).getDate(),i=[];for(let e=1;e<=r;e++)i.push(e);return{dateMonth:t,dateMonthNext:a,dateSelected:n,days:i,startClass:`start${o[t.getDay()]}`}}function x(e){return new Date(e).toISOString().split(".")[0].replace(/-/g,"").replace(/:/g,"")+"Z"}const g={day:"numeric",month:"long",weekday:"long",year:"numeric"};function b(e,s){return(0,a.jsx)("div",{className:"itemLink",children:(0,a.jsx)("a",{href:`#/${e}`,children:s})})}const f=r.I4.div`
align-items: flex-start;
display: flex;
justify-content: flex-start;
margin: 0.5rem 0.75rem;
> div+div {
margin-left: 0.5rem;
}
> div.itemTime+div.itemBlock {
margin-left: 0.25rem;
}
.exportCal {
padding: 0;
position: absolute;
right: 1.5rem;
.ui--Icon {
width: 0.7rem;
height: 0.7rem;
}
}
.exportCal-allEvents {
right: 3.5rem;
}
.itemBlock {
background: #aaa;
color: #eee;
font-size: var(--font-size-small);
align-self: center;
padding: 0.075rem 0.375rem;
border-radius: 0.25rem;
}
.itemDate {
padding: 0 0.375rem;
border-radius: 0.25rem;
width: 17rem;
}
.itemTime {
background: #999;
color: #eee;
padding: 0 0.375rem;
border-radius: 0.25rem;
}
`,j=n.memo(function({className:e,item:{blockNumber:s,date:t,info:o,type:i},showAllEvents:d}){const{t:m}=u(),[h,p]=(0,n.useState)(""),j=(0,n.useCallback)(()=>function(e,s){const t="BEGIN:VCALENDAR\nCALSCALE:GREGORIAN\nMETHOD:PUBLISH\nPRODID:-//Test Cal//EN\nVERSION:2.0\nBEGIN:VEVENT\nUID:test-1\nDTSTART;VALUE=DATE:"+x(e)+"\nDTEND;VALUE=DATE:"+x(new Date(new Date(e).setHours(new Date(e).getHours()+1)))+"\nSUMMARY:"+s+"\nDESCRIPTION:"+s+"\nEND:VEVENT\nEND:VCALENDAR",a=encodeURI(s)+".ics",n=new File([t],a,{type:"text/plain"}),r=window.document.createElement("a");r.href=window.URL.createObjectURL(n),r.download=a,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(r.href)}(t,h),[h,t]),v=(0,n.useMemo)(()=>{const e=o&&((0,l.K)(o)?o:(0,c.Z)(o)),s=["councilElection"].includes(i)?b("council",m("via Council")):["councilMotion"].includes(i)?b("council/motions",m("via Council/Motions")):["democracyDispatch","scheduler"].includes(i)?b("democracy/dispatch",m("via Democracy/Dispatch")):["democracyLaunch","referendumDispatch","referendumVote"].includes(i)?b("/democracy",m("via Democracy")):["societyChallenge","societyRotate"].includes(i)?b("society",m("via Society")):["stakingEpoch","stakingEra"].includes(i)?b("staking",m("via Staking")):["stakingSlash"].includes(i)?b("staking/slashes",m("via Staking/Slashed")):["treasurySpend"].includes(i)?b("treasury",m("via Treasury")):["teyrchainLease"].includes(i)?b("teyrchains",m("via Teyrchains")):["teyrchainAuction"].includes(i)?b("teyrchains/auction",m("via Teyrchains/Auction")):void 0;let t="";switch(i){case"councilElection":t=m("Election of new council candidates");break;case"councilMotion":t=m("Voting ends on council motion {{id}}",{replace:{id:e}});break;case"democracyDispatch":t=m("Enactment of the result of referendum {{id}}",{replace:{id:e}});break;case"democracyLaunch":t=m("Start of the next referendum voting period");break;case"teyrchainAuction":t=m("End of the current teyrchain auction {{id}}",{replace:{id:e}});break;case"teyrchainLease":t=m("Start of the next teyrchain lease period {{id}}",{replace:{id:e}});break;case"referendumDispatch":t=m("Potential dispatch of referendum {{id}} (if passed)",{replace:{id:e}});break;case"referendumVote":t=m("Voting ends for referendum {{id}}",{replace:{id:e}});break;case"scheduler":t=e?m("Execute named scheduled task {{id}}",{replace:{id:e}}):m("Execute anonymous scheduled task");break;case"stakingEpoch":t=m("Start of a new staking session {{id}}",{replace:{id:e}});break;case"stakingEra":t=m("Start of a new staking era {{id}}",{replace:{id:e}});break;case"stakingSlash":t=m("Application of slashes from era {{id}}",{replace:{id:e}});break;case"treasurySpend":t=m("Start of next spending period");break;case"societyChallenge":t=m("Start of next membership challenge period");break;case"societyRotate":t=m("Acceptance of new members and bids");break;default:return function(e){throw new Error(`We should not get here, unhandled ${e}`)}(i)}return p(t),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"itemDesc",children:t}),s]})},[o,m,i]);return(0,a.jsxs)(f,{className:e,children:[d&&(0,a.jsx)("div",{className:"itemDate",children:t.toLocaleString(void 0,g)}),(0,a.jsx)("div",{className:"itemTime",children:t.toLocaleTimeString().split(":").slice(0,2).join(":")}),(0,a.jsxs)("div",{className:"itemBlock",children:["#",(0,c.Z)(s)]}),v,t&&(0,a.jsx)(r.$n,{className:d?"exportCal exportCal-allEvents":"exportCal",icon:"calendar-plus",onClick:j})]})}),v=36e5,y=r.I4.div`
align-items: center;
display: flex;
position: relative;
z-index: 2;
&:nth-child(odd) {
background: var(--bg-table);
}
&.isPast {
opacity: 0.75;
}
.hourContainer {
flex: 1;
padding: 0.25rem 0;
}
.hourLabel {
flex: 0;
font-size: var(--font-size-small);
font-weight: var(--font-weight-normal);
line-height: 1;
min-width: 5.5rem;
opacity: var(--opacity-light);
padding: 0.5rem 1rem;
text-align: right;
text-transform: uppercase;
z-index: 1;
}
&.hasItems .hourLabel {
font-size: 1.1rem;
font-weight: var(--font-weight-normal);
opacity: 1;
padding: 0.7rem 1rem;
}
`,C=n.memo(function({className:e="",date:s,hour:t,index:r,minutes:o,scheduled:i}){const l=(0,n.useMemo)(()=>function(e,s,t,a){const n=e.getTime()+t*v,r=n+v,o=n+6e4*s;return a.filter(({dateTime:e})=>e>=o&&e<r).sort((e,s)=>e.dateTime-s.dateTime||e.type.localeCompare(s.type))}(s,o,r,i),[s,r,o,i]),c=`${` ${t}`.slice(-2)} ${t>=12?"pm":"am"}`;return(0,a.jsxs)(y,{className:`${e}${l.length?" hasItems":""}`,children:[(0,a.jsx)("div",{className:"hourLabel"+(l.length?" highlight--color":""),children:c}),(0,a.jsx)("div",{className:"hourContainer",children:l.map((e,s)=>(0,a.jsx)(j,{item:e},s))})]})}),w=n.memo(function(){const[e,s]=(0,n.useState)(new Date);return(0,n.useEffect)(()=>{const e=setInterval(()=>s(new Date),1e3);return()=>{clearInterval(e)}},[]),(0,a.jsx)(a.Fragment,{children:e.toLocaleTimeString().split(":").slice(0,2).join(":")})}),k=(()=>{const e=[];for(let s=0;s<24;s++)e.push(s);return e})(),S=r.I4.div`
flex: 1;
.dayHeader {
align-items: center;
display: flex;
font-size: 1.25rem;
justify-content: space-between;
padding: 1rem 1.5rem 0;
}
.hoursContainer {
z-index: 1;
}
`,N=n.memo(function({className:e,date:s,hasNextDay:t,now:o,scheduled:l,setNextDay:c,setPrevDay:d,setView:m}){const{t:h}=u(),p=(0,n.useRef)(i.map(e=>h(e))),[x,g,b]=(0,n.useMemo)(()=>[s.getMonth()===o.getMonth()&&s.getFullYear()===o.getFullYear()&&s.getDate()===o.getDate(),o.getHours(),o.getMinutes()],[s,o]),f=(0,n.useCallback)(()=>m(!0),[m]);return(0,a.jsxs)(S,{className:e,children:[(0,a.jsxs)("h1",{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(r.$n,{className:"all-events-button",icon:"list",onClick:f}),s.getDate()," ",p.current[s.getMonth()]," ",s.getFullYear()," ",x&&(0,a.jsx)(w,{})]}),(0,a.jsxs)(r.$n.Group,{children:[(0,a.jsx)(r.$n,{icon:"chevron-left",isDisabled:x,onClick:d}),(0,a.jsx)(r.$n,{icon:"chevron-right",isDisabled:!t,onClick:c})]})]}),(0,a.jsx)("div",{className:"hoursContainer highlight--bg-faint",children:k.map((e,t)=>(0,a.jsx)(C,{date:s,hour:e,index:t,minutes:x&&g===t?b:0,scheduled:l},e))})]})}),A=864e5,F=r.I4.div`
background-color: transparent;
border: 1px solid transparent;
border-radius: 50%;
line-height: 1;
padding: 1rem;
position: relative;
text-align: center;
z-index: 1;
&:before {
border-radius: 50%;
}
&:not(.isDisabled) {
cursor: pointer;
}
&:not(.isSelected):hover {
background: #f7f5f3;
}
.eventIndicator {
border: 0.25rem solid transparent;
border-radius: 50%;
height: 0.25rem;
position: absolute;
right: 0.625rem;
top: 0.625rem;
width: 0.25rem;
}
&.isDisabled {
opacity: 0.375;
&:hover {
background: transparent;
}
.eventIndicator {
display: none;
}
}
`,I=n.memo(function({className:e="",dateMonth:s,day:t,isCurrent:r,isDisabled:o,scheduled:i,setDay:l}){const c=(0,n.useMemo)(()=>{const e=s.getTime()+(t-1)*A,a=e+A;return i.some(({dateTime:s})=>s>=e&&s<a)},[s,t,i]),d=(0,n.useCallback)(()=>{!o&&l(t)},[t,o,l]);return(0,a.jsxs)(F,{className:`${e} day ${o?"isDisabled":r?"highlight--bg-light highlight--color isSelected":""}`,onClick:d,children:[t,c&&(0,a.jsx)("div",{className:"eventIndicator highlight--border"})]})}),E=r.I4.div`
flex: 0;
max-width: max-content;
.calendar {
padding: 1rem 1.5rem;
.dateGrid,
.dayOfWeek {
display: grid;
grid-template-columns: repeat(7, 1fr);
}
.dateGrid {
margin-top: 0.5em;
}
&.startSun .dateGrid .day:first-child { grid-column: 1 }
&.startMon .dateGrid .day:first-child { grid-column: 2 }
&.startTue .dateGrid .day:first-child { grid-column: 3 }
&.startWed .dateGrid .day:first-child { grid-column: 4 }
&.startThu .dateGrid .day:first-child { grid-column: 5 }
&.startFri .dateGrid .day:first-child { grid-column: 6 }
&.startSat .dateGrid .day:first-child { grid-column: 7 }
.dayOfWeek {
> * {
font-size: var(--font-size-tiny);
font-weight: var(--font-weight-normal);
letter-spacing: 0.1em;
text-align: center;
text-transform: uppercase;
}
}
.monthIndicator {
align-items: center;
display: flex;
font-size: 1.25rem;
justify-content: space-between;
}
}
`,T=n.memo(function({className:e,hasNextMonth:s,lastDay:t,now:l,scheduled:c,setDay:d,setNextMonth:m,setPrevMonth:h,state:{dateMonth:p,dateSelected:x,days:g,startClass:b}}){const{t:f}=u(),j=(0,n.useRef)(o.map(e=>f(e))),v=(0,n.useRef)(i.map(e=>f(e))),[y,C,w,k,S]=(0,n.useMemo)(()=>[p.getFullYear()===x.getFullYear(),p.getMonth()===x.getMonth(),l.getFullYear()===p.getFullYear(),l.getMonth()===p.getMonth(),l.getMonth()>p.getMonth()],[p,x,l]);return(0,a.jsxs)(E,{className:e,children:[(0,a.jsxs)("h1",{children:[(0,a.jsxs)("div",{children:[v.current[p.getMonth()]," ",p.getFullYear()]}),(0,a.jsxs)(r.$n.Group,{children:[(0,a.jsx)(r.$n,{icon:"chevron-left",isDisabled:w&&(S||k),onClick:h}),(0,a.jsx)(r.$n,{icon:"chevron-right",isDisabled:!s,onClick:m})]})]}),(0,a.jsxs)("div",{className:`calendar ${b}`,children:[(0,a.jsx)("div",{className:"dayOfWeek",children:j.current.map(e=>(0,a.jsx)("div",{children:f(e)},e))}),(0,a.jsx)("div",{className:"dateGrid",children:g.map(e=>(0,a.jsx)(I,{dateMonth:p,day:e,isCurrent:y&&C&&e===x.getDate(),isDisabled:w&&(S||k&&l.getDate()>e)||!s&&e>t,scheduled:c,setDay:d},e))})]})]})}),D=r.I4.div`
flex: 0;
max-width: max-content;
.all-events-rows {
padding: 10px 0;
font-size: 13px;
&:nth-child(odd) {
background: var(--bg-table);
}
}
.allEventsWrapper {
padding-inline-start: 10px;
}
`,M=n.memo(function({className:e,scheduled:s,setView:t}){const{t:o}=u(),i=(0,n.useMemo)(()=>s.sort((e,s)=>e.dateTime-s.dateTime),[s]),l=(0,n.useCallback)(()=>t(!1),[t]);return(0,a.jsxs)(D,{className:e,children:[(0,a.jsx)("h1",{children:(0,a.jsxs)("div",{children:[(0,a.jsx)(r.$n,{className:"all-events-button",icon:"calendar",onClick:l}),o("Upcoming Events")]})}),(0,a.jsx)("ul",{className:"allEventsWrapper",children:i.map((e,s)=>(0,a.jsx)(j,{className:"all-events-rows",item:e,showAllEvents:!0},s))})]})});var B=t(18782),P=t(61020),$=t(13648),L=t(40941),V=t(79129),R=t(55155),z=t(51524);function H(e,s){const t=new Date(Date.now()+e.mul(s).toNumber());return{date:t,dateTime:t.getTime()}}function q(e,s){return s.reduce((e,[s,t])=>e.filter(({type:e})=>e!==s).concat(...t.map(e=>(e.type=s,e))),e)}const O=(0,R.F)("useScheduled",function(){const{api:e}=(0,P.g)(),s=(0,$.y)(),t=(0,L.x)(),a=(0,B.p)(),r=(0,V.Gc)(e.query.auctions?.auctionInfo),o=(0,V.Gc)(e.derive.council?.proposals),i=(0,V.Gc)(e.derive.democracy?.dispatchQueue),l=(0,V.Gc)(e.derive.democracy?.referendums),c=(0,V.Gc)(e.query.scheduler?.agenda?.entries),d=(0,V.Gc)(e.derive.session?.progress),u=(0,V.Gc)(e.query.staking?.unappliedSlashes.entries),[m,h]=(0,n.useState)([]);return(0,n.useEffect)(()=>{t&&i&&h(e=>q(e,function(e,s,t){return t.map(({at:t,index:a})=>{const n=t.sub(e);return["democracyDispatch",[{...H(n,s),blockNumber:t,blocks:n,info:a}]]})}(t,s,i)))},[t,s,i]),(0,n.useEffect)(()=>{t&&o&&h(e=>q(e,function(e,s,t){return[["councilMotion",t.map(({hash:t,votes:a})=>{if(!a)return null;const n=t.toHex(),r=a.end.sub(e);return{...H(r,s),blockNumber:a.end,blocks:r,info:`${n.slice(0,6)}${n.slice(-4)}`}}).filter(e=>!!e)]]}(t,s,o)))},[t,s,o]),(0,n.useEffect)(()=>{t&&l&&h(e=>q(e,function(e,s,t){return t.reduce((t,{index:a,status:n})=>{const r=n.end.add(n.delay).isub(e),o=n.end.sub(e).isub(z.Uu);return t.push(["referendumVote",[{...H(o,s),blockNumber:e.add(o),blocks:o,info:a}]]),t.push(["referendumDispatch",[{...H(r,s),blockNumber:e.add(r),blocks:r,info:a,isPending:!0}]]),t},[])}(t,s,l)))},[t,s,l]),(0,n.useEffect)(()=>{t&&c&&h(e=>q(e,function(e,s,t){return[["scheduler",t.filter(([,e])=>e.some(e=>e.isSome)).reduce((t,[a,n])=>{const r=a.args[0];return n.filter(e=>e.isSome).map(e=>e.unwrap()).reduce((t,{maybeId:a})=>{const n=a.unwrapOr(null),o=r.sub(e);return t.push({...H(o,s),blockNumber:r,blocks:o,info:n?n.isAscii?n.toUtf8():n.toHex():null}),t},t)},[])]]}(t,s,c)))},[t,s,c]),(0,n.useEffect)(()=>{t&&d?.sessionLength.gt(z.Uu)&&h(a=>q(a,function(e,s,t,a,n){const r=t.eraLength.sub(t.eraProgress),o=t.sessionLength.sub(t.sessionProgress),i=n?.mul(t.eraLength),l=i?a.filter(([,e])=>e.length).map(([a])=>{const n=a.args[0],r=t.activeEra.sub(n).isub(z.Uu).imul(t.eraLength).iadd(t.eraProgress),o=i.sub(r);return{...H(o,s),blockNumber:e.add(o),blocks:o,info:n}}):[];return[["stakingEpoch",[{...H(o,s),blockNumber:e.add(o),blocks:o,info:t.currentIndex.add(z.Uu)}]],["stakingEra",[{...H(r,s),blockNumber:e.add(r),blocks:r,info:t.activeEra.add(z.Uu)}]],["stakingSlash",l]]}(t,s,d,u||[],e.consts.staking?.slashDeferDuration)))},[e,t,s,d,u]),(0,n.useEffect)(()=>{t&&r?.isSome&&h(e=>q(e,function(e,s,t,[a,n]){const r=n.sub(e);return[["teyrchainAuction",[{...H(r,s),blockNumber:n,blocks:r,info:`${a.toString()} - ${a.add(t).toString()}`}]]]}(t,s,a,r.unwrap())))},[r,t,s,a]),(0,n.useEffect)(()=>{t&&h(a=>q(a,function(e,s,t){return t.map(([t,a,n=z.Yz,r=z.Yz])=>{if(!a)return[t,[]];const o=e.sub(r),i=a.sub(o.mod(a));return[t,[{...H(i,s),blockNumber:o.add(i),blocks:i,info:o.div(a).iadd(n)}]]})}(t,s,[["councilElection",(e.consts.elections||e.consts.phragmenElection||e.consts.electionsPhragmen)?.termDuration],["democracyLaunch",e.consts.democracy?.launchPeriod],["teyrchainLease",e.consts.slots?.leasePeriod,z.Uu,e.consts.slots?.leaseOffset],["societyChallenge",e.consts.society?.challengePeriod],["societyRotate",e.consts.society?.rotationPeriod],["treasurySpend",e.consts.treasury?.spendPeriod]])))},[e,t,s]),m}),W=r.I4.main`
.calendarFlex {
align-items: flex-start;
display: flex;
flex-wrap: nowrap;
.wrapper-style {
flex: 1;
.upcoming-events {
position: relative;
max-width: 100%;
}
}
> div {
background-color: var(--bg-table);
border: 1px solid var(--border-table);
border-radius: 0.25rem;
&+div {
margin-left: 1.5rem;
}
.ui--Button-Group {
margin: 0;
}
}
h1 {
align-items: center;
border-bottom: 0.25rem solid var(--bg-page);
display: flex;
justify-content: space-between;
padding: 0.5rem 0.5rem 0.5rem 1rem;
> div:first-child {
align-items: center;
display: inline-flex;
}
.all-events-button {
margin-right: 1rem;
}
.ui--Button {
font-size: var(--font-size-small);
}
}
}
`,U=n.memo(function({basePath:e,className:s}){const{t}=u(),o=O(),[i,l]=(0,n.useState)(()=>new Date),[c,d]=(0,n.useState)(()=>p(i,i)),[m,x]=(0,n.useState)(!1),g=(0,n.useRef)([{isRoot:!0,name:"view",text:t("Upcoming events")}]);(0,n.useEffect)(()=>{const e=setInterval(()=>l(new Date),3e4);return()=>{clearInterval(e)}},[]);const[b,f,j]=(0,n.useMemo)(()=>{const e=new Date(c.dateSelected);e.setDate(e.getDate()+1);const s=e.getTime(),t=c.dateMonthNext.getTime(),a=o.some(({dateTime:e})=>e>=t);return[a,a||o.some(({dateTime:e})=>e>=s),a?42:o.reduce((e,{date:s})=>s.getFullYear()===c.dateMonth.getFullYear()&&s.getMonth()===c.dateMonth.getMonth()?Math.max(e,s.getDate()):e,0)]},[c,o]),v=(0,n.useCallback)(()=>d(({dateMonth:e,dateSelected:s})=>p(h(e),s)),[]),y=(0,n.useCallback)(()=>d(({dateMonth:e,dateSelected:s})=>p(function(e){const s=e.getMonth();return 0===s?new Date(e.getFullYear()-1,11,1):new Date(e.getFullYear(),s-1,1)}(e),s)),[]),C=(0,n.useCallback)(()=>d(({dateSelected:e})=>{const s=new Date(e);return s.setDate(s.getDate()+1),p(s,s)}),[]),w=(0,n.useCallback)(()=>d(({dateSelected:e})=>{const s=new Date(e);return s.setDate(s.getDate()-1),p(s,s)}),[]),k=(0,n.useCallback)(e=>d(({dateMonth:s})=>{const t=new Date(s);return t.setDate(e),p(t,t)}),[]),S=(0,n.useCallback)(e=>x(e),[]);return(0,a.jsxs)(W,{className:s,children:[(0,a.jsx)(r.tU,{basePath:e,items:g.current}),(0,a.jsxs)("div",{className:"calendarFlex",children:[(0,a.jsx)(T,{hasNextMonth:b,lastDay:j,now:i,scheduled:o,setDay:k,setNextMonth:v,setPrevMonth:y,state:c}),(0,a.jsx)("div",{className:"wrapper-style",children:m?(0,a.jsx)(M,{className:"upcoming-events",scheduled:o,setView:S}):(0,a.jsx)(N,{date:c.dateSelected,hasNextDay:f,now:i,scheduled:o,setNextDay:C,setPrevDay:w,setView:S})})]})]})})},76869(e,s,t){t.d(s,{A:()=>le});var a=t(31085),n=t(14041),r=t(18690),o=t(1445),i=t(61020),l=t(28138),c=t(79129),d=t(17722),u=t(24067),m=t(69312),h=t(8525),p=t(95927),x=t.n(p),g=t(76733);const b=new(x())(600),f=new(x())(1800),j=n.memo(function({imageHash:e,members:s,threshold:t}){const{t:r}=(0,d.B)(),{api:u}=(0,i.g)(),[p,j]=(0,l.e)(),[v,y]=(0,n.useState)(null),[C,w]=(0,n.useState)(b),[k,S]=(0,n.useState)(u.consts.democracy.fastTrackVotingPeriod||f),[{proposal:N,proposalLength:A},F]=(0,n.useState)(()=>({proposalLength:0})),[I,E]=(0,l.e)(!0),T=(0,h.L)("technicalCommittee"),D=(0,c.Gc)(T&&u.query[T].proposalCount),M=(0,n.useMemo)(()=>new(x())(Math.ceil(s.length*(0,m.zu)(u,!k||u.consts.democracy.fastTrackVotingPeriod.lte(k)))),[u,s,k]),B=(0,n.useMemo)(()=>{if(!(T&&N&&D&&u.tx.utility))return null;const e=3===u.tx[T].propose.meta.args.length?u.tx[T].propose(M,N,A):u.tx[T].propose(M,N);return I&&s.length>1?u.tx.utility.batch([e,u.tx[T].vote(N.method.hash,D,!0)]):e},[u,s,M,T,N,D,A,I]);return(0,n.useEffect)(()=>{const s=C&&!C.isZero()&&k&&!k.isZero()?u.tx.democracy.fastTrack(e,k,C):null;F({proposal:s,proposalLength:s?.length||0})},[u,C,e,s,k]),T&&u.tx.utility?(0,a.jsxs)(a.Fragment,{children:[p&&(0,a.jsxs)(o.aF,{header:r("Fast track proposal"),onClose:j,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:r("Select the committee account you wish to make the proposal with."),children:(0,a.jsx)(o.B4,{filter:s,label:r("propose from account"),onChange:y,type:"account",withLabel:!0})}),(0,a.jsx)(o.aF.Columns,{hint:r("The external proposal to send to the technical committee"),children:(0,a.jsx)(o.pd,{isDisabled:!0,label:r("preimage hash"),value:(0,g.K)(e)?e:e.toHex()})}),(0,a.jsxs)(o.aF.Columns,{hint:r("The voting period and delay to apply to this proposal. The threshold is calculated from these values."),children:[(0,a.jsx)(o.YI,{autoFocus:!0,isZeroable:!1,label:r("voting period"),onChange:S,value:k}),(0,a.jsx)(o.YI,{isZeroable:!1,label:r("delay"),onChange:w,value:C}),(0,a.jsx)(o.YI,{defaultValue:M,isDisabled:!0,label:r("threshold")})]}),s.length>1&&(0,a.jsx)(o.aF.Columns,{hint:r("Submit an Aye vote alongside the proposal as part of a batch"),children:(0,a.jsx)(o.lM,{label:r("Submit Aye vote with proposal"),onChange:E,value:I})})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.jX,{accountId:v,extrinsic:B,icon:"forward",isDisabled:!v,label:r("Fast track"),onStart:j})})]}),(0,a.jsx)(o.$n,{icon:"forward",isDisabled:t.isSuperMajorityApprove,label:r("Fast track"),onClick:j})]}):null});var v=t(43754),y=t(20666);const C=n.memo(function({className:e="",value:{image:s,imageHash:t,threshold:n}}){const{isMember:r,members:i}=(0,u.r)("technicalCommittee"),[c,d]=(0,l.e)(!1);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("tr",{className:`${e} isExpanded isFirst ${c?"":"isLast"}`,children:[(0,a.jsx)(y.A,{imageHash:t,proposal:s?.proposal}),(0,a.jsx)("td",{className:"address",children:s&&(0,a.jsx)(o.ov,{value:s.proposer})}),(0,a.jsx)(o.XI.Column.Balance,{value:s?.balance}),(0,a.jsx)("td",{className:"actions",children:(0,a.jsxs)(o.$n.Group,{children:[!s?.proposal&&(0,a.jsx)(v.A,{imageHash:t}),n&&r&&(0,a.jsx)(j,{imageHash:t,members:i,threshold:n}),(0,a.jsx)(o.L3,{expanded:c,onClick:d})]})})]}),(0,a.jsx)("tr",{className:`${e} ${c?"isExpanded isLast":"isCollapsed"}`,children:(0,a.jsx)("td",{className:"columar",colSpan:100,children:(0,a.jsx)(o.Yt,{is100:!0,children:(0,a.jsx)(o.Yt.Column,{children:(0,a.jsx)(o.e9,{data:t,type:"democracyExternal",withTitle:!0})})})})})]})}),w=n.memo(function({className:e}){const{t:s}=(0,d.B)(),{api:t}=(0,i.g)(),r=(0,c.Gc)(t.derive.democracy.nextExternal),l=(0,n.useRef)([[s("external"),"start"],[s("proposer"),"address"],[s("locked")],[]]);return(0,a.jsx)(o.XI,{className:e,empty:null===r&&s("No external proposal"),header:l.current,children:r&&(0,a.jsx)(C,{value:r})})});var k=t(34202),S=t(33168),N=t(97186),A=t(54979);const F=n.memo(function({deposit:e,depositors:s,image:t,proposalId:r}){const{t:c}=(0,d.B)(),{hasAccounts:u}=(0,N.o)(),{api:m}=(0,i.g)(),[h,p]=(0,n.useState)(null),[x,g]=(0,l.e)();return u?(0,a.jsxs)(a.Fragment,{children:[x&&(0,a.jsxs)(o.aF,{header:c("Endorse proposal"),onClose:g,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:c("The proposal is in the queue for future referendums. One proposal from this list will move forward to voting."),children:(0,a.jsx)(A.A,{idNumber:r,proposal:t?.proposal})}),(0,a.jsx)(o.aF.Columns,{hint:c("Endorsing a proposal that indicates your backing for the proposal. Proposals with greater interest moves up the queue for potential next referendums."),children:(0,a.jsx)(o.B4,{label:c("endorse with account"),onChange:p,type:"account",withLabel:!0})}),(0,a.jsx)(o.aF.Columns,{hint:c("The deposit will be locked for the lifetime of the proposal."),children:(0,a.jsx)(o.xg,{defaultValue:e||m.consts.democracy.minimumDeposit,isDisabled:!0,label:c("deposit required")})})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.jX,{accountId:h,icon:"sign-in-alt",isDisabled:!h,label:c("Endorse"),onStart:g,params:2===m.tx.democracy.second.meta.args.length?[r,s.length]:[r],tx:m.tx.democracy.second})})]}),(0,a.jsx)(o.$n,{icon:"toggle-off",label:c("Endorse"),onClick:g})]}):null}),I=n.memo(function({className:e="",value:{balance:s,image:t,imageHash:r,index:i,proposer:c,seconds:u}}){const{t:m}=(0,d.B)(),[h,p]=(0,l.e)(!1),x=(0,n.useMemo)(()=>u.filter((e,s)=>0!==s),[u]),g=(0,n.useCallback)(()=>x.map((e,s)=>(0,a.jsx)(o.ov,{value:e,withBalance:!1,withShrink:!0},`${s}:${e.toHex()}`)),[x]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("tr",{className:`${e} isExpanded isFirst ${h?"":"isLast"}`,children:[(0,a.jsx)(o.XI.Column.Id,{value:i}),(0,a.jsx)(y.A,{imageHash:r,proposal:t?.proposal}),(0,a.jsx)("td",{className:"address",children:(0,a.jsx)(o.ov,{value:c})}),(0,a.jsx)("td",{className:"number together media--1200",children:(0,a.jsx)(S.A,{value:s})}),(0,a.jsx)("td",{className:"expand",children:0!==x.length&&(0,a.jsx)(o.PW,{empty:x&&m("No endorsements"),renderChildren:g,summary:m("Endorsed ({{count}})",{replace:{count:x.length}})})}),(0,a.jsx)("td",{className:"actions",children:(0,a.jsxs)(o.$n.Group,{children:[!t?.proposal&&(0,a.jsx)(v.A,{imageHash:r}),(0,a.jsx)(F,{deposit:s,depositors:u||[],image:t,proposalId:i}),(0,a.jsx)(o.L3,{expanded:h,onClick:p})]})})]}),(0,a.jsxs)("tr",{className:`${e} ${h?"isExpanded isLast":"isCollapsed"}`,children:[(0,a.jsx)("td",{}),(0,a.jsx)("td",{className:"columar",colSpan:100,children:(0,a.jsx)(o.Yt,{is100:!0,children:(0,a.jsx)(o.Yt.Column,{children:(0,a.jsx)(o.e9,{data:i,type:"democracyProposal",withTitle:!0})})})})]})]})}),E=n.memo(function({className:e}){const{t:s}=(0,d.B)(),{api:t}=(0,i.g)(),r=(0,c.Gc)(t.derive.democracy.proposals),l=(0,n.useRef)([[s("proposals"),"start",2],[s("proposer"),"address"],[s("locked"),"media--1200"],[void 0,void 0,2]]);return(0,a.jsx)(o.XI,{className:e,empty:r&&s("No active proposals"),header:l.current,children:r?.map(e=>(0,a.jsx)(I,{value:e},e.index.toString()))})});var T=t(96348),D=t(44366),M=t(51524),B=t(54143),P=t(6404);const $=n.memo(function({className:e="",onClose:s}){const{t}=(0,d.B)(),{api:r}=(0,i.g)(),[l,u]=(0,n.useState)(null),[m,h]=(0,n.useState)(),[{imageHash:p,isImageHashValid:x},g]=(0,n.useState)({imageHash:null,isImageHashValid:!1}),[{imageLen:b,imageLenDefault:f,isImageLenValid:j},v]=(0,n.useState)({imageLen:M.Yz,isImageLenValid:!1}),y=(0,c.Gc)(r.query.democracy.publicProps),C=(0,T.I2)(p);(0,n.useEffect)(()=>{C?.proposalLength&&v(e=>({imageLen:e.imageLen,imageLenDefault:C.proposalLength,isImageLenValid:e.isImageLenValid}))},[C]);const w=(0,n.useCallback)(e=>g({imageHash:e,isImageHashValid:(0,B.qv)(e,256)}),[]),k=(0,n.useCallback)(e=>{e&&v(s=>({imageLen:e,imageLenDefault:s.imageLenDefault,isImageLenValid:!e.isZero()}))},[]),S=m?.gte(r.consts.democracy.minimumDeposit);return(0,a.jsxs)(o.aF,{className:e,header:t("Submit proposal"),onClose:s,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:t("The proposal will be registered from this account and the balance lock will be applied here."),children:(0,a.jsx)(o.B4,{label:t("send from account"),labelExtra:(0,a.jsx)(D.A,{label:(0,a.jsx)("span",{className:"label",children:t("transferable")}),params:l}),onChange:u,type:"account"})}),(0,a.jsxs)(o.aF.Columns,{hint:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{children:t("The hash of the preimage for the proposal as previously submitted or intended.")}),(0,a.jsx)("p",{children:t("The length value will be auto-populated from the on-chain value if it is found.")})]}),children:[(0,a.jsx)(o.pd,{autoFocus:!0,isError:!x,label:t("preimage hash"),onChange:w,value:p||""}),(0,a.jsx)(o.YI,{defaultValue:f,isDisabled:!!C?.proposalLength&&!C?.proposalLength.isZero()&&x&&j,isError:!j,label:t("preimage length"),onChange:k,value:b},"inputLength")]}),(0,a.jsxs)(o.aF.Columns,{hint:t("The associated deposit for this proposal should be more then the minimum on-chain deposit required. It will be locked until the proposal passes."),children:[(0,a.jsx)(o.xg,{defaultValue:r.consts.democracy.minimumDeposit,isError:!S,label:t("locked balance"),onChange:h}),(0,a.jsx)(o.xg,{defaultValue:r.consts.democracy.minimumDeposit,isDisabled:!0,label:t("minimum deposit")})]})]}),(0,a.jsx)(o.aF.Actions,{children:(0,a.jsx)(o.jX,{accountId:l,icon:"plus",isDisabled:!m||!S||!x||!l||!y||(0,P.T)(r.tx.preimage?.notePreimage)&&!(0,P.T)(r.tx.democracy?.notePreimage)&&!C,label:t("Submit proposal"),onStart:s,params:3===r.tx.democracy.propose.meta.args.length?[p,m,y?.length]:(0,P.T)(r.tx.preimage?.notePreimage)&&!(0,P.T)(r.tx.democracy?.notePreimage)?[C&&{Lookup:{hash:C.proposalHash,len:b}},m]:[p,m],tx:r.tx.democracy.propose})})]})});var L=t(40941),V=t(69832),R=t(21327),z=t(45414),H=t(55155),q=t(85159);const O=new(x())(-1),W=new(x())(2);function U(e,s,t,a,n,r){const o=1===r?M.Uu:O,i=t.add(a),l=M.Uu.muln(10*n).mul(i).div(M.Xx);return[i,e.add(o.mul(i)),x().max(M.Yz,s.add(o.mul(l)))]}function G(e,s,{votedAye:t,votedNay:a,votedTotal:n},r,o,i){for(;;){const[l,c,d]=U(t,n,o,i,r?0:1,r?-1:1);if((0,q.X8)(e,s,{votedAye:c,votedNay:a,votedTotal:d})!==r)return o;o=l}}function Y(e,s,{votedAye:t,votedNay:a,votedTotal:n},r,o,i){for(;;){const[l,c,d]=U(a,n,o,i,r?1:0,r?1:-1);if((0,q.X8)(e,s,{votedAye:t,votedNay:c,votedTotal:d})!==r)return o;o=l}}const X=(0,H.F)("useChangeCalc",function(e,s,t,a){const{api:r}=(0,i.g)(),o=(0,c.Gc)(r.derive.democracy.sqrtElectorate),[l,d]=(0,n.useState)({changeAye:M.Yz,changeNay:M.Yz});return(0,n.useEffect)(()=>{o&&d(function(e,s,t){const a=(0,q.X8)(e,s,t);if(e.isSimpleMajority){const e=a?t.votedAye.sub(t.votedNay):t.votedNay.sub(t.votedAye);return{changeAye:t.votedNay.isZero()?M.Yz:e,changeNay:t.votedAye.isZero()?M.Yz:e}}let n=M.Yz,r=M.Yz,o=t.votedTotal.div(W);for(;!o.isZero();){n=G(e,s,t,a,n,o),r=Y(e,s,t,a,r,o);const i=o.div(W);i.isZero()&&(n=n.add(o),r=r.add(o)),o=i}return{changeAye:t.votedNay.isZero()?M.Yz:a?x().min(n,t.votedAye):n,changeNay:t.votedAye.isZero()?M.Yz:a?r:x().min(r,t.votedNay)}}(e,o,{votedAye:s,votedNay:t,votedTotal:a}))},[o,e,s,t,a]),l}),Z=["0.1x","1x","2x","3x","4x","5x","6x"];function _({conviction:e},s){return`${Z[e.toNumber()]}${s?"/d":""} - `}const J=n.memo(function({vote:{accountId:e,balance:s,isDelegating:t,vote:n}}){return(0,a.jsx)(o.ov,{balance:s,labelBalance:_(n,t),value:e,withBalance:!0})}),K=[1,10,20,30,40,50,60],Q=n.memo(function({className:e,count:s,isAye:t,total:r,votes:i}){const{t:l}=(0,d.B)(),c=(0,n.useMemo)(()=>i.sort((e,s)=>{const t=e.balance.muln(K[e.vote.conviction.toNumber()]).div(M.Xx);return s.balance.muln(K[s.vote.conviction.toNumber()]).div(M.Xx).cmp(t)}),[i]),u=(0,n.useCallback)(()=>c.map(e=>(0,a.jsx)(J,{vote:e},e.accountId.toString())),[c]);return(0,a.jsx)(o.PW,{className:e,empty:i&&l("No voters"),renderChildren:i.length?u:void 0,summary:(0,a.jsxs)(a.Fragment,{children:[l(t?"Aye {{count}}":"Nay {{count}}",{replace:{count:s?` (${(0,R.Z)(s)})`:""}}),(0,a.jsx)("div",{children:(0,a.jsx)(S.A,{value:r})})]})})}),ee=n.memo(function({proposal:e,referendumId:s}){const{t}=(0,d.B)(),{api:r}=(0,i.g)(),{hasAccounts:c}=(0,N.o)(),[u,m]=(0,n.useState)(null),[h,p]=(0,n.useState)(),[x,g]=(0,n.useState)(1),[b,f]=(0,l.e)(),j=(0,n.useMemo)(()=>!!r.query.democracy.votingOf,[r]);if(!c)return null;const v=!!j&&!h;return(0,a.jsxs)(a.Fragment,{children:[b&&(0,a.jsxs)(o.aF,{header:t("Vote on proposal"),onClose:f,size:"large",children:[(0,a.jsxs)(o.aF.Content,{children:[(0,a.jsx)(o.aF.Columns,{hint:t("If this proposal is passed, the changes will be applied via dispatch and the deposit returned."),children:(0,a.jsx)(A.A,{idNumber:s,proposal:e})}),(0,a.jsx)(o.aF.Columns,{hint:t("The vote will be recorded for this account. If another account delegated to this one, the delegated votes will also be counted."),children:(0,a.jsx)(o.g1,{onChange:m})}),(0,a.jsxs)(o.aF.Columns,{hint:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{children:t("The balance associated with the vote will be locked as per the conviction specified and will not be available for transfer during this period.")}),(0,a.jsx)("p",{children:t("Conviction locks do overlap and are not additive, meaning that funds locked during a previous vote can be locked again.")})]}),children:[j&&(0,a.jsx)(o.mB,{accountId:u,autoFocus:!0,onChange:p}),(0,a.jsx)(o.GC,{label:t("conviction"),onChange:g,value:x,voteLockingPeriod:r.consts.democracy.voteLockingPeriod||r.consts.democracy.enactmentPeriod})]})]}),(0,a.jsxs)(o.aF.Actions,{children:[(0,a.jsx)(o.jX,{accountId:u,icon:"ban",isDisabled:v,label:t("Vote Nay"),onStart:f,params:j?[s,{Standard:{balance:h,vote:{aye:!1,conviction:x}}}]:[s,{aye:!1,conviction:x}],tx:r.tx.democracy.vote}),(0,a.jsx)(o.jX,{accountId:u,icon:"check",isDisabled:v,label:t("Vote Aye"),onStart:f,params:j?[s,{Standard:{balance:h,vote:{aye:!0,conviction:x}}}]:[s,{aye:!0,conviction:x}],tx:r.tx.democracy.vote})]})]}),(0,a.jsx)(o.$n,{icon:"check-to-slot",label:t("Vote"),onClick:f})]})});function se(e,s){return Math.min(100,e.muln(1e4).div(s).toNumber()/100).toFixed(2)}const te=n.memo(function({className:e="",value:{allAye:s,allNay:t,image:r,imageHash:u,index:m,isPassing:h,status:p,voteCountAye:g,voteCountNay:b,votedAye:f,votedNay:j,votedTotal:C}}){const{t:w}=(0,d.B)(),{api:k}=(0,i.g)(),{allAccounts:S}=(0,N.o)(),A=(0,L.x)(),[F,I]=(0,l.e)(!1),E=(0,c.Gc)(k.query.balances?.totalIssuance),{changeAye:T,changeNay:D}=X(p.threshold,f,j,C),B=(0,n.useMemo)(()=>p.threshold.type.toString().replace("majority"," majority "),[p]),P=f.add(j),[$,{hasVoted:H,hasVotedAye:q}]=(0,n.useMemo)(()=>{if(E){const e=s.reduce((e,{balance:s})=>e.add(s),new(x())(0)),a=t.reduce((e,{balance:s})=>e.add(s),new(x())(0)),n=s.some(({accountId:e})=>S.includes(e.toString()));return[{aye:C.isZero()?"":`${se(e,C)}%`,nay:C.isZero()?"":`${se(a,C)}%`,turnout:`${se(C,E)}%`},{hasVoted:n||t.some(({accountId:e})=>S.includes(e.toString())),hasVotedAye:n}]}return[null,{hasVoted:!1,hasVotedAye:!1}]},[S,s,t,E,C]);if(!A||p.end.sub(A).lten(0))return null;const O=p.end.add(p.delay),W=p.end.sub(A).isub(M.Uu);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("tr",{className:`${e} isExpanded isFirst ${F?"":"isLast"}`,children:[(0,a.jsx)(o.XI.Column.Id,{value:m}),(0,a.jsx)(y.A,{imageHash:u,proposal:r?.proposal}),(0,a.jsxs)("td",{className:"number together media--1200",children:[(0,a.jsx)(V.A,{value:W}),w("{{blocks}} blocks",{replace:{blocks:(0,R.Z)(W)}})]}),(0,a.jsxs)("td",{className:"number together media--1400",children:[(0,a.jsx)(V.A,{value:O.sub(A)}),"#",(0,R.Z)(O)]}),(0,a.jsx)("td",{className:"number together media--1400",children:$&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{children:$.turnout})})}),(0,a.jsx)("td",{className:"badge",children:(0,z.L)(h)&&(0,a.jsx)(o.Ex,{color:h?"green":"red",hover:w(h?"{{threshold}}, passing":"{{threshold}}, not passing",{replace:{threshold:B}}),icon:h?"check":"times"})}),(0,a.jsxs)("td",{className:"expand",children:[(0,a.jsx)(Q,{change:T,count:g,isAye:!0,isWinning:h,total:f,votes:s}),(0,a.jsx)(Q,{change:D,count:b,isAye:!1,isWinning:!h,total:j,votes:t})]}),(0,a.jsx)("td",{className:"media--1000 middle chart",children:(0,a.jsx)(o.ke,{total:P,value:f})}),(0,a.jsx)("td",{className:"badge",children:(0,a.jsx)(o.In,{color:H?q?"green":"red":"gray",icon:"asterisk"})}),(0,a.jsx)("td",{className:"actions",children:(0,a.jsxs)(o.$n.Group,{children:[!r?.proposal&&(0,a.jsx)(v.A,{imageHash:u}),(0,a.jsx)(ee,{proposal:r?.proposal,referendumId:m}),(0,a.jsx)(o.L3,{expanded:F,onClick:I})]})})]}),(0,a.jsxs)("tr",{className:`${e} ${F?"isExpanded isLast":"isCollapsed"}`,children:[(0,a.jsx)("td",{}),(0,a.jsx)("td",{className:"columar",colSpan:100,children:(0,a.jsx)(o.Yt,{is100:!0,children:(0,a.jsx)(o.Yt.Column,{children:(0,a.jsx)(o.e9,{data:m,type:"democracyReferendum",withTitle:!0})})})})]})]})}),ae=n.memo(function({className:e="",referendums:s}){const{t}=(0,d.B)(),r=(0,n.useRef)([[t("referenda"),"start",2],[t("remaining"),"media--1200"],[t("activate"),"media--1400"],[t("turnout"),"media--1400"],[void 0,"badge"],[t("votes"),"expand"],[void 0,"media--1000"],[void 0,void 0,2]]);return(0,a.jsx)(o.XI,{className:e,empty:s&&t("No active referendums"),header:r.current,children:s?.map(e=>(0,a.jsx)(te,{value:e},e.index.toString()))})});var ne=t(87497);const re={defaultValue:[void 0,void 0]},oe=n.memo(function({referendumCount:e}){const{t:s}=(0,d.B)(),{api:t}=(0,i.g)(),n=(0,c.Gc)(t.derive.democracy.proposals),r=(0,L.x)(),[l,u]=(0,ne.x)([t.query.democracy.publicPropCount,t.query.democracy.referendumCount],re);return(0,a.jsxs)(o.cp,{children:[(0,a.jsxs)("section",{children:[(0,a.jsx)(o.dS,{label:s("proposals"),children:n?(0,R.Z)(n.length):(0,a.jsx)("span",{className:"--tmp",children:"99"})}),(0,a.jsx)(o.dS,{label:s("total"),children:l?(0,R.Z)(l):(0,a.jsx)("span",{className:"--tmp",children:"99"})})]}),(0,a.jsxs)("section",{children:[(0,a.jsx)(o.dS,{label:s("referenda"),children:void 0!==e?(0,R.Z)(e):(0,a.jsx)("span",{className:"--tmp",children:"99"})}),(0,a.jsx)(o.dS,{label:s("total"),children:u?(0,R.Z)(u):(0,a.jsx)("span",{className:"--tmp",children:"99"})})]}),t.consts.democracy.launchPeriod&&(0,a.jsx)("section",{className:"media--1100",children:(0,a.jsx)(o.dS,{label:s("launch period"),progress:{isBlurred:!r,total:t.consts.democracy.launchPeriod,value:r?r.mod(t.consts.democracy.launchPeriod).iadd(M.Uu):t.consts.democracy.launchPeriod.mul(M.u_).div(M.iz),withTime:!0}})})]})}),ie=n.memo(function({className:e}){const{t:s}=(0,d.B)(),{api:t}=(0,i.g)(),[n,r]=(0,l.e)(),[u,m]=(0,l.e)(),h=(0,c.Gc)(t.derive.democracy.referendums);return(0,a.jsxs)("div",{className:e,children:[(0,a.jsx)(oe,{referendumCount:h?.length}),(0,a.jsxs)(o.$n.Group,{children:[t.tx.democracy.notePreimage&&(0,a.jsx)(o.$n,{icon:"plus",label:s("Submit preimage"),onClick:r}),(0,a.jsx)(o.$n,{icon:"plus",label:s("Submit proposal"),onClick:m})]}),n&&(0,a.jsx)(k.A,{onClose:r}),u&&(0,a.jsx)($,{onClose:m}),(0,a.jsx)(ae,{referendums:h}),(0,a.jsx)(E,{}),(0,a.jsx)(w,{})]})}),le=n.memo(function({basePath:e}){const{t:s}=(0,d.B)(),t=(0,n.useMemo)(()=>[{isRoot:!0,name:"overview",text:s("Overview")}],[s]);return(0,a.jsxs)("main",{className:"democracy--App",children:[(0,a.jsx)(o.tU,{basePath:e,items:t}),(0,a.jsx)(r.BV,{children:(0,a.jsx)(r.qh,{path:e,children:(0,a.jsx)(r.qh,{element:(0,a.jsx)(ie,{}),index:!0})})})]})})},79294(e,s,t){t.d(s,{A:()=>L});var a=t(31085),n=t(14041),r=t(1445),o=t(45060),i=t.n(o),l=t(51999),c=t(70020),d=t.n(c);const u={files:[],isLoad:!0};var m=t(37140);function h(){return(0,m.Bd)("app-files")}var p=t(63816),x=t(41042),g=t(770),b=t(6404),f=t(58797),j=t(26865),v=t(92100),y=t(79876);const C=r.I4.div`
width: 100%;
background: unset;
overflow: hidden;
height: 1.4rem;
border-radius: 0.7rem;
border-style: solid;
border-width: 1px;
.file-progress-bar {
transition: width 100ms ease-in-out;
width: 0;
height: 100%;
}
`,w=n.memo(function({className:e="",progress:s,style:t}){return(0,a.jsx)(C,{className:`${e} highlight--border`,style:t,children:(0,a.jsx)("div",{className:"file-progress-bar highlight--bg",style:{width:`${s}%`}})})});var k=t(1048).Buffer;const S=()=>{};function N(e){const s=e.file;return(0,a.jsxs)("div",{className:"file",children:[(0,a.jsx)(r.JU,{label:s.webkitRelativePath||e.file.name}),(0,a.jsx)("span",{children:`${s.size} bytes`})]})}const A=(0,r.I4)(r.aF)`
.files {
max-height: 300;
overflow: auto;
padding-left: 2rem;
width: 100%;
.file {
background-color: white;
border-bottom: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 4px;
padding: 5px 2rem;
}
}
.progress {
margin-left: 2rem;
margin-top: 2rem;
width: calc(100% - 2rem);
}
`,F=n.memo(function({className:e,file:s,onClose:t=S,onSuccess:o=S}){const{t:i}=h(),l=(0,n.useMemo)(()=>function(e){return[{location:e("Singapore"),text:e("DCF"),value:"https://crustipfs.xyz"},{location:e("Seattle"),text:e("Crust Network"),value:"https://gw.crustfiles.app"},{location:e("Berlin"),text:e("⚡️ Thunder Gateway"),value:"https://gw.crustfiles.net"}]}(i).sort(()=>Math.random()>.5?-1:1).map(e=>({...e,text:`${e.text??""}(${e.location??""})`})),[i]),[c,d]=(0,n.useState)(l[0]),u=(0,n.useMemo)(()=>[{text:i("Crust Pinner"),value:"https://pin.crustcode.com"}],[i]),[m,C]=(0,n.useState)(u[0]),[F,I]=(0,n.useState)(()=>g.AC.getPairs()[0]||null),[E,T]=(0,n.useState)(""),[{isInjected:D},M]=(0,n.useState)({isExternal:!1,isHardware:!1,isInjected:!1}),[B,P]=(0,n.useState)(!1),[{isUsable:$,signer:L},V]=(0,n.useState)({isUsable:!0,signer:null}),[R,z]=(0,n.useState)(""),[H,q]=(0,n.useState)(!1),O=(0,n.useMemo)(()=>{const e=104857600;if(s.file)return s.file.size>e;if(s.files){let t=0;for(const e of s.files)t+=e.size;return t>e}return!1},[s]),[W,U]=(0,n.useState)(""),G=O?i("Do not upload files larger than 100MB!"):W,[Y,X]=(0,n.useState)({progress:0,up:!1}),[Z,_]=(0,n.useState)(null),J=(0,n.useCallback)(e=>{e&&(T(e),I(g.AC.getPair(e)))},[T,I]);(0,n.useEffect)(()=>{const e=F?.meta||{},s=e.isExternal||!1,t=e.isHardware||!1,a=e.isInjected||!1,n=!(s||t||a);M({isExternal:s,isHardware:t,isInjected:a}),P(!a&&(F&&F.isLocked||!1)),V({isUsable:n,signer:null}),e.source&&a&&(0,x.tV)(e.source).catch(()=>null).then(e=>V({isUsable:(0,b.T)(e?.signer?.signRaw),signer:e?.signer||null})).catch(console.error)},[F]);const K=(0,n.useCallback)(()=>new Promise((e,s)=>{(0,f.d)(()=>{try{F.decodePkcs8(R),e(1)}catch(e){s(e)}})}),[F,R]),Q=(0,n.useCallback)(()=>{Z&&Z.cancel(),t()},[Z,t]),ee=(0,n.useCallback)(async()=>{if(U(""),$&&F)try{q(!0),B&&await K();let e="";e=L&&(0,b.T)(L.signRaw)?(await L.signRaw({address:F.address,data:(0,j.i)(F.address),type:"bytes"})).signature:(0,v.X)(F.sign((0,y.j)(F.address)));const t=`${F.address}:${e}`,a=k.from(t).toString("base64"),n=`Basic ${a}`,r=`Bearer ${a}`,i=p.A.CancelToken.source();_(i),X({progress:0,up:!0});const l=new FormData;if(s.file)l.append("file",s.file,s.file.name);else if(s.files)for(const e of s.files)l.append("file",e,e.webkitRelativePath);const d=c.value,u=await p.A.request({cancelToken:i.token,data:l,headers:{Authorization:n},maxContentLength:104857600,method:"POST",onUploadProgress:({loaded:e,total:s})=>{const t=e/(s||e||1);X({progress:Math.round(99*t),up:!0})},params:{pin:!0},url:`${d}/api/v0/add`});let h;if("string"==typeof u.data){const e=u.data.replace(/}\n{/g,"},{"),s=JSON.parse(`[${e}]`),t=s.length-1;h=s[t],delete s[t],h.items=s}else h=u.data;console.info("upResult:",u),_(null),X({progress:100,up:!1});const x=m.value;await p.A.request({data:{cid:h.Hash,name:h.Name},headers:{Authorization:r},method:"POST",url:`${x}/psa/pins`}),o({...h,PinEndpoint:x,UpEndpoint:d})}catch(e){X({progress:0,up:!1}),q(!1),console.error(e),U(e.message)}},[s,K,L,B,$,F,m,c,o]),se=(0,n.useCallback)(e=>{const s=l.find(s=>s.value===e);s&&d(s)},[l,d]),te=(0,n.useCallback)(e=>{const s=u.find(s=>s.value===e);s&&C(s)},[u,C]);return(0,a.jsxs)(A,{className:e,header:i("Upload File"),onClose:Q,open:!0,size:"medium",children:[(0,a.jsxs)(r.aF.Content,{children:[(0,a.jsx)(r.aF.Columns,{children:(0,a.jsxs)("div",{className:"files",children:[s.file&&(0,a.jsx)(N,{file:s.file}),s.files?.map((e,s)=>(0,a.jsx)(N,{file:e},`file_item:${s}`))]})}),(0,a.jsx)(r.aF.Columns,{children:(0,a.jsx)(r.ms,{isDisabled:H,label:i("Select a Web3 IPFS Gateway"),onChange:se,options:l,value:c.value})}),(0,a.jsx)(r.aF.Columns,{children:(0,a.jsx)(r.ms,{isDisabled:!0,label:i("Select a Web3 IPFS Pinner"),onChange:te,options:u,value:m.value})}),(0,a.jsxs)(r.aF.Columns,{children:[(0,a.jsx)(r.B4,{defaultValue:E,isDisabled:H,label:i("Please choose account"),labelExtra:(0,a.jsx)(r.y,{label:i("transferable"),params:E}),onChange:J,type:"account"}),!Y.up&&B&&!D&&(0,a.jsx)(r._2,{isError:!1,label:i("password"),onChange:z,value:R}),(0,a.jsx)(w,{className:"progress",progress:Y.progress}),G&&(0,a.jsx)(r.o_,{content:G})]})]}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.$n,{icon:"arrow-circle-up",isBusy:H,isDisabled:O,label:i("Sign and Upload"),onClick:ee})})]})}),I=(0,r.I4)(r.i8)`
.copySpan {
display: none;
}
`,E=r.I4.tr`
height: 3.5rem;
.end {
text-align: end;
}
.actions {
display: flex;
justify-content: flex-end;
align-items: center;
}
`,T=(e,s=6)=>e.length>2*s?`${e.substring(0,s)}...${e.substring(e.length-s)}`:e;function D(e){return`https://cf-ipfs.com/ipfs/${e.Hash}?filename=${e.Name}`}const M=e=>()=>{window.open(D(e),"_blank")},B=()=>{},P=r.I4.main`
h1 {
text-transform: unset !important;
}
.uploadBtn {
position: relative;
padding: 5px 0;
&:hover {
.uploadMenu {
display: block;
}
}
}
.uploadMenu {
z-index: 200;
display: none;
background-color: var(--bg-table);
position: absolute;
top: 43px;
left: 0;
box-shadow: 0 0 8px rgba(0, 0, 0, 0.4);
border-radius: 4px;
overflow: hidden;
line-height: 40px;
.menuItem {
cursor: pointer;
padding: 0 2rem;
display: flex;
align-items: center;
white-space: nowrap;
&:hover {
background-color: var(--bg-page);
}
}
}
`,$=n.memo(function({className:e}){const{t:s}=h(),{queueAction:t}=(0,l.x)(),[o,c]=(0,n.useState)(!1),m=function(){const[e,s]=(0,n.useState)(u),[t,a]=(0,n.useState)(!0);(0,n.useEffect)(()=>{try{const e=d().get("files",u);e!==u&&s(e),a(!1)}catch(e){a(!1),console.error(e)}},[]);const r=(0,n.useCallback)(t=>{const a={...e,files:t};s(a),d().set("files",a)},[e]);return(0,n.useMemo)(()=>({...e,isLoad:t,setFiles:r}),[e,r,t])}(),[p,x]=(0,n.useState)(void 0),g=(0,n.useRef)(null),b=(0,n.useCallback)((e=!1)=>{g.current&&(g.current.webkitdirectory=e,g.current.multiple=e,g.current.click())},[g]),f=(0,n.useCallback)(()=>b(!1),[b]),j=(0,n.useCallback)(()=>b(!0),[b]),v=(0,n.useCallback)(e=>{const a=e.target.files;if(a)if(a.length>2e3)t({action:"Upload Folder",message:s("Please do not upload more than 2000 files"),status:"error"});else if(0!==a.length){if(e.target.webkitdirectory){if(a.length>=1){const e=[];for(let s=0,t=a.length;s<t;s++)e.push(a[s]);console.info(e);const[s]=e[0].webkitRelativePath.split("/");x({dir:s,files:e}),c(!0)}}else x({file:a[0]}),c(!0);e.target.value=""}else t({action:"Upload Folder",message:s("Please select non-empty folder"),status:"error"})},[x,c,t,s]),y=(0,n.useCallback)((e,a="queued")=>{t&&t({action:s("Import files"),message:e,status:a})},[t,s]),C=(0,n.useRef)(null),w=(0,n.useCallback)(()=>{C.current&&C.current.click()},[C]),k=(0,n.useCallback)(e=>{try{y(s("Importing"));const t=new FileReader,a=e.target.files;if(!a)return;if(t.readAsText(a[0],"UTF-8"),!/(.json)$/i.test(e.target.value))return y(s("file error"),"error");t.onload=e=>{const t=JSON.parse(e.target?.result);if(!Array.isArray(t))return y(s("file content error"),"error");const a=[],n={};for(const e of t)e.Hash&&e.Name&&e.UpEndpoint&&e.PinEndpoint&&(a.push(e),n[e.Hash]=!0);const r=m.files.filter(e=>!n[e.Hash]);m.setFiles([...a,...r]),y(s("Import Success"),"success")}}catch{y(s("file content error"),"error")}},[m,y,s]),S=(0,n.useCallback)(()=>{c(!1)},[]),N=(0,n.useCallback)(e=>{c(!1);const s=m.files.filter(s=>s.Hash!==e.Hash);m.setFiles([e,...s])},[m]),A=(0,n.useCallback)(()=>{const e=new Blob([JSON.stringify(m.files)],{type:"application/json; charset=utf-8"});i().saveAs(e,"files.json")},[m]);return(0,a.jsxs)(P,{className:e,children:[(0,a.jsx)("header",{}),(0,a.jsx)("input",{onChange:v,ref:g,style:{display:"none"},type:"file"}),(0,a.jsx)("input",{onChange:k,ref:C,style:{display:"none"},type:"file"}),p&&o&&(0,a.jsx)(F,{file:p,onClose:S,onSuccess:N}),(0,a.jsxs)("div",{style:{display:"flex",paddingBottom:"1.5rem"},children:[(0,a.jsxs)("div",{className:"uploadBtn",children:[(0,a.jsx)(r.$n,{icon:"upload",label:s("Upload"),onClick:B}),(0,a.jsxs)("div",{className:"uploadMenu",children:[(0,a.jsx)("div",{className:"menuItem",onClick:f,children:s("File")}),(0,a.jsx)("div",{className:"menuItem",onClick:j,children:s("Folder")})]})]}),(0,a.jsx)("div",{style:{flex:1}}),(0,a.jsx)(r.$n,{icon:"file-import",label:s("Import"),onClick:w}),(0,a.jsx)(r.$n,{icon:"file-export",label:s("Export"),onClick:A})]}),(0,a.jsx)(r.XI,{empty:s("No files"),emptySpinner:s("Loading"),header:[[s("files"),"start",2],[s("file cid"),"expand",2],[void 0,"start"],[s("file size"),"expand",2],[s("status"),"expand"],[s("action"),"expand"],[]],children:m.files.map((e,t)=>(0,a.jsxs)(E,{children:[(0,a.jsxs)("td",{className:"",colSpan:2,children:[e.items&&(0,a.jsx)(r.In,{className:"highlight--color",icon:"folder"}),T(e.Name)]}),(0,a.jsx)("td",{className:"end",colSpan:2,children:e.Hash}),(0,a.jsx)("td",{className:"",colSpan:1,children:(0,a.jsx)(I,{value:e.Hash,children:(0,a.jsx)(r.Ex,{color:"highlight",hover:s("Copy file cid"),icon:"copy"})})}),(0,a.jsx)("td",{className:"end",colSpan:2,children:`${e.Size} bytes`}),(0,a.jsx)("td",{className:"end",colSpan:1,children:(0,a.jsx)("a",{href:"https://apps.crust.network/?rpc=wss%3A%2F%2Frpc.crust.network#/storage_files/status/"+e.Hash,rel:"noreferrer",target:"_blank",children:s("View status in Crust")})}),(0,a.jsx)("td",{className:"end",colSpan:1,children:(0,a.jsxs)("div",{className:"actions",children:[!e.items&&(0,a.jsx)(r.Ex,{color:"highlight",hover:s("Download"),icon:"download",onClick:M(e)}),(0,a.jsx)(I,{value:D(e),children:(0,a.jsx)(r.Ex,{color:"highlight",hover:s("Copy link"),icon:"copy"})})]})}),(0,a.jsx)("td",{colSpan:1})]},`files_item-${t}`))}),(0,a.jsx)("div",{children:s("Note: The file list is cached locally, switching browsers or devices will not keep displaying the original browser information.")})]})}),L=n.memo(function({basePath:e,className:s}){const{t}=h(),o=(0,n.useRef)([{isRoot:!0,name:"crust",text:t("Your Files")}]);return(0,a.jsxs)("main",{className:s,children:[(0,a.jsx)(r.tU,{basePath:e,items:o.current}),(0,a.jsx)($,{})]})})},81035(e,s,t){t.d(s,{A:()=>c});var a=t(14041),n=t(55155),r=t(97186),o=t(61020),i=t(79129),l=t(22067);const c=(0,n.F)("useCounter",function(){const{hasAccounts:e}=(0,r.o)(),{api:s,isApiReady:t}=(0,o.g)(),n=(0,l.T)(),c=(0,i.Gc)(t&&e&&s.derive.democracy?.proposals),d=(0,i.Gc)(t&&e&&s.derive.democracy?.referendumsActive),[u,m]=(0,a.useState)(0);return(0,a.useEffect)(()=>{n.current&&m((c?.length||0)+(d?.length||0))},[n,c,d]),u})},84278(e,s,t){t.d(s,{A:()=>ye});var a=t(31085),n=t(14041),r=t(61020),o=t(53663),i=t(86832),l=t(95927),c=t.n(l);const d={block:{coretime:{dicle:53793,"paseo testnet":22316,pezkuwi:100988,zagros:7363}},timeslice:{coretime:{dicle:284920,"paseo testnet":38469,pezkuwi:282525,zagros:245402}}},u={[i.qk.Reservation]:"orange",[i.qk.Lease]:"blue",[i.qk["Bulk Coretime"]]:"pink"};function m(e,s=!1){const t=e.getDate(),a=e.toLocaleString("default",{month:"short"}),n=e.getFullYear();return s?`${t} ${a} ${n}, ${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}`:`${t} ${a} ${n}`}const h=(e,s,{blocksPerTimeslice:t,blocktimeMs:a})=>{if(!s||!e)return console.error("Invalid input: one or more inputs are missing"),null;try{const n=new(c())(Date.now()),r=new(c())(a),o=new(c())(t),i=new(c())(Number(e)).mul(o),l=new(c())(s),d=i.sub(l).mul(r),u=n.add(d);return{formattedDate:m(new Date(u.toNumber())),timestamp:u.toNumber()}}catch(e){return console.error("Error in calculation:",e),null}},p=e=>({blocks:{coretime:s=>s*e.coretime.blocksPerTimeslice,relay:s=>s*e.relay.blocksPerTimeslice},timeslices:{coretime:s=>s/e.coretime.blocksPerTimeslice,relay:s=>s/e.relay.blocksPerTimeslice}}),x=(e,s)=>({currentRegionEndTs:e.regionBegin,currentRegionStartTs:e.regionBegin-s}),g={coretimeInfo:null,currentRegionEnd:null,currentRegionStart:null,get:null,saleEndDate:null,saleStartDate:null},b=(0,n.createContext)(g),f=({api:e,children:s,isApiReady:t})=>{const r=(0,o.Q)(e,t),i=(0,n.useMemo)(()=>r?.constants?p(r.constants):null,[r?.constants]),l=(0,n.useMemo)(()=>r?r?.salesInfo.regionEnd-r?.config.regionLength:0,[r]),c=(0,n.useMemo)(()=>r?r.salesInfo.regionEnd-2*r?.config.regionLength:0,[r]),d=(0,n.useMemo)(()=>i&&r&&h(c,i.blocks.relay(r?.status?.lastTimeslice),r.constants.relay)?.formattedDate,[c,r,i]),u=(0,n.useMemo)(()=>i&&r&&h(l,i.blocks.relay(r?.status?.lastTimeslice),r.constants.relay)?.formattedDate,[l,r,i]),m=(0,n.useMemo)(()=>r&&l&&c&&i&&u&&d?{coretimeInfo:r??null,currentRegionEnd:l,currentRegionStart:c,get:i,saleEndDate:u,saleStartDate:d}:g,[r,l,c,i,u,d]);return(0,a.jsx)(b.Provider,{value:m,children:s})},j=()=>(0,n.useContext)(b);var v,y=t(18690),C=t(1445),w=t(79129),k=t(37140);function S(){return(0,k.Bd)("app-coretime")}function N(e,s,t){return e&&s&&t?[...e.filter(e=>!!s[e]?.workTaskInfo[0])].sort((e,a)=>{const n=s[e]?.workTaskInfo[0],r=s[a]?.workTaskInfo[0];return"DESC"===t?r.lastBlock-n.lastBlock:n.lastBlock-r.lastBlock}):e||[]}!function(e){e.BLOCKS="blocks",e.SEARCH="search",e.TYPE="type"}(v||(v={}));var A=t(25232);const F=[{text:"All",value:"All"},...Object.keys(i.qk).filter(e=>isNaN(Number(e))).map(e=>({text:(0,a.jsx)(C.vw,{color:u[i.qk[e]],label:e}),value:i.qk[e].toString()}))];function I({chainInfo:e,data:s,onFilter:t}){const[a,r]=(0,n.useState)(""),[o,i]=(0,n.useState)([]),l=(0,n.useCallback)((e,s)=>s.length>0?e.filter(e=>s.includes(e)):e,[]),c=(0,n.useCallback)(()=>{r(""),i([]),t(s)},[s,t]),d=(0,n.useCallback)(a=>{if(r(a),!a||"All"===a)return i([]),void t(s);const n=s.filter(s=>{const t=e[s]?.workTaskInfo;return t?.length>0&&t[0].type.toString()===a});i(n),t(l(s,n))},[e,s,t,l]);return{activeType:o,apply:l,onApply:d,reset:c,selectedType:a,typeOptions:F}}const E=function({chainInfo:e,data:s,onFilter:t}){const{t:r}=S(),[o,i]=(0,n.useState)({search:[],type:[]}),{apply:l,direction:c,onApply:d,reset:u}=function({chainInfo:e,data:s,onFilter:t}){const[a,r]=(0,n.useState)(""),o=(0,n.useCallback)((s,t)=>t?N(s,e,t):s,[e]),i=(0,n.useCallback)(()=>{const n={"":"DESC",ASC:"",DESC:"ASC"}[a];r(n),t(n?N(s,e,n):s)},[s,e,t,a]),l=(0,n.useCallback)(()=>{r(""),t(s||[])},[s,t]);return{apply:o,direction:a,onApply:i,reset:l}}({chainInfo:e,data:s,onFilter:e=>w(e,v.BLOCKS)}),{apply:m,onApply:h,reset:p,searchValue:x}=function({data:e,onFilter:s}){const[t,a]=(0,n.useState)(""),r=(0,A.DF)(),o=(0,n.useMemo)(()=>Object.fromEntries(r.filter(e=>e?.text&&e.paraId).map(e=>[n.isValidElement(e.text)?"":String(e.text),e.paraId])),[r]),i=(0,n.useCallback)((e,s)=>s.length>0?e.filter(e=>s.includes(e)):e,[]),l=(0,n.useCallback)(()=>{a(""),s(e)},[e,s]),c=(0,n.useCallback)(t=>{a(t);const n=t.trim().toLowerCase();if(!n)return void s(e);const r=new Set;for(const s of e)if(s.toString().toLowerCase().includes(n))r.add(s);else for(const[e,t]of Object.entries(o))if(e.toLowerCase().includes(n)&&t===s){r.add(s);break}const l=Array.from(r);s(i(e,l))},[e,o,s,i]);return{apply:i,onApply:c,reset:l,searchValue:t}}({data:s,onFilter:e=>w(e,v.SEARCH)}),{apply:g,onApply:b,reset:f,selectedType:j,typeOptions:y}=I({chainInfo:e,data:s,onFilter:e=>w(e,v.TYPE)}),w=(0,n.useCallback)((e,a)=>{let n=e;a!==v.SEARCH&&(n=m(n,o.search)),a!==v.TYPE&&(n=g(n,o.type)),a!==v.BLOCKS&&c&&(n=l(n,c)),a!==v.BLOCKS&&i(t=>({...t,[a]:e.length===s.length?[]:e})),t(n)},[s,t,o,c,l,g,m]),k=(0,n.useCallback)(()=>{p(),f(),u(),i({search:[],type:[]}),t(s)},[s,t,p,f,u]),F=x||j||c;return(0,a.jsxs)("div",{style:{alignItems:"center",display:"flex",flexDirection:"row",gap:"10px"},children:[(0,a.jsx)("div",{style:{minWidth:"250px"},children:(0,a.jsx)(C.pd,{"aria-label":r("Search by teyrchain id or name"),className:"full isSmall",label:r("Search"),onChange:h,placeholder:r("teyrchain id or name"),value:x})}),(0,a.jsx)(C.ms,{className:"isSmall",label:r("type"),onChange:b,options:y,placeholder:"select type",value:j}),(0,a.jsx)("div",{style:{height:"20px"},children:(0,a.jsx)(C.$n,{icon:c?"DESC"===c?"arrow-up":"arrow-down":"sort",label:r("blocks"),onClick:d})}),F&&(0,a.jsx)("div",{style:{height:"20px"},children:(0,a.jsx)(C.$n,{icon:"times",label:r("Reset filters"),onClick:k})})]})};var T=t(28138),D=t(1989),M=t(21327),B=t(848);const P=C.I4.td`
&& {
background-color: ${({$p:e})=>e?"#F9FAFB":void 0};
width: ${({$width:e})=>e};
}
height: 55px;
`,$=(0,C.I4)(C.WM)`
width: fit-content;
margin: 0;
display: inline-block;
vertical-align: middle;
&.mark {
margin: 0 0 0 1rem;
display: inline;
}
`,L=n.memo(function({chainRecord:e,highlight:s=!1,id:t,lastCommittedTimeslice:r,lease:o,regionBegin:l,regionEnd:d,relayName:m}){const{renewalStatus:p}=e,x=p===i.qe.Renewed,g=p===i.qe.Eligible,b=x?d:l,f=g&&(0,a.jsx)("a",{href:`https://app.regionx.tech/renew?network=${m}&paraId=${t}&core=${e?.workload?.core}`,rel:"noopener noreferrer",target:"_blank",children:"Renew on RegionX"}),v=x?e.renewalStatusMessage:g?f:"-",y=o?.until||b,w=!!y&&Object.values(i.qk)[e.type]!==i.qk.Reservation,{coretimeInfo:k,get:S}=j(),N=w&&S&&k&&h(y,S.blocks.relay(r),k?.constants?.relay),A=!!N&&new Date(N.timestamp).getTime()-Date.now()<6048e5,F=e.type===i.qk.Reservation;return(0,a.jsxs)(n.Fragment,{children:[(0,a.jsx)(P,{$p:s,$width:"150px",children:t}),(0,a.jsx)(P,{$p:s,$width:"150px",className:"media--800",children:(0,a.jsx)(C.JV,{id:new(c())(t)})}),(0,a.jsx)(P,{$p:s,children:e?.workload?.core}),(0,a.jsx)(P,{$p:s,children:(0,a.jsx)(C.vw,{color:u[e.type],label:Object.values(i.qk)[e.type]})}),(0,a.jsx)(P,{$p:s,className:"media--800",children:w&&e?.lastBlock&&m&&(0,a.jsx)("a",{href:`https://${m.split(" ")[0]}.subscan.io/block/${e?.lastBlock}`,rel:"noreferrer",target:"_blank",children:(0,M.Z)(e?.lastBlock)})}),(0,a.jsx)(P,{$p:s,className:"media--1000",style:{whiteSpace:"nowrap"},children:(0,a.jsxs)("span",{children:[N&&N?.formattedDate,!!A&&!F&&e?.renewalStatus!==i.qe.Renewed&&(0,a.jsx)($,{content:"Expires Soon"})]})}),(0,a.jsx)(P,{$p:s,className:"media--1200",children:v}),(0,a.jsx)(P,{$p:s,className:"media--1200",children:e?.renewal?(0,B.Q)(e.renewal?.price.toString()):""}),(0,a.jsx)(P,{$p:s,className:"media--800",children:(0,a.jsxs)("div",{style:{alignItems:"center",columnGap:"12px",display:"flex",flexDirection:"row",justifyContent:"left"},children:[(0,a.jsx)(C.JV,{id:new(c())(t),showLogo:!1,type:D.X.SUBSCAN}),(0,a.jsx)("div",{style:{marginBottom:"2px"},children:(0,a.jsx)(C.JV,{id:new(c())(t),showLogo:!1,type:D.X.HOME})})]})}),s&&(0,a.jsx)(P,{$p:s})]},`${t}`)}),V=n.memo(function({chain:e,lastCommittedTimeslice:s,regionBegin:t,regionEnd:n,relayName:r}){const[o,i]=(0,T.e)(!1),l=e.workTaskInfo,c=e.workTaskInfo[0],d=l.length>1,u=l.slice(1);if(!c)return(0,a.jsx)(a.Fragment,{});const m=(l,c,u=!1)=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(L,{chainRecord:l,highlight:u,id:e.id,lastCommittedTimeslice:s,lease:e.lease,regionBegin:t,regionEnd:n,relayName:r}),0===c&&(0,a.jsx)("td",{style:{paddingRight:"2rem",textAlign:"right",verticalAlign:"top"},children:!!d&&(0,a.jsx)(C.L3,{expanded:o,onClick:i})})]});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("tr",{className:"isExpanded isFirst "+(o?"":"isLast"),children:m(c,0)},e.id),o&&u?.map((s,t)=>(0,a.jsx)("tr",{children:m(s,t+1,!0)},`${e.id}${t}`))]})}),R=n.memo(function({coretimeInfo:e,relayName:s}){const{t}=S(),r=(0,n.useRef)([[t("teyrchains"),"start"],[t("name"),"start media--800"],[t("core number"),"start"],[t("type"),"start"],[t("last block"),"start media--800"],[t("end date (approx)"),"start media--1000"],[t("renewal"),"start media--1200"],[t("renewal price"),"start media--1200"],[t("links"),"start media--800"],[t("other cores"),"end"]]),[o,i]=(0,n.useState)([]),l=(0,n.useCallback)(e=>{i(e)},[]);return(0,n.useEffect)(()=>{e?.taskIds&&i(e?.taskIds)},[e?.taskIds]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(E,{chainInfo:e?.chainInfo,data:e?.taskIds,onFilter:l}),(0,a.jsx)(C.XI,{emptySpinner:!1,header:r.current,isSplit:!1,children:o?.map(t=>{const n=e.chainInfo[t];return n?(0,a.jsx)(V,{chain:n,lastCommittedTimeslice:e.status.lastCommittedTimeslice,regionBegin:e.salesInfo.regionBegin,regionEnd:e.salesInfo.regionEnd,relayName:s},n.id):null})})]})}),z=n.memo(function({config:e,relayName:s,status:t,teyrchainCount:r}){const{t:o}=S(),{coretimeInfo:i,currentRegionEnd:l,currentRegionStart:u,saleEndDate:m,saleStartDate:h}=j(),p=(0,n.useMemo)(()=>{if(s&&l)return Math.floor((l-d.timeslice.coretime[s])/e.regionLength)},[l,s,e]),x=(0,n.useMemo)(()=>l&&new(c())(e?.regionLength).sub(new(c())(l).sub(new(c())(t.lastTimeslice))),[t,e,l]);return(0,a.jsxs)(C.cp,{children:[(0,a.jsxs)("section",{children:[t&&(0,a.jsx)(C.dS,{label:o("sale number"),children:(0,a.jsx)("div",{children:p})}),(0,a.jsx)(C.dS,{label:o("timeslice"),children:t?.lastTimeslice}),(0,a.jsx)(C.dS,{label:o("teyrchains"),children:r&&r}),e&&t&&l&&m&&h&&x&&i?.constants&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(C.dS,{className:"media--800",label:o("timeslice progress"),progress:{hideGraph:!0,hideValue:!1,isBlurred:!1,total:new(c())(e?.regionLength),value:x,withTime:!1}}),(0,a.jsx)(C.dS,{label:o("cycle"),progress:{total:new(c())(e.regionLength).mul(new(c())(i?.constants.relay.blocksPerTimeslice)),value:x.mul(new(c())(i?.constants.relay.blocksPerTimeslice)),withTime:!0}})]})]}),(0,a.jsxs)("section",{className:"media--1200",children:[(0,a.jsx)(C.dS,{label:o("sale dates"),children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{style:{fontSize:"14px"},children:h}),(0,a.jsx)("div",{style:{fontSize:"14px"},children:m})]})}),(0,a.jsx)(C.dS,{label:o("sale ts"),children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{style:{fontSize:"14px"},children:u}),(0,a.jsx)("div",{style:{fontSize:"14px"},children:l})]})})]})]})}),H=n.memo(function({className:e,relayName:s}){const{coretimeInfo:t}=j();return(0,a.jsxs)("main",{className:e,children:[t&&(0,a.jsx)(z,{config:t?.config,region:t?.region,relayName:s,saleInfo:t?.salesInfo,status:t?.status,teyrchainCount:t.taskIds?.length||0}),!!t&&(0,a.jsx)(R,{coretimeInfo:t,relayName:s})]})});var q=t(26689);const O="Fixed Price",W="Price Discovery",U="Renewals",G=new(c())(1e4),Y=e=>(0,B.Q)(e,{forceUnit:B.Q.getDefaults().unit,withAll:!0,withUnit:!0}),X=(e,s)=>{if(!s||!e)return new(c())(0);const{endPrice:t,leadinLength:a,saleStart:n}=s,r=new(c())(e),o=new(c())(n),i=new(c())(a),l=r.sub(o);return(e=>{const s=G.div(new(c())(2));return e.lte(s)?G.mul(new(c())(100)).sub(e.mul(new(c())(180))):G.mul(new(c())(19)).sub(e.mul(new(c())(18)))})((l.lt(i)?l:i).mul(new(c())(1e4)).div(i)).mul(t).div(G)},Z=(e,s,t,a)=>{const n=e-s;return n<t?U:n<t+a?W:O},_=(e,s,t,a,n)=>({end:{blocks:{coretime:t.blocks.coretime(s),relay:t.blocks.relay(s)},date:a(s),ts:s},name:n??"",start:{blocks:{coretime:t.blocks.coretime(e),relay:t.blocks.relay(e)},date:a(e),ts:e}}),J=({config:e,constants:s,salesInfo:t},a,n,r=-1)=>{const o=p(s),i=o.timeslices.coretime(e.interludeLength),l=o.timeslices.coretime(e.leadinLength);let{currentRegionEndTs:c,currentRegionStartTs:u}=x(t,e.regionLength);const m=e=>h(e,o.blocks.relay(n),s.relay)?.formattedDate??null,g=((e,s,t)=>s&&e?Math.ceil((e-d.timeslice.coretime[s])/t.regionLength):-1)(c,a,e);let b;if(-1!==r){if("dicle"===a){const s=848;0===r?(u=d.timeslice.coretime[a],c=u+e.regionLength):1===r?(u=d.timeslice.coretime[a]+e.regionLength,c=u+s):(u=d.timeslice.coretime[a]+e.regionLength*(r-1)+s,c=u+e.regionLength)}else u=d.timeslice.coretime[a]+e.regionLength*r,c=u+e.regionLength;b={end:{blocks:{coretime:0,relay:o.blocks.relay(c)},date:m(c)??"",ts:c},start:{blocks:{coretime:0,relay:o.blocks.relay(u)},date:m(u)??"",ts:u}}}else b=_(u,c,o,m);let f=null;return c-u===e.regionLength&&(f=((e,s,t,a,n,r)=>{const o=e+t,i=o+a,l=i+(s-t-a),c=p(r),d=e=>h(e,c.blocks.relay(n),r.relay)?.formattedDate??null;return{config:{[O]:_(i,l,c,d,O),[W]:_(o,i,c,d,W),[U]:_(e,o,c,d,U)},currentPhaseName:Z(n,e,t,a)}})(u,e.regionLength,i,l,n,s)),{currentRegion:b,interlude:{blocks:e.interludeLength,ts:i},leadin:{blocks:e.leadinLength,ts:l},phaseConfig:f,regionForSale:{end:{blocks:{coretime:0,relay:b.end.blocks.relay+o.blocks.relay(e.regionLength)},date:h(b.end.ts+e.regionLength,o.blocks.relay(n),s.relay)?.formattedDate??null,ts:b.end.ts+e.regionLength},start:{blocks:{coretime:0,relay:b.end.blocks.relay},date:b.end.date,ts:b.end.ts}},saleNumber:g}};var K=t(85121);const Q=({children:e,style:s})=>{const{theme:t}=(0,K.D)(),n="dark"===t?"#333":"white";return(0,a.jsx)("div",{style:{backgroundColor:n,borderRadius:"4px",display:"flex",flexDirection:"column",justifyItems:"center",minWidth:"250px",padding:"24px",...s},children:e})},ee=({color:e,phaseName:s,salesInfo:t})=>{const{t:o}=S(),{apiCoretime:i}=(0,r.g)(),l=(0,w.Gc)(i?.derive.chain.bestNumberFinalized),c=(0,n.useMemo)(()=>l&&t&&X(l.toNumber(),t),[t,l]),d=(0,n.useMemo)(()=>c?Y(c):null,[c]),u=(0,C.I4)(Q)`
justify-self: flex-end;
@media (max-width: 1150px) {
width: 100%;
}
`;return(0,a.jsxs)(u,{children:[(0,a.jsx)("p",{style:{fontSize:"16px",fontWeight:"bold"},children:"Cores"}),s===U?(0,a.jsx)("h4",{children:o("Cores cannot be purchased now")}):(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{style:{fontSize:"14px",marginBottom:"0.15rem",opacity:"0.8"},children:o("current price")}),(0,a.jsx)("p",{style:{color:`${e}`,fontSize:"20px"},children:d})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{style:{fontSize:"14px",marginBottom:"0.15rem",opacity:"0.8"},children:o("available cores")}),(0,a.jsxs)("p",{style:{fontSize:"20px"},children:[" ",t.coresOffered-t.coresSold]})]})]})})]})},se=(0,C.I4)(Q)`
justify-self: center;
@media (min-width: 1150px) {
width: 100%;
}
`,te=({regionForSale:e})=>{const{t:s}=S();return(0,a.jsxs)(se,{children:[(0,a.jsx)("p",{style:{fontSize:"16px",fontWeight:"bold"},children:s("Region for sale")}),e&&(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{style:{fontSize:"14px",marginBottom:"0.15rem",opacity:"0.8"},children:"period"}),(0,a.jsxs)("p",{style:{fontSize:"20px"},children:[e.start.date," - ",e.end.date]})]}),(0,a.jsxs)("div",{style:{marginTop:"0.5rem"},children:[(0,a.jsx)("p",{style:{fontSize:"14px",marginBottom:"0.15rem",opacity:"0.8"},children:s("relay chain blocks")}),(0,a.jsxs)("p",{style:{fontSize:"20px"},children:[(0,M.Z)(e.start.blocks.relay)," - ",(0,M.Z)(e.end.blocks.relay)]})]})]})]})},ae=({color:e,coretimeInfo:{salesInfo:s,status:t},phaseName:r,saleParams:o})=>{const{t:i}=S(),l=(0,n.useMemo)(()=>o&&s.regionBegin&&((e,s,t,a,n)=>{if(!(e&&s&&t&&a&&n))return[];const r=e-s;return[{label:U,total:t,value:Math.min(r,t)},{label:W,total:a,value:Math.min(Math.max(r-t,0),a)},{label:O,total:n-s-t-a,value:Math.max(r-t-a,0)}]})(t.lastTimeslice,o.currentRegion.start.ts,o.interlude.ts,o.leadin.ts,s.regionBegin),[o,t.lastTimeslice,s.regionBegin]),c=(0,n.useMemo)(()=>s&&X(s.saleStart,s),[s]),d=(0,n.useMemo)(()=>c&&Y(c),[c]),u=(0,n.useMemo)(()=>s?.endPrice&&Y(s.endPrice),[s?.endPrice]);return(0,a.jsxs)(ne,{children:[(0,a.jsx)("p",{style:{fontSize:"16px",fontWeight:"bold"},children:i("Sale timeline")}),(0,a.jsx)(re,{children:(0,a.jsxs)(oe,{children:[r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(C.dS,{label:"current phase",children:r}),(0,a.jsx)(C.dS,{label:"current phase end",children:o?.phaseConfig?.config[r].end.date}),(0,a.jsx)(C.dS,{label:"last phase block",children:(0,M.Z)(o?.phaseConfig?.config[r].end.blocks.relay)})]}),(0,a.jsx)(C.dS,{label:"start price",children:d}),(0,a.jsx)(C.dS,{label:"fixed price",children:u})]})}),(0,a.jsx)(C.z2,{color:e,sections:l??[]})]})},ne=(0,C.I4)(Q)`
justify-self: flex-start;
@media (min-width: 769px) and (max-width: 1024px) {
width: 100%;
}
`,re=(0,C.I4)(C.cp)`
margin-top: 0;
`,oe=C.I4.div`
display: grid;
grid-template-columns: repeat(3, 1fr);
column-gap: 0.5rem;
row-gap: 1rem;
width: 100%;
/* Override CardSummary styling to align text left and remove padding */
article {
justify-content: flex-start;
padding: 0;
> .ui--Labelled {
text-align: left;
}
}
`,ie=(0,C.I4)(C.XI)`
border-collapse: collapse;
tr:last-child {
border-bottom: 1px solid #e6e6e6;
}
`,le=n.memo(function({phaseInfo:e}){const{t:s}=S(),t=(0,n.useRef)([[],[s("Dates"),"start media--800"],[s("Blocks (relay)"),"start"],[s("Timeslices"),"start"]]);return(0,a.jsx)("div",{style:{maxWidth:"500px"},children:(0,a.jsxs)(ie,{emptySpinner:!1,header:t.current,isSplit:!1,children:[(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{style:{width:"100px"},children:"Start"}),(0,a.jsx)("td",{children:e.start.date}),(0,a.jsx)("td",{children:(0,M.Z)(e.start.blocks.relay)}),(0,a.jsx)("td",{children:(0,M.Z)(e.start.ts)})]}),(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{style:{width:"100px"},children:"End"}),(0,a.jsx)("td",{children:e.end.date}),(0,a.jsx)("td",{children:(0,M.Z)(e.end.blocks.relay)}),(0,a.jsx)("td",{children:(0,M.Z)(e.end.ts)})]})]})})});function ce(e){const s=new Date(e+" UTC");return`${s.getFullYear()}-${s.getMonth()+1}-${s.getDate()}`}const de=({call:e="purchase",chainName:s,chosenSaleNumber:t,currentRegion:r,module:o="broker",urlTitle:i})=>{const l=(0,n.useMemo)(()=>((e,s,t,a="broker",n="purchase")=>`https://coretime-${t}.subscan.io/extrinsic?page=1&time_dimension=date&page_size=25&module=${a}&signed=all&call=${n}&date_start=${e}&date_end=${s}`)(ce(r.start.date),ce(r.end.date),s,o,e),[r,s,o,e]);return-1!==t&&r?(0,a.jsx)("a",{href:l,rel:"noopener noreferrer",target:"_blank",children:i}):null},ue=C.I4.div`
display: flex;
flex-direction: row;
justify-content: flex-start;
gap: 10rem;
margin-top: 2rem;
@media (max-width: 1000px) {
flex-direction: column;
}
`,me=C.I4.h3`
font-weight: bold;
margin-bottom: 1rem;
`,he=({alt:e,href:s,logo:t})=>(0,a.jsx)("a",{href:s,rel:"noopener noreferrer",target:"_blank",children:(0,a.jsx)("img",{alt:e,height:25,src:t})}),pe={lastic:{alt:"Lastic",href:e=>`https://www.lastic.xyz/${e}/bulkcore1`,logo:"https://www.lastic.xyz/_next/image?url=%2Fassets%2FImages%2FLogos%2Flastic-logo.png&w=384&q=100"},regionx:{alt:"RegionX",href:e=>`https://app.regionx.tech/?network=${e}`,logo:"https://app.regionx.tech/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Flogo.8f0fd171.png&w=3840&q=75"},subscan:{alt:"Subscan",href:e=>`https://coretime-${e}.subscan.io/coretime_dashboard`,logo:"https://www.subscan.io/_next/image?url=%2Fwebsite%2Flogo-light.png&w=256&q=75"}},xe={[U]:{description:"In this phase, core owners can renew existing cores at a fixed price to ensure continued operation in the next region. No new core purchases are permitted.",name:"Interlude/Renewals phase"},[W]:{description:"The period during which cores are available for both purchase and renewal. The price decreases linearly over time.",name:"Price Discovery phase"},[O]:{description:"The period during which cores are available for both purchase and renewal. The price remains fixed towards the end of the sales period.",name:"Fixed price phase"}},ge=({chosenSaleNumber:e,relayName:s,saleParams:t})=>{const{t:r}=S(),o=(0,n.useMemo)(()=>`https://coretime-${s}.subscan.io/coretime_dashboard`,[s]);return-1!==e&&t?(0,a.jsxs)(ue,{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(me,{children:"Sale phases"}),(0,a.jsxs)("div",{style:{display:"grid",gap:"1rem",gridTemplateRows:"1fr 1fr 1fr",minWidth:"200px"},children:[!t?.phaseConfig&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{children:r(`This sale is of unusual length of ${t.currentRegion.end.ts-t.currentRegion.start.ts} timeslices, hence the regular phases are not applicable.`)}),(0,a.jsx)("p",{children:r(`Sale start timeslice: ${t.currentRegion.start.ts}`)}),(0,a.jsx)("p",{children:r(`Sale end timeslice: ${t.currentRegion.end.ts}`)})]}),t?.phaseConfig&&Object.entries(xe).map(([e,{description:s,name:n}])=>(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{children:r(n)}),(0,a.jsx)("p",{style:{maxWidth:"600px",opacity:"0.8"},children:r(s)}),t?.phaseConfig&&(0,a.jsx)(le,{phaseInfo:t?.phaseConfig.config[e]})]},e))]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(me,{children:r("Region for sale ")}),(0,a.jsx)("p",{style:{maxWidth:"600px",opacity:"0.8"},children:r("Region is an asset of Coretime. It signifies the upcoming sales period within which a core can be secured by purchasing coretime. Acquiring coretime grants access to a core for the duration of that specific region.")}),t?.regionForSale&&(0,a.jsx)(le,{phaseInfo:t?.regionForSale}),(0,a.jsx)(me,{children:r("Subscan Links")}),(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(0,a.jsx)("a",{href:o,rel:"noopener noreferrer",target:"_blank",children:"Sale Purchase Graph"}),(0,a.jsx)(de,{chainName:s,chosenSaleNumber:e,currentRegion:t.currentRegion,urlTitle:"Sale Purchase Transactions"}),(0,a.jsx)(de,{call:"renew",chainName:s,chosenSaleNumber:e,currentRegion:t.currentRegion,urlTitle:"Sale Renewal Transactions"})]}),(0,a.jsx)(me,{children:r("DotLake Coretime Dashboard")}),(0,a.jsx)("a",{href:"https://data.parity.io/coretime",rel:"noopener noreferrer",target:"_blank",children:"Dot Lake"}),(0,a.jsx)(me,{children:r("Coretime providers")}),(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:Object.entries(pe).map(([e,{alt:t,href:n,logo:r}])=>(0,a.jsx)(he,{alt:t,href:n(s),logo:r},e))})]})]}):null},be=n.memo(function({config:e,saleInfo:s,saleNumber:t,status:n}){const{t:r}=S(),{currentRegionEndTs:o,currentRegionStartTs:i}=x(s,e.regionLength),{get:l,saleEndDate:d,saleStartDate:u}=j();return(0,a.jsxs)(C.cp,{children:[(0,a.jsxs)("section",{children:[n&&(0,a.jsx)(C.dS,{label:r("sale number"),children:(0,a.jsx)("div",{children:t>-1?t:"-"})}),(0,a.jsx)(C.dS,{label:r("sold/offered"),children:`${s?.coresSold} / ${s?.coresOffered}`}),(0,a.jsx)(C.dS,{label:r("sale end"),children:(0,a.jsx)("div",{children:d})}),(0,a.jsx)(C.dS,{label:r("last block"),children:(0,a.jsx)("div",{children:l&&(0,M.Z)(l.blocks.relay(o))})}),(0,a.jsx)(C.dS,{label:r("last timeslice"),children:(0,a.jsx)("div",{children:(0,M.Z)(o)})}),e&&n&&(0,a.jsx)(C.dS,{className:"media--800",label:r("sale progress"),progress:{isBlurred:!1,total:new(c())(e?.regionLength),value:new(c())(e?.regionLength-(o-n.lastTimeslice)),withTime:!1}})]}),(0,a.jsxs)("section",{className:"media--1200",children:[n&&(0,a.jsx)(C.dS,{label:r("current region dates"),children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{style:{fontSize:"14px"},children:u}),(0,a.jsx)("div",{style:{fontSize:"14px"},children:d})]})}),n&&(0,a.jsx)(C.dS,{label:r("region ts"),children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{style:{fontSize:"14px"},children:i}),(0,a.jsx)("div",{style:{fontSize:"14px"},children:o})]})})]})]})}),fe=C.I4.div`
display: grid;
align-items: stretch;
gap: 2rem;
grid-template-rows: auto auto;
margin-top: 4rem;
@media (max-width: 768px) {
grid-template-columns: 1fr;
}
@media (min-width: 769px) and (max-width: 1150px) {
grid-template-columns: 1fr 1fr;
> *:nth-child(3) {
grid-column: 1 / -1;
}
}
@media (min-width: 1150px) {
grid-template-columns: 1fr 1fr 3fr;
}
`,je=function({relayName:e}){const{coretimeInfo:s}=j(),{api:t,apiEndpoint:o,isApiReady:i}=(0,r.g)(),{t:l}=S(),c=s?.status?.lastTimeslice,[d,u]=(0,n.useState)(-1),[m,h]=(0,n.useState)(null),[p,x]=(0,n.useState)(null),g=o?.ui.color||q.q,b=(0,n.useMemo)(()=>[{text:l("Pick a sale number"),value:-1},...Array.from({length:m?.saleNumber??0},(e,s)=>({text:`sale #${s+1}`,value:s})).reverse()],[m?.saleNumber,l]);(0,n.useEffect)(()=>{s&&!m&&h(J(s,e,c??0))},[s,m,c,e]);const f=(0,n.useMemo)(()=>m?.phaseConfig?.currentPhaseName,[m]),v=(0,n.useCallback)(t=>{if(u(t),-1!==t){if(!s)return;x(J(s,e,c??0,t))}},[s,e,c]);return(0,a.jsxs)("div",{children:[s&&!!m?.saleNumber&&(0,a.jsx)(be,{api:i?t:null,config:s?.config,region:s?.region,saleInfo:s?.salesInfo,saleNumber:m?.saleNumber,status:s?.status}),(0,a.jsxs)(fe,{children:[f&&s&&(0,a.jsx)(ee,{color:g,phaseName:f,salesInfo:s?.salesInfo}),m?.regionForSale&&(0,a.jsx)(te,{regionForSale:m.regionForSale}),f&&s&&m&&(0,a.jsx)(ae,{color:g,coretimeInfo:s,phaseName:f,saleParams:m}),(0,a.jsxs)("div",{style:{borderRadius:"4px",gridColumn:"1 / -1",justifySelf:"center",padding:"24px",width:"100%"},children:[(0,a.jsx)("p",{style:{fontSize:"16px",fontWeight:"bold",marginBottom:"1rem"},children:l("Sale information")}),(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(0,a.jsx)("div",{style:{maxWidth:"300px"},children:(0,a.jsx)(C.ms,{className:"isSmall",label:l("Pick a sale number"),onChange:v,options:b,value:d})}),m&&p&&(0,a.jsx)(ge,{chosenSaleNumber:d,relayName:e,saleParams:p})]})]})]})]})},ve=n.memo(function({api:e,basePath:s,className:t,isApiReady:r}){const{t:o}=S(),i=(0,n.useRef)(function(e){return[{isRoot:!0,name:"overview",text:e("Overview")},{name:"sale",text:e("Sale")}]}(o)),l=(0,w.Gc)(r&&e?.rpc.system.chain)?.toString().toLowerCase();return(0,a.jsxs)("main",{className:t,children:[(0,a.jsx)(C.tU,{basePath:s,items:i.current}),l?(0,a.jsx)(y.BV,{children:(0,a.jsxs)(y.qh,{path:s,children:[(0,a.jsx)(y.qh,{element:(0,a.jsx)(H,{relayName:l}),index:!0}),(0,a.jsx)(y.qh,{element:(0,a.jsx)(je,{relayName:l}),path:"sale"})]})}):(0,a.jsx)("div",{children:(0,a.jsx)(C.y$,{})})]})}),ye=n.memo(function({basePath:e,className:s}){const{api:t,isApiReady:n}=(0,r.g)();return(0,a.jsx)(f,{api:t,isApiReady:n,children:(0,a.jsx)(ve,{api:t,basePath:e,className:s,isApiReady:n})})})},84596(e,s,t){t.d(s,{A:()=>m});var a=t(31085),n=t(14041),r=t(1445),o=t(61020),i=t(79129),l=t(11683),c=t(21327),d=t(51524),u=t(68300);const m=n.memo(function({className:e,withEra:s=!0,withSession:t=!0}){const{t:n}=(0,u.B)(),{api:m}=(0,o.g)(),h=(0,i.Gc)(m.derive.session?.progress),p=(0,i.Gc)(m.query.staking?.forceEra),x=n("era"),g=m.query.babe?n("epoch"):n("session"),b=h?.activeEraStart.unwrapOr(null);return(0,a.jsx)(a.Fragment,{children:m.derive.session&&(0,a.jsxs)(a.Fragment,{children:[t&&(m.query.babe?(0,a.jsx)(r.dS,{className:e,label:g,progress:{isBlurred:!h,total:h?.sessionLength||d.iz,value:h?.sessionProgress||d.u_,withTime:!0}}):(0,a.jsxs)(r.dS,{label:g,children:["#",h?(0,c.Z)(h.currentIndex):(0,a.jsx)("span",{className:"--tmp",children:"123"}),s&&b&&(0,a.jsx)("div",{className:"isSecondary",children:" "})]})),s&&(m.query.babe?(0,a.jsx)(r.dS,{className:e,label:x,progress:{isBlurred:!(h&&p),total:h&&p?p.isForceAlways?h.sessionLength:h.eraLength:d.iz,value:h&&p?p.isForceAlways?h.sessionProgress:h.eraProgress:d.u_,withTime:!0}}):(0,a.jsxs)(r.dS,{className:e,label:x,children:["#",h?(0,c.Z)(h.activeEra):(0,a.jsx)("span",{className:"--tmp",children:"123"}),b&&(0,a.jsxs)(l.A,{className:(h?"":"--tmp")+" isSecondary",value:b,children:[" ",n("elapsed")]})]}))]})})})},92362(e,s,t){t.d(s,{A:()=>ve});var a=t(31085),n=t(14041),r=t(1445),o=t(61020),i=t(79129),l=t(40941),c=t(55155),d=t(51524);const u=(0,c.F)("useBounties",function(){const{api:e}=(0,o.g)(),s=(0,i.Gc)(e.derive.bounties.bounties),t=(0,i.Gc)((e.query.bounties||e.query.treasury).bountyCount),a=(0,i.Gc)(e.query.childBounties?.childBountyCount),r=(0,l.x)(),c=(0,n.useMemo)(()=>function(e){const s=e.consts.bounties||e.consts.treasury,t=e.tx.bounties||e.tx.treasury;return{bountyCuratorDeposit:s.bountyCuratorDeposit||d.Yz,bountyDepositBase:s.bountyDepositBase,bountyUpdatePeriod:s.bountyUpdatePeriod,bountyValueMinimum:s.bountyValueMinimum,dataDepositPerByte:s.dataDepositPerByte,maximumReasonLength:s.maximumReasonLength.toNumber(),acceptCurator:t.acceptCurator,approveBounty:t.approveBounty,awardBounty:t.awardBounty,claimBounty:t.claimBounty,closeBounty:t.closeBounty,extendBountyExpiry:t.extendBountyExpiry,proposeBounty:t.proposeBounty,proposeCurator:t.proposeCurator,unassignCurator:t.unassignCurator}}(e),[e]);return(0,n.useMemo)(()=>({...c,bestNumber:r,bounties:s,bountyCount:t,childCount:a}),[r,s,t,a,c])});var m=t(28138),h=t(33168);const p=(0,c.F)("useBountyStatus",function(e){return(0,n.useCallback)(()=>(e=>{let s={beneficiary:void 0,bountyStatus:e.type,curator:void 0,unlockAt:void 0,updateDue:void 0};return e.isCuratorProposed&&(s={...s,bountyStatus:"CuratorProposed",curator:e.asCuratorProposed.curator}),e.isActive&&(s={...s,curator:e.asActive.curator,updateDue:e.asActive.updateDue}),e.isPendingPayout&&(s={...s,beneficiary:e.asPendingPayout.beneficiary,bountyStatus:"PendingPayout",curator:e.asPendingPayout.curator,unlockAt:e.asPendingPayout.unlockAt}),s})(e),[e])()});var x=t(97186);function g(e,s){return e.length>s?e.substring(0,s-1)+String.fromCharCode(8230):e}var b=t(37140);function f(){return(0,b.Bd)("app-bounties")}const j=n.memo(function({curatorId:e,description:s,index:t}){const{t:o}=f(),{awardBounty:i}=u(),{allAccounts:l}=(0,x.o)(),[c,d]=(0,m.e)(),[h,p]=(0,n.useState)(null);return(0,n.useMemo)(()=>l.includes(e.toString()),[l,e])?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.$n,{icon:"award",isDisabled:!1,label:o("Reward implementer"),onClick:d}),c&&(0,a.jsxs)(r.aF,{header:`${o("award bounty")} - "${g(s,30)}"`,onClose:d,size:"large",children:[(0,a.jsxs)(r.aF.Content,{children:[(0,a.jsx)(r.aF.Columns,{hint:o("The Curator account that will be used to send this transaction. Any applicable fees will be paid by this account."),children:(0,a.jsx)(r.B4,{defaultValue:e,isDisabled:!0,label:o("award with account"),type:"account",withLabel:!0})}),(0,a.jsx)(r.aF.Columns,{hint:o("Reward the bounty to an implementer's account. The implementer will be able to claim the funds after a delay period."),children:(0,a.jsx)(r.B4,{label:o("implementer account"),onChange:p,withLabel:!0})})]}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.jX,{accountId:e,icon:"check",label:o("Approve"),onStart:d,params:[t,h],tx:i})})]})]}):null});var v=t(24067);const y=(0,c.F)("useUserRole",function(e){const{allAccounts:s,hasAccounts:t}=(0,x.o)(),{isMember:a}=(0,v.r)("council");return(0,n.useMemo)(()=>{const n=!!e&&s.includes(e.toString()),r=[];return n&&r.push("Curator"),a&&r.push("Member"),t&&r.push("User"),{isCurator:n,roles:r}},[s,e,t,a])}),C=n.memo(function({curatorId:e,description:s,fee:t,index:o}){const{t:i}=f(),{acceptCurator:l}=u(),{isCurator:c}=y(e),{bountyCuratorDeposit:h}=u(),[p,x]=(0,m.e)(),b=(0,n.useMemo)(()=>{return e=h,t.mul(e).div(d.i5);var e},[t,h]);return c?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.$n,{icon:"check",isDisabled:!1,label:i("Accept"),onClick:x}),p&&(0,a.jsxs)(r.aF,{header:`${i("accept curator role")} - "${g(s,30)}"`,onClose:x,size:"large",children:[(0,a.jsxs)(r.aF.Content,{children:[(0,a.jsx)(r.aF.Columns,{hint:i("Only the account proposed as curator by the council can create the assign curator transaction"),children:(0,a.jsx)(r.B4,{isDisabled:!0,label:i("curator account"),type:"account",value:e.toString(),withLabel:!0})}),(0,a.jsx)(r.aF.Columns,{hint:i("This amount will be sent to your account after bounty is rewarded and you claim curator's fee."),children:(0,a.jsx)(r.xg,{defaultValue:t.toString(),isDisabled:!0,label:i("curator's fee")})}),(0,a.jsx)(r.aF.Columns,{hint:i("This amount will be reserved from your account and returned after bounty claim is confirmed or if you give up, unless you are slashed earlier."),children:(0,a.jsx)(r.xg,{defaultValue:b.toString(),isDisabled:!0,label:i("curator's deposit")})})]}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.jX,{accountId:e,icon:"check",label:i("Accept Curator Role"),onStart:x,params:[o],tx:l})})]})]}):null}),w=n.memo(function({beneficiaryId:e,index:s,payoutDue:t}){const{t:o}=f(),{claimBounty:i}=u(),{allAccounts:l}=(0,x.o)();return(0,n.useMemo)(()=>function(e,s,t){return t.ltn(0)&&e.includes(s.toString())}(l,e,t),[l,e,t])?(0,a.jsx)(r.jX,{accountId:e,icon:"plus",label:o("Claim"),params:[s],tx:i}):null});var k=t(69312),S=t(8525),N=t(95927),A=t.n(N);const F=["approveBounty","closeBounty"],I=n.memo(function({description:e,index:s,proposals:t}){const{t:i}=f(),{api:l}=(0,o.g)(),{isMember:c,members:d}=(0,v.r)("council"),h=(0,S.L)("council"),{approveBounty:p,closeBounty:x}=u(),[b,j]=(0,m.e)(),[y,C]=(0,n.useState)(null),[w,N]=(0,n.useState)();(0,n.useEffect)(()=>{d&&N(new(A())(Math.ceil(d.length*(0,k.nm)(l))))},[l,d]);const I=(0,n.useRef)(p(s)),E=(0,n.useRef)(x(s)),T=(0,n.useMemo)(()=>0!==t?.filter(({proposal:e})=>e&&F.includes(e.method)).length,[t]);return c&&!T&&h?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.$n,{icon:"step-forward",isDisabled:!1,label:i("Initiate voting"),onClick:j}),b&&(0,a.jsxs)(r.aF,{header:`${i("Initiate voting")} - "${g(e,30)}"`,onClose:j,size:"large",children:[(0,a.jsx)(r.aF.Content,{children:(0,a.jsx)(r.aF.Columns,{hint:i('The council member that will create a motion, submission equates to an "aye" vote for chosen option.'),children:(0,a.jsx)(r.B4,{filter:d,label:i("vote with account"),onChange:C,type:"account",withLabel:!0})})}),(0,a.jsxs)(r.aF.Actions,{children:[(0,a.jsx)(r.jX,{accountId:y,icon:"check",isDisabled:!1,label:i("Approve"),onStart:j,params:[w,I.current,I.current.length],tx:l.tx[h].propose}),(0,a.jsx)(r.jX,{accountId:y,icon:"ban",isDisabled:!1,label:i("Reject"),onStart:j,params:[w,E.current,E.current.length],tx:l.tx[h].propose})]})]})]}):null}),E=["proposeCurator"],T=n.memo(function({description:e,index:s,proposals:t,value:i}){const{t:l}=f(),{api:c}=(0,o.g)(),{isMember:d,members:h}=(0,v.r)("council"),p=(0,S.L)("council"),{proposeCurator:x}=u(),[b,j]=(0,m.e)(),[y,C]=(0,n.useState)(null),[w,N]=(0,n.useState)(null),[F,I]=(0,n.useState)(),[T,D]=(0,n.useState)(),[M,B]=(0,n.useState)(!1);(0,n.useEffect)(()=>{h&&I(new(A())(Math.ceil(h.length*(0,k.nm)(c))))},[c,h]);const P=(0,n.useMemo)(()=>w&&x(s,w,T),[w,T,s,x]),$=(0,n.useMemo)(()=>0!==t?.filter(({proposal:e})=>e&&E.includes(e.method)).length,[t]);return(0,n.useEffect)(()=>{B(!!T&&!!i?.gt(T))},[i,T]),d&&!$&&p?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.$n,{icon:"step-forward",isDisabled:!1,label:l("Propose curator"),onClick:j}),b&&(0,a.jsxs)(r.aF,{header:`${l("Propose curator")} - "${g(e,30)}"`,onClose:j,size:"large",testId:"propose-curator-modal",children:[(0,a.jsxs)(r.aF.Content,{children:[(0,a.jsx)(r.aF.Columns,{hint:l("The council member that will create the motion."),children:(0,a.jsx)(r.B4,{filter:h,label:l("proposing account"),onChange:C,type:"account",withLabel:!0})}),(0,a.jsx)(r.aF.Columns,{hint:l("Choose a curator whose background and expertise is such that they are capable of determining when the task is complete."),children:(0,a.jsx)(r.B4,{label:l("select curator"),onChange:N,withLabel:!0})}),(0,a.jsxs)(r.aF.Columns,{hint:l("Part of the bounty value that will go to the Curator as a reward for their work"),children:[(0,a.jsx)(r.xg,{isError:!M,isZeroable:!0,label:l("curator's fee"),onChange:D,value:T}),!M&&(0,a.jsx)(r.o_,{content:l("Curator's fee can't be higher than bounty value.")})]})]}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.jX,{accountId:y,icon:"check",isDisabled:!M,label:l("Propose curator"),onStart:j,params:[F,P,P?.length],tx:c.tx[p].propose})})]})]}):null});function D({bestNumber:e,description:s,fee:t,index:r,proposals:o,status:i,value:l}){const{beneficiary:c,curator:d,unlockAt:u}=p(i),m=(0,n.useMemo)(()=>u?.sub(e),[e,u]);return(0,a.jsxs)(a.Fragment,{children:[i.isProposed&&(0,a.jsx)(I,{description:s,index:r,proposals:o}),i.isFunded&&(0,a.jsx)(T,{description:s,index:r,proposals:o,value:l}),i.isCuratorProposed&&d&&t&&(0,a.jsx)(C,{curatorId:d,description:s,fee:t,index:r}),i.isPendingPayout&&c&&m&&(0,a.jsx)(w,{beneficiaryId:c,index:r,payoutDue:m}),i.isActive&&d&&(0,a.jsx)(j,{curatorId:d,description:s,index:r})]})}const M=n.memo(function({curatorId:e,description:s,index:t,toggleOpen:n}){const{t:o}=f(),{unassignCurator:i}=u();return(0,a.jsxs)(r.aF,{header:`${o("reject curator")} - "${g(s,30)}"`,onClose:n,size:"large",children:[(0,a.jsx)(r.aF.Content,{children:(0,a.jsx)(r.aF.Columns,{hint:o("Only the account proposed as curator by the council can create the unassign curator transaction "),children:(0,a.jsx)(r.B4,{isDisabled:!0,label:o("curator account"),type:"account",value:e.toString(),withLabel:!0})})}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.jX,{accountId:e,icon:"times",label:o("Reject"),onStart:n,params:[t],tx:i})})]})}),B=n.memo(function({description:e,index:s,toggleOpen:t}){const{t:i}=f(),{api:l}=(0,o.g)(),{members:c}=(0,v.r)("council"),d=(0,S.L)("council"),{closeBounty:m}=u(),[h,p]=(0,n.useState)(null),[x,b]=(0,n.useState)();(0,n.useEffect)(()=>{c&&b(new(A())(Math.ceil(c.length*(0,k.nm)(l))))},[l,c]);const j=(0,n.useRef)(m(s));return d?(0,a.jsxs)(r.aF,{header:`${i("close bounty")} - "${g(e,30)}"`,onClose:t,size:"large",children:[(0,a.jsx)(r.aF.Content,{children:(0,a.jsx)(r.aF.Columns,{hint:i('The council member that will create the close bounty proposal, submission equates to an "aye" vote.'),children:(0,a.jsx)(r.B4,{filter:c,label:i("propose with account"),onChange:p,type:"account",withLabel:!0})})}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.jX,{accountId:h,icon:"ban",isDisabled:!1,label:i("Close Bounty"),onStart:t,params:[x,j.current,j.current.length],tx:l.tx[d].propose})})]}):null});var P=t(66707);const $=n.memo(function({curatorId:e,description:s,index:t,toggleOpen:o}){const{t:i}=f(),{bountyUpdatePeriod:l,extendBountyExpiry:c}=u(),[d,m]=(0,n.useState)(""),[h,p]=(0,P.e)(l),x=(0,n.useCallback)(e=>{m(e)},[]),b=(0,n.useMemo)(()=>l&&function(e,s){return new Date(Date.now()+e.muln(s).toNumber())}(l,h),[l,h]);return(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(r.aF,{header:`${i("extend expiry")} - "${g(s,30)}"`,onClose:o,size:"large",children:[(0,a.jsxs)(r.aF.Content,{children:[(0,a.jsx)(r.aF.Columns,{hint:i("Only curator can extend the bounty time."),children:(0,a.jsx)(r.B4,{isDisabled:!0,label:i("curator account"),type:"account",value:e.toString(),withLabel:!0})}),b&&(0,a.jsx)(r.aF.Columns,{hint:i(`Bounty expiry time will be set to ${p} from now.`),children:(0,a.jsx)(r.pd,{isDisabled:!0,label:i("new expiry date and time"),value:`${b.toLocaleDateString()} ${b.toLocaleTimeString()}`})}),(0,a.jsx)(r.aF.Columns,{hint:i("The note that will be added to the transaction. It won't be stored on chain"),children:(0,a.jsx)(r.pd,{autoFocus:!0,defaultValue:"",label:i("bounty remark"),onChange:x,value:d})})]}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.jX,{accountId:e,icon:"check",label:i("Accept"),onStart:o,params:[t,d],tx:c})})]})})}),L=n.memo(function({curatorId:e,description:s,index:t,toggleOpen:n}){const{t:o}=f(),{unassignCurator:i}=u();return(0,a.jsxs)(r.aF,{header:`${o("give up curator's role")} - "${g(s,30)}"`,onClose:n,size:"large",children:[(0,a.jsx)(r.aF.Content,{children:(0,a.jsx)(r.aF.Columns,{hint:o("You are giving up your curator role, the bounty will return to the Funded state. You will get your deposit back."),children:(0,a.jsx)(r.B4,{isDisabled:!0,label:o("curator account"),type:"account",value:e.toString(),withLabel:!0})})}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.jX,{accountId:e,icon:"check",label:o("Give up"),onStart:n,params:[t],tx:i})})]})}),V=n.memo(function({action:e,curatorId:s,description:t,index:i,toggleOpen:l}){const{t:c}=f(),{api:d}=(0,o.g)(),{members:m}=(0,v.r)("council"),h=(0,S.L)("council"),{unassignCurator:p}=u(),[b,j]=(0,n.useState)(null),[y,C]=(0,n.useState)(),{allAccounts:w}=(0,x.o)();(0,n.useEffect)(()=>{m&&C(new(A())(Math.ceil(m.length*(0,k.nm)(d))))},[d,m]);const N=(0,n.useMemo)(()=>p(i),[i,p]),F=(0,n.useMemo)(()=>({SlashCuratorAction:{filter:w,header:c("This action will Slash the Curator."),params:[i],proposingAccountTip:c("The account that will create the transaction."),tip:c("Curator's deposit will be slashed and curator will be unassigned. Bounty will return to the Funded state."),title:c("Slash curator"),tx:p},SlashCuratorMotion:{filter:m,header:c("This action will create a Council motion to slash the Curator."),params:[y,N,N?.length],proposingAccountTip:c('The council member that will create the motion, submission equates to an "aye" vote.'),tip:c("If the motion is approved, Curator's deposit will be slashed and Curator will be unassigned. Bounty will return to the Funded state."),title:c("Slash curator"),tx:h&&d.tx[h].propose},UnassignCurator:{filter:m,header:c("This action will create a Council motion to unassign the Curator."),params:[y,N,N?.length],proposingAccountTip:c('The council member that will create the motion, submission equates to an "aye" vote.'),tip:c("If the motion is approved, the current Curator will be unassigned and the Bounty will return to the Funded state."),title:c("Unassign curator"),tx:h&&d.tx[h].propose}}),[c,i,p,d,w,h,m,y,N]),{filter:I,params:E,proposingAccountTip:T,tip:D,title:M,tx:B}=F[e];return B?(0,a.jsxs)(r.aF,{header:`${M} - "${g(t,30)}"`,onClose:l,size:"large",children:[(0,a.jsxs)(r.aF.Content,{children:[(0,a.jsx)(r.aF.Columns,{hint:T,children:(0,a.jsx)(r.B4,{filter:I,label:c("proposing account"),onChange:j,type:"account",withLabel:!0})}),(0,a.jsx)(r.aF.Columns,{hint:D,children:(0,a.jsx)(r.B4,{defaultValue:s,isDisabled:!0,label:c("current curator"),withLabel:!0})})]}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.jX,{accountId:b,icon:"check",label:"Approve",onStart:l,params:E,tx:B})})]}):null}),R=n.memo(function({bestNumber:e,className:s,description:t,index:o,proposals:i,status:l}){const[c,u]=(0,m.e)(),[h,x]=(0,m.e)(),[g,b]=(0,m.e)(),[j,C]=(0,m.e)(),[w,k]=(0,m.e)(),[S,N]=(0,n.useState)(),{t:A}=f(),{isMember:F}=(0,v.r)("council"),{curator:I,updateDue:E}=p(l),{isCurator:T,roles:D}=y(I),P=function(e,s,t){const a=[];return s.isCuratorProposed&&e.includes("Member")&&a.push("UnassignCurator"),s.isActive&&(e.includes("Member")&&a.push("SlashCuratorMotion"),e.includes("User")&&t&&t.lt(d.Yz)&&a.push("SlashCuratorAction")),s.isPendingPayout&&e.includes("Member")&&a.push("SlashCuratorMotion"),a}(D,l,(0,n.useMemo)(()=>E?.sub(e),[e,E])),R=(0,n.useRef)({SlashCuratorAction:A("Slash curator"),SlashCuratorMotion:A("Slash curator (Council)"),UnassignCurator:A("Unassign curator")}),z=(0,n.useMemo)(()=>i?.find(({proposal:e})=>e&&"closeBounty"===e.method),[i]),H=(0,n.useMemo)(()=>i?.find(({proposal:e})=>e&&"unassignCurator"===e.method),[i]),q=(l.isFunded||l.isActive||l.isCuratorProposed)&&F&&!z,O=l.isCuratorProposed&&T,W=l.isActive&&T,U=l.isActive&&T,G=(l.isCuratorProposed||l.isActive||l.isPendingPayout)&&!H&&0!==P.length,Y=!(q||O||U||G||W),X=(0,n.useCallback)(e=>()=>{N(e),b()},[b]);return Y?null:(0,a.jsxs)("div",{className:s,children:[c&&(0,a.jsx)(B,{description:t,index:o,toggleOpen:u}),h&&I&&(0,a.jsx)(M,{curatorId:I,description:t,index:o,toggleOpen:x}),j&&I&&(0,a.jsx)($,{curatorId:I,description:t,index:o,toggleOpen:C}),w&&I&&(0,a.jsx)(L,{curatorId:I,description:t,index:o,toggleOpen:k}),g&&I&&S&&(0,a.jsx)(V,{action:S,curatorId:I,description:t,index:o,toggleOpen:b}),(0,a.jsx)(r.zD,{value:(0,a.jsxs)(r.W1,{className:"settings-menu",children:[q&&(0,a.jsx)(r.W1.Item,{label:A("Close"),onClick:u},"closeBounty"),O&&(0,a.jsx)(r.W1.Item,{label:A("Reject curator"),onClick:x},"rejectCurator"),U&&(0,a.jsx)(r.W1.Item,{label:A("Extend expiry"),onClick:C},"extendExpiry"),W&&(0,a.jsx)(r.W1.Item,{label:A("Give up"),onClick:k},"giveUpCurator"),G&&P.map(e=>(0,a.jsx)(r.W1.Item,{label:R.current[e],onClick:X(e)},e))]})})]})}),z=r.I4.div`
margin-top: 0.28rem;
font-size: var(--font-size-tiny);
line-height: 0.85rem;
color: var(--color-label);
`,H=n.memo(function({className:e="",dataTestId:s="",description:t}){return(0,a.jsx)(z,{className:e,"data-testid":s,children:t})}),q={Active:["closeBounty","unassignCurator"],Approved:[],CuratorProposed:["closeBounty","unassignCurator"],Funded:["proposeCurator","closeBounty"],PendingPayout:["unassignCurator"],Proposed:["approveBounty","closeBounty"]};function O(e,s){return function(e,s){return e.find(({proposal:e})=>e&&e.method===s)}(e,function(e,s){const t=e.map(({proposal:e})=>e?.method);return function(e){return q[e.type]}(s).find(e=>t.includes(e))}(e,s))??null}const W=r.I4.div`
margin-left: 0.2rem;
`,U=n.memo(function({className:e,proposal:s,status:t}){const o=function(e,s){return e.proposal&&"unassignCurator"!==e.proposal.method?e.proposal.method:s.isCuratorProposed?"unassignCurator":"slashCurator"}(s,t),{t:i}=f(),l=(0,n.useRef)({approveBounty:i("Bounty approval under voting"),closeBounty:i("Bounty rejection under voting"),proposeCurator:i("Curator proposal under voting"),slashCurator:i("Curator slash under voting"),unassignCurator:i("Unassign curator under voting")});return(0,a.jsx)(W,{className:e,"data-testid":"voting-description",children:o&&l.current[o]&&(0,a.jsx)(r.On,{help:l.current[o]})})}),G=r.I4.a`
line-height: 0.85rem;
font-size: var(--font-size-tiny);
text-decoration: underline;
`,Y=n.memo(function({className:e}){const{t:s}=f();return(0,a.jsx)(G,{className:e,href:"#/council/motions",children:s("Voting")})}),X=r.I4.div`
.voting-summary-text {
font-size: var(--font-size-small);
line-height: 1.5rem;
color: var(--color-label);
span {
min-width: 0.5rem;
margin-right: 0.5rem;
}
}
.link-info {
display: flex;
justify-content: space-between;
align-items: center;
line-height: 1.5rem;
}
`,Z=n.memo(function({className:e,proposal:s,status:t}){const{members:r}=(0,v.r)("council"),{t:o}=f(),i=(0,n.useMemo)(()=>s?.votes?.ayes?.length,[s]),l=(0,n.useMemo)(()=>s?.votes?.nays?.length,[s]),c=(0,n.useMemo)(()=>s?.votes?.threshold.toNumber(),[s]),d=(0,n.useMemo)(()=>r?.length&&c?r.length-c+1:0,[r,c]);return(0,a.jsx)(a.Fragment,{children:s&&(0,a.jsxs)(X,{className:e,"data-testid":"voting-summary",children:[(0,a.jsxs)("div",{className:"voting-summary-text",children:[(0,a.jsx)("span",{children:o("Aye")})," ",(0,a.jsxs)("b",{children:[i,"/",c]})]}),(0,a.jsxs)("div",{className:"voting-summary-text",children:[(0,a.jsx)("span",{children:o("Nay")})," ",(0,a.jsxs)("b",{children:[l,"/",d]})]}),(0,a.jsxs)("div",{className:"link-info",children:[(0,a.jsx)(Y,{}),(0,a.jsx)(U,{proposal:s,status:t})]})]})})}),_=n.memo(function({beneficiary:e,proposals:s,status:t}){const{t:o}=f(),i=(0,n.useMemo)(()=>s&&O(s,t),[s,t]);return(0,a.jsxs)(a.Fragment,{children:[i&&(0,a.jsx)(Z,{proposal:i,status:t}),e&&(0,a.jsxs)("div",{children:[(0,a.jsx)(r.y1,{value:e}),(0,a.jsx)(H,{description:o("Beneficiary")})]})]})}),J=r.I4.div`
display: flex;
align-items: center;
font-size: var(--font-size-small);
line-height: 1.5rem;
.info-icon {
margin-right: 0.2rem;
svg {
color: var(--color-bounty-info);
}
}
.description {
font-weight: var(--font-weight-normal);
var(font-size: var(--font-size-tiny);)
line-height: 0.864rem;
color: var(--color-label);
word-wrap: break-word;
}
`,K=n.memo(function({className:e="",description:s,type:t="info"}){return(0,a.jsxs)(J,{className:e,children:["warning"===t&&(0,a.jsx)("div",{className:"info-icon",children:(0,a.jsx)(r.In,{icon:"exclamation-triangle"})}),(0,a.jsx)("div",{className:"description",children:s})]})}),Q=new(A())("10000"),ee=n.memo(function({bestNumber:e,blocksUntilUpdate:s,status:t}){const{t:r}=f(),{unlockAt:o}=p(t),{bountyUpdatePeriod:i}=u(),l=(0,n.useMemo)(()=>o?.sub(e),[e,o]),c=i?.muln(10).div(d.cM),m=c??Q;return(0,a.jsxs)("div",{children:[s?.lte(d.Yz)&&(0,a.jsx)(K,{description:r("Update overdue"),type:"warning"}),s?.lt(m)&&s?.gt(d.Yz)&&(0,a.jsx)(K,{description:r("Close deadline"),type:"warning"}),t.isApproved&&(0,a.jsx)(K,{description:r("Waiting for Bounty Funding"),type:"info"}),t.isCuratorProposed&&(0,a.jsx)(K,{description:r("Waiting for Curator's acceptance"),type:"info"}),l?.lt(d.Yz)&&(0,a.jsx)(K,{description:r("Waiting for implementer to claim"),type:"info"})]})}),se=r.I4.div`
display: flex;
align-items: center;
`,te=n.memo(function({bountyStatus:e,className:s=""}){return(0,a.jsx)(se,{className:s,"data-testid":"bountyStatus",children:(t=e,t.replace(/([a-z])([A-Z])/g,"$1 $2"))});var t}),ae=n.memo(function({curator:e,isFromProposal:s}){const{t}=f();return(0,a.jsxs)("div",{children:[(0,a.jsx)(r.y1,{value:e.toString()}),s&&(0,a.jsx)(H,{description:t("Proposed Curator")})]})});var ne=t(69832),re=t(21327);const oe=n.memo(function({dueBlocks:e,endBlock:s,label:t}){return(0,a.jsx)(a.Fragment,{children:e.gtn(0)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(ne.A,{value:e,children:[" (",t,")"]}),"#",(0,re.Z)(s)]})})}),ie={ayes:"check",nays:"times"},le=r.I4.div`
width: 50%;
.vote-numbers {
display: flex;
align-items: center;
margin-bottom: 0.85rem;
}
.vote-numbers-icon svg {
max-width: 10px;
color: var(--color-label);
}
.vote-numbers-label {
margin-left: 0.75rem;
font-weight: var(--font-weight-bold);
font-size: var(--font-size-tiny);
line-height: 0.85rem;
text-transform: uppercase;
color: var(--color-label);
}
`,ce=n.memo(function({className:e,option:s,proposals:t,status:o}){const{t:i}=f(),l=(0,n.useMemo)(()=>O(t,o),[t,o]),c=(0,n.useMemo)(()=>"ayes"===s?l?.votes?.ayes:l?.votes?.nays,[l,s]),d=(0,n.useMemo)(()=>c?.map(e=>(0,a.jsx)("div",{className:"voter","data-testid":`voters_${s}_${e.toString()}`,children:(0,a.jsx)(r.y1,{value:e})},e.toString())),[s,c]);return(0,a.jsx)(a.Fragment,{children:l&&(0,a.jsxs)(le,{className:e,children:[(0,a.jsxs)("div",{className:"vote-numbers",children:[(0,a.jsx)("span",{className:"vote-numbers-icon",children:(0,a.jsx)(r.In,{icon:ie[s]})}),(0,a.jsxs)("span",{className:"vote-numbers-label",children:["ayes"===s&&i("Aye: {{count}}",{replace:{count:c?c.length:0}}),"nays"===s&&i("Nay: {{count}}",{replace:{count:c?c.length:0}})]})]}),d]})})}),de=r.I4.tr`
.description-column {
max-width: 200px;
div {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
& .links {
display: inline-flex;
}
& .inline-balance {
width: 50%;
font-size: var(--font-size-base);
line-height: normal;
}
.column {
align-items: center;
display: flex;
padding: 0 0 0.5rem;
h5 {
text-align: right;
padding: 0 1.7rem 0 0;
width: 50%;
}
}
& .td-info-action-row {
padding-right: 0;
}
.td-row {
display: flex;
justify-content: space-between;
align-items: center;
& :only-child {
margin-left: auto;
}
}
.bounty-action-row {
display: flex;
justify-content: flex-end;
align-items: center;
& > * + * {
margin-left: 0.6rem;
}
}
.block-to-time {
font-size: var(--font-size-tiny);
line-height: 1.5rem;
color: var(--color-label);
}
& .votes-table {
display: flex;
justify-content: space-between;
}
`,ue=n.memo(function({bestNumber:e,bounty:s,className:t="",description:o,index:i,proposals:l}){const{t:c}=f(),[d,u]=(0,m.e)(!1),{bond:x,curatorDeposit:g,fee:b,proposer:j,status:v,value:y}=s,{beneficiary:C,bountyStatus:w,curator:k,unlockAt:S,updateDue:N}=p(v),A=(0,n.useMemo)(()=>N?.sub(e),[e,N]),F=(0,n.useMemo)(()=>S?.sub(e),[e,S]),I=(0,n.useMemo)(()=>{if(k)return{curator:k,isFromProposal:!1};const e=l&&O(l,v);return"proposeCurator"===e?.proposal?.method?{curator:e.proposal.args[1],isFromProposal:!0}:null},[k,l,v]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(de,{className:`${t} isExpanded isFirst ${d?"":"isLast"}`,children:[(0,a.jsx)(r.XI.Column.Id,{value:i}),(0,a.jsx)("td",{className:"description-column","data-testid":"description",children:(0,a.jsx)("div",{title:o,children:o})}),(0,a.jsx)("td",{children:(0,a.jsx)(te,{bountyStatus:w})}),(0,a.jsx)(r.XI.Column.Balance,{value:y}),(0,a.jsx)("td",{children:I&&(0,a.jsx)(ae,{curator:I.curator,isFromProposal:I.isFromProposal})}),(0,a.jsxs)("td",{children:[F&&S&&(0,a.jsx)(oe,{dueBlocks:F,endBlock:S,label:c("payout")}),A&&N&&(0,a.jsx)(oe,{dueBlocks:A,endBlock:N,label:c("update")}),(0,a.jsx)(ee,{bestNumber:e,blocksUntilUpdate:A,status:v}),(0,a.jsx)(D,{bestNumber:e,description:o,fee:b,index:i,proposals:l,status:v,value:y})]}),(0,a.jsx)("td",{children:(0,a.jsx)(_,{beneficiary:C,proposals:l,status:v})}),(0,a.jsx)("td",{className:"actions",children:(0,a.jsxs)("div",{children:[(0,a.jsx)(R,{bestNumber:e,description:o,index:i,proposals:l,status:v}),(0,a.jsx)(r.L3,{expanded:d,onClick:u})]})})]}),(0,a.jsxs)(de,{className:`${t} ${d?"isExpanded isLast":"isCollapsed"}`,children:[(0,a.jsx)("td",{}),(0,a.jsx)("td",{className:"columar",colSpan:3,children:(0,a.jsxs)(r.Yt,{children:[(0,a.jsx)(r.Yt.Column,{children:(0,a.jsx)(r.e9,{data:i,type:"bounty",withTitle:!0})}),(0,a.jsxs)(r.Yt.Column,{children:[(0,a.jsxs)("div",{className:"column",children:[(0,a.jsx)("h5",{children:c("Proposer")}),(0,a.jsx)(r.y1,{value:j})]}),(0,a.jsxs)("div",{className:"column",children:[(0,a.jsx)("h5",{children:c("Bond")}),(0,a.jsx)("div",{className:"inline-balance",children:(0,a.jsx)(h.A,{value:x})})]}),k&&(0,a.jsxs)("div",{className:"column",children:[(0,a.jsx)("h5",{children:c("Curator's fee")}),(0,a.jsx)("div",{className:"inline-balance",children:(0,a.jsx)(h.A,{value:b})})]}),(0,a.jsx)("div",{className:"column",children:k&&!g.isZero()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h5",{children:c("Curator's deposit")}),(0,a.jsx)("div",{className:"inline-balance",children:(0,a.jsx)(h.A,{value:g})})]})})]})]})}),(0,a.jsx)("td",{}),(0,a.jsx)("td",{}),(0,a.jsx)("td",{children:l&&(0,a.jsxs)("div",{className:"votes-table",children:[(0,a.jsx)(ce,{option:"ayes",proposals:l,status:v}),(0,a.jsx)(ce,{option:"nays",proposals:l,status:v})]})}),(0,a.jsx)("td",{})]})]})});function me(e){return new Blob([e]).size}const he=(0,c.F)("useBalance",function(e){const{api:s}=(0,o.g)(),t=(0,i.Gc)(s.derive.balances?.all,[e]);return t?.transferable||t?.availableBalance}),pe=d.Yz,xe=n.memo(function(){const{t:e}=f(),{bountyDepositBase:s,bountyValueMinimum:t,dataDepositPerByte:o,maximumReasonLength:i,proposeBounty:l}=u(),[c,d]=(0,n.useState)(null),h=he(c),[p,x]=(0,n.useState)(""),[g,b]=(0,n.useState)(s),[j,v]=(0,n.useState)(pe),[y,C]=(0,m.e)(),[w,k]=(0,n.useState)(!1),[S,N]=(0,n.useState)(!1),[A,F]=(0,n.useState)(!1);(0,n.useEffect)(()=>{k(p?.length>=1&&me(p)<=i)},[i,p]),(0,n.useEffect)(()=>{N(!!j?.gte(t))},[t,j]),(0,n.useEffect)(()=>{F(!!h?.gte(g))},[h,g]);const I=A&&w&&S,E=(0,n.useCallback)(e=>{var t,a;x(e),b((t=e,a=o,s.add(a.muln(me(t)))))},[s,o]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.$n,{icon:"plus",isDisabled:!1,label:e("Add Bounty"),onClick:C}),y&&(0,a.jsxs)(r.aF,{className:"ui--AddBountyModal",header:e("Add Bounty"),onClose:C,children:[(0,a.jsxs)(r.aF.Content,{children:[(0,a.jsxs)(r.aF.Columns,{hint:e("Description of the Bounty (to be stored on-chain)"),children:[(0,a.jsx)(r.pd,{autoFocus:!0,defaultValue:"",isError:!w,label:e("bounty title"),onChange:E,value:p}),!w&&""!==p&&(0,a.jsx)(r.o_,{content:e("Title too long")})]}),(0,a.jsxs)(r.aF.Columns,{hint:e("How much should be paid out for completed Bounty. Upon funding, the amount will be reserved in treasury."),children:[(0,a.jsx)(r.xg,{isError:!S,isZeroable:!0,label:e("bounty requested allocation"),onChange:v,value:j}),!S&&!j?.eq(pe)&&(0,a.jsx)(r.o_,{content:e("Allocation value is smaller than the minimum bounty value.")})]}),(0,a.jsx)(r.aF.Columns,{hint:e("Proposer bond depends on bounty title length."),children:(0,a.jsx)(r.xg,{defaultValue:g.toString(),isDisabled:!0,label:e("bounty bond")})}),(0,a.jsxs)(r.aF.Columns,{hint:e("This account will propose the bounty. Bond amount will be reserved on its balance."),children:[(0,a.jsx)(r.B4,{isError:!A,label:e("submit with account"),onChange:d,type:"account",withLabel:!0}),!A&&(0,a.jsx)(r.o_,{content:e("Account does not have enough funds.")})]})]}),(0,a.jsx)(r.aF.Actions,{children:(0,a.jsx)(r.jX,{accountId:c,icon:"plus",isDisabled:!c||!I,label:e("Add Bounty"),onStart:C,params:[j,p],tx:l})})]})]})});var ge=t(76791);const be=n.memo(function({className:e="",info:{bestNumber:s,bounties:t,bountyCount:o,childCount:i}}){const{t:l}=f(),{spendPeriod:c}=(0,ge.h)(),d=(0,n.useMemo)(()=>(t||[]).reduce((e,{bounty:{value:s}})=>e.iadd(s),new(A())(0)),[t]);return(0,a.jsxs)(r.cp,{className:`${e} ui--BountySummary`,children:[(0,a.jsxs)("section",{children:[t&&(0,a.jsx)(r.dS,{label:l("active"),children:(0,re.Z)(t.length)}),o&&t&&(0,a.jsx)(r.dS,{label:l("past"),children:(0,re.Z)(o.subn(t.length))}),i&&(0,a.jsx)(r.dS,{label:l("children"),children:(0,re.Z)(i)})]}),(0,a.jsx)("section",{children:(0,a.jsx)(r.dS,{label:l("active total"),children:(0,a.jsx)(h.A,{value:d,withSi:!0})})}),(0,a.jsx)("section",{children:s&&!c.isZero()&&(0,a.jsx)(r.dS,{label:l("funding period"),progress:{total:c,value:s.mod(c),withTime:!0}})})]})}),fe=r.I4.div`
.bounties-table-wrapper table {
tr {
td, &:not(.filter) th {
&:last-child {
padding-right: 1.14rem;
}
}
}
}
.ui--IdentityIcon {
margin-right: 0.42rem;
}
.via-identity .name {
font-size: var(--font-size-base);
line-height: 1.7rem;
text-transform: initial;
filter: initial;
opacity: 1;
}
`,je=n.memo(function({className:e}){const{t:s}=f(),t=u(),o=(0,n.useMemo)(()=>t?.bounties&&[...t.bounties].sort((e,s)=>s.index.cmp(e.index)),[t]),i=(0,n.useRef)([[s("bounties"),"start",3],[s("value")],[s("curator"),"start"],[s("next action"),"start",3]]),l=t.bestNumber;return(0,a.jsxs)(fe,{className:e,children:[(0,a.jsx)(be,{info:t}),(0,a.jsx)(r.$n.Group,{children:(0,a.jsx)(xe,{})}),(0,a.jsx)(r.XI,{className:"bounties-table-wrapper",empty:o&&s("No open bounties"),header:i.current,children:o&&l&&o.map(({bounty:e,description:s,index:t,proposals:n})=>(0,a.jsx)(ue,{bestNumber:l,bounty:e,description:s,index:t,proposals:n},t.toNumber()))})]})}),ve=n.memo(function({basePath:e,className:s=""}){const{t}=f(),o=(0,n.useRef)([{isRoot:!0,name:"index",text:t("Overview")}]);return(0,a.jsxs)("main",{className:`${s} bounties--App`,children:[(0,a.jsx)(r.tU,{basePath:e,items:o.current}),(0,a.jsx)(je,{})]})})},98487(e,s,t){t.d(s,{A:()=>n});var a=t(66530);const n=(0,t(55155).F)("useCounter",function(){return(0,a.r)("ambassadorReferenda")})},98586(e,s,t){t.d(s,{A:()=>c});var a=t(14041),n=t(55155),r=t(97186),o=t(61020),i=t(79129),l=t(22067);const c=(0,n.F)("usePezkuwiPreclaims",function(){const{allAccounts:e}=(0,r.o)(),{api:s}=(0,o.g)(),t=(0,l.T)(),[n,c]=(0,a.useState)([]),d=(0,i.Gc)(s.query.claims?.preclaims?.multi,[e],{transform:s=>s.map((s,t)=>[e[t],s]).filter(([,e])=>e.isSome).map(([e,s])=>[e,s.unwrap()])});return(0,a.useEffect)(()=>{d&&s.queryMulti(d.reduce((e,[,t])=>e.concat([[s.query.claims.claims,t],[s.query.claims.vesting,t]]),[]),e=>{t.current&&c(d.filter((s,t)=>e[2*t].isSome||e[2*t+1].isSome).map(([e])=>e))}).catch(console.error)},[s,e,t,d]),n})}}]);