var C=Object.create;var u=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var X=(t,e)=>{for(var o in e)u(t,o,{get:e[o],enumerable:!0})},k=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of W(e))!_.call(t,s)&&s!==o&&u(t,s,{get:()=>e[s],enumerable:!(a=D(e,s))||a.enumerable});return t};var N=(t,e,o)=>(o=t!=null?C(Y(t)):{},k(e||!t||!t.__esModule?u(o,"default",{value:t,enumerable:!0}):o,t)),O=t=>k(u({},"__esModule",{value:!0}),t);var i=(t,e,o)=>new Promise((a,s)=>{var c=r=>{try{d(o.next(r))}catch(l){s(l)}},A=r=>{try{d(o.throw(r))}catch(l){s(l)}},d=r=>r.done?a(r.value):Promise.resolve(r.value).then(c,A);d((o=o.apply(t,e)).next())});var V={};X(V,{default:()=>M});module.exports=O(V);var lt=require("react");var K=N(require("axios"),1);var y=require("react"),R=require("react/jsx-runtime"),G=(0,y.createContext)(void 0),P="production";var g=P==="development"?"https://qa-api-v2.bandit.network/sdk":"https://api-v2.bandit.network/sdk";var x=(t,e)=>i(void 0,null,function*(){try{return(yield K.default.get(`${g}/users/${t}`,{headers:{"X-API-KEY":e}})).data}catch(o){throw new Error(o)}});var m=require("react-redux");var h=require("react"),w=require("@stacks/connect"),B=()=>{let[t,e]=(0,h.useState)(""),o=new w.AppConfig(["store_write","publish_data"]),a=new w.UserSession({appConfig:o}),s=()=>{a.signUserOut(),e("")};return(0,h.useEffect)(()=>{if(a)try{let c=a.loadUserData();e(c.profile.stxAddress.testnet)}catch(c){}},[a]),{stacksAddress:t,userSession:a,disconnectStacks:s}},b=B;var U=require("@web3-react/core"),E=require("@solana/wallet-adapter-react");var v=require("@reduxjs/toolkit"),L={selectedWallet:void 0,selectedSolanaWallet:void 0,accessKey:null,details:{}},I=(0,v.createSlice)({name:"user",initialState:L,reducers:{updateSelectedWallet(t,{payload:{wallet:e}}){t.selectedWallet=e},updateSolanaSelectedWallet(t,{payload:{wallet:e}}){t.selectedSolanaWallet=e},updateAccessKey(t,{payload:{accessKey:e}}){t.accessKey=e},updateUserDetails(t,{payload:{details:e}}){t.details=e}}}),{updateSelectedWallet:rt,updateSolanaSelectedWallet:nt,updateAccessKey:ct,updateUserDetails:S}=I.actions,dt=I.reducer;var T=()=>{let{selectedWallet:t,accessKey:e,details:o={}}=(0,m.useSelector)(n=>n.user),{stacksAddress:a}=b(),{account:s}=(0,U.useWeb3React)(),{publicKey:c,disconnect:A}=(0,E.useWallet)(),d=(0,m.useDispatch)();return{user:o,fetchUser:()=>i(void 0,null,function*(){var n;try{let f=c?c.toBase58():"",p=t==="stacks"?a:t==="Phantom"?f:s;if(((n=o==null?void 0:o.walletAddress)==null?void 0:n.toLowerCase())===(p==null?void 0:p.toLowerCase()))return;let $=yield x(p,e);d(S({details:$}))}catch(f){console.log(f)}}),refreshUser:()=>i(void 0,null,function*(){try{if(!o.walletAddress)return;let n=yield x(o.walletAddress,e);d(S({details:n}))}catch(n){console.log(n)}})}},M=T;
