"use strict";(self["webpackChunkcrystal_dapp"]=self["webpackChunkcrystal_dapp"]||[]).push([[836],{24802:(e,t,n)=>{n.r(t),n.d(t,{default:()=>gt});var l=n(59835),a=n(86970);const s=e=>((0,l.dD)("data-v-957b7c20"),e=e(),(0,l.Cn)(),e),o={class:"q-pa-md",style:{"max-width":"1439px"}},i={class:"row q-pa-none justify-center",style:{"max-width":"540px"}},r=["onClick"],c={class:"gem-count text-right text-bold"},u=s((()=>(0,l._)("i",{class:"mdi-blank"},null,-1))),m=s((()=>(0,l._)("i",{class:"mdi-blank"},null,-1))),d={class:"gem-box row items-center justify-evenly"},v={key:1,class:"nft-id"},f=s((()=>(0,l._)("i",{class:"las la-angle-down inline",sixe:"xs"},null,-1))),p=[f],y=s((()=>(0,l._)("div",{class:"text-h6"},[(0,l._)("i",{class:"las la-plus"})],-1))),g={class:"gem-box row items-center justify-evenly"},w={key:1,class:"nft-id"},h=s((()=>(0,l._)("i",{class:"las la-angle-down",sixe:"xs"},null,-1))),b=[h],x=s((()=>(0,l._)("i",{class:"mdi-blank"},null,-1))),_=s((()=>(0,l._)("i",{class:"mdi-blank"},null,-1))),k=s((()=>(0,l._)("div",{class:"text-center"},[(0,l._)("i",{class:"las la-angle-double-down"})],-1))),G={class:"gem-box row items-center justify-evenly"},q={key:1,class:"info",style:{"text-shadow":"#000 1px 0 10px",position:"absolute",transform:"translate(0%, -50%)",top:"50%",left:"50%","padding-left":"35px"}},C={class:""},I={class:"gem-level q-pr-sm"},T={class:"q-pr-sm text-h6"},W={class:"gem-quality text-caption text-grey text-center"},S=s((()=>(0,l._)("div",{class:"text-center"},null,-1))),z={class:"row items-center justify-evenly"},D={class:"gem-id text-center"},N=s((()=>(0,l._)("div",{class:"text-h6"},[(0,l._)("i",{class:"las la-plus"})],-1))),H={class:"gem-id text-center"},L=s((()=>(0,l._)("div",{class:"text-h6"},[(0,l._)("i",{class:"las la-angle-double-right"})],-1))),R={key:0},A={class:"gem-id text-center"},U={key:1,class:"text-h6"},Z=s((()=>(0,l._)("i",{class:"las la-question"},null,-1))),$=[Z],E=s((()=>(0,l._)("span",{class:"text-h6 q-ml-sm"},"Incorrect blockchain",-1))),j=s((()=>(0,l._)("span",{class:"q-ml-sm"},"You are currently not connected to the correct network.",-1))),Q={class:"info row",style:{"text-shadow":"#000 1px 0 10px"}},V={class:"text-h6"},M={key:0,class:"gem-box row items-center justify-evenly"},P={class:"nft-id-2"},O=["onClick"],F=s((()=>(0,l._)("i",{class:"las la-plus"},null,-1))),B=[F],J=s((()=>(0,l._)("br",null,null,-1))),K=(0,l.Uk)(" Choose a Target "),Y=["onClick"],X={class:"gem-count text-right text-bold"},ee=s((()=>(0,l._)("span",{class:"text-h6 q-ml-sm"},"Combine Gem",-1))),te={class:"q-pa-xs"},ne={key:0,class:"text-left"},le=s((()=>(0,l._)("a",null,[(0,l._)("span",{class:"cursor-pointer"}," Sign transaction with your wallet and we will never touch your private key! ")],-1))),ae=[le],se={key:1,class:"text-left text-red"},oe=["href"],ie={class:"cursor-pointer"},re=s((()=>(0,l._)("a",null,[(0,l._)("span",{class:"cursor-pointer"}," Transaction is broadcasted, waiting for confirmation. ")],-1))),ce={class:"row"},ue=s((()=>(0,l._)("div",{class:"gem-frame row items-center justify-evenly col"},[(0,l._)("div",{class:"text-h3"},"?")],-1))),me={class:"gem-info",style:{"text-shadow":"#000 1px 0 10px"}},de={class:"text-h6 gem-name"},ve={class:"gem-level"},fe={class:"gem-scale"},pe={class:"gem-quality"},ye=s((()=>(0,l._)("br",null,null,-1))),ge={class:"cursor-pointer"},we={class:"row result"},he={class:"gem-frame row items-center justify-evenly col"},be={class:"gem-info",style:{"text-shadow":"#000 1px 0 10px"}},xe={class:"text-bold text-grey"},_e={class:"row"},ke={class:"gem-level q-pr-sm"},Ge={class:"gem-scale q-pr-sm"},qe={class:"gem-quality q-pr-sm"},Ce=s((()=>(0,l._)("div",{style:{height:"10px",width:"100%"}},null,-1))),Ie=s((()=>(0,l._)("span",{class:"text-subtitle2 text-secondary q-ml-sm"},"https://crystal.network",-1)));function Te(e,t,n,s,f,h){const Z=(0,l.up)("CrystalGem"),F=(0,l.up)("q-card-section"),le=(0,l.up)("q-btn"),Te=(0,l.up)("q-badge"),We=(0,l.up)("q-item-section"),Se=(0,l.up)("q-item"),ze=(0,l.up)("q-list"),De=(0,l.up)("q-tab-panel"),Ne=(0,l.up)("q-tab-panels"),He=(0,l.up)("nft-menu"),Le=(0,l.up)("q-avatar"),Re=(0,l.up)("q-space"),Ae=(0,l.up)("q-card-actions"),Ue=(0,l.up)("q-card"),Ze=(0,l.up)("q-dialog"),$e=(0,l.up)("q-step"),Ee=(0,l.up)("q-linear-progress"),je=(0,l.up)("q-chip"),Qe=(0,l.up)("q-stepper"),Ve=(0,l.up)("BalanceView"),Me=(0,l.up)("q-page"),Pe=(0,l.Q2)("close-popup");return(0,l.wg)(),(0,l.j4)(Me,{class:"row justify-evenly bg-pic",style:{"padding-top":"58px"}},{default:(0,l.w5)((()=>[(0,l._)("div",o,[(0,l.Wm)(Ne,{class:"",flat:"","model-value":"crafting",animated:""},{default:(0,l.w5)((()=>[(0,l.Wm)(De,{class:"items-center q-pa-xs",name:"crafting"},{default:(0,l.w5)((()=>[(0,l.Wm)(F,{class:"row items-start justfy-center"},{default:(0,l.w5)((()=>[(0,l._)("div",i,[((0,l.wg)(!0),(0,l.iD)(l.HY,null,(0,l.Ko)(e.canCombineGems,(t=>((0,l.wg)(),(0,l.iD)("div",{key:t},[(0,l._)("div",{class:"gem-box row items-center justify-evenly",onClick:n=>e.setToCombine(t,0)},[(0,l.Wm)(Z,{nft:0,level:t.level,color:t.color,quality:100,scale:.64,size:50},null,8,["level","color","scale"])],8,r),(0,l._)("div",c," x "+(0,a.zw)(t.text),1)])))),128))])])),_:1}),(0,l.Wm)(F,{class:"row items-center justify-evenly"},{default:(0,l.w5)((()=>[u,m,(0,l._)("div",d,[e.fromGem1?((0,l.wg)(),(0,l.iD)("div",{key:e.fromGem1},[(0,l.Wm)(Z,{nft:e.fromGem1.nft,level:e.fromGem1.level,color:e.fromGem1.color,quality:e.fromGem1.quality,scale:e.fromGem1.scale,size:50,detail:!0},null,8,["nft","level","color","quality","scale"])])):(0,l.kq)("",!0),e.fromGem1?((0,l.wg)(),(0,l.iD)("div",v,"#"+(0,a.zw)(e.fromGem1.nft),1)):(0,l.kq)("",!0),e.fromGem1&&e.fromGems.length>2?((0,l.wg)(),(0,l.iD)("div",{key:2,class:"choose-from-gem text-center no-padding",onClick:t[0]||(t[0]=t=>{e.chooseFrom=!0,e.chooseNum=1})},p)):(0,l.kq)("",!0)]),y,(0,l._)("div",g,[e.fromGem2?((0,l.wg)(),(0,l.iD)("div",{key:e.fromGem2},[(0,l.Wm)(Z,{nft:e.fromGem2.nft,level:e.fromGem2.level,color:e.fromGem2.color,quality:e.fromGem2.quality,scale:e.fromGem2.scale,size:50,detail:!0},null,8,["nft","level","color","quality","scale"])])):(0,l.kq)("",!0),e.fromGem2?((0,l.wg)(),(0,l.iD)("div",w,"#"+(0,a.zw)(e.fromGem2.nft),1)):(0,l.kq)("",!0),e.fromGem2&&e.fromGems.length>2?((0,l.wg)(),(0,l.iD)("div",{key:2,class:"choose-from-gem text-center",onClick:t[1]||(t[1]=t=>{e.chooseFrom=!0,e.chooseNum=2})},b)):(0,l.kq)("",!0)]),x,_])),_:1}),k,(0,l.Wm)(F,{class:"row items-center justify-evenly"},{default:(0,l.w5)((()=>[(0,l._)("div",null,[(0,l._)("div",G,[e.toCombineGem?((0,l.wg)(),(0,l.j4)(Z,{key:e.toCombineGem,nft:0,level:e.toCombineGem.level,color:e.toCombineGem.color,quality:100,scale:.8,size:50},null,8,["level","color","scale"])):(0,l.kq)("",!0)]),e.toCombineGem?((0,l.wg)(),(0,l.iD)("div",{key:0,class:"info",style:{"text-shadow":"#000 1px 0 10px",position:"absolute",transform:"translate(0%, -50%)",top:"50%",right:"50%","padding-right":"35px"},onClick:t[2]||(t[2]=t=>e.updateTree(!1))},[(0,l._)("div",{class:(0,a.C_)(e.getRarity(e.toCombineGem.level).rarity+" text-h6 text-right")},(0,a.zw)(e.$t("gems.levels."+e.toCombineGem.level)+e.$t("gems.names."+e.toCombineGem.color)),3),(0,l._)("div",{class:(0,a.C_)(e.getRarity(e.toCombineGem.level).rarity+" text-right")},(0,a.zw)(e.$t("gems."+e.getRarity(e.toCombineGem.level).rarity)+" "+e.$t("gems.gem")),3)])):(0,l.kq)("",!0),e.toCombineGem?((0,l.wg)(),(0,l.iD)("div",q,[(0,l._)("div",C,[(0,l._)("div",I,(0,a.zw)(e.$t("crafting.successRate")+":"),1),(0,l._)("div",T,(0,a.zw)((((e.fromGem1?e.fromGem1.quality:0)+(e.fromGem2?e.fromGem2.quality:0)+300)/5).toFixed(2))+" % ",1)])])):(0,l.kq)("",!0)])])),_:1}),(0,l._)("div",W,(0,a.zw)(e.$t("crafting.successInfo")),1),S,(0,l.Wm)(F,null,{default:(0,l.w5)((()=>[(0,l.Wm)(le,{unelevated:"",color:"primary",class:"min-width-320 full-width","no-caps":"",onClick:t[3]||(t[3]=t=>e.combineClicked())},{default:(0,l.w5)((()=>[(0,l.Uk)((0,a.zw)(e.$t("crafting.combine")),1)])),_:1})])),_:1}),(0,l.Wm)(F,null,{default:(0,l.w5)((()=>[((0,l.wg)(!0),(0,l.iD)(l.HY,null,(0,l.Ko)(e.combineEvents,((t,n,s)=>((0,l.wg)(),(0,l.j4)(ze,{dense:"",class:"reverse",key:t},{default:(0,l.w5)((()=>[s==Object.keys(e.combineEvents).length-1?((0,l.wg)(),(0,l.j4)(Se,{key:0},{default:(0,l.w5)((()=>[(0,l.Wm)(We,null,{default:(0,l.w5)((()=>[(0,l._)("div",z,[(0,l._)("div",null,[(0,l.Wm)(Z,{nft:0,level:t.fromLevel,color:t.color,quality:100,scale:.5,size:40},null,8,["level","color","scale"]),(0,l._)("div",D,(0,a.zw)("#"+t.from1),1)]),N,(0,l._)("div",null,[(0,l.Wm)(Z,{nft:0,level:t.fromLevel,color:t.color,quality:100,scale:.5,size:40},null,8,["level","color","scale"]),(0,l._)("div",H,(0,a.zw)("#"+t.from2),1)]),L,t.toLevel>=0?((0,l.wg)(),(0,l.iD)("div",R,[(0,l.Wm)(Z,{nft:t.gemId,level:t.toLevel,color:t.color,quality:e.uriToNum(t.uri).quality,scale:e.uriToNum(t.uri).scale,size:40,detail:!0},null,8,["nft","level","color","quality","scale"]),(0,l._)("div",A,"#"+(0,a.zw)(n),1)])):((0,l.wg)(),(0,l.iD)("div",U,$)),t.toLevel>=0?((0,l.wg)(),(0,l.j4)(Te,{key:2,style:{top:"-10px",right:"10%"},align:"top",color:"orange",floating:"",transparent:""},{default:(0,l.w5)((()=>[(0,l.Uk)((0,a.zw)(t.toLevel>t.fromLevel?e.$t("gems.success"):e.$t("gems.failed"))+"! ",1)])),_:2},1024)):(0,l.kq)("",!0)])])),_:2},1024)])),_:2},1024)):(0,l.kq)("",!0)])),_:2},1024)))),128))])),_:1})])),_:1})])),_:1})]),(0,l.Wm)(He),(0,l.Wm)(Ze,{modelValue:e.switchNet,"onUpdate:modelValue":t[5]||(t[5]=t=>e.switchNet=t),persistent:""},{default:(0,l.w5)((()=>[(0,l.Wm)(Ue,{class:"bg-glass"},{default:(0,l.w5)((()=>[(0,l.Wm)(F,{class:"row items-center q-pb-none"},{default:(0,l.w5)((()=>[(0,l.Wm)(Le,{icon:"signal_wifi_off",color:"primary","text-color":"white",size:"xs"}),E,(0,l.Wm)(Re),(0,l.wy)((0,l.Wm)(le,{icon:"close",flat:"",round:"",dense:""},null,512),[[Pe]])])),_:1}),(0,l.Wm)(F,{class:"row items-center"},{default:(0,l.w5)((()=>[j])),_:1}),(0,l.Wm)(Ae,{align:"right"},{default:(0,l.w5)((()=>[(0,l.wy)((0,l.Wm)(le,{class:"full-width",label:"Switch",color:"primary",onClick:t[4]||(t[4]=t=>e.switchNetwork(e.netIndex))},null,512),[[Pe]])])),_:1})])),_:1})])),_:1},8,["modelValue"]),(0,l.Wm)(Ze,{modelValue:e.chooseFrom,"onUpdate:modelValue":t[6]||(t[6]=t=>e.chooseFrom=t)},{default:(0,l.w5)((()=>[(0,l.Wm)(Ue,{class:"bg-glass min-width-320"},{default:(0,l.w5)((()=>[(0,l.Wm)(F,{class:"row items-center q-pb-none"},{default:(0,l.w5)((()=>[(0,l._)("div",Q,[(0,l._)("div",V,(0,a.zw)(e.$t("crafting.chooseA"))+" ",1),(0,l._)("div",{class:(0,a.C_)(e.getRarity(e.fromGems[0].level).rarity+" text-h6")}," ["+(0,a.zw)(e.$t("gems.levels."+e.fromGems[0].level)+e.$t("gems.names."+e.fromGems[0].color))+"] ",3)])])),_:1}),(0,l.Wm)(F,{class:"row items-center q-pb-none"},{default:(0,l.w5)((()=>[((0,l.wg)(!0),(0,l.iD)(l.HY,null,(0,l.Ko)(e.fromGems,(t=>((0,l.wg)(),(0,l.iD)("div",{class:"row",key:t},[t.nft!=e.fromGem1.nft&&t.nft!=e.fromGem2.nft?((0,l.wg)(),(0,l.iD)("div",M,[(0,l._)("div",null,[(0,l.Wm)(Z,{nft:t.nft,level:t.level,color:t.color,quality:t.quality,scale:t.scale,size:50,detail:!0},null,8,["nft","level","color","quality","scale"])]),(0,l._)("div",P,"#"+(0,a.zw)(t.nft),1),(0,l._)("div",{class:"choose-from-gem text-center",onClick:n=>e.setToCombine(t,e.chooseNum)},B,8,O)])):(0,l.kq)("",!0)])))),128))])),_:1}),(0,l.Wm)(F,{class:"row items-center q-pb-none"},{default:(0,l.w5)((()=>[J])),_:1})])),_:1})])),_:1},8,["modelValue"]),(0,l.Wm)(Ze,{modelValue:e.chooseTar,"onUpdate:modelValue":t[7]||(t[7]=t=>e.chooseTar=t)},{default:(0,l.w5)((()=>[(0,l.Wm)(Ue,{class:"bg-glass min-width-320"},{default:(0,l.w5)((()=>[(0,l.Wm)(F,{class:"row items-center q-pb-none"},{default:(0,l.w5)((()=>[K])),_:1}),(0,l.Wm)(F,{class:"row items-center q-pb-none"},{default:(0,l.w5)((()=>[((0,l.wg)(!0),(0,l.iD)(l.HY,null,(0,l.Ko)(e.canCombineGems,(t=>((0,l.wg)(),(0,l.iD)("div",{key:t},[(0,l._)("div",{class:"gem-box row items-center justify-evenly",onClick:n=>e.setToCombine(t,0)},[(0,l.Wm)(Z,{nft:0,level:t.level,color:t.color,quality:100,scale:.64,size:45},null,8,["level","color","scale"])],8,Y),(0,l._)("div",X,"x "+(0,a.zw)(t.text),1)])))),128))])),_:1}),(0,l.Wm)(F,{class:"row items-center q-pb-none"})])),_:1})])),_:1},8,["modelValue"]),(0,l.Wm)(Ze,{modelValue:e.signTx,"onUpdate:modelValue":t[10]||(t[10]=t=>e.signTx=t),position:"top"},{default:(0,l.w5)((()=>[(0,l.Wm)(Ue,{style:{top:"50px"}},{default:(0,l.w5)((()=>[(0,l.Wm)(F,{class:"q-pa-xs row items-center q-pb-none"},{default:(0,l.w5)((()=>[ee,(0,l.Wm)(Re),(0,l.wy)((0,l.Wm)(le,{icon:"close",flat:"",round:"",dense:""},null,512),[[Pe]])])),_:1}),(0,l.Wm)(F,{class:"row items-center q-pa-xs"},{default:(0,l.w5)((()=>[(0,l._)("div",te,[(0,l.Wm)(Qe,{modelValue:e.txStep,"onUpdate:modelValue":t[9]||(t[9]=t=>e.txStep=t),vertical:"",color:"primary",flat:"",animated:""},{default:(0,l.w5)((()=>[(0,l.Wm)($e,{name:1,title:"Sign Transaction",icon:"las la-wallet",done:e.txStep>1,error:e.signTxErr.length>0},{default:(0,l.w5)((()=>[""==e.signTxErr?((0,l.wg)(),(0,l.iD)("div",ne,ae)):((0,l.wg)(),(0,l.iD)("div",se,(0,a.zw)(e.signTxErr),1))])),_:1},8,["done","error"]),(0,l.Wm)($e,{name:2,title:"Send Transaction",icon:"las la-receipt",done:e.txStep>2},{default:(0,l.w5)((()=>[(0,l._)("a",{href:e.linkAddress(e.signTxHash,e.netIndex,"tx"),target:"_blank",class:"text-grey-6"},[(0,l._)("span",ie,(0,a.zw)(" tx hash: "+e.shortAddress(e.signTxHash,6,!1)),1)],8,oe),re,(0,l.Wm)(Ee,{dark:"",rounded:"",indeterminate:"",color:"secondary",class:"q-mt-sm"})])),_:1},8,["done"]),(0,l.Wm)($e,{name:3,title:"Waiting for Result",icon:"las la-hourglass-half",done:e.txStep>3},{default:(0,l.w5)((()=>[(0,l._)("div",ce,[ue,(0,l._)("div",me,[(0,l._)("div",de,(0,a.zw)(e.$t("gems.gem")+":")+" #"+(0,a.zw)(e.txGem),1),(0,l._)("div",ve,(0,a.zw)(e.$t("gems.level")+":")+" ?? ",1),(0,l._)("div",fe,(0,a.zw)(e.$t("gems.weight")+":")+" ?? ",1),(0,l._)("div",pe,(0,a.zw)(e.$t("gems.quality")+":")+" ?? ",1)])]),(0,l.Wm)(Ee,{dark:"",rounded:"",indeterminate:"",color:"secondary",class:"q-mt-sm"}),ye,(0,l._)("a",null,[(0,l._)("span",ge,(0,a.zw)(e.$t("airdrop.whenAppear")),1)])])),_:1},8,["done"]),(0,l.Wm)($e,{name:4,done:4==e.txStep,title:"Result",icon:"las la-trophy"},{default:(0,l.w5)((()=>[(0,l._)("div",we,[(0,l._)("div",he,[(0,l.Wm)(Z,{nft:e.txGemDetail.nft,level:e.txGemDetail.level,color:e.txGemDetail.color,quality:e.txGemDetail.quality,scale:e.txGemDetail.scale,size:50},null,8,["nft","level","color","quality","scale"])]),(0,l._)("div",be,[(0,l._)("div",xe,(0,a.zw)(e.txGemSuccess?e.$t("gems.success"):e.$t("gems.failed"))+"! ",1),(0,l._)("div",{class:(0,a.C_)(e.getRarity(e.txGemDetail.level).rarity+" text-h6")},(0,a.zw)(e.$t("gems.levels."+e.txGemDetail.level)+e.$t("gems.names."+e.txGemDetail.color)),3),(0,l._)("div",{class:(0,a.C_)(e.getRarity(e.txGemDetail.level).rarity)},[(0,l.Uk)((0,a.zw)(e.$t("gems."+e.getRarity(e.txGemDetail.level).rarity)+" "+e.$t("gems.gem"))+" ",1),(0,l.Wm)(je,{dense:"",color:"grey"},{default:(0,l.w5)((()=>[(0,l._)("a",{class:(0,a.C_)(e.getRarity(e.txGemDetail.level).rarity)},(0,a.zw)(e.getRarity(e.txGemDetail.level).short),3)])),_:1})],2),(0,l._)("div",_e,[(0,l._)("div",ke,(0,a.zw)(e.$t("gems.level")+": "+(4*parseInt(e.txGemDetail.level)+10)),1),(0,l._)("div",Ge,(0,a.zw)(e.$t("gems.weight")+": "+parseInt(100*e.txGemDetail.scale)),1),(0,l._)("div",qe,(0,a.zw)(e.$t("gems.quality")+": "+e.txGemDetail.quality),1)])]),Ce,(0,l.Wm)(le,{onClick:t[8]||(t[8]=t=>e.signTx=!1),color:"primary",label:"OK",class:"q-ml-sm full-width",dense:""})])])),_:1},8,["done"])])),_:1},8,["modelValue"])])])),_:1}),(0,l.Wm)(F,{class:"q-pa-xs row items-center q-pb-none"},{default:(0,l.w5)((()=>[Ie])),_:1})])),_:1})])),_:1},8,["modelValue"]),(0,l.Wm)(Ve)])),_:1})}var We=n(60499),Se=n(19302),ze=n(65457),De=n(9229),Ne=n(17387),He=n(16898),Le=n(85990),Re=n(28488),Ae=n(88576),Ue=n.n(Ae),Ze=n(17779),$e=function(e,t,n,l){function a(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,s){function o(e){try{r(l.next(e))}catch(t){s(t)}}function i(e){try{r(l["throw"](e))}catch(t){s(t)}}function r(e){e.done?n(e.value):a(e.value).then(o,i)}r((l=l.apply(e,t||[])).next())}))},Ee=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"===typeof __values?__values(e):e[Symbol.iterator](),t={},l("next"),l("throw"),l("return"),t[Symbol.asyncIterator]=function(){return this},t);function l(n){t[n]=e[n]&&function(t){return new Promise((function(l,s){t=e[n](t),a(l,s,t.done,t.value)}))}}function a(e,t,n,l){Promise.resolve(l).then((function(t){e({value:t,done:n})}),t)}};const je=n(10875),Qe=n(72593);function Ve(e){Ze.log("Switch network: ",(0,Le.v)().networks[e].name,(0,Le.v)().networks[e].id),(0,Le.v)().initWeb3(e)}const Me={title:"Crystal - Crafting"},Pe=(0,l.aZ)({name:"CraftingPage",components:{NftMenu:De.Z,CrystalGem:Ne.Z,BalanceView:He.Z},setup(){const e=(0,Se.Z)();e.dark.set(!0),(0,ze.Z)(Me);const t=(0,We.iH)({}),n=(0,We.iH)(0),l=(0,We.iH)([]),a=(0,We.iH)([]),s=(0,We.iH)([]),o=(0,We.iH)([]),i=(0,We.iH)(),r=(0,We.iH)(),c=(0,We.iH)(),u=(0,We.iH)(!1),m=(0,We.iH)(""),d=(0,We.iH)(""),v=(0,We.iH)(1),f=(0,We.iH)(0),p=(0,We.iH)(),y=(0,We.iH)(!1);let g,w,h=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],b=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];const x=e=>new Promise((t=>setTimeout(t,e))),_=(0,We.iH)(!1),k=(0,We.iH)(!1),G=(0,We.iH)(!1),q=(0,We.iH)(0),C="polygon",I=(0,We.iH)(0),T=(0,We.iH)("0xE2956E26d7d0a8F65389d1Ec095e83475C0bdf37"),W=(0,We.iH)("0x30a8C517b35e7D635f77AaeeBb0C704015dFaa6A");function S(){return $e(this,void 0,void 0,(function*(){const e=yield(0,Le.v)().web3.eth.net.getId().then((e=>e)).catch((e=>(Ze.log("checkNetwork: ",e),-1)));return e}))}function z(e){return $e(this,void 0,void 0,(function*(){const t=(0,Le.v)().networks[e].id,n=(0,Le.v)().networks[e].name,l=(0,Le.v)().networks[e].tokenName,a=(0,Le.v)().networks[e].symbol,s=(0,Le.v)().networks[e].rpcUrl,o=(0,Le.v)().networks[e].explorer,i="0x"+t.toString(16);if("undefined"!==typeof window.ethereum)try{yield window.ethereum.request({method:"wallet_switchEthereumChain",params:[{chainId:i}]}),location.reload()}catch(r){if(Ze.log(r),4902===r.code){Ze.log("Add Chain");try{yield window.ethereum.request({method:"wallet_addEthereumChain",params:[{chainId:i,chainName:n,nativeCurrency:{name:l,symbol:a,decimals:18},rpcUrls:[s],blockExplorerUrls:[o]}]}),location.reload()}catch(c){alert(c.message)}}else alert(r.message)}}))}function D(e){return $e(this,void 0,void 0,(function*(){const t=yield Ue().Web3API.token.reSyncMetadata({chain:C,address:W.value,token_id:e,flag:"uri"});Ze.log("reSyncURI resp:",e,t)}))}function N(e){var t,n,l,a;return $e(this,void 0,void 0,(function*(){try{for(t=Ee(e);n=yield t.next(),!n.done;){const e=n.value;yield x(1e3),yield D(e),yield H(e)}}catch(s){l={error:s}}finally{try{n&&!n.done&&(a=t.return)&&(yield a.call(t))}finally{if(l)throw l.error}}}))}function H(e){return $e(this,void 0,void 0,(function*(){Ze.log("getGemURI id:",e);const t=(0,Le.v)().web3Instance,n=new t.eth.Contract(je,W.value);n.methods.tokenURI(e).call().then((function(t){if(!t.length)return void Ze.log("getGemURI length: ",t.length);Ze.log("getGemURI: ",t);const n=parseInt(e),l=JSON.parse(t),s=(0,Le.v)().web3.utils.toHex(l.properties);let o=10,i=10;for(let e=2;e<14;e++){const t=parseInt(s[e],16);e<8?o+=t:e<14&&(i+=t)}const r={nft:n,level:l.level,color:l.color,quality:o,scale:i/100,properties:s,text:""};for(let e=0;e<a.value.length;e++){const t=a.value[e];t.nft==n&&a.value.splice(e,1)}j(r,n)})).catch((function(e){Ze.log("getGemURI: ",e)}))}))}function L(){var e;return $e(this,void 0,void 0,(function*(){const t="https://g19udojubwks.usemoralis.com:2053/server",n="P749qSdfiW93rIsFAtUSWNAnJK4HX8hyvauadRFz";yield Ue().start({serverUrl:t,appId:n});const s=(0,Le.v)().account,o=(0,Le.v)().web3Instance;if(!o.utils.isAddress(s))return alert("Need Connect Wallet!"),void Ze.log("Not Address:",s);try{let t=yield Ue().Web3API.account.getNFTsForContract({chain:C,address:s,token_address:W.value});const n=t.result||[];while(t.next){if(t=yield t.next(),0==(null===(e=null===t||void 0===t?void 0:t.result)||void 0===e?void 0:e.length))break;n.push(...t.result||[])}V(n);let o=[];a.value=[],n.forEach((e=>{const t=parseInt(e.token_id);if(e.token_uri){const n=JSON.parse(e.token_uri),l=(0,Le.v)().web3.utils.toHex(n.properties);let a=10,s=10;for(let e=2;e<14;e++){const t=parseInt(l[e],16);e<8?a+=t:e<14&&(s+=t)}const o={nft:t,level:n.level,color:n.color,quality:a,scale:s/100,properties:l,text:""};j(o,t)}else{const n={nft:t,level:8,color:0,quality:10,scale:1,properties:"0xffffffffffff",text:""};o.push(e.token_id);let s=!1;for(let e=0;e<l.value.length;e++){const n=l.value[e];if(n.nft==t){s=!0;break}}s||(a.value.unshift(n),Ze.log(n))}})),N(o),M(!1)}catch(i){Ze.log(i)}}))}function R(e,t){var n="0";for(let l=0;l<e.length;l++){const a=e[l];if(a.address.toUpperCase()==t.toUpperCase()){const e=(0,Le.v)().web3.eth.abi.decodeParameters([{type:"uint256",name:"color"},{type:"uint256",name:"from1"},{type:"uint256",name:"from2"},{type:"uint256",name:"fromLevel"},{type:"uint256",name:"rate"},{type:"uint256",name:"gemId"}],a.data);n=e.gemId.toString();break}}return parseInt(n)}function A(e,t){return $e(this,void 0,void 0,(function*(){if(!(0,Le.v)().web3.utils.isAddress((0,Le.v)().account))return void alert("Need Connect Wallet!");const n=I.value,l=yield S();if(l!=(0,Le.v)().networks[n].id)return Ze.log(l,"!=",(0,Le.v)().networks[n].id),void(_.value=!0);m.value="",d.value="",v.value=1,u.value=!0;const a=(0,Le.v)().web3,s=T.value,o=(0,Le.v)().account,i=new a.eth.Contract(Qe,s);let r=i.methods.combineGem(e,t),c=r.encodeABI();a.eth.estimateGas({from:o,to:s,value:0,data:c}).then((function(e){Ze.log("gasAmount: ",e),a.eth.sendTransaction({from:o,to:s,value:0,gas:parseInt((1.05*e).toString()),gasPrice:36e9,data:c}).on("transactionHash",(e=>{Ze.log("transactionHash: ",e),v.value=2,d.value=e})).on("receipt",(e=>{const t=R(e.logs,s);Ze.log("gemId:",t),f.value=t,v.value=3,L()})).on("error",(e=>{Ze.log("tx combineGem",e),m.value=e.message,v.value=1}))})).catch((function(e){Ze.log("estimateGas: ",e);let t=e.message.toString(),n=t.split(".")[1],l=JSON.parse(n),a=l.message.split(":");m.value=a[0]+": "+a[1]}))}))}function U(){return $e(this,void 0,void 0,(function*(){const e=(0,Le.v)().account,n=(0,Le.v)().web3Instance;if(!n.utils.isAddress(e))return alert("Need Connect Wallet!"),void Ze.log("Not Address:",e);Ze.log("listenGemCombine:",e);const l=new n.eth.Contract(Qe,T.value),a={filter:{user:e},fromBlock:29827141};g=l.events.GemCombine(a).on("data",(function(e){if(!e.removed){const n=e.returnValues,l=n.gemId,a={color:parseInt(n.color),from1:parseInt(n.from1),from2:parseInt(n.from2),fromLevel:parseInt(n.fromLevel),gemId:parseInt(l),rate:parseInt(n.rate),user:n.user,success:void 0!=t.value[l]&&void 0!=t.value[l].success?t.value[l].success:"",toLevel:void 0!=t.value[l]&&void 0!=t.value[l].toLevel?t.value[l].toLevel:-1,uri:void 0!=t.value[l]&&void 0!=t.value[l].uri?t.value[l].uri:""};t.value[l]=a,Q(n.from1),Q(n.from2),M(!1)}})).on("changed",(function(e){Ze.log("listenGemCombine changed:",e)})).on("error",(function(e){Ze.log("listenGemCombine Err:",e)})).on("connected",(function(e){Ze.log("listenGemCombine subscription id:",e)}))}))}function Z(){return $e(this,void 0,void 0,(function*(){const e=(0,Le.v)().account,n=(0,Le.v)().web3Instance;if(!n.utils.isAddress(e))return alert("Need Connect Wallet!"),void Ze.log("Not Address:",e);Ze.log("listenGemSettled:",e);const l=new n.eth.Contract(Qe,T.value),a={filter:{user:e},fromBlock:29827141};w=l.events.GemSettled(a).on("data",(function(e){return $e(this,void 0,void 0,(function*(){if(!e.removed){const n=e.returnValues,l=n.gemId,a={color:parseInt(n.color),from1:parseInt(n.from1),from2:parseInt(n.from2),gemId:parseInt(l),user:n.user,success:n.success,toLevel:parseInt(n.toLevel),uri:n.uri,rate:void 0!=t.value[l]&&void 0!=t.value[l].rate?t.value[l].rate:0,fromLevel:void 0!=t.value[l]?void 0!=t.value[l].fromLevel?t.value[l].fromLevel:"true"==n.success?parseInt(n.toLevel)-1:-1:-1};t.value[l]=a,parseInt(l)==f.value&&(p.value={nft:parseInt(l),level:parseInt(n.toLevel),color:parseInt(n.color),quality:O(n.uri).quality,scale:O(n.uri).scale,properties:"",text:""},y.value=t.value[l].toLevel>t.value[l].fromLevel,v.value=4,yield H(l),M(!1))}}))})).on("changed",(function(e){Ze.log("listenGemSettled changed:",e)})).on("error",(function(e){Ze.log("listenGemSettled Err:",e)})).on("connected",(function(e){Ze.log("listenGemSettled subscription id:",e)}))}))}function $(){return $e(this,void 0,void 0,(function*(){const e=(0,Le.v)().account,n=(0,Le.v)().web3Instance;if(!n.utils.isAddress(e))return alert("Need Connect Wallet!"),void Ze.log("Not Address:",e);Ze.log("getAllEvents:",e);const l=new n.eth.Contract(Qe,T.value),a={filter:{user:e},fromBlock:29827141,toBlock:"latest"};l.getPastEvents("GemSettled",a).then((function(e){Ze.log("GemSettled:",e),e.forEach((e=>{if(e.removed)Ze.log("event.removed: ",e);else{const n=e.returnValues,l=n.gemId,a={color:parseInt(n.color),from1:parseInt(n.from1),from2:parseInt(n.from2),gemId:parseInt(l),user:n.user,success:n.success,toLevel:parseInt(n.toLevel),uri:n.uri,rate:void 0!=t.value[l]?t.value[l].rate:0,fromLevel:void 0!=t.value[l]?t.value[l].fromLevel:"true"==n.success?parseInt(n.toLevel)-1:-1};t.value[l]=a}}))})).catch((function(e){Ze.log("getAllEvents Err: ",e)}))}))}function E(){g&&g.unsubscribe(),w&&w.unsubscribe()}function j(e,t){let n=!1;for(let a=0;a<l.value.length;a++){const e=l.value[a];if(e.nft==t){n=!0;break}}n||(l.value.unshift(e),Ze.log(e))}function Q(e){for(let t=0;t<l.value.length;t++){const n=l.value[t];if(n.nft==e){l.value.splice(t,1);break}}}function V(e){let t=[];for(let n=0;n<l.value.length;n++){const a=l.value[n];for(let n=0;n<e.length;n++){const l=e[n].token_id;l==a.nft&&t.push(a)}}l.value=t,M(!1)}function M(e){i.value=void 0,r.value=void 0,c.value=void 0;for(let n=0;n<6;n++)for(let e=0;e<16;e++)h[n][e]=0;for(let n=0;n<l.value.length;n++){const e=l.value[n],t=e.color,a=e.level;h[t][a]+=1}let t=[];for(let n=0;n<6;n++)for(let e=0;e<15;e++)if(h[n][e]>=2){const l=Math.floor(h[n][e]/2);b[n][e+1]=l;const a={nft:0,level:e+1,color:n,quality:100,scale:1,properties:"0xffffffffffff",text:l.toString()};t.push(a)}s.value=t}function P(e,t){switch(t){case 0:c.value=e,o.value=[];for(let t=0;t<l.value.length;t++){const n=l.value[t];n.color==e.color&&n.level+1==e.level&&o.value.push(n)}o.value.sort((function(e,t){return e.quality<t.quality?1:e.quality>t.quality?-1:0})),i.value=o.value[0],r.value=o.value[1];break;case 1:i.value=e;break;case 2:r.value=e;break;default:Ze.log("default");break}k.value=!1,G.value=!1}function O(e){const t=JSON.parse(e),n=(0,Le.v)().web3.utils.toHex(t.properties);let l=10,a=10;for(let s=2;s<14;s++){const e=parseInt(n[s],16);s<8?l+=e:s<14&&(a+=e)}return{quality:l,scale:a/100}}function F(){Ze.log(t.value["7600"])}let B={};for(let J=0;J<101;J++)B[J.toString()]=0;return{test:F,shortAddress:Re.sC,copyAddress:Re.c4,linkAddress:Re.ol,uriToNum:O,listenerGemCombine:g,listenerGemSettled:w,signTx:u,signTxErr:m,signTxHash:d,txStep:v,txGem:f,txGemDetail:p,txGemSuccess:y,gemNftContract:W,combineContract:T,netIndex:I,chain:C,switchNet:_,chooseTar:k,chooseFrom:G,chooseNum:q,userGems:l,newGems:a,canCombineGems:s,fromGems:o,fromGem1:i,fromGem2:r,toCombineGem:c,gemTree:h,combineTree:b,combineEvents:t,updateEvents:n,checkNetwork:S,switchNetwork:z,getUserGems:L,combineGemTx:A,listenGemCombine:U,listenGemSettled:Z,getAllEvents:$,updateTree:M,setToCombine:P,removeListeners:E,initGame(){return $e(this,void 0,void 0,(function*(){let e=new URLSearchParams(window.location.search),t=e.get("ref");Ze.log(t||"No Ref");const n=I.value;Ve(n);const l=yield S();if(l!=(0,Le.v)().networks[n].id)return Ze.log(l,"!=",(0,Le.v)().networks[n].id),void(_.value=!0);U(),Z()}))},combineClicked(){return $e(this,void 0,void 0,(function*(){void 0!=i.value&&void 0!=r.value&&i.value.level==r.value.level&&i.value.color==r.value.color&&(Ze.log("Combine Gems: ",i.value.nft,r.value.nft),A(i.value.nft,r.value.nft),i.value=void 0,r.value=void 0,c.value=void 0)}))},getRarity(e){let t="Common",n="C";switch(e){case 4:case 5:case 6:case 7:n="UC";break;case 8:case 9:n="R";break;case 10:n="RR";break;case 11:n="RRR";break;case 12:n="SR";break;case 13:n="HR";break;case 14:n="UR";break;case 15:n="SSR";break;default:break}switch(e){case 4:case 5:case 6:case 7:t="Uncommon";break;case 8:case 9:case 10:case 11:t="Rare";break;case 12:case 13:case 14:case 15:t="Epic";break;default:break}return{rarity:t,short:n}},initDate(){localStorage.getItem((0,Le.v)().account.concat("-userGems"))&&Object.assign(l.value,JSON.parse(localStorage.getItem((0,Le.v)().account.concat("-userGems"))||""))},storeData(){Ze.log("storeData: userGems"),localStorage.setItem((0,Le.v)().account.concat("-userGems"),JSON.stringify(l.value))}}},beforeMount(){this.initDate(),this.initGame(),this.getUserGems(),this.updateTree(!1)},beforeUnmount(){this.removeListeners(),this.storeData()}});var Oe=n(11639),Fe=n(69885),Be=n(89800),Je=n(84106),Ke=n(63190),Ye=n(57691),Xe=n(68879),et=n(13246),tt=n(490),nt=n(76749),lt=n(20990),at=n(32074),st=n(44458),ot=n(61357),it=n(90136),rt=n(11821),ct=n(8225),ut=n(46017),mt=n(21992),dt=n(8289),vt=n(62146),ft=n(69984),pt=n.n(ft);const yt=(0,Oe.Z)(Pe,[["render",Te],["__scopeId","data-v-957b7c20"]]),gt=yt;pt()(Pe,"components",{QPage:Fe.Z,QTabPanels:Be.Z,QTabPanel:Je.Z,QCardSection:Ke.Z,QChip:Ye.Z,QBtn:Xe.Z,QList:et.Z,QItem:tt.Z,QItemSection:nt.Z,QBadge:lt.Z,QDialog:at.Z,QCard:st.Z,QAvatar:ot.Z,QSpace:it.Z,QCardActions:rt.Z,QStepper:ct.Z,QStep:ut.Z,QStepperNavigation:mt.Z,QLinearProgress:dt.Z}),pt()(Pe,"directives",{ClosePopup:vt.Z})},72593:e=>{e.exports=JSON.parse('[{"inputs":[{"internalType":"address","name":"gem","type":"address"},{"internalType":"address","name":"rand","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newGame","type":"address"}],"name":"GameAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"removedGame","type":"address"}],"name":"GameRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"color","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"from1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"from2","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fromLevel","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"gemId","type":"uint256"}],"name":"GemCombine","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"color","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"from1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"from2","type":"uint256"},{"indexed":false,"internalType":"bool","name":"success","type":"bool"},{"indexed":false,"internalType":"uint256","name":"gemId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toLevel","type":"uint256"},{"indexed":false,"internalType":"string","name":"uri","type":"string"}],"name":"GemSettled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"newGame","type":"address"}],"name":"addGame","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gem1","type":"uint256"},{"internalType":"uint256","name":"gem2","type":"uint256"}],"name":"combineGem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"games","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"who","type":"address"}],"name":"isGame","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"game","type":"address"}],"name":"removeGame","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"}],"name":"setGem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"requestId","type":"bytes32"},{"internalType":"uint256","name":"randomness","type":"uint256"}],"name":"settleRand","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleGameIsLive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]')}}]);