import{kasm,casq,eask,tasF,nasYe,iasJe,IasZe,sasB,Basxe,aasG,basen,dasN,fasV}from"./index-CENwOupW.js";constnn=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,tn=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;functionan(e){const{domain:n={},message:t,primaryType:i}=e,r={EIP712Domain:un({domain:n}),...e.types};on({domain:n,message:t,primaryType:i,types:r});consta=["0x1901"];returnn&&a.push(sn({domain:n,types:r})),i!=="EIP712Domain"&&a.push($({data:t,primaryType:i,types:r})),m(q(a))}functionsn({domain:e,types:n}){return$({data:e,primaryType:"EIP712Domain",types:n})}function$({data:e,primaryType:n,types:t}){consti=K({data:e,primaryType:n,types:t});returnm(i)}functionK({data:e,primaryType:n,types:t}){consti=[{type:"bytes32"}],r=[cn({primaryType:n,types:t})];for(constaoft[n]){const[u,l]=Q({types:t,name:a.name,type:a.type,value:e[a.name]});i.push(u),r.push(l)}returnk(i,r)}functioncn({primaryType:e,types:n}){constt=F(rn({primaryType:e,types:n}));returnm(t)}functionrn({primaryType:e,types:n}){lett="";consti=X({primaryType:e,types:n});i.delete(e);constr=[e,...Array.from(i).sort()];for(constaofr)t+=`${a}(${n[a].map(({name:u,type:l})=>`${l}${u}`).join(",")})`;returnt}functionX({primaryType:e,types:n},t=newSet){consti=e.match(/^\w*/u),r=i==null?void0:i[0];if(t.has(r)||n[r]===void0)returnt;t.add(r);for(constaofn[r])X({primaryType:a.type,types:n},t);returnt}functionQ({types:e,name:n,type:t,value:i}){if(e[t]!==void0)return[{type:"bytes32"},m(K({data:i,primaryType:t,types:e}))];if(t==="bytes")returni=`0x${(i.length%2?"0":"")+i.slice(2)}`,[{type:"bytes32"},m(i)];if(t==="string")return[{type:"bytes32"},m(F(i))];if(t.lastIndexOf("]")===t.length-1){constr=t.slice(0,t.lastIndexOf("[")),a=i.map(u=>Q({name:n,type:r,types:e,value:u}));return[{type:"bytes32"},m(k(a.map(([u])=>u),a.map(([,u])=>u)))]}return[{type:t},i]}functionon(e){const{domain:n,message:t,primaryType:i,types:r}=e,a=(u,l)=>{for(constfofu){const{name:v,type:g}=f,h=l[v],p=g.match(tn);if(p&&(typeofh=="number"||typeofh=="bigint")){const[M,S,L]=p;Ye(h,{signed:S==="int",size:Number.parseInt(L)/8})}if(g==="address"&&typeofh=="string"&&!Je(h))thrownewZe({address:h});constC=g.match(nn);if(C){const[M,S]=C;if(S&&B(h)!==Number.parseInt(S))thrownewxe({expectedSize:Number.parseInt(S),givenSize:B(h)})}constD=r[g];D&&a(D,h)}};r.EIP712Domain&&n&&a(r.EIP712Domain,n),i!=="EIP712Domain"&&a(r[i],t)}functionun({domain:e}){return[typeof(e==null?void0:e.name)=="string"&&{name:"name",type:"string"},(e==null?void0:e.version)&&{name:"version",type:"string"},typeof(e==null?void0:e.chainId)=="number"&&{name:"chainId",type:"uint256"},(e==null?void0:e.verifyingContract)&&{name:"verifyingContract",type:"address"},(e==null?void0:e.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}constdn=`Ethereum Signed Message: