import{$ as se,au as ae,a3 as te,a1 as ie,a0 as d,bL as ne,ac as m,bM as C,at as oe,U as I,V as N,R as k,ax as ce,a4 as e,a5 as le,a7 as re,bN as H,ab as R,a8 as z,ad as w,ae as de}from"./index-F5308wi0.js";import{f as me}from"./formatSearchParams-C4IYAEpQ.js";import{S as ue}from"./simulation-BVbaiQyH.js";import{T as pe,a as G,S as fe,F as J,B as U,b as W,I as K,c as be,G as he,d as ge,e as ve,f as je,M as Se,g as xe,h as Ie}from"./index-CZQ6ebD4.js";import{j as we,h as Te,d as ye}from"./index-COHSasgJ.js";import"./index.browser.esm-td0i8UXo.js";import{i as Ee}from"./isEmpty-CGFgSwqF.js";import"./_baseIteratee-7dBAmCi8.js";import"./hasIn-C3MZ1Y6C.js";import"./pickBy-CE5Bwd1O.js";import"./_basePickBy-CSkpdVhT.js";import"./lossFormat-BiHP7XfF.js";import"./uniq-C1h4ayRv.js";import"./_baseUniq-CKqWSnHK.js";import"./index-CSp3_H7k.js";import"./capitalize-CGrE5d6Y.js";import"./_stringToArray-BUSBCKuZ.js";import"./select-DwsZfEcO.js";import"./index-BYn-cCFi.js";import"./index-5SwdtDpC.js";const Ce=()=>{var V,_,L;const{network:o="",txnHash:n=""}=ae(),[u,$]=te(),a=ie(()=>new Ie),[j,D]=d.useState({width:0,height:0}),{isLaptop:A}=ne(),{focusVisible:P,txTraceData:T,txProfileData:s,modalSimulateVisible:X,setFullScreenTipVisible:B,setModalSimulateVisible:Q}=a,p=me(u),F=u.get("event")??"",Y=u.get("forkId")??"",Z=u.get("blockNumber")??"",y=u.get("blocked")??"",M=m.isSolana(o);d.useEffect(()=>{D({width:window.innerWidth,height:window.innerHeight-72})},[]),d.useEffect(()=>{A&&C.setSidebarCollapsed(!0)},[A]),d.useEffect(()=>{M?a.getSolanaData(n):(async()=>{await a.setCustomMap(),await a.setLocalforage(),await a.initDebugGuideVisible();const c=m.getChainIdBySimpleName(o),{type:l,params:r}=Te({chainId:c,event:F,forkId:Y,blockNumber:Z,txnHash:n,blocked:y});Promise.allSettled([w.getProfileData(l,r),w.getTxAddressLabel(l,r),w.getMainTraceData(l,r)]).then(([f,b,h])=>{var O;let g=null;if(f.status==="fulfilled"){const{value:{data:i,msg:v,success:E}}=f;E?(g=i,a.initProfile(i),n&&o&&!F&&!y&&a.save2Cache(n,m.getChainIdBySimpleName(o),i!=null&&i.securityEvent?`${(O=i==null?void 0:i.securityEvent)==null?void 0:O.project} Incidents`:"")):de.error(v)}if(b.status==="fulfilled"){const{value:{data:i,success:v}}=b;v&&(a.packageGlobalMapList(i.labels),a.setAddressLabels(i.labels))}if(h.status==="fulfilled"){const{value:{data:i,success:v}}=h;if(v){const E=ye(i);a.parseTxData(E,g)}}});const{data:S,success:x}=await w.getBalanceChangesData(l,r);x&&a.initBalanceChanges(S.balanceChanges)})()},[JSON.stringify(oe(p,["line","debugLine"])),o,n,y]),d.useEffect(()=>{I&&(I.onmessage=t=>{var c;switch(t.data.type){case N.POST_DATA_TO_MAIN_VIEW:a.setData(t.data.data),t.data.data.jsonView&&$({...p,line:t.data.data.jsonView.id,debugLine:t.data.data.jsonView.id});break;case N.RELOAD_REMOTE_TAB:(c=I)==null||c.postMessage({type:N.POST_DATA_TO_SUB_VIEW,data:{jsonView:k(a.jsonView),debugTree:k(a.debugTree),undoStack:k(a.undoStack)}}),a.setControlStatus(ce.CODE_IN_SEPARATE_TAB);break}})},[I]),d.useEffect(()=>{if(C.fullScreen){B(!0);const t=setTimeout(()=>{t&&clearTimeout(t),B(!1)},1500)}},[C.fullScreen]);const q=a.customMapList.filter(t=>!!t.decode).findIndex(t=>{var c;return t.value===((c=a.labelInfo)==null?void 0:c.value)})>-1,ee=d.useMemo(()=>{var t,c,l,r,S,x,f,b,h,g;return{chainID:m.getChainIdBySimpleName(o),txnHash:n,position:(t=s==null?void 0:s.basicInfo)==null?void 0:t.txnIndex,block:(c=s==null?void 0:s.basicInfo)==null?void 0:c.blockNumber,inputData:(l=s==null?void 0:s.basicInfo)==null?void 0:l.callData,gasLimit:(r=s==null?void 0:s.basicInfo)==null?void 0:r.gasLimit,value:(S=s==null?void 0:s.basicInfo)==null?void 0:S.formatValue,sender:(x=s==null?void 0:s.basicInfo)==null?void 0:x.sender,receiver:(f=s==null?void 0:s.basicInfo)!=null&&f.isContractCreation?"":(b=s==null?void 0:s.basicInfo)==null?void 0:b.receiver,gasPrice:((h=s==null?void 0:s.basicInfo)==null?void 0:h.gasPrice)??"",sourceTxnHash:(g=s==null?void 0:s.basicInfo)==null?void 0:g.sourceTxnHash}},[o,n,s]);return e.jsx(le,{theme:{token:{fontFamily:"var(--code-font-family)"}},children:e.jsx(pe.Provider,{value:a,children:e.jsxs("div",{children:[e.jsxs(re,{children:[e.jsxs("title",{children:[n==null?void 0:n.slice(0,20)," | Phalcon Explorer"]}),e.jsx("meta",{name:"description",content:"Phalcon Explorer helps developers, traders, and researchers understand complicated transactions to make better decisions. It supports ETH, BNB Chain, Arbitrum, Polygon, and more."})]}),e.jsxs("div",{className:"font-code",children:[M?e.jsxs(e.Fragment,{children:[e.jsx(G,{}),e.jsxs("div",{className:"mt-5 space-y-4",children:[e.jsx(fe,{}),e.jsx(J,{}),e.jsx(U,{}),e.jsx(H,{paddingSize:"sm",title:e.jsx("div",{children:e.jsxs("div",{className:R("flex items-center gap-1.5 text-base font-semibold leading-none text-default"),children:[e.jsx(z,{type:"icon-invocation-flow",size:20}),"Invocation Flow"]})}),defaultActiveKey:"0",className:"font-code",children:m.isSolana(o)?e.jsx(W,{}):e.jsx(K,{style:{position:"relative"},width:j.width,height:j.height,dataSource:a.mainTree})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(G,{}),e.jsxs("div",{className:"mt-5 space-y-4",children:[e.jsx(be,{}),e.jsx(J,{}),e.jsx(U,{}),e.jsx(he,{data:(V=T==null?void 0:T.gasFlame)==null?void 0:V[0]}),((_=s==null?void 0:s.basicInfo)==null?void 0:_.debugEnable)&&e.jsx(ge,{}),e.jsx(H,{paddingSize:"sm",title:e.jsx("div",{children:e.jsxs("div",{className:R("flex items-center gap-1.5 text-base font-semibold leading-none text-default"),children:[e.jsx(z,{type:"icon-invocation-flow",size:20}),"Invocation Flow"]})}),defaultActiveKey:"0",className:"font-code",children:m.isSolana(o)?e.jsx(W,{}):e.jsx(K,{style:{position:"relative"},width:j.width,height:j.height,dataSource:a.mainTree})})]})]}),e.jsx(ve,{visible:P}),e.jsx(je,{visible:a.expandFundFlow}),e.jsx(Se,{onClose:()=>{a.setLabel({})},onSuccess:a.setCustomizeMap,visible:!Ee(a.labelInfo),data:a.labelInfo,isDecoded:q}),((L=we(o,n))==null?void 0:L.valid)&&e.jsx(xe,{extraData:ee,visible:X,type:Number((p==null?void 0:p.type)??ue.TXN_HASH),onClose:()=>{Q(!1),a.onCloseJsonView(),a.resetDebugData()}})]})]},n)})})},Pe=se(Ce);export{Pe as default};