var f=Object.create;var m=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var Y=(t,r)=>{for(var e in r)m(t,e,{get:r[e],enumerable:!0})},g=(t,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of S(r))!K.call(t,a)&&a!==e&&m(t,a,{get:()=>r[a],enumerable:!(o=k(r,a))||o.enumerable});return t};var X=(t,r,e)=>(e=t!=null?f(I(t)):{},g(r||!t||!t.__esModule?m(e,"default",{value:t,enumerable:!0}):e,t)),B=t=>g(m({},"__esModule",{value:!0}),t);var p=(t,r,e)=>new Promise((o,a)=>{var i=n=>{try{l(e.next(n))}catch(c){a(c)}},s=n=>{try{l(e.throw(n))}catch(c){a(c)}},l=n=>n.done?o(n.value):Promise.resolve(n.value).then(i,s);l((e=e.apply(t,r)).next())});var N={};Y(N,{default:()=>q});module.exports=B(N);var d=require("@solana/wallet-adapter-react"),b=require("@solana/web3.js"),$=require("react");var u=X(require("axios"),1);var h=require("react"),C=require("react/jsx-runtime"),H=(0,h.createContext)(void 0),D="production";var w=D==="development"?"https://qa-api-v2.bandit.network/sdk":"https://api-v2.bandit.network/sdk";var P=(t,r,e,o,a,i)=>p(void 0,null,function*(){try{return(yield u.default.post(`${w}/collection/sns/registerDomain`,{name:r,claimWallet:e,price:o,payUsing:a,space:i},{headers:{"X-API-KEY":t}})).data}catch(s){throw new Error(s)}}),E=(t,r,e)=>p(void 0,null,function*(){try{return(yield u.default.post(`${w}/collection/sns/claimDomain`,{name:r,transactionHash:e},{headers:{"X-API-KEY":t}})).data}catch(o){throw new Error(o)}});var _=()=>{let t=(0,d.useWallet)(),{connection:r}=(0,d.useConnection)();return{registerSns:(0,$.useCallback)((o,a,i,s,l,n)=>p(void 0,null,function*(){if(!(!t.connected||!t.publicKey||!r))try{let c=a,A=yield P(o,s.name,l,c.toString(),i.value,n*1e3),v=yield r.getLatestBlockhash(),y=b.Transaction.from(Buffer.from(A));y.recentBlockhash=v.blockhash;let x=yield t.sendTransaction(y,r);console.log(x),yield E(o,s.name,x)}catch(c){throw c}}),[t,r])}},q=_;
