"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach((function(r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})})),e.default=t,e}Object.defineProperty(exports,"__esModule",{value:!0});var r=t(require("node-fetch")),n=require("@ethersproject/bytes"),a=require("@ethersproject/contracts"),s=require("@3rdweb/contracts"),i=require("@ethersproject/constants"),o=require("@ethersproject/units"),u=require("ethers"),c=require("ts-enum-util"),p=require("@ethersproject/bignumber"),d=require("ethers/lib/utils"),l=require("uuid"),f=require("@ethersproject/providers"),h=require("eventemitter2"),m=require("json2typescript"),y=require("merkletreejs"),x=t(y),v=require("tslib"),g=require("@ethersproject/address"),b=require("crypto-js");function w(t,e,r,n,a,s,i){try{var o=t[s](i),u=o.value}catch(t){return void r(t)}o.done?e(u):Promise.resolve(u).then(n,a)}function k(t){return function(){var e=this,r=arguments;return new Promise((function(n,a){var s=t.apply(e,r);function i(t){w(s,n,a,i,o,"next",t)}function o(t){w(s,n,a,i,o,"throw",t)}i(void 0)}))}}function C(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var N,F=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",s=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function o(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{o({},"")}catch(t){o=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var a=Object.create((e&&e.prototype instanceof d?e:d).prototype),s=new C(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(a,s){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw s;return{value:void 0,done:!0}}for(r.method=a,r.arg=s;;){var i=r.delegate;if(i){var o=b(i,r);if(o){if(o===p)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,s),a}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p={};function d(){}function l(){}function f(){}var h={};o(h,a,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m(T([])));y&&y!==e&&r.call(y,a)&&(h=y);var x=f.prototype=d.prototype=Object.create(h);function v(t){["next","throw","return"].forEach((function(e){o(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(a,s){function i(){return new e((function(n,i){!function n(a,s,i,o){var u=c(t[a],t,s);if("throw"!==u.type){var p=u.arg,d=p.value;return d&&"object"==typeof d&&r.call(d,"__await")?e.resolve(d.__await).then((function(t){n("next",t,i,o)}),(function(t){n("throw",t,i,o)})):e.resolve(d).then((function(t){p.value=t,i(p)}),(function(t){return n("throw",t,i,o)}))}o(u.arg)}(a,s,n,i)}))}return n=n?n.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,p;var a=n.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function T(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,s=function e(){for(;++n=0;--a){var s=this.tryEntries[a],i=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;k(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:T(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(N={exports:{}}),N.exports),L=function(t){function e(e){return t.call(this,e?"Object with id "+e+" NOT FOUND":"NOT_FOUND")||this}return S(e,t),e}(_(Error)),I=function(t){function e(e){return t.call(this,e?"'"+e+"' is an invalid address":"Invalid address passed")||this}return S(e,t),e}(_(Error)),D=function(t){function e(e,r){return t.call(this,"MISSING ROLE: "+e+" does not have the '"+r+"' role")||this}return S(e,t),e}(_(Error)),U=function(t){function e(e){return void 0===e&&(e="The asset you're trying to use could not be found."),t.call(this,"message: "+e)||this}return S(e,t),e}(_(Error)),V=function(t){function e(e){return t.call(this,"UPLOAD_FAILED: "+e)||this}return S(e,t),e}(_(Error)),j=function(t){function e(){return t.call(this,"File name is required when object is not a `File` type object.")||this}return S(e,t),e}(_(Error)),q=function(t){function e(e){return t.call(this,"DUPLICATE_FILE_NAME_ERROR: File name "+e+" was passed for more than one file.")||this}return S(e,t),e}(_(Error)),J=function(t){function e(e,r,n){return t.call(this,"BALANCE ERROR: you do not have enough balance on contract "+e+" to use "+r+" tokens. You have "+n+" tokens available.")||this}return S(e,t),e}(_(Error)),W=function(t){function e(){return t.call(this,"LIST ERROR: you should be the owner of the token to list it.")||this}return S(e,t),e}(_(Error)),G=function(t){function e(e){return t.call(this,"BUY ERROR: You cannot buy more than "+e+" tokens")||this}return S(e,t),e}(_(Error)),Z=function(t){function e(e,r){var n;return(n=t.call(this,"FETCH_FAILED: "+e)||this).innerError=void 0,n.innerError=r,n}return S(e,t),e}(_(Error)),z=function(t){function e(e){return t.call(this,"DUPLICATE_LEAFS"+(e?" : "+e:""))||this}return S(e,t),e}(_(Error)),H=function(t){function e(e){return t.call(this,"Auction already started with existing bid"+(e?", id: "+e:""))||this}return S(e,t),e}(_(Error)),K=function(t){function e(e){return t.call(this,"FUNCTION DEPRECATED. "+(e?"Use "+e+" instead":""))||this}return S(e,t),e}(_(Error)),Q=function(t){function e(e,r){return t.call(this,"Could not find listing."+(e?" marketplace address: "+e:"")+(r?" listing id: "+r:""))||this}return S(e,t),e}(_(Error)),Y=function(t){function e(e,r,n,a){return t.call(this,"Incorrect listing type. Are you sure you're using the right method?."+(e?" marketplace address: "+e:"")+(r?" listing id: "+r:"")+(a?" expected type: "+a:"")+(n?" actual type: "+n:""))||this}return S(e,t),e}(_(Error)),X=function(t){function e(e){return t.call(this,"Failed to transfer asset, transfer is restricted."+(e?" Address : "+e:""))||this}return S(e,t),e}(_(Error)),$=function(t){function e(e,r,n){return void 0===n&&(n="Failed to execute transaction"),t.call(this,n+", admin role is missing"+(e?" on address: "+e:"")+(r?" on contract: "+r:""))||this}return S(e,t),e}(_(Error)),tt=function(t){function e(e,r){return t.call(this,"Auction has not ended yet"+(e?", id: "+e:"")+(r?", end time: "+r.toString():""))||this}return S(e,t),e}(_(Error));function et(t,e){return"object"==typeof t&&Object.keys(t).forEach((function(r){"object"==typeof t[r]?t[r]=et(t[r],e):"string"==typeof t[r]&&(t[r]=e.resolveFullUrl(t[r]))})),t}function rt(t,e,r){return nt.apply(this,arguments)}function nt(){return(nt=k(F.mark((function t(e,r,n){var a,s,i;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={"X-App-Name":"CONSOLE-TS-SDK-"+r,"X-Public-Address":n||""},(s=new FormData).append("file",e),t.next=5,fetch("https://upload.nftlabs.co/upload",{method:"POST",body:s,headers:a});case 5:return i=t.sent,t.prev=6,t.next=9,i.json();case 9:return t.abrupt("return",t.sent.IpfsUri);case 13:throw t.prev=13,t.t0=t.catch(6),new V("Failed to upload to IPFS: "+t.t0);case 16:case"end":return t.stop()}}),t,null,[[6,13]])})))).apply(this,arguments)}function at(t,e,r){return st.apply(this,arguments)}function st(){return(st=k(F.mark((function t(e,r,n){var a,s;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=function(){return(s=k(F.mark((function t(e){var s,i,o,u;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:s=Object.keys(e),t.t0=F.keys(s);case 2:if((t.t1=t.t0()).done){t.next=18;break}if(!(u=(o=e[s[i=t.t1.value]])instanceof File||o instanceof Buffer)){t.next=10;break}return t.next=9,rt(e[s[i]],r,n);case 9:e[s[i]]=t.sent;case 10:if(!u||"string"==typeof e[s[i]]){t.next=12;break}throw new Error("Upload to IPFS failed");case 12:if("object"!=typeof o){t.next=16;break}return t.next=15,a(e[s[i]]);case 15:e[s[i]]=t.sent;case 16:t.next=2;break;case 18:return t.abrupt("return",e);case 19:case"end":return t.stop()}}),t)})))).apply(this,arguments)},a=function(t){return s.apply(this,arguments)},"string"!=typeof e){t.next=4;break}return t.abrupt("return",e);case 4:return t.next=6,a(e);case 6:return e=t.sent,t.next=9,rt(JSON.stringify(e),r,n);case 9:return t.abrupt("return",t.sent);case 10:case"end":return t.stop()}}),t)})))).apply(this,arguments)}globalThis.FormData||(globalThis.FormData=require("form-data")),globalThis.File||(globalThis.File=require("@web-std/file").File);var it,ot=n.arrayify("0x80ac58cd"),ut=n.arrayify("0xd9b67a26"),ct=[{inputs:[],name:"contractURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}];function pt(t,e,r,n){return dt.apply(this,arguments)}function dt(){return(dt=k(F.mark((function t(e,r,n,s){var i,o,u,c,p;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===s&&(s=!1),i=new a.Contract(r,ct,e),t.next=4,i.contractURI();case 4:return o=t.sent,t.next=7,n.get(o);case 7:return u=t.sent,t.prev=8,c=JSON.parse(u),s&&(c=et(c,n)),p=M({},c),t.abrupt("return",p);case 15:throw t.prev=15,t.t0=t.catch(8),new Error("Failed to parse metadata for contract "+r+" with uri "+o);case 18:case"end":return t.stop()}}),t,null,[[8,15]])})))).apply(this,arguments)}function lt(t,e){return ft.apply(this,arguments)}function ft(){return(ft=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getCode(r);case 2:return t.t0=t.sent,t.abrupt("return","0x"!==t.t0);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}!function(t){t[t.Mainnet=1]="Mainnet",t[t.Ropsten=3]="Ropsten",t[t.Rinkeby=4]="Rinkeby",t[t.Goerli=5]="Goerli",t[t.Kovan=42]="Kovan",t[t.BSC=56]="BSC",t[t.xDai=100]="xDai",t[t.Polygon=137]="Polygon",t[t.Moonriver=1285]="Moonriver",t[t.Mumbai=80001]="Mumbai",t[t.Harmony=16666e5]="Harmony",t[t.Localhost=1337]="Localhost",t[t.Hardhat=31337]="Hardhat",t[t.Fantom=250]="Fantom",t[t.FantomTestnet=4002]="FantomTestnet",t[t.Avalanche=43114]="Avalanche",t[t.AvalancheFujiTestnet=43113]="AvalancheFujiTestnet"}(it||(it={}));var ht,mt,yt=[it.Mainnet,it.Rinkeby,it.Polygon,it.Mumbai,it.Fantom,it.FantomTestnet,it.Avalanche,it.AvalancheFujiTestnet],xt="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",vt=((ht={})[it.Mainnet]={name:"Ether",symbol:"ETH",decimals:18,wrapped:{address:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",name:"Wrapped Ether",symbol:"WETH"}},ht[it.Rinkeby]={name:"Ether",symbol:"ETH",decimals:18,wrapped:{address:"0xc778417E063141139Fce010982780140Aa0cD5Ab",name:"Wrapped Ether",symbol:"WETH"}},ht[it.Polygon]={name:"Matic",symbol:"MATIC",decimals:18,wrapped:{address:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",name:"Wrapped Matic",symbol:"WMATIC"}},ht[it.Mumbai]={name:"Matic",symbol:"MATIC",decimals:18,wrapped:{address:"0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889",name:"Wrapped Matic",symbol:"WMATIC"}},ht[it.Avalanche]={name:"Avalanche",symbol:"AVAX",decimals:18,wrapped:{address:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",name:"Wrapped AVAX",symbol:"WAVAX"}},ht[it.AvalancheFujiTestnet]={name:"Avalanche",symbol:"AVAX",decimals:18,wrapped:{address:"0xd00ae08403B9bbb9124bB305C09058E32C39A48c",name:"Wrapped AVAX",symbol:"WAVAX"}},ht[it.Fantom]={name:"Fantom",symbol:"FTM",decimals:18,wrapped:{address:"0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83",name:"Wrapped Fantom",symbol:"WFTM"}},ht[it.FantomTestnet]={name:"Fantom",symbol:"FTM",decimals:18,wrapped:{address:"0xf1277d1Ed8AD466beddF92ef448A132661956621",name:"Wrapped Fantom",symbol:"WFTM"}},ht[it.Hardhat]={name:"Ether",symbol:"ETH",decimals:18,wrapped:{address:"0x5FbDB2315678afecb367f032d93F642f64180aa3",name:"Wrapped Ether",symbol:"WETH"}},ht);function gt(t,e){return bt.apply(this,arguments)}function bt(){return(bt=k(F.mark((function t(e,r){var n,a,i,o;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,!Ct(r)){t.next=10;break}return n=u.Signer.isSigner(e)?e.provider:e,t.next=5,n.getNetwork();case 5:return a=At(t.sent.chainId),t.abrupt("return",{name:a.name,symbol:a.symbol,decimals:a.decimals});case 10:return i=s.ERC20__factory.connect(r,e),t.next=13,Promise.all([i.name(),i.symbol(),i.decimals()]);case 13:return t.abrupt("return",{name:(o=t.sent)[0],symbol:o[1],decimals:o[2]});case 18:t.next=22;break;case 20:t.prev=20,t.t0=t.catch(0);case 22:return t.abrupt("return",{name:"",symbol:"",decimals:0});case 23:case"end":return t.stop()}}),t,null,[[0,20]])})))).apply(this,arguments)}function wt(t,e,r){return kt.apply(this,arguments)}function kt(){return(kt=k(F.mark((function t(e,r,n){var a;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,gt(e,r);case 2:return t.abrupt("return",M({},a=t.sent,{value:n.toString(),displayValue:o.formatUnits(n,a.decimals)}));case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Ct(t){return t.toLowerCase()===xt||t.toLowerCase()===i.AddressZero}function Tt(t,e,r){return Mt.apply(this,arguments)}function Mt(){return(Mt=k(F.mark((function t(e,r,n){var a,i,o;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=St(e),!Ct(r)){t.next=7;break}return t.next=4,a.getBalance(n);case 4:i=t.sent,t.next=18;break;case 7:return t.prev=7,o=s.ERC20__factory.connect(r,a),t.next=11,o.balanceOf(n);case 11:i=t.sent,t.next=18;break;case 14:throw t.prev=14,t.t0=t.catch(7),console.error(t.t0),new Error("invalid ERC20 token address");case 18:return t.abrupt("return",wt(e,r,i));case 19:case"end":return t.stop()}}),t,null,[[7,14]])})))).apply(this,arguments)}function St(t){return u.Signer.isSigner(t)?t.provider:t}function At(t){return vt[t]}var Ot,Rt=((mt={})[it.Polygon]={vrfCoordinator:"0x3d2341ADb2D31f1c5530cDC622016af293177AE0",linkTokenAddress:"0xb0897686c545045aFc77CF20eC7A532E3120E0F1",keyHash:"0xf86195cf7690c55907b2b611ebb7343a6f649bff128701cc542f0569e2c549da",fees:u.ethers.utils.parseEther("0.0001")},mt[it.Mumbai]={vrfCoordinator:"0x8C7382F9D8f56b33781fE506E897a4F1e2d17255",linkTokenAddress:"0x326C977E6efc84E512bB9C30f76E30c160eD06FB",keyHash:"0x6e75b569a01ef56d18cab6a8e71e6600d6ce853834d4a5748b720d06f878b3a4",fees:u.ethers.utils.parseEther("0.0001")},mt[it.Rinkeby]={vrfCoordinator:"0xb3dCcb4Cf7a26f6cf6B120Cf5A73875B7BBc655B",linkTokenAddress:"0x01be23585060835e02b77ef475b0cc51aa1e0709",keyHash:"0x2ed0feb3e7fd2022120aa84fab1945545a9f2ffc9076fd6156fa96eaff4c1311",fees:u.ethers.utils.parseEther("0.1")},mt[it.Mainnet]={vrfCoordinator:"0xf0d54349aDdcf704F77AE15b96510dEA15cb7952",linkTokenAddress:"0x514910771AF9Ca656af840dff83E8264EcF986CA",keyHash:"0xAA77729D3466CA35AE8D28B3BBAC7CC36A5031EFDC430821C02BC31A238AF445",fees:u.ethers.utils.parseEther("2")},mt[it.Hardhat]={vrfCoordinator:"0x8C7382F9D8f56b33781fE506E897a4F1e2d17255",linkTokenAddress:"0x326C977E6efc84E512bB9C30f76E30c160eD06FB",keyHash:"0x6e75b569a01ef56d18cab6a8e71e6600d6ce853834d4a5748b720d06f878b3a4",fees:u.ethers.utils.parseEther("0.0001")},mt);(Ot=exports.ModuleType||(exports.ModuleType={}))[Ot.CURRENCY=0]="CURRENCY",Ot[Ot.TOKEN=0]="TOKEN",Ot[Ot.COLLECTION=1]="COLLECTION",Ot[Ot.BUNDLE=1]="BUNDLE",Ot[Ot.NFT=2]="NFT",Ot[Ot.DYNAMIC_NFT=3]="DYNAMIC_NFT",Ot[Ot.ACCESS_NFT=4]="ACCESS_NFT",Ot[Ot.PACK=5]="PACK",Ot[Ot.MARKET=6]="MARKET",Ot[Ot.DROP=7]="DROP",Ot[Ot.DATASTORE=8]="DATASTORE",Ot[Ot.SPLITS=9]="SPLITS",Ot[Ot.VOTE=10]="VOTE",Ot[Ot.BUNDLE_DROP=11]="BUNDLE_DROP",Ot[Ot.MARKETPLACE=12]="MARKETPLACE",Ot[Ot.BUNDLE_SIGNATURE=13]="BUNDLE_SIGNATURE";var Pt=[{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"uri",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}];function _t(t,e,r,n){return Bt.apply(this,arguments)}function Bt(){return(Bt=k(F.mark((function t(e,r,n,s){var i;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=new a.Contract(r,Pt,e),t.abrupt("return",Et(i,n,s));case 2:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Et(t,e,r){return Nt.apply(this,arguments)}function Nt(){return(Nt=k(F.mark((function t(e,r,n){var a,s,i;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,It(e,r);case 2:if(a=t.sent){t.next=5;break}throw new L;case 5:return t.prev=5,t.next=8,n.get(a);case 8:return s=et(JSON.parse(t.sent),n),i=M({},s,{id:r,uri:a}),t.abrupt("return",i);case 14:return t.prev=14,t.t0=t.catch(5),console.error("failed to fetch nft",t.t0),t.abrupt("return",{id:r,uri:a});case 18:case"end":return t.stop()}}),t,null,[[5,14]])})))).apply(this,arguments)}function Ft(t,e,r,n){return Lt.apply(this,arguments)}function Lt(){return(Lt=k(F.mark((function t(e,r,n,s){var i,o,u,c;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=new a.Contract(e,Pt,r),t.next=3,It(i,n);case 3:if(o=t.sent){t.next=6;break}throw new L;case 6:return t.prev=6,t.t0=JSON,t.next=10,s.get(o);case 10:return t.t1=t.sent,u=t.t0.parse.call(t.t0,t.t1),c=M({},u,{id:n}),t.abrupt("return",c);case 16:return t.prev=16,t.t2=t.catch(6),console.error("failed to fetch nft",t.t2),t.abrupt("return",{id:n,uri:o});case 20:case"end":return t.stop()}}),t,null,[[6,16]])})))).apply(this,arguments)}function It(t,e){return Dt.apply(this,arguments)}function Dt(){return(Dt=k(F.mark((function t(e,r){var n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="",t.prev=1,t.next=4,e.tokenURI(r);case 4:n=t.sent,t.next=9;break;case 7:t.prev=7,t.t0=t.catch(1);case 9:if(n){t.next=18;break}return t.prev=10,t.next=13,e.uri(r);case 13:n=t.sent,t.next=18;break;case 16:t.prev=16,t.t1=t.catch(10);case 18:if(n){t.next=27;break}return t.prev=19,t.next=22,e.uri(r);case 22:n=t.sent,t.next=27;break;case 25:t.prev=25,t.t2=t.catch(19);case 27:return t.abrupt("return",n);case 28:case"end":return t.stop()}}),t,null,[[1,7],[10,16],[19,25]])})))).apply(this,arguments)}var Ut,Vt={admin:"admin",minter:"minter",pauser:"pauser",transfer:"transfer",editor:"editor",lister:"lister",asset:"asset"},jt={admin:"",transfer:"TRANSFER_ROLE",minter:"MINTER_ROLE",pauser:"PAUSER_ROLE",editor:"EDITOR_ROLE",lister:"LISTER_ROLE",asset:"ASSET_ROLE"};function qt(t){return"admin"===t?u.ethers.utils.hexZeroPad([0],32):u.ethers.utils.id(jt[t])}function Jt(t){return t&&t===it.Polygon?"https://gasstation-mainnet.matic.network":null}function Wt(t,e,r){return Gt.apply(this,arguments)}function Gt(){return(Gt=k(F.mark((function t(e,r,n){var a,s;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=Jt(e)){t.next=3;break}return t.abrupt("return",null);case 3:return t.prev=3,t.next=6,fetch(a);case 6:return t.next=8,t.sent.json();case 8:if(s=t.sent[r],e!==it.Polygon&&e!==it.Mumbai||(s=Math.max(s,31)),!(s>0)){t.next=13;break}return t.abrupt("return",Math.min(s,n));case 13:t.next=18;break;case 15:t.prev=15,t.t0=t.catch(3),console.error("failed to fetch gas",t.t0);case 18:return t.abrupt("return",null);case 19:case"end":return t.stop()}}),t,null,[[3,15]])})))).apply(this,arguments)}function Zt(t,e){if(!t)throw new Error(e)}function zt(t,e,r,n){return Ht.apply(this,arguments)}function Ht(){return(Ht=k(F.mark((function t(e,r,n,a){var s,i,o,c,p;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=null==e?void 0:e.provider){t.next=3;break}throw new Error("missing provider");case 3:if(o=u.ethers.utils._TypedDataEncoder.getPayload(r,n,a),c="",null==i||null==(s=i.provider)||!s.isWalletConnect){t.next=17;break}return t.t0=i,t.next=9,e.getAddress();case 9:return t.t1=t.sent.toLowerCase(),t.t2=JSON.stringify(o),t.t3=[t.t1,t.t2],t.next=14,t.t0.send.call(t.t0,"eth_signTypedData",t.t3);case 14:c=t.sent,t.next=38;break;case 17:return t.prev=17,t.next=20,e._signTypedData(r,n,a);case 20:c=t.sent,t.next=38;break;case 23:if(t.prev=23,t.t4=t.catch(17),null==t.t4||null==(p=t.t4.message)||!p.includes("Method eth_signTypedData_v4 not supported")){t.next=37;break}return t.t5=i,t.next=29,e.getAddress();case 29:return t.t6=t.sent.toLowerCase(),t.t7=JSON.stringify(o),t.t8=[t.t6,t.t7],t.next=34,t.t5.send.call(t.t5,"eth_signTypedData",t.t8);case 34:c=t.sent,t.next=38;break;case 37:throw t.t4;case 38:return t.abrupt("return",{payload:o,signature:u.ethers.utils.joinSignature(u.ethers.utils.splitSignature(c))});case 39:case"end":return t.stop()}}),t,null,[[17,23]])})))).apply(this,arguments)}!function(t){t.Transaction="transaction",t.Signature="signature"}(Ut||(Ut={}));var Kt,Qt=function(){function t(t,e,r,n){this.address=void 0,this.ipfsGatewayUrl=void 0,this.options=void 0,this.sdk=void 0,this._providerOrSigner=null,this._signer=null,this.contract=void 0,this.readOnlyContract=void 0,this.address=e,this.options=r,this.ipfsGatewayUrl=r.ipfsGatewayUrl,this.setProviderOrSigner(t),this.contract=this.connectContract(),this.readOnlyContract=this.options.readOnlyRpcUrl?this.contract.connect(u.ethers.getDefaultProvider(this.options.readOnlyRpcUrl)):this.contract,this.sdk=n}var e=t.prototype;return e.exists=function(){var t=k(F.mark((function t(){var e;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getProvider();case 2:return(e=t.sent)||Zt(!1),t.abrupt("return",lt(e,this.address));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getMetadata=function(){var t=k(F.mark((function t(e){var r,n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e=!0),t.next=3,this.exists();case 3:if(t.sent){t.next=7;break}Zt(!1),t.next=8;break;case 7:case 8:return r=this.connectContract(),n=this.getModuleType(),t.t0=pt,t.next=13,this.getProvider();case 13:return t.t1=t.sent,t.t2=r.address,t.t3=this.sdk.getStorage(),t.t4=e,t.next=19,(0,t.t0)(t.t1,t.t2,t.t3,t.t4);case 19:return t.t5=t.sent,t.t6=r.address,t.t7=n,t.abrupt("return",{metadata:t.t5,address:t.t6,type:t.t7});case 23:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.setMetadata=function(){var t=k(F.mark((function t(e){var r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.exists();case 2:if(t.sent){t.next=6;break}Zt(!1),t.next=7;break;case 6:case 7:return t.next=9,at(e);case 9:return r=t.sent,t.next=12,this.sendTransaction("setContractURI",[r]);case 12:return t.abrupt("return",this.getMetadata());case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.setProviderOrSigner=function(t){this.providerOrSigner=t,u.Signer.isSigner(t)&&(this.signer=t),this.contract=this.connectContract(),this.readOnlyContract=this.options.readOnlyRpcUrl?this.contract.connect(u.ethers.getDefaultProvider(this.options.readOnlyRpcUrl)):this.contract},e.clearSigner=function(){this.signer=null},e.getProviderOrSigner=function(){return this.signer||this.providerOrSigner},e.getSigner=function(){return u.Signer.isSigner(this.signer)?this.signer:null},e.hasValidSigner=function(){return u.Signer.isSigner(this.signer)},e.getSignerAddress=function(){var t=k(F.mark((function t(){var e;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(e=this.getSigner())||Zt(!1),t.next=4,e.getAddress();case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getProvider=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.readOnlyContract.provider);case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getChainID=function(){var t=k(F.mark((function t(){var e;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getProvider();case 2:return(e=t.sent)||Zt(!1),t.next=6,e.getNetwork();case 6:return t.abrupt("return",t.sent.chainId);case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.connectContract=function(){throw new Error("connectContract has to be implemented")},e.getModuleType=function(){throw new Error("getModuleType has to be implemented")},e.getCallOverrides=function(){var t=k(F.mark((function t(){var e,r,n,a;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChainID();case 2:return e=t.sent,r=this.options.gasSpeed,n=this.options.maxGasPriceInGwei,t.next=7,Wt(e,r,n);case 7:if(a=t.sent){t.next=10;break}return t.abrupt("return",{});case 10:return t.abrupt("return",{gasPrice:u.ethers.utils.parseUnits(a.toString(),"gwei")});case 11:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.emitTransactionEvent=function(t,e){this.sdk.event.emit(Ut.Transaction,{status:t,transactionHash:e})},e.sendTransaction=function(){var t=k(F.mark((function t(e,r,n){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.sendContractTransaction(this.contract,e,r,n));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.sendContractTransaction=function(){var t=k(F.mark((function t(e,r,n,a){var s,i,o,u,c;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a){t.next=4;break}return t.next=3,this.getCallOverrides();case 3:a=t.sent;case 4:if(!this.options.transactionRelayerUrl&&!this.options.gasless.biconomy.apiKey){t.next=19;break}return t.next=7,this.getProvider();case 7:return s=t.sent,t.next=10,this.sendGaslessTransaction(e,r,n,a);case 10:return this.emitTransactionEvent("submitted",i=t.sent),t.next=14,s.waitForTransaction(i);case 14:return o=t.sent,this.emitTransactionEvent("completed",i),t.abrupt("return",o);case 19:return t.next=21,this.sendTransactionByFunction(e,r,n,a);case 21:return this.emitTransactionEvent("submitted",(u=t.sent).hash),c=u.wait(),this.emitTransactionEvent("completed",u.hash),t.abrupt("return",c);case 26:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),e.sendTransactionByFunction=function(){var t=k(F.mark((function t(e,r,n,a){var s;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=e.functions[r]){t.next=3;break}throw new Error("invalid function");case 3:return t.next=5,s.apply(void 0,n.concat([a]));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),e.sendGaslessTransaction=function(){var t=k(F.mark((function t(e,r,n,a){var s,i,o,c,p,d,l,f;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.getSigner()||Zt(!1),t.next=4,this.getProvider();case 4:return t.sent||Zt(!1),t.next=8,this.getChainID();case 8:return i=t.sent,t.next=11,this.getSignerAddress();case 11:if(o=t.sent,c=this.address,!u.BigNumber.from((null==a?void 0:a.value)||0).gt(0)){t.next=16;break}throw new Error("Cannot send native token value with gasless transaction");case 16:return p=e.interface.encodeFunctionData(r,n),t.next=19,(s=e.estimateGas)[r].apply(s,n);case 19:return l=(d=t.sent).mul(2),d.lt(25e3)&&(l=u.BigNumber.from(5e5)),f={from:o,to:c,data:p,chainId:i,gasLimit:l,functionName:r,functionArgs:n,callOverrides:a},t.next=25,this.options.gaslessSendFunction(e,f);case 25:return t.abrupt("return",t.sent);case 27:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),e.signTypedDataEmitEvent=function(){var t=k(F.mark((function t(e,r,n,a){var s;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.sdk.event.emit(Ut.Signature,{status:"submitted",message:a,signature:s=""}),t.next=4,zt(e,r,n,a);case 4:return this.sdk.event.emit(Ut.Signature,{status:"completed",message:a,signature:s=t.sent.signature}),t.abrupt("return",s);case 9:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),e.parseEventLogs=function(t,e){if(!e)return null;for(var r,n=E(e);!(r=n()).done;){var a=r.value;try{return this.contract.interface.decodeEventLog(t,a.data,a.topics)}catch(t){}}return null},e.parseLogs=function(t,e,r){if(void 0===r&&(r=this.contract),!e||0===e.length)return[];var n=r.interface.getEventTopic(t);return e.filter((function(t){return t.topics.indexOf(n)>=0})).map((function(t){return r.interface.parseLog(t)}))},T(t,[{key:"providerOrSigner",get:function(){return this.signer||this._providerOrSigner||this.getProviderOrSigner()},set:function(t){this._providerOrSigner=t}},{key:"signer",get:function(){return this._signer},set:function(t){this._signer=t}}]),t}(),Yt=function(t){S(r,t);var e=r.prototype;function r(e,r,n,a){return t.call(this,e,r,n,a)||this}return e.getModuleRoles=function(){throw new Error("getModuleRoles has to be implemented by a subclass")},e.getRoleMembers=function(){var t=k(F.mark((function t(e){var r,n,a;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.roles.includes(e)||Zt(!1),r=this.readOnlyContract,n=qt(e),t.next=5,r.getRoleMemberCount(n);case 5:return a=t.sent.toNumber(),t.next=8,Promise.all(Array.from(Array(a).keys()).map((function(t){return r.getRoleMember(n,t)})));case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getAllRoleMembers=function(){var t=k(F.mark((function t(){var e,r,n,a;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.roles.length||Zt(!1),e={},r=E(this.roles);case 3:if((n=r()).done){t.next=10;break}return a=n.value,t.next=7,this.getRoleMembers(a);case 7:e[a]=t.sent;case 8:t.next=3;break;case 10:return t.abrupt("return",e);case 11:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.setAllRoleMembers=function(){var t=k(F.mark((function t(e){var r,n,a,s=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(r=Object.keys(e)).length||Zt(!1),r.every((function(t){return s.roles.includes(t)}))||Zt(!1),t.next=5,this.getAllRoleMembers();case 5:return n=t.sent,a=[],r.sort((function(t){return"admin"===t?1:-1})).forEach(function(){var t=k(F.mark((function t(r){var i,o,u,c;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=n[r]||[],u=(i=e[r]||[]).filter((function(t){return!o.includes(t)})),c=o.filter((function(t){return!i.includes(t)})),u.length&&u.forEach((function(t){a.push(s.contract.interface.encodeFunctionData("grantRole",[qt(r),t]))})),c.length&&c.forEach(function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.getRevokeRoleFunctionName(e);case 2:a.push(s.contract.interface.encodeFunctionData(t.sent,[qt(r),e]));case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),t.next=10,this.sendTransaction("multicall",[a]);case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.revokeAllRolesFromAddress=function(){var t=k(F.mark((function t(e){var r,n,a,s=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAllRoleMembers();case 2:return r=t.sent,n=[],a=[],Object.keys(r).sort((function(t){return"admin"===t?1:-1})).forEach(function(){var t=k(F.mark((function t(i){var o;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null==(o=r[i])||!o.includes(e)){t.next=6;break}return t.next=3,s.getRevokeRoleFunctionName(e);case 3:n.push(s.contract.interface.encodeFunctionData(t.sent,[qt(i),e])),a.push(i);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),t.next=8,this.sendTransaction("multicall",[n]);case 8:return t.abrupt("return",a);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.grantRole=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.roles.includes(e)||Zt(!1),t.next=3,this.sendTransaction("grantRole",[qt(e),r]);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.revokeRole=function(){var t=k(F.mark((function t(e,r){var n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.roles.includes(e)||Zt(!1),t.next=3,this.getRevokeRoleFunctionName(r);case 3:return n=t.sent,t.next=6,this.sendTransaction(n,[qt(e),r]);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.getRevokeRoleFunctionName=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getSignerAddress();case 2:if(t.sent.toLowerCase()!==e.toLowerCase()){t.next=5;break}return t.abrupt("return","renounceRole");case 5:return t.abrupt("return","revokeRole");case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.prepareMetadata=function(){var t=k(F.mark((function t(e){var r,n=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof e){t.next=2;break}return t.abrupt("return",e);case 2:return r=function(){var t=k(F.mark((function t(e){var a,s,i,o;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=Object.keys(e),t.t0=F.keys(a);case 2:if((t.t1=t.t0()).done){t.next=18;break}if(!(o=(i=e[a[s=t.t1.value]])instanceof File||i instanceof Buffer)){t.next=10;break}return t.next=9,n.sdk.getStorage().upload(e[a[s]]);case 9:e[a[s]]=t.sent;case 10:if(!o||"string"==typeof e[a[s]]){t.next=12;break}throw new Error("Upload to IPFS failed");case 12:if("object"!=typeof i){t.next=16;break}return t.next=15,r(e[a[s]]);case 15:e[a[s]]=t.sent;case 16:t.next=2;break;case 18:return t.abrupt("return",e);case 19:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.next=5,r(e);case 5:return e=t.sent,t.abrupt("return",JSON.stringify(e));case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),e.prepareBatchMetadata=function(){var t=k(F.mark((function t(e){var r=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map(function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.prepareMetadata(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),e.onlyRoles=function(){var t=k(F.mark((function t(e,r){var n=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map(function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.getRoleMembers(e);case 2:if(t.sent.map((function(t){return t.toLowerCase()})).includes(r.toLowerCase())){t.next=5;break}throw new D(r,e);case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 2:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),T(r,[{key:"roles",get:function(){return this.getModuleRoles()}}]),r}(Qt),Xt=[{name:"to",type:"address"},{name:"royaltyRecipient",type:"address"},{name:"royaltyBps",type:"uint256"},{name:"primarySaleRecipient",type:"address"},{name:"tokenId",type:"uint256"},{name:"uri",type:"string"},{name:"quantity",type:"uint256"},{name:"pricePerToken",type:"uint256"},{name:"currency",type:"address"},{name:"validityStartTimestamp",type:"uint128"},{name:"validityEndTimestamp",type:"uint128"},{name:"uid",type:"bytes32"}],$t=function(t){function e(){return t.apply(this,arguments)||this}S(e,t);var r=e.prototype;return r.getModuleRoles=function(){return e.roles},r.connectContract=function(){return s.SignatureMint1155__factory.connect(this.address,this.providerOrSigner)},r.getModuleType=function(){return e.moduleType},r.get=function(){var t=k(F.mark((function t(e,r){var n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=Promise,t.t1=Et(this.readOnlyContract,e,this.sdk.getStorage()),t.t2=this.readOnlyContract.totalSupply(e).catch((function(){return p.BigNumber.from("0")})),!r){t.next=9;break}return t.next=6,this.balanceOf(r,e);case 6:t.t3=t.sent.toNumber(),t.next=10;break;case 9:t.t3=0;case 10:return t.t4=t.t3,t.t5=[t.t1,t.t2,t.t4],t.next=14,t.t0.all.call(t.t0,t.t5);case 14:return t.abrupt("return",{supply:(n=t.sent)[1],metadata:n[0],quantityOwnedByAddress:p.BigNumber.from(n[2])});case 19:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.getAll=function(){var t=k(F.mark((function t(e){var r,n=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.nextTokenIdToMint();case 2:return r=t.sent.toNumber(),t.next=5,Promise.all(Array.from(Array(r).keys()).map((function(t){return n.get(t.toString(),e)})));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.balanceOf=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.balanceOf(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.balance=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this.readOnlyContract,t.next=3,this.getSignerAddress();case 3:return t.t1=t.sent,t.t2=e,t.next=7,t.t0.balanceOf.call(t.t0,t.t1,t.t2);case 7:return t.abrupt("return",t.sent);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.isApproved=function(){var t=k(F.mark((function t(e,r,n,a){var i,o,u;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n){t.next=4;break}return t.next=3,this.readOnlyContract.isApprovedForAll(e,r);case 3:return t.abrupt("return",t.sent);case 4:if(a){t.next=6;break}throw new Error("tokenId is required");case 6:return i=s.ERC721__factory.connect(n,this.providerOrSigner),t.t0=i,t.next=10,this.getSignerAddress();case 10:return t.t1=t.sent,t.t2=this.address,t.next=14,t.t0.isApprovedForAll.call(t.t0,t.t1,t.t2);case 14:return o=t.sent,t.next=17,i.getApproved(a);case 17:return t.t3=t.sent.toLowerCase(),t.t4=this.address.toLowerCase(),u=t.t3===t.t4,t.abrupt("return",o||u);case 21:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),r.setApproval=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=!0),t.next=3,this.sendTransaction("setApprovalForAll",[e,r]);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.transfer=function(){var t=k(F.mark((function t(e,r,n){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this.getSignerAddress();case 3:return t.t1=t.sent,t.t2=e,t.t3={tokenId:r,amount:n},t.t4=[0],t.next=9,t.t0.transferFrom.call(t.t0,t.t1,t.t2,t.t3,t.t4);case 9:return t.abrupt("return",t.sent);case 10:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.createAndMint=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this.getSignerAddress();case 3:return t.t1=t.sent,t.t2=e,t.next=7,t.t0.createAndMintTo.call(t.t0,t.t1,t.t2);case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.createAndMintTo=function(){var t=k(F.mark((function t(e,r){var n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sdk.getStorage().uploadMetadata(r.metadata);case 2:return n=t.sent,t.next=5,this.sendTransaction("mintTo",[e,u.ethers.constants.MaxUint256,n,r.supply]);case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.createAndMintBatch=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this.getSignerAddress();case 3:return t.t1=t.sent,t.t2=e,t.next=7,t.t0.createAndMintBatchTo.call(t.t0,t.t1,t.t2);case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.createAndMintBatchTo=function(){var t=k(F.mark((function t(e,r){var n,a,s,i=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.map((function(t){return t.metadata})),a=r.map((function(t){return t.supply})),t.next=4,this.sdk.getStorage().uploadMetadataBatch(n);case 4:return s=t.sent.metadataUris.map((function(t,r){return i.readOnlyContract.interface.encodeFunctionData("mintTo",[e,u.ethers.constants.MaxUint256,t,a[r]])})),t.next=9,this.sendTransaction("multicall",[s]);case 9:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.mintAdditionalCopiesTo=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("mintTo",[e,r.tokenId,"",r.amount]);case 2:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.mintAdditionalCopiesBatchTo=function(){var t=k(F.mark((function t(e,r){var n,a,s,i=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.map((function(t){return t.tokenId})),a=r.map((function(t){return t.amount})),s=n.map((function(t,r){return i.readOnlyContract.interface.encodeFunctionData("mintTo",[e,t,"",a[r]])})),t.next=5,this.sendTransaction("multicall",[s]);case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.burn=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this.getSignerAddress();case 3:return t.t1=t.sent,t.t2=e,t.next=7,t.t0.burnFrom.call(t.t0,t.t1,t.t2);case 7:return t.abrupt("return",t.sent);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.burnBatch=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this.getSignerAddress();case 3:return t.t1=t.sent,t.t2=e,t.next=7,t.t0.burnBatchFrom.call(t.t0,t.t1,t.t2);case 7:return t.abrupt("return",t.sent);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.burnFrom=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("burn",[e,r.tokenId,r.amount]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.burnBatchFrom=function(){var t=k(F.mark((function t(e,r){var n,a;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.map((function(t){return t.tokenId})),a=r.map((function(t){return t.amount})),t.next=4,this.sendTransaction("burnBatch",[e,n,a]);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.transferFrom=function(){var t=k(F.mark((function t(e,r,n,a){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===a&&(a=[0]),t.next=3,this.sendTransaction("safeTransferFrom",[e,r,n.tokenId,n.amount,a]);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),r.transferBatchFrom=function(){var t=k(F.mark((function t(e,r,n,a){var s,i;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===a&&(a=[0]),s=n.map((function(t){return t.tokenId})),i=n.map((function(t){return t.amount})),t.next=5,this.sendTransaction("safeBatchTransferFrom",[e,r,s,i,a]);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),r.setDefaultRoyaltyInfo=function(){var t=k(F.mark((function t(e,r){var n,a,s;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getMetadata(!1);case 2:if(a=[],n=t.sent.metadata){t.next=7;break}throw new Error("No metadata found, this module might be invalid!");case 7:return n.fee_recipient=e,n.seller_fee_basis_points=r,t.t0=this.sdk.getStorage(),t.t1=M({},n),t.t2=this.address,t.next=14,this.getSignerAddress();case 14:return t.t3=t.sent,t.next=17,t.t0.uploadMetadata.call(t.t0,t.t1,t.t2,t.t3);case 17:return s=t.sent,a.push(this.contract.interface.encodeFunctionData("setDefaultRoyaltyInfo",[e,r])),a.push(this.contract.interface.encodeFunctionData("setContractURI",[s])),t.next=22,this.sendTransaction("multicall",[a]);case 22:return t.abrupt("return",t.sent);case 23:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.setTokenRoyaltyInfo=function(){var t=k(F.mark((function t(e,r,n){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("setRoyaltyInfoForToken",[e,r,n]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.setModuleMetadata=function(){var t=k(F.mark((function t(e){var r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sdk.getStorage().uploadMetadata(e);case 2:return r=t.sent,t.next=5,this.sendTransaction("setContractURI",[r]);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getOwned=function(){var t=k(F.mark((function t(e){var r,n,a,s=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e){t.next=4;break}t.t0=e,t.next=7;break;case 4:return t.next=6,this.getSignerAddress();case 6:t.t0=t.sent;case 7:return r=t.t0,t.next=10,this.readOnlyContract.nextTokenIdToMint();case 10:return n=t.sent,t.next=13,this.readOnlyContract.balanceOfBatch(Array(n.toNumber()).fill(r),Array.from(Array(n.toNumber()).keys()));case 13:return a=t.sent.map((function(t,e){return{tokenId:e,balance:t}})).filter((function(t){return t.balance.gt(0)})),t.next=17,Promise.all(a.map(function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.get(e.tokenId.toString());case 2:return t.abrupt("return",M({},t.sent,{ownedByAddress:e.balance}));case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 17:return t.abrupt("return",t.sent);case 18:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getDefaultRoyaltyInfo=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.getDefaultRoyaltyInfo();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getTokenRoyaltyInfo=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.getRoyaltyInfoForToken(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.isTransferRestricted=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.readOnlyContract.transfersRestricted());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.setRestrictedTransfer=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e=!1),t.t0=this,t.t1=["admin"],t.next=5,this.getSignerAddress();case 5:return t.t2=t.sent,t.next=8,t.t0.onlyRoles.call(t.t0,t.t1,t.t2);case 8:return t.next=10,this.sendTransaction("setRestrictedTransfer",[e]);case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.mintWithSignature=function(){var t=k(F.mark((function t(e,r){var n,a,s,i;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=M({},this.mapPayload(e),{uri:e.uri}),t.next=3,this.getCallOverrides();case 3:return a=t.sent,t.next=6,this.setAllowance(p.BigNumber.from(n.pricePerToken).mul(e.quantity),e.currencyAddress,a);case 6:return t.next=8,this.sendTransaction("mintWithSignature",[n,r],a);case 8:return s=t.sent,t.next=11,this.parseLogs("MintWithSignature",s.logs);case 11:if(0!==(i=t.sent).length){t.next=14;break}throw new Error("No MintWithSignature event found");case 14:return t.abrupt("return",i[0].args.tokenIdMinted);case 15:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.verify=function(){var t=k(F.mark((function t(e,r){var n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.mapPayload(e),t.next=3,this.readOnlyContract.verify(M({},n,{uri:e.uri}),r);case 3:return t.abrupt("return",t.sent[0]);case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.generateSignatureBatch=function(){var t=k(F.mark((function t(e){var r,a,s,i,o=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=function(t){if(void 0===t.id){var e=Buffer.alloc(16);return l.v4({},e),n.hexlify(d.toUtf8Bytes(e.toString("hex")))}return n.hexlify(t.id)},t.t0=this,t.t1=["minter"],t.next=5,this.getSignerAddress();case 5:return t.t2=t.sent,t.next=8,t.t0.onlyRoles.call(t.t0,t.t1,t.t2);case 8:return t.next=10,this.sdk.getStorage().uploadMetadataBatch(e.map((function(t){return t.metadata})));case 10:return a=t.sent.metadataUris,t.next=14,this.getChainID();case 14:return s=t.sent,i=this.getSigner(),t.next=18,Promise.all(e.map(function(){var t=k(F.mark((function t(e,n){var u,c;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=r(e),t.t0=M({},e,{id:u,uri:c=a[n]}),t.next=5,o.signTypedDataEmitEvent(i,{name:"SignatureMint1155",version:"1",chainId:s,verifyingContract:o.address},{MintRequest:Xt},M({uri:c},o.mapPayload(e),{uid:u}));case 5:return t.t1=t.sent.toString(),t.abrupt("return",{payload:t.t0,signature:t.t1});case 7:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()));case 18:return t.abrupt("return",t.sent);case 19:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.generateSignature=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.generateSignatureBatch([e]);case 2:return t.abrupt("return",t.sent[0]);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.mapPayload=function(t){return{to:t.to,royaltyRecipient:t.royaltyRecipient,royaltyBps:t.royaltyBps,primarySaleRecipient:t.primarySaleRecipient,tokenId:t.tokenId,quantity:t.quantity,pricePerToken:t.price,currency:t.currencyAddress,validityEndTimestamp:t.mintEndTimeEpochSeconds,validityStartTimestamp:t.mintStartTimeEpochSeconds,uid:t.id}},r.setAllowance=function(){var t=k(F.mark((function t(e,r,n){var a,o,u,c;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r!==xt&&r!==i.AddressZero){t.next=4;break}n.value=e,t.next=16;break;case 4:return a=s.ERC20__factory.connect(r,this.providerOrSigner),t.next=7,this.getSignerAddress();case 7:return o=t.sent,u=this.address,t.next=11,a.allowance(o,u);case 11:if(!(c=t.sent).lt(e)){t.next=15;break}return t.next=15,this.sendContractTransaction(a,"increaseAllowance",[u,e.sub(c)]);case 15:return t.abrupt("return",n);case 16:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e}(Yt);$t.moduleType=exports.ModuleType.BUNDLE_SIGNATURE,$t.roles=[Vt.admin,Vt.minter,Vt.pauser,Vt.transfer];var te=((Kt={})[it.Mainnet]={registry:"0x902a29f2cfe9f8580ad672AaAD7E917d85ca9a2E",biconomyForwarder:"0x84a0856b038eaAd1cC7E297cF34A7e72685A8693"},Kt[it.Rinkeby]={registry:"0x902a29f2cfe9f8580ad672AaAD7E917d85ca9a2E",biconomyForwarder:"0xFD4973FeB2031D4409fB57afEE5dF2051b171104"},Kt[it.Polygon]={registry:"0x902a29f2cfe9f8580ad672AaAD7E917d85ca9a2E",biconomyForwarder:"0x86C80a8aa58e0A4fa09A69624c31Ab2a6CAD56b8"},Kt[it.Mumbai]={registry:"0x902a29f2cfe9f8580ad672AaAD7E917d85ca9a2E",biconomyForwarder:"0x9399BB24DBB5C4b782C70c2969F58716Ebbd6a3b"},Kt[it.Avalanche]={registry:"0x902a29f2cfe9f8580ad672AaAD7E917d85ca9a2E",biconomyForwarder:"0x64CD353384109423a966dCd3Aa30D884C9b2E057"},Kt[it.AvalancheFujiTestnet]={registry:"0x902a29f2cfe9f8580ad672AaAD7E917d85ca9a2E",biconomyForwarder:"0x6271Ca63D30507f2Dcbf99B52787032506D75BBF"},Kt[it.Fantom]={registry:"0x902a29f2cfe9f8580ad672AaAD7E917d85ca9a2E",biconomyForwarder:u.ethers.constants.AddressZero},Kt[it.FantomTestnet]={registry:"0x902a29f2cfe9f8580ad672AaAD7E917d85ca9a2E",biconomyForwarder:u.ethers.constants.AddressZero},Kt[it.Hardhat]={registry:"0x902a29f2cfe9f8580ad672AaAD7E917d85ca9a2E",biconomyForwarder:u.ethers.constants.AddressZero},Kt);function ee(t,e){return void 0===e&&(e="registry"),te[t][e]}var re=[{name:"from",type:"address"},{name:"to",type:"address"},{name:"value",type:"uint256"},{name:"gas",type:"uint256"},{name:"nonce",type:"uint256"},{name:"data",type:"bytes"}],ne=[{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"uint256",name:"batchId",type:"uint256"}],name:"getNonce",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],ae={},se={};function ie(t,e,r){return oe.apply(this,arguments)}function oe(){return(oe=k(F.mark((function t(e,r,n){var a,s,i,o,c,p;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=n.join("|"),s=se[a],i=Date.now()-s>=2e3,a in ae&&!i){t.next=9;break}return t.next=6,(o=e.functions)[r].apply(o,n);case 6:c=t.sent,ae[a]=Array.isArray(c)&&c.length>0?u.BigNumber.from(c[0]):u.BigNumber.from(c),se[a]=Date.now();case 9:return p=ae[a],ae[a]=u.BigNumber.from(ae[a]).add(1),t.abrupt("return",p);case 12:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ue=[{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}],ce=[{constant:!0,inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{inputs:[],name:"getDomainSeperator",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"}],pe=[{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"user",type:"address"}],name:"getNonce",outputs:[{internalType:"uint256",name:"nonce",type:"uint256"}],stateMutability:"view",type:"function"}];function de(t,e){return le.apply(this,arguments)}function le(){return(le=k(F.mark((function t(e,r){var n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new u.Contract(r,pe,e),t.prev=1,t.t0=n,t.next=5,e.getAddress();case 5:return t.t1=t.sent,t.next=8,t.t0.nonces.call(t.t0,t.t1);case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t2=t.catch(1),t.t3=n,t.next=16,e.getAddress();case 16:return t.t4=t.sent,t.next=19,t.t3.getNonce.call(t.t3,t.t4);case 19:return t.abrupt("return",t.sent);case 20:case"end":return t.stop()}}),t,null,[[1,11]])})))).apply(this,arguments)}function fe(t,e){return he.apply(this,arguments)}function he(){return(he=k(F.mark((function t(e,r){var n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new u.Contract(r,ce,e),t.prev=1,t.next=4,n.DOMAIN_SEPARATOR();case 4:return t.abrupt("return",t.sent);case 7:return t.prev=7,t.t0=t.catch(1),t.next=11,n.getDomainSeperator();case 11:return t.abrupt("return",t.sent);case 12:case"end":return t.stop()}}),t,null,[[1,7]])})))).apply(this,arguments)}function me(t,e){return ye.apply(this,arguments)}function ye(){return(ye=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new u.Contract(r,ue,e).name());case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function xe(t,e){return ve.apply(this,arguments)}function ve(){return(ve=k(F.mark((function t(e,r){var n,a;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fe(e,r.verifyingContract);case 2:if(n=t.sent,a={name:r.name,version:r.version,verifyingContract:r.verifyingContract,salt:u.ethers.utils.hexZeroPad(u.BigNumber.from(r.chainId).toHexString(),32)},u.ethers.utils._TypedDataEncoder.hashDomain(a)!==n){t.next=6;break}return t.abrupt("return",a);case 6:return t.abrupt("return",r);case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function ge(t,e,r,n,a,s,i){return be.apply(this,arguments)}function be(){return(be=k(F.mark((function t(e,r,n,a,s,i,o){var c,p,d,l,f;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=xe,t.t1=e,t.next=4,me(e,r);case 4:return t.t2=t.sent,t.next=7,e.getChainId();case 7:return t.t3=t.sent,t.t4=r,t.t5={name:t.t2,version:"1",chainId:t.t3,verifyingContract:t.t4},t.next=12,(0,t.t0)(t.t1,t.t5);case 12:if(d=t.sent,null==(c=o)){t.next=17;break}t.t6=c,t.next=20;break;case 17:return t.next=19,de(e,r);case 19:t.t6=t.sent.toString();case 20:return i=null!=(p=i)?p:u.ethers.constants.MaxUint256,l={owner:n,spender:a,value:s,nonce:o=t.t6,deadline:i},f={Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},t.next=26,zt(e,d,f,l);case 26:return t.abrupt("return",{message:l,signature:t.sent.signature});case 29:case"end":return t.stop()}}),t)})))).apply(this,arguments)}exports.CommonModuleMetadata=function(){this.name="",this.description=void 0,this.image=void 0,this.externalLink=void 0},v.__decorate([m.JsonProperty("name",String)],exports.CommonModuleMetadata.prototype,"name",void 0),v.__decorate([m.JsonProperty("description",String,m.PropertyConvertingMode.IGNORE_NULLABLE)],exports.CommonModuleMetadata.prototype,"description",void 0),v.__decorate([m.JsonProperty("image",String,m.PropertyConvertingMode.IGNORE_NULLABLE)],exports.CommonModuleMetadata.prototype,"image",void 0),v.__decorate([m.JsonProperty("external_link",String,m.PropertyConvertingMode.IGNORE_NULLABLE)],exports.CommonModuleMetadata.prototype,"externalLink",void 0),exports.CommonModuleMetadata=v.__decorate([m.JsonObject("CommonModuleMetadata")],exports.CommonModuleMetadata);var we=exports.CommonModuleMetadata;exports.BundleDropModuleMetadata=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),a=0;a=Date.now()/1e3||Zt(!1),s=function(){var t=k(F.mark((function t(){var e,n,a,s,i;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=[],t.next=3,r.getBlock("latest");case 3:n=t.sent,a=0;case 5:if(!(a<5)){t.next=17;break}return t.next=8,r.getBlock(n.number-a);case 8:return s=t.sent,t.next=11,r.getBlock(n.number-a-1);case 11:e.push(s.timestamp-t.sent.timestamp);case 14:a++,t.next=5;break;case 17:return i=e.reduce((function(t,e){return t+e}),0),t.abrupt("return",i/e.length);case 19:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),!Te[a].synced){t.next=9;break}return t.abrupt("return",Te[a].secondsBetweenBlocks);case 9:return t.next=11,r.getBlock("latest");case 11:return i=t.sent,t.prev=12,t.next=15,s();case 15:Te[a]={synced:!0,secondsBetweenBlocks:o=t.sent},t.next=22;break;case 19:t.prev=19,t.t0=t.catch(12),o=Te[a].secondsBetweenBlocks;case 22:return console.log("Seconds until block",n),u=Math.ceil(n/o),t.abrupt("return",i.number+u);case 25:case"end":return t.stop()}}),t,null,[[12,19]])})))).apply(this,arguments)}var Se=function(t){function e(){return t.apply(this,arguments)||this}S(e,t);var r=e.prototype;return r.getModuleRoles=function(){return e.roles},r.connectContract=function(){return s.Coin__factory.connect(this.address,this.providerOrSigner)},r.getModuleType=function(){return e.moduleType},r.get=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,gt(this.providerOrSigner,this.address);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getValue=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,wt(this.providerOrSigner,this.address,u.BigNumber.from(e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.totalSupply=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.totalSupply();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.balance=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this.getSignerAddress();case 3:return t.t1=t.sent,t.next=6,t.t0.balanceOf.call(t.t0,t.t1);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.balanceOf=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this.readOnlyContract.balanceOf(e);case 3:return t.t1=t.sent,t.next=6,t.t0.getValue.call(t.t0,t.t1);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.allowance=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this.getSignerAddress();case 3:return t.t1=t.sent,t.t2=e,t.next=7,t.t0.allowanceOf.call(t.t0,t.t1,t.t2);case 7:return t.abrupt("return",t.sent);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.allowanceOf=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.allowance(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.getVoteBalance=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this.getSignerAddress();case 3:return t.t1=t.sent,t.next=6,t.t0.getVoteBalanceOf.call(t.t0,t.t1);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getVoteBalanceOf=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.getVotes(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getDelegation=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this.getSignerAddress();case 3:return t.t1=t.sent,t.next=6,t.t0.getDelegationOf.call(t.t0,t.t1);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getDelegationOf=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.delegates(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.delegateTo=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("delegate",[e]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.transfer=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("transfer",[e,r]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.setAllowance=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("approve",[e,r]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.mint=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this.getSignerAddress();case 3:return t.t1=t.sent,t.t2=e,t.next=7,t.t0.mintTo.call(t.t0,t.t1,t.t2);case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.mintTo=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("mint",[e,r]);case 2:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.mintBatchTo=function(){var t=k(F.mark((function t(e){var r,n,a,s;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r=[],n=E(e);!(a=n()).done;)r.push(this.contract.interface.encodeFunctionData("mint",[(s=a.value).address,s.amount]));return t.next=4,this.sendTransaction("multicall",[r]);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getAllHolderBalances=function(){var t=k(F.mark((function t(){var e,r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.contract.queryFilter(this.contract.filters.Transfer());case 2:return e=t.sent.map((function(t){return t.args})),r={},e.forEach((function(t){var e=t.from,n=t.to,a=t.value;e!==i.AddressZero&&(e in r||(r[e]=u.BigNumber.from(0)),r[e]=r[e].sub(a)),n!==i.AddressZero&&(n in r||(r[n]=u.BigNumber.from(0)),r[n]=r[n].add(a))})),t.abrupt("return",r);case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.burn=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("burn",[e]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.burnFrom=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("burnFrom",[e,r]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.transferFrom=function(){var t=k(F.mark((function t(e,r,n){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("transferFrom",[e,r,n]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.setModuleMetadata=function(){var t=k(F.mark((function t(e){var r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sdk.getStorage().uploadMetadata(e);case 2:return r=t.sent,t.next=5,this.sendTransaction("setContractURI",[r]);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.transferBatch=function(){var t=k(F.mark((function t(e){var r,n=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.map((function(t){return n.contract.interface.encodeFunctionData("transfer",[t.address,t.amount])})),t.next=3,this.sendTransaction("multicall",[r]);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.transferFromBatch=function(){var t=k(F.mark((function t(e){var r,n=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.map((function(t){return n.contract.interface.encodeFunctionData("transferFrom",[t.fromAddress,t.address,t.amount])})),t.next=3,this.sendTransaction("multicall",[r]);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.isTransferRestricted=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.readOnlyContract.transfersRestricted());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.setRestrictedTransfer=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e=!1),t.t0=this,t.t1=["admin"],t.next=5,this.getSignerAddress();case 5:return t.t2=t.sent,t.next=8,t.t0.onlyRoles.call(t.t0,t.t1,t.t2);case 8:return t.next=10,this.sendTransaction("setRestrictedTransfer",[e]);case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e}(Yt);Se.moduleType=exports.ModuleType.CURRENCY,Se.roles=[Vt.admin,Vt.minter,Vt.pauser,Vt.transfer];var Ae=function(t){function e(){return t.apply(this,arguments)||this}return S(e,t),e}(Se),Oe=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),a=0;a=0&&e.votingQuorumFraction<=100||Zt(!1),t.next=4,this.getChainID();case 4:return n=e.proposalVotingTimeInSeconds/(r=Te[t.sent]).secondsBetweenBlocks,e.votingDelay=e.proposalStartWaitTimeInSeconds/r.secondsBetweenBlocks,e.votingPeriod=n,t.prev=10,t.next=13,s.Coin__factory.connect(e.votingTokenAddress,this.readOnlyContract.provider).callStatic.getPastTotalSupply(0);case 13:t.next=18;break;case 15:t.prev=15,t.t0=t.catch(10),Zt(!1);case 18:return t.t1=this.jsonConvert,t.next=21,this._prepareMetadata(e);case 21:return t.t2=t.sent,t.t3=exports.VoteModuleMetadata,a=t.t1.serializeObject.call(t.t1,t.t2,t.t3),t.t4=this.sdk.getStorage(),t.t5=a,t.t6=this.address,t.next=29,this.getSignerAddress();case 29:return t.t7=t.sent,t.next=32,t.t4.uploadMetadata.call(t.t4,t.t5,t.t6,t.t7);case 32:return i=t.sent,t.t8=this,t.t9=exports.ModuleType.VOTE,t.t10=e.name,t.t11=e.votingTokenAddress,t.t12=u.BigNumber.from(Math.ceil(e.votingDelay)),t.t13=u.BigNumber.from(Math.ceil(e.votingPeriod)),t.t14=u.BigNumber.from(e.minimumNumberOfTokensNeededToPropose),t.t15=e.votingQuorumFraction,t.next=43,this.getForwarder();case 43:return t.t16=t.sent,t.t17=i,t.t18=[t.t10,t.t11,t.t12,t.t13,t.t14,t.t15,t.t16,t.t17],t.t19=s.VotingGovernor__factory,t.next=49,t.t8._deployModule.call(t.t8,t.t9,t.t18,t.t19);case 49:return t.abrupt("return",this.sdk.getVoteModule(t.sent));case 51:case"end":return t.stop()}}),t,this,[[10,15]])})));return function(e){return t.apply(this,arguments)}}(),r.shouldUpgradeToV2=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV1();case 2:if(t.t0=t.sent,!t.t0){t.next=5;break}t.t0=this.hasValidSigner();case 5:if(!t.t0){t.next=23;break}return t.t1=this.readOnlyContract,t.t2=u.ethers.utils.hexZeroPad([0],32),t.next=10,this.getSignerAddress();case 10:return t.t3=t.sent,t.next=13,t.t1.hasRole.call(t.t1,t.t2,t.t3);case 13:if(t.t4=t.sent,!t.t4){t.next=21;break}return t.next=18,this.getRoyaltyTreasury();case 18:t.t5=t.sent,t.t6=this.address,t.t4=t.t5===t.t6;case 21:if(!t.t4){t.next=23;break}return t.abrupt("return",!0);case 23:return t.abrupt("return",!1);case 24:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.shouldUpgradeModuleList=function(){var t=k(F.mark((function t(){var e=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV1();case 2:if(t.sent){t.next=4;break}return t.abrupt("return",[]);case 4:return t.next=6,this.getRoyaltyTreasury();case 6:if(t.t0=t.sent,t.t1=this.address,t.t0!==t.t1){t.next=10;break}return t.abrupt("return",[]);case 10:return t.next=12,this.getAllModuleMetadata([exports.ModuleType.NFT,exports.ModuleType.BUNDLE,exports.ModuleType.PACK,exports.ModuleType.DROP,exports.ModuleType.BUNDLE_DROP],!1);case 12:return t.abrupt("return",t.sent.filter((function(t){var r,n;return(null==(r=t.metadata)||null==(n=r.fee_recipient)?void 0:n.toLowerCase())===e.address.toLowerCase()})));case 14:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.upgradeModuleList=function(){var t=k(F.mark((function t(e){var r,n,a,s,i,o,u,c,p=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(r=this.getSigner())||Zt(!1),t.next=4,this.shouldUpgradeModuleList();case 4:return n=t.sent.filter((function(t){return e.includes(t.address)})),t.next=8,this.getRoyaltyTreasury();case 8:return a=t.sent,t.next=11,Promise.all(n.map((function(t){return p.sdk.getStorage().uploadMetadata(M({},t.metadata,{fee_recipient:a}))})));case 11:return s=t.sent,t.next=14,r.getTransactionCount("pending");case 14:return i=t.sent,o=s.map((function(t){return p.contract.interface.encodeFunctionData("setContractURI",[t])})),u=o.map((function(t,e){return{to:n[e].address,nonce:i+e,data:t}})),t.next=19,Promise.all(u.map((function(t){return r.sendTransaction(t)})));case 19:return c=t.sent,t.next=22,Promise.all(c.map((function(t){return t.wait()})));case 22:return t.abrupt("return",t.sent);case 23:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.upgradeToV2=function(){var t=k(F.mark((function t(e){var r,n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e={}),t.next=3,this.isV1UpgradedOrV2();case 3:if(!t.sent){t.next=5;break}return t.abrupt("return");case 5:if(r="",!e.splitsModuleAddress){t.next=10;break}r=e.splitsModuleAddress,t.next=22;break;case 10:if(e.splitsRecipients){t.next=16;break}return t.next=13,this.getSignerAddress();case 13:t.t0=t.sent,t.t1={address:t.t0,shares:100},e.splitsRecipients=[t.t1];case 16:return t.next=18,this.getMetadata();case 18:return n=t.sent.metadata,t.next=21,this.deploySplitsModule({name:(null==n?void 0:n.name)+" Royalty Treasury",recipientSplits:e.splitsRecipients,isRoyalty:!0});case 21:r=t.sent.address;case 22:return t.next=24,this.setRoyaltyTreasury(r);case 24:return t.abrupt("return",t.sent);case 25:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.balance=function(){var t=k(F.mark((function t(){var e,r,n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.provider.getBalance(this.address);case 2:return e=t.sent,r=u.BigNumber.from(0),t.next=6,this.getRoyaltyTreasury();case 6:if((n=t.sent).toLowerCase()===this.address.toLowerCase()){t.next=11;break}return t.next=10,this.readOnlyContract.provider.getBalance(n);case 10:r=t.sent;case 11:return t.abrupt("return",e.add(r));case 12:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.balanceOfToken=function(){var t=k(F.mark((function t(e){var r,n,a;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=u.BigNumber.from(0),!Ct(e)){t.next=7;break}return t.next=4,this.balance();case 4:r=t.sent,t.next=39;break;case 7:return n=s.IERC20__factory.connect(e,this.readOnlyContract.provider),t.next=10,this.isV1();case 10:if(t.sent){t.next=23;break}return t.prev=11,t.t0=r,t.next=15,n.balanceOf(this.address);case 15:t.t1=t.sent,r=t.t0.add.call(t.t0,t.t1),t.next=23;break;case 19:throw t.prev=19,t.t2=t.catch(11),console.error(t.t2),new Error("invalid token address");case 23:return t.next=25,this.getRoyaltyTreasury();case 25:if((a=t.sent).toLowerCase()===this.address.toLowerCase()){t.next=39;break}return t.prev=27,t.t3=r,t.next=31,n.balanceOf(a);case 31:t.t4=t.sent,r=t.t3.add.call(t.t3,t.t4),t.next=39;break;case 35:throw t.prev=35,t.t5=t.catch(27),console.error(t.t5),new Error("invalid token address");case 39:return t.next=41,wt(this.providerOrSigner,e,r);case 41:return t.abrupt("return",t.sent);case 42:case"end":return t.stop()}}),t,this,[[11,19],[27,35]])})));return function(e){return t.apply(this,arguments)}}(),r.isV1=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._shouldCheckVersion){t.next=11;break}return t.prev=1,t.next=4,this.readOnlyContract.callStatic.version();case 4:this._isV1=!1,t.next=10;break;case 7:t.prev=7,t.t0=t.catch(1),this._isV1=!0;case 10:this._shouldCheckVersion=!1;case 11:return t.abrupt("return",this._isV1);case 12:case"end":return t.stop()}}),t,this,[[1,7]])})));return function(){return t.apply(this,arguments)}}(),r.isV1UpgradedOrV2=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV1();case 2:if(t.t0=!t.sent,t.t0){t.next=7;break}return t.next=6,this.shouldUpgradeToV2();case 6:t.t0=!t.sent;case 7:return t.abrupt("return",t.t0);case 8:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.deployMarketplaceModule=function(){var t=k(F.mark((function t(e){var r,n,a;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this.jsonConvert,t.next=3,this._prepareMetadata(e);case 3:return t.t1=t.sent,t.t2=Ce,r=t.t0.serializeObject.call(t.t0,t.t1,t.t2),t.t3=this.sdk.getStorage(),t.t4=r,t.t5=this.address,t.next=11,this.getSignerAddress();case 11:return t.t6=t.sent,t.next=14,t.t3.uploadMetadata.call(t.t3,t.t4,t.t5,t.t6);case 14:return n=t.sent,t.t7=At,t.next=18,this.getChainID();case 18:return t.t8=t.sent,a=(0,t.t7)(t.t8).wrapped.address,t.t9=this,t.t10=exports.ModuleType.MARKETPLACE,t.t11=this.address,t.next=25,this.getForwarder();case 25:return t.t12=t.sent,t.t13=a,t.t14=n,t.t15=e.marketFeeBasisPoints,t.t16=[t.t11,t.t12,t.t13,t.t14,t.t15],t.t17=s.Marketplace__factory,t.next=33,t.t9._deployModule.call(t.t9,t.t10,t.t16,t.t17);case 33:return t.abrupt("return",this.sdk.getMarketplaceModule(t.sent));case 35:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e}(Yt);Oe.roles=[Vt.admin];var Re,Pe,_e,Be,Ee,Ne=function(t){function e(){return t.apply(this,arguments)||this}S(e,t);var r=e.prototype;return r.getModuleRoles=function(){return e.roles},r.connectContract=function(){return s.NFTCollection__factory.connect(this.address,this.providerOrSigner)},r.getModuleType=function(){return e.moduleType},r.get=function(){var t=k(F.mark((function t(e,r){var n,a;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=Promise,t.t1=Et(this.readOnlyContract,e,this.sdk.getStorage()),t.t2=this.readOnlyContract.totalSupply(e).catch((function(){return p.BigNumber.from("0")})),!r){t.next=9;break}return t.next=6,this.balanceOf(r,e);case 6:t.t3=t.sent.toNumber(),t.next=10;break;case 9:t.t3=0;case 10:return t.t4=t.t3,t.t5=this.readOnlyContract.tokenState(e),t.t6=[t.t1,t.t2,t.t4,t.t5],t.next=15,t.t0.all.call(t.t0,t.t6);case 15:return t.abrupt("return",{creator:(a=(n=t.sent)[3]).creator,supply:n[1],metadata:n[0],ownedByAddress:p.BigNumber.from(n[2]),underlyingType:a.underlyingType});case 21:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.getAll=function(){var t=k(F.mark((function t(e){var r,n=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.nextTokenId();case 2:return r=t.sent.toNumber(),t.next=5,Promise.all(Array.from(Array(r).keys()).map((function(t){return n.get(t.toString(),e)})));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.balanceOf=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.balanceOf(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.balance=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this.readOnlyContract,t.next=3,this.getSignerAddress();case 3:return t.t1=t.sent,t.t2=e,t.next=7,t.t0.balanceOf.call(t.t0,t.t1,t.t2);case 7:return t.abrupt("return",t.sent);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.isApproved=function(){var t=k(F.mark((function t(e,r,n,a){var i,o,u;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n){t.next=4;break}return t.next=3,this.readOnlyContract.isApprovedForAll(e,r);case 3:return t.abrupt("return",t.sent);case 4:if(a){t.next=6;break}throw new Error("tokenId is required");case 6:return i=s.ERC721__factory.connect(n,this.providerOrSigner),t.t0=i,t.next=10,this.getSignerAddress();case 10:return t.t1=t.sent,t.t2=this.address,t.next=14,t.t0.isApprovedForAll.call(t.t0,t.t1,t.t2);case 14:return o=t.sent,t.next=17,i.getApproved(a);case 17:return t.t3=t.sent.toLowerCase(),t.t4=this.address.toLowerCase(),u=t.t3===t.t4,t.abrupt("return",o||u);case 21:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),r.setApproval=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=!0),t.next=3,this.sendTransaction("setApprovalForAll",[e,r]);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.transfer=function(){var t=k(F.mark((function t(e,r,n){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this.getSignerAddress();case 3:return t.t1=t.sent,t.t2=e,t.t3={tokenId:r,amount:n},t.t4=[0],t.next=9,t.t0.transferFrom.call(t.t0,t.t1,t.t2,t.t3,t.t4);case 9:return t.abrupt("return",t.sent);case 10:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.create=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.createBatch([e]);case 2:return t.abrupt("return",t.sent[0]);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.createBatch=function(){var t=k(F.mark((function t(e){var r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.map((function(t){return{metadata:t,supply:0}})),t.abrupt("return",this.createAndMintBatch(r));case 2:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.createAndMint=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.createAndMintBatch([e]);case 2:return t.abrupt("return",t.sent[0]);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.createAndMintBatch=function(){var t=k(F.mark((function t(e){var r,n,a,s,i,o,u,c=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.map((function(t){return t.metadata})),t.next=3,this.sdk.getStorage().uploadMetadataBatch(r);case 3:return n=t.sent.metadataUris,a=e.map((function(t){return t.supply})),t.next=8,this.getSignerAddress();case 8:return s=t.sent,t.next=11,this.sendTransaction("createNativeTokens",[s,n,a,[0]]);case 11:return o=this.parseEventLogs("NativeTokens",null==(i=t.sent)?void 0:i.logs),u=null==o?void 0:o.tokenIds,t.next=16,Promise.all(u.map((function(t){return c.get(t.toString())})));case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.createWithToken=function(){var t=k(F.mark((function t(e,r,n){var a,i;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=s.ERC20__factory.connect(e,this.providerOrSigner),t.t0=a,t.next=4,this.getSignerAddress();case 4:return t.t1=t.sent,t.t2=this.address,t.next=8,t.t0.allowance.call(t.t0,t.t1,t.t2);case 8:if(!(t.sent=0||Zt(!1),this._price=t,this._currencyAddress=e,this},e.setConditionStartTime=function(t){return this._conditionStartTime="number"==typeof t?Math.floor(t):Math.floor(t.getTime()/1e3),this},e.setMaxQuantity=function(t){return this._maxQuantity=t,this},e.setMaxQuantityPerTransaction=function(t){var e=u.BigNumber.from(t);return e.gte(1)||Zt(!1),this._quantityLimitPerTransaction=e,this},e.setMerkleRoot=function(t){return this._merkleRootHash=t,this},e.setSnapshot=function(t){return this._snapshot=t,this},e.getSnapshot=function(){return this._merkleCondition},e.buildPublicClaimCondition=function(){var t=k(F.mark((function t(){var e;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._snapshot){t.next=4;break}return t.next=3,this.createSnapshot(this._snapshot);case 3:this._merkleCondition=t.sent;case 4:return t.abrupt("return",{startTimestamp:u.BigNumber.from(this._conditionStartTime.toString()),pricePerToken:this._price,currency:this._currencyAddress||i.AddressZero,maxMintSupply:this._maxQuantity,waitTimeSecondsLimitPerTransaction:this._waitInSeconds,quantityLimitPerTransaction:this._quantityLimitPerTransaction,currentMintSupply:0,merkleRoot:null!=(e=this._merkleCondition)&&e.merkleRoot?this._merkleCondition.merkleRoot:this._merkleRootHash});case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.setWaitTimeBetweenClaims=function(t){return this._waitInSeconds=t,this},t}(),Ie=function(){function t(t){this.phases=[],this.createSnapshot=void 0,this.createSnapshot=t}var e=t.prototype;return e.buildConditions=function(){var t=k(F.mark((function t(){var e;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=[],t.next=3,Promise.all(this.phases.map((function(t){return t.buildPublicClaimCondition()}))).then((function(t){e=t.sort((function(t,e){return t.startTimestamp.eq(e.startTimestamp)?0:t.startTimestamp.gt(e.startTimestamp)?1:-1}))}));case 3:return t.abrupt("return",e);case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.buildConditionsForDropV1=function(){var t=k(F.mark((function t(){var e,r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(this.phases.map((function(t){return t.buildPublicClaimCondition()})));case 2:return e=(e=t.sent).map((function(t){var e=Math.floor(Date.now()/1e3);return M({},t,{startTimestamp:t.startTimestamp.lt(e)?u.BigNumber.from(0):t.startTimestamp.sub(e)})})),r=e.sort((function(t,e){return t.startTimestamp.eq(e.startTimestamp)?0:t.startTimestamp.gt(e.startTimestamp)?1:-1})),t.abrupt("return",r);case 6:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.fromPublicClaimConditions=function(t){for(var e,r=[],n=E(t);!(e=n()).done;){var a=e.value,s=new Le(this.createSnapshot);a.currency&&s.setPrice(a.pricePerToken,a.currency),a.maxMintSupply&&s.setMaxQuantity(a.maxMintSupply),s.setConditionStartTime(new Date(1e3*a.startTimestamp.toNumber())),r.push(s)}return this.phases=r,this},e.newClaimPhase=function(t){var e=t.startTime,r=t.maxQuantity,n=void 0===r?u.ethers.constants.MaxUint256:r,a=t.maxQuantityPerTransaction,s=void 0===a?u.ethers.constants.MaxUint256:a,i=new Le(this.createSnapshot);return i.setConditionStartTime(e),i.setMaxQuantity(u.BigNumber.from(n)),i.setMaxQuantityPerTransaction(u.BigNumber.from(s)),this.phases.push(i),i},e.deleteClaimPhase=function(){var t=k(F.mark((function t(e){var r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e<0||e>=this.phases.length)){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this.buildConditions();case 4:r=t.sent.splice(e-1,1),this.fromPublicClaimConditions(r);case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.removeClaimPhase=function(t){throw new K("deleteClaimPhase")},e.allSnapshots=function(){return this.phases.filter((function(t){return void 0!==t.getSnapshot()})).map((function(t){return t.getSnapshot()}))},t}();exports.ClaimProof=function(){this.address="",this.proof=[]},v.__decorate([m.JsonProperty("address",String)],exports.ClaimProof.prototype,"address",void 0),v.__decorate([m.JsonProperty("proof",[String])],exports.ClaimProof.prototype,"proof",void 0),exports.ClaimProof=v.__decorate([m.JsonObject("ClaimProof")],exports.ClaimProof),exports.Snapshot=function(){this.merkleRoot="",this.claims=[]},v.__decorate([m.JsonProperty("merkleRoot",String)],exports.Snapshot.prototype,"merkleRoot",void 0),v.__decorate([m.JsonProperty("claims",[exports.ClaimProof])],exports.Snapshot.prototype,"claims",void 0),exports.Snapshot=v.__decorate([m.JsonObject("Snapshot")],exports.Snapshot);var De=[{inputs:[{internalType:"uint256",name:"_tokenId",type:"uint256"},{internalType:"uint256",name:"_quantity",type:"uint256"},{internalType:"bytes32[]",name:"_proofs",type:"bytes32[]"}],name:"claim",outputs:[],stateMutability:"payable",type:"function"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"claimConditionIndex",type:"uint256"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"claimer",type:"address"},{indexed:!1,internalType:"uint256",name:"quantityClaimed",type:"uint256"}],name:"ClaimedTokens",type:"event"}],Ue=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),a=0;a0)){t.next=26;break}return p=o.merkleRoot.toString(),t.next=24,this.getClaimerProofs(p,n);case 24:0===t.sent.length&&u.ethers.utils.keccak256(n).toLowerCase()!==p&&a.push(exports.ClaimEligibility.AddressNotAllowed);case 26:return t.next=28,this.readOnlyContract.getTimestampForNextValidClaim(e,i,n);case 28:if(d=t.sent,!u.BigNumber.from(Date.now()).div(1e3).lt(d)){t.next=39;break}if(!u.BigNumber.from(o.waitTimeSecondsLimitPerTransaction).eq(d)){t.next=38;break}return t.next=34,this.readOnlyContract.balanceOf(n,e);case 34:t.sent.gte(1)&&a.push(exports.ClaimEligibility.AlreadyClaimed),t.next=39;break;case 38:a.push(exports.ClaimEligibility.WaitBeforeNextClaimTransaction);case 39:if(!o.pricePerToken.gt(0)){t.next=58;break}if(l=o.pricePerToken.mul(r),!Ct(o.currency)){t.next=51;break}return t.next=44,this.getProvider();case 44:return f=t.sent,t.next=47,f.getBalance(n);case 47:t.sent.lt(l)&&a.push(exports.ClaimEligibility.NotEnoughTokens),t.next=58;break;case 51:return t.next=53,this.getProvider();case 53:return h=t.sent,t.next=56,s.ERC20__factory.connect(o.currency,h).balanceOf(n);case 56:t.sent.lt(l)&&a.push(exports.ClaimEligibility.NotEnoughTokens);case 58:return t.abrupt("return",a);case 59:case"end":return t.stop()}}),t,this,[[3,11]])})));return function(e,r,n){return t.apply(this,arguments)}}(),r.canClaim=function(){var t=k(F.mark((function t(e,r,n){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n){t.next=4;break}return t.next=3,this.getSignerAddress();case 3:n=t.sent;case 4:return t.next=6,this.getClaimIneligibilityReasons(e,r,n);case 6:return t.t0=t.sent.length,t.abrupt("return",0===t.t0);case 8:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.getClaimerProofs=function(){var t=k(F.mark((function t(e,r){var n,a,s,i,o;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=4;break}return t.next=3,this.getSignerAddress();case 3:r=t.sent;case 4:return t.next=6,this.getMetadata();case 6:return n=t.sent.metadata,t.next=10,this.sdk.getStorage().get(null==n?void 0:n.merkle[e]);case 10:if(a=t.sent,s=new m.JsonConvert,i=s.deserializeObject(JSON.parse(a),exports.Snapshot),void 0!==(o=i.claims.find((function(t){var e;return t.address.toLowerCase()===(null==(e=r)?void 0:e.toLowerCase())})))){t.next=16;break}return t.abrupt("return",[]);case 16:return t.abrupt("return",o.proof);case 17:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.isTransferRestricted=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.readOnlyContract.transfersRestricted());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.setRestrictedTransfer=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e=!1),t.t0=this,t.t1=["admin"],t.next=5,this.getSignerAddress();case 5:return t.t2=t.sent,t.next=8,t.t0.onlyRoles.call(t.t0,t.t1,t.t2);case 8:return t.next=10,this.sendTransaction("setRestrictedTransfer",[e]);case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.isNewClaim=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.checkVersion();case 2:return t.abrupt("return",this._isNewClaim);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.checkVersion=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._shouldCheckVersion){t.next=11;break}return t.prev=1,t.next=4,this.readOnlyContract.VERSION();case 4:this._isNewClaim=!0,t.next=10;break;case 7:t.prev=7,t.t0=t.catch(1),this._isNewClaim=!1;case 10:this._shouldCheckVersion=!1;case 11:case"end":return t.stop()}}),t,this,[[1,7]])})));return function(){return t.apply(this,arguments)}}(),e}(Yt);Ue.moduleType=exports.ModuleType.BUNDLE_DROP,Ue.roles=[Vt.admin,Vt.minter,Vt.transfer];var Ve=function(t){function e(){return t.apply(this,arguments)||this}S(e,t);var r=e.prototype;return r.getModuleRoles=function(){return e.roles},r.connectContract=function(){return s.DataStore__factory.connect(this.address,this.providerOrSigner)},r.getModuleType=function(){return e.moduleType},r.getUint=function(){var t=k(F.mark((function t(e){var r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=u.ethers.utils.id(e.toString()),t.next=3,this.readOnlyContract.getUint(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.setUint=function(){var t=k(F.mark((function t(e,r){var n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=u.ethers.utils.id(e.toString()),t.next=3,this.sendTransaction("setUint",[n,r]);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e}(Yt);Ve.moduleType=exports.ModuleType.DATASTORE,Ve.roles=[Vt.admin,Vt.editor];var je=[{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"claimConditionIndex",type:"uint256"},{indexed:!0,internalType:"address",name:"claimer",type:"address"},{indexed:!1,internalType:"uint256",name:"startTokenId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"quantityClaimed",type:"uint256"}],name:"ClaimedTokens",type:"event"},{inputs:[{internalType:"uint256",name:"_quantity",type:"uint256"},{internalType:"bytes32[]",name:"_proofs",type:"bytes32[]"}],name:"claim",outputs:[],stateMutability:"payable",type:"function"}],qe=[{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"startTokenId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endTokenId",type:"uint256"},{indexed:!1,internalType:"string",name:"baseURI",type:"string"}],name:"LazyMintedTokens",type:"event"},{inputs:[{internalType:"uint256",name:"_amount",type:"uint256"},{internalType:"string",name:"_baseURIForTokens",type:"string"}],name:"lazyMint",outputs:[],stateMutability:"nonpayable",type:"function"}],Je=function(t){function e(e,r,n,a){var s;return(s=t.call(this,e,r,n,a)||this)._shouldCheckVersion=!0,s._isV0=!1,s._version=0,s.v1Module=void 0,s.v1Module=new We(e,r,n,a),s}S(e,t);var r=e.prototype;return r.setProviderOrSigner=function(e){var r;t.prototype.setProviderOrSigner.call(this,e),null==(r=this.v1Module)||r.setProviderOrSigner(e)},r.getModuleRoles=function(){return e.roles},r.connectContract=function(){return s.LazyMintERC721__factory.connect(this.address,this.providerOrSigner)},r.getModuleType=function(){return e.moduleType},r.getTokenMetadata=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Et(this.readOnlyContract,e,this.sdk.getStorage());case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.get=function(){var t=k(F.mark((function t(e){var r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all([this.ownerOf(e).catch((function(){return i.AddressZero})),this.getTokenMetadata(e)]);case 2:return t.abrupt("return",{owner:(r=t.sent)[0],metadata:r[1]});case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getAll=function(){var t=k(F.mark((function t(e){var r,n,a,s=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV0();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.v1Module.getAll(e));case 4:return r=u.BigNumber.from((null==e?void 0:e.start)||0).toNumber(),n=u.BigNumber.from((null==e?void 0:e.count)||100).toNumber(),t.t0=Math,t.next=9,this.readOnlyContract.nextTokenIdToMint();case 9:return t.t1=t.sent.toNumber(),t.t2=r+n,a=t.t0.min.call(t.t0,t.t1,t.t2),t.next=14,Promise.all(Array.from(Array(a-r).keys()).map((function(t){return s.get((r+t).toString())})));case 14:return t.abrupt("return",t.sent);case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getAllUnclaimed=function(){var t=k(F.mark((function t(e){var r,n,a,s,o=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV0();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.v1Module.getAllUnclaimed());case 4:return r=u.BigNumber.from((null==e?void 0:e.start)||0).toNumber(),n=u.BigNumber.from((null==e?void 0:e.count)||100).toNumber(),t.t0=u.BigNumber,t.t1=Math,t.next=10,this.readOnlyContract.nextTokenIdToMint();case 10:return t.t2=t.sent.toNumber(),t.t3=r+n,t.t4=t.t1.min.call(t.t1,t.t2,t.t3),a=t.t0.from.call(t.t0,t.t4),t.next=16,this.readOnlyContract.nextTokenIdToClaim();case 16:return s=t.sent,t.next=19,Promise.all(Array.from(Array(a.sub(s).toNumber()).keys()).map((function(t){return o.getTokenMetadata(s.add(t).toString())})));case 19:return t.abrupt("return",t.sent.map((function(t){return{owner:i.AddressZero,metadata:t}})));case 20:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getAllClaimed=function(){var t=k(F.mark((function t(e){var r,n,a,s=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV0();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.v1Module.getAllClaimed());case 4:return r=u.BigNumber.from((null==e?void 0:e.start)||0).toNumber(),n=u.BigNumber.from((null==e?void 0:e.count)||100).toNumber(),t.t0=Math,t.next=9,this.readOnlyContract.nextTokenIdToClaim();case 9:return t.t1=t.sent.toNumber(),t.t2=r+n,a=t.t0.min.call(t.t0,t.t1,t.t2),t.next=14,Promise.all(Array.from(Array(a).keys()).map((function(t){return s.get(t.toString())})));case 14:return t.abrupt("return",t.sent);case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.ownerOf=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.ownerOf(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getDefaultSaleRecipient=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.defaultSaleRecipient();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.setDefaultSaleRecipient=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("setDefaultSaleRecipient",[e]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getOwned=function(){var t=k(F.mark((function t(e){var r,n,a,s=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e){t.next=4;break}t.t0=e,t.next=7;break;case 4:return t.next=6,this.getSignerAddress();case 6:t.t0=t.sent;case 7:return r=t.t0,t.next=10,this.readOnlyContract.balanceOf(r);case 10:return n=Array.from(Array(t.sent.toNumber()).keys()),t.next=14,Promise.all(n.map((function(t){return s.readOnlyContract.tokenOfOwnerByIndex(r,t)})));case 14:return a=t.sent,t.next=17,Promise.all(a.map((function(t){return s.get(t.toString())})));case 17:return t.abrupt("return",t.sent);case 18:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.transformResultToMintCondition=function(t){return{startTimestamp:t.startTimestamp,maxMintSupply:t.maxClaimableSupply,currentMintSupply:t.supplyClaimed,quantityLimitPerTransaction:t.quantityLimitPerTransaction,waitTimeSecondsLimitPerTransaction:t.waitTimeInSecondsBetweenClaims,pricePerToken:t.pricePerToken,currency:t.currency,merkleRoot:t.merkleRoot}},r.transformResultToClaimCondition=function(){var t=k(F.mark((function t(e){var r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,wt(this.providerOrSigner,e.currency,e.pricePerToken);case 2:return r=t.sent,t.abrupt("return",{startTimestamp:new Date(1e3*u.BigNumber.from(e.startTimestamp).toNumber()),maxMintSupply:e.maxClaimableSupply.toString(),currentMintSupply:e.supplyClaimed.toString(),availableSupply:u.BigNumber.from(e.maxClaimableSupply).sub(e.supplyClaimed).toString(),quantityLimitPerTransaction:e.quantityLimitPerTransaction.toString(),waitTimeSecondsLimitPerTransaction:e.waitTimeInSecondsBetweenClaims.toString(),price:u.BigNumber.from(e.pricePerToken),pricePerToken:u.BigNumber.from(e.pricePerToken),currency:e.currency,currencyContract:e.currency,currencyMetadata:r,merkleRoot:e.merkleRoot});case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getActiveMintCondition=function(){var t=k(F.mark((function t(){var e;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV0();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.v1Module.getActiveMintCondition());case 4:return t.next=6,this.readOnlyContract.getIndexOfActiveCondition();case 6:return e=t.sent,t.t0=this,t.next=10,this.readOnlyContract.getClaimConditionAtIndex(e);case 10:return t.t1=t.sent,t.abrupt("return",t.t0.transformResultToMintCondition.call(t.t0,t.t1));case 12:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getActiveClaimCondition=function(){var t=k(F.mark((function t(){var e,r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV0();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.v1Module.getActiveClaimCondition());case 4:return t.next=6,this.readOnlyContract.getIndexOfActiveCondition();case 6:return e=t.sent,t.next=9,this.readOnlyContract.getClaimConditionAtIndex(e);case 9:return r=t.sent,t.next=12,this.transformResultToClaimCondition(r);case 12:return t.abrupt("return",t.sent);case 13:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getAllMintConditions=function(){var t=k(F.mark((function t(){var e,r,n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV0();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.v1Module.getAllMintConditions());case 4:return t.next=6,this.readOnlyContract.claimConditions();case 6:e=t.sent.totalConditionCount.toNumber(),r=[],n=0;case 10:if(!(n0?s.merkle=a:0===r.filter((function(t){return t.merkleRoot!==u})).length&&(s.merkle={}),c=[],Fe(o,s.merkle)){t.next=23;break}return t.next=21,this.sdk.getStorage().upload(JSON.stringify(s));case 21:c.push(this.contract.interface.encodeFunctionData("setContractURI",[t.sent]));case 23:return c.push(this.contract.interface.encodeFunctionData("setClaimConditions",[r])),t.next=26,this.sendTransaction("multicall",[c]);case 26:return t.abrupt("return",t.sent);case 27:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.updateClaimConditions=function(){var t=k(F.mark((function t(e){var r,n,a,s,o;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV0();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.v1Module.setClaimCondition(e));case 4:return t.next=6,e.buildConditions();case 6:return r=t.sent.map((function(t){return{startTimestamp:t.startTimestamp,maxClaimableSupply:t.maxMintSupply,supplyClaimed:0,quantityLimitPerTransaction:t.quantityLimitPerTransaction,waitTimeInSecondsBetweenClaims:t.waitTimeSecondsLimitPerTransaction,pricePerToken:t.pricePerToken,currency:t.currency===i.AddressZero?xt:t.currency,merkleRoot:t.merkleRoot}})),n={},e.allSnapshots().forEach((function(t){n[t.merkleRoot]=t.snapshotUri})),a=[],t.next=12,this.getMetadata(!1);case 12:if((s=t.sent.metadata)||Zt(!1),o=s.merkle,s.merkle=0===e.allSnapshots().length&&"merkle"in s?{}:n,Fe(o,s.merkle)){t.next=22;break}return t.next=20,this.sdk.getStorage().upload(JSON.stringify(s));case 20:a.push(this.contract.interface.encodeFunctionData("setContractURI",[t.sent]));case 22:return a.push(this.contract.interface.encodeFunctionData("updateClaimConditions",[r])),t.next=25,this.sendTransaction("multicall",[a]);case 25:return t.abrupt("return",t.sent);case 26:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getClaimConditionsFactory=function(){var t=this.sdk.createSnapshot.bind(this.sdk);return new Ie(t)},r.getMintConditionsFactory=function(){return this.getClaimConditionsFactory()},r.setPublicMintConditions=function(){var t=k(F.mark((function t(e){var r,a;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV0();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.v1Module.setPublicMintConditions(e));case 4:return r=u.BigNumber.from(Date.now()).div(1e3),a=e.map((function(t){return{startTimestamp:r.add(t.startTimestampInSeconds||0),maxClaimableSupply:t.maxMintSupply,supplyClaimed:0,quantityLimitPerTransaction:t.quantityLimitPerTransaction||t.maxMintSupply,waitTimeInSecondsBetweenClaims:t.waitTimeSecondsLimitPerTransaction||0,pricePerToken:t.pricePerToken||0,currency:t.currency||i.AddressZero,merkleRoot:t.merkleRoot||n.hexZeroPad([0],32)}})),t.next=8,this.sendTransaction("setClaimConditions",[a]);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getClaimIneligibilityReasons=function(){var t=k(F.mark((function t(e,r){var n,a,i,o,c,p,d,l,f;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],void 0!==r){t.next=3;break}throw new Error("addressToCheck is required");case 3:return t.prev=3,t.next=6,Promise.all([this.readOnlyContract.getIndexOfActiveCondition(),this.getActiveClaimCondition()]);case 6:a=(o=t.sent)[0],i=o[1],t.next=18;break;case 11:if(t.prev=11,t.t0=t.catch(3),!t.t0.message.includes("no public mint condition.")){t.next=16;break}return n.push(exports.ClaimEligibility.NoActiveClaimPhase),t.abrupt("return",n);case 16:throw console.error("Failed to get active claim condition",t.t0),new Error("Failed to get active claim condition");case 18:if(u.BigNumber.from(i.availableSupply).lt(e)&&n.push(exports.ClaimEligibility.NotEnoughSupply),!(u.ethers.utils.stripZeros(i.merkleRoot).length>0)){t.next=26;break}return c=i.merkleRoot.toString(),t.next=24,this.getClaimerProofs(c,r);case 24:0===t.sent.length&&u.ethers.utils.keccak256(r).toLowerCase()!==c&&n.push(exports.ClaimEligibility.AddressNotAllowed);case 26:return t.next=28,this.readOnlyContract.getTimestampForNextValidClaim(a,r);case 28:if(p=t.sent,!u.BigNumber.from(Date.now()).div(1e3).lt(p)){t.next=39;break}if(!u.BigNumber.from(i.waitTimeSecondsLimitPerTransaction).eq(p)){t.next=38;break}return t.next=34,this.readOnlyContract.balanceOf(r);case 34:t.sent.gte(1)&&n.push(exports.ClaimEligibility.AlreadyClaimed),t.next=39;break;case 38:n.push(exports.ClaimEligibility.WaitBeforeNextClaimTransaction);case 39:if(!i.pricePerToken.gt(0)){t.next=58;break}if(d=i.pricePerToken.mul(e),!Ct(i.currency)){t.next=51;break}return t.next=44,this.getProvider();case 44:return l=t.sent,t.next=47,l.getBalance(r);case 47:t.sent.lt(d)&&n.push(exports.ClaimEligibility.NotEnoughTokens),t.next=58;break;case 51:return t.next=53,this.getProvider();case 53:return f=t.sent,t.next=56,s.ERC20__factory.connect(i.currency,f).balanceOf(r);case 56:t.sent.lt(d)&&n.push(exports.ClaimEligibility.NotEnoughTokens);case 58:return t.abrupt("return",n);case 59:case"end":return t.stop()}}),t,this,[[3,11]])})));return function(e,r){return t.apply(this,arguments)}}(),r.canClaim=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==r){t.next=4;break}return t.next=3,this.getSignerAddress();case 3:r=t.sent;case 4:return t.next=6,this.isV0();case 6:if(!t.sent){t.next=8;break}return t.abrupt("return",this.v1Module.canClaim(e,[]));case 8:return t.next=10,this.getClaimIneligibilityReasons(e,r);case 10:return t.t0=t.sent.length,t.abrupt("return",0===t.t0);case 12:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.prepareClaim=function(){var t=k(F.mark((function t(e,r){var a,o,c,p,d,l,f,h,y,x,v,g,b;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=[n.hexZeroPad([0],32)]),t.next=3,this.getActiveClaimCondition();case 3:return a=t.sent,t.next=6,this.getMetadata();case 6:return o=t.sent.metadata,t.next=10,this.getSignerAddress();case 10:if(c=t.sent,a.merkleRoot.toString().startsWith(i.AddressZero)){t.next=21;break}return t.next=14,this.sdk.getStorage().get(null==o?void 0:o.merkle[a.merkleRoot.toString()]);case 14:if(p=t.sent,d=new m.JsonConvert,l=d.deserializeObject(JSON.parse(p),exports.Snapshot),void 0!==(f=l.claims.find((function(t){return t.address.toLowerCase()===c.toLowerCase()})))){t.next=20;break}throw new Error("No claim found for this address");case 20:r=f.proof;case 21:return t.next=23,this.getCallOverrides();case 23:if(t.t0=t.sent,t.t0){t.next=26;break}t.t0={};case 26:if(h=t.t0,!a.pricePerToken.gt(0)){t.next=44;break}if(!Ct(a.currency)){t.next=32;break}h.value=u.BigNumber.from(a.pricePerToken).mul(e),t.next=44;break;case 32:return y=s.ERC20__factory.connect(a.currency,this.providerOrSigner),t.next=35,this.getSignerAddress();case 35:return x=t.sent,v=this.address,t.next=39,y.allowance(x,v);case 39:if(g=t.sent,b=u.BigNumber.from(a.pricePerToken).mul(u.BigNumber.from(e)),!g.lt(b)){t.next=44;break}return t.next=44,this.sendContractTransaction(y,"approve",[v,g.add(b)]);case 44:return t.abrupt("return",{overrides:h,proofs:r});case 45:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.claimTo=function(){var t=k(F.mark((function t(e,r,a){var s,i,o,c,p,d,l,f;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===a&&(a=[n.hexZeroPad([0],32)]),t.next=3,this.prepareClaim(e,a);case 3:return s=t.sent,t.next=6,this.isNewClaim();case 6:if(!t.sent){t.next=10;break}return t.next=9,this.sendTransaction("claim",[r,e,s.proofs],s.overrides);case 9:return t.abrupt("return",t.sent);case 10:return i=new u.Contract(this.address,je,this.providerOrSigner),t.next=13,this.sendContractTransaction(i,"claim",[e,s.proofs],s.overrides);case 13:c=[],p=this.parseLogs("ClaimedTokens",null==(o=t.sent)?void 0:o.logs,i),l=(d=p[0].args.startTokenId).add(e),f=d;case 19:if(!f.lt(l)){t.next=33;break}return t.t0=c,t.t1=this.contract.interface,t.next=24,this.getSignerAddress();case 24:t.t2=t.sent,t.t3=r,t.t4=f,t.t5=[t.t2,t.t3,t.t4],t.t6=t.t1.encodeFunctionData.call(t.t1,"transferFrom",t.t5),t.t0.push.call(t.t0,t.t6);case 30:f=f.add(1),t.next=19;break;case 33:return t.next=35,this.sendTransaction("multicall",[c],s.overrides);case 35:return t.abrupt("return",t.sent);case 36:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.claim=function(){var t=k(F.mark((function t(e,r){var a,s,i,o,c,p,d,l,f,h=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=[n.hexZeroPad([0],32)]),t.next=3,this.isV0();case 3:if(!t.sent){t.next=5;break}return t.abrupt("return",this.v1Module.claim(e,r));case 5:return t.next=7,this.prepareClaim(e,r);case 7:return s=t.sent,o=this.contract,t.next=11,this.isNewClaim();case 11:if(!t.sent){t.next=25;break}return t.t0=this,t.next=15,this.getSignerAddress();case 15:return t.t1=t.sent,t.t2=e,t.t3=s.proofs,t.t4=[t.t1,t.t2,t.t3],t.t5=s.overrides,t.next=22,t.t0.sendTransaction.call(t.t0,"claim",t.t4,t.t5);case 22:i=t.sent,t.next=29;break;case 25:return o=new u.Contract(this.address,je,this.providerOrSigner),t.next=28,this.sendContractTransaction(o,"claim",[e,s.proofs],s.overrides);case 28:i=t.sent;case 29:for(c=this.parseLogs("ClaimedTokens",null==(a=i)?void 0:a.logs,o),d=(p=c[0].args.startTokenId).add(e),l=[],f=p;f.lt(d);f=f.add(1))l.push(u.BigNumber.from(f.toString()));return t.next=36,Promise.all(l.map(function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.get(e.toString());case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 36:return t.abrupt("return",t.sent);case 37:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.burn=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("burn",[e]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.transferFrom=function(){var t=k(F.mark((function t(e,r,n){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("transferFrom",[e,r,n]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.setModuleMetadata=function(){var t=k(F.mark((function t(e){var r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sdk.getStorage().uploadMetadata(e);case 2:return r=t.sent,t.next=5,this.sendTransaction("setContractURI",[r]);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.setRoyaltyBps=function(){var t=k(F.mark((function t(e){var r,n,a;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getMetadata(!1);case 2:if(n=[],r=t.sent.metadata){t.next=7;break}throw new Error("No metadata found, this module might be invalid!");case 7:return r.seller_fee_basis_points=e,t.t0=this.sdk.getStorage(),t.t1=M({},r),t.t2=this.address,t.next=13,this.getSignerAddress();case 13:return t.t3=t.sent,t.next=16,t.t0.uploadMetadata.call(t.t0,t.t1,t.t2,t.t3);case 16:return a=t.sent,n.push(this.contract.interface.encodeFunctionData("setRoyaltyBps",[e])),n.push(this.contract.interface.encodeFunctionData("setContractURI",[a])),t.next=21,this.sendTransaction("multicall",[n]);case 21:return t.abrupt("return",t.sent);case 22:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getRoyaltyBps=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.royaltyBps();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getRoyaltyRecipientAddress=function(){var t=k(F.mark((function t(){var e,r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getMetadata();case 2:if(void 0===(null==(e=(r=t.sent).metadata)?void 0:e.fee_recipient)){t.next=5;break}return t.abrupt("return",r.metadata.fee_recipient);case 5:return t.abrupt("return","");case 6:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.createBatch=function(){var t=k(F.mark((function t(e){var r,n,a,s,i,o,c,p,d,l;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV0();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.v1Module.createBatch(e));case 4:return t.next=6,this.readOnlyContract.nextTokenIdToMint();case 6:return n=t.sent,t.next=9,this.sdk.getStorage().uploadMetadataBatch(e,this.address,n.toNumber());case 9:return a=t.sent.baseUri,i=this.contract,t.next=14,this.hasDelayedReveal();case 14:if(!t.sent){t.next=20;break}return t.next=17,this.sendTransaction("lazyMint",[e.length,a.endsWith("/")?a:a+"/",u.ethers.utils.toUtf8Bytes("")]);case 17:s=t.sent,t.next=24;break;case 20:return i=new u.Contract(this.address,qe,this.providerOrSigner),t.next=23,this.sendContractTransaction(i,"lazyMint",[e.length,a.endsWith("/")?a:a+"/"]);case 23:s=t.sent;case 24:for(o=this.parseLogs("LazyMintedTokens",null==(r=s)?void 0:r.logs,i),p=(c=o[0].args)[1],d=[],l=c[0];l.lte(p);l=l.add(1))d.push(l.toString());return t.abrupt("return",d);case 29:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.hashDelayRevealPassword=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChainID();case 2:return t.abrupt("return",u.ethers.utils.solidityKeccak256(["string","uint256","uint256","address"],[r,t.sent,e,this.address]));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.createDelayedRevealBatch=function(){var t=k(F.mark((function t(e,r,n){var a,s,i,o,c,p,d,l,f,h,m;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.hasDelayedReveal();case 2:if(t.sent){t.next=4;break}throw new Error("delay reveal unsupported");case 4:if(n){t.next=6;break}throw new Error("Password is required");case 6:return t.next=8,this.sdk.getStorage().uploadMetadataBatch([e],this.address);case 8:return a=t.sent.baseUri,t.next=12,this.readOnlyContract.nextTokenIdToMint();case 12:return s=t.sent,t.next=15,this.sdk.getStorage().uploadMetadataBatch(r,this.address,s.toNumber());case 15:return i=t.sent.baseUri,t.next=19,this.readOnlyContract.getBaseURICount();case 19:return o=t.sent,t.t0=this.readOnlyContract,t.t1=u.ethers.utils.toUtf8Bytes(i.endsWith("/")?i:i+"/"),t.next=24,this.hashDelayRevealPassword(o,n);case 24:return t.t2=t.sent,t.next=27,t.t0.encryptDecrypt.call(t.t0,t.t1,t.t2);case 27:return c=t.sent,t.next=30,this.sendTransaction("lazyMint",[r.length,a.endsWith("/")?a:a+"/",c]);case 30:for(d=this.parseLogs("LazyMintedTokens",null==(p=t.sent)?void 0:p.logs),f=(l=d[0].args)[1],h=[],m=l[0];m.lte(f);m=m.add(1))h.push(m.toString());return t.abrupt("return",h);case 36:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.reveal=function(){var t=k(F.mark((function t(e,r){var n,a;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.hasDelayedReveal();case 2:if(t.sent){t.next=4;break}throw new Error("delay reveal unsupported");case 4:if(r){t.next=6;break}throw new Error("Password is required");case 6:return t.next=8,this.hashDelayRevealPassword(e,r);case 8:return n=t.sent,t.prev=9,t.next=12,this.contract.callStatic.reveal(e,n);case 12:if((a=t.sent).includes("://")&&a.endsWith("/")){t.next=15;break}throw new Error("Error revealing batch "+e+" - make sure your password is correct");case 15:t.next=21;break;case 17:throw t.prev=17,t.t0=t.catch(9),console.log("Error revealing batch "+e,t.t0),new Error("Error revealing batch "+e+" - make sure your password is correct");case 21:return t.next=23,this.sendTransaction("reveal",[e,n]);case 23:case"end":return t.stop()}}),t,this,[[9,17]])})));return function(e,r){return t.apply(this,arguments)}}(),r.getBatchesToReveal=function(){var t=k(F.mark((function t(){var e,r,n,a,s,i,o,c=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.hasDelayedReveal();case 2:if(t.sent){t.next=4;break}throw new Error("Contract does not support delay reveal");case 4:return t.next=6,this.readOnlyContract.getBaseURICount();case 6:if(!(e=t.sent).isZero()){t.next=9;break}return t.abrupt("return",[]);case 9:return r=Array.from(Array(e.toNumber()).keys()),t.next=12,Promise.all(r.map((function(t){return c.readOnlyContract.baseURIIndices(t)})));case 12:return a=(n=t.sent).slice(0,n.length-1),t.next=16,Promise.all(Array.from([0].concat(a)).map((function(t){return c.readOnlyContract.tokenURI(t)})));case 16:return s=t.sent,t.next=19,Promise.all(Array.from([0].concat(a)).map((function(t){return c.getTokenMetadata(t.toString())})));case 19:return i=t.sent,t.next=22,Promise.all(Array.from([].concat(n)).map((function(t){return c.readOnlyContract.encryptedBaseURI(t)})));case 22:return o=t.sent,t.abrupt("return",s.map((function(t,e){return{batchId:u.BigNumber.from(e),batchUri:t,placeholderMetadata:i[e]}})).filter((function(t,e){return u.ethers.utils.hexDataLength(o[e])>0})));case 24:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.canCreateBatch=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV0();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.v1Module.canCreateBatch());case 4:return t.abrupt("return",!0);case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.isV0=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.checkVersion();case 2:return t.abrupt("return",this._isV0);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.isNewClaim=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.checkVersion();case 2:return t.abrupt("return",this._version>=1);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.hasDelayedReveal=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.checkVersion();case 2:return t.abrupt("return",this._version>=2);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.checkVersion=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._shouldCheckVersion){t.next=20;break}return t.prev=1,t.next=4,this.readOnlyContract.nextTokenIdToMint();case 4:this._isV0=!1,t.next=10;break;case 7:t.prev=7,t.t0=t.catch(1),this._isV0=!0;case 10:return t.prev=10,t.next=13,this.readOnlyContract.VERSION();case 13:this._version=t.sent.toNumber(),t.next=19;break;case 16:t.prev=16,t.t1=t.catch(10),this._version=0;case 19:this._shouldCheckVersion=!1;case 20:case"end":return t.stop()}}),t,this,[[1,7],[10,16]])})));return function(){return t.apply(this,arguments)}}(),r.getClaimerProofs=function(){var t=k(F.mark((function t(e,r){var n,a,s,i,o;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=4;break}return t.next=3,this.getSignerAddress();case 3:r=t.sent;case 4:return t.next=6,this.getMetadata();case 6:return n=t.sent.metadata,t.next=10,this.sdk.getStorage().get(null==n?void 0:n.merkle[e]);case 10:if(a=t.sent,s=new m.JsonConvert,i=s.deserializeObject(JSON.parse(a),exports.Snapshot),void 0!==(o=i.claims.find((function(t){var e;return t.address.toLowerCase()===(null==(e=r)?void 0:e.toLowerCase())})))){t.next=16;break}return t.abrupt("return",[]);case 16:return t.abrupt("return",o.proof);case 17:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.isTransferRestricted=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.readOnlyContract.transfersRestricted());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.setRestrictedTransfer=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e=!1),t.t0=this,t.t1=["admin"],t.next=5,this.getSignerAddress();case 5:return t.t2=t.sent,t.next=8,t.t0.onlyRoles.call(t.t0,t.t1,t.t2);case 8:return t.next=10,this.sendTransaction("setRestrictedTransfer",[e]);case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e}(Yt);Je.moduleType=exports.ModuleType.DROP,Je.roles=[Vt.admin,Vt.minter,Vt.transfer];var We=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),a=0;a0||Zt(!1),t.next=11,d.supportsInterface(ot);case 11:if(!t.sent){t.next=28;break}return l=s.ERC721__factory.connect(e,this.providerOrSigner),t.next=16,l.isApprovedForAll(p,this.address);case 16:if(t.sent){t.next=26;break}return t.next=20,l.getApproved(r);case 20:if(t.t0=t.sent.toLowerCase(),t.t1=this.address.toLowerCase(),t.t0===t.t1){t.next=26;break}return t.next=26,this.sendContractTransaction(l,"setApprovalForAll",[this.address,!0]);case 26:t.next=35;break;case 28:return f=s.ERC1155__factory.connect(e,this.providerOrSigner),t.next=31,f.isApprovedForAll(p,this.address);case 31:if(t.sent){t.next=35;break}return t.next=35,this.sendContractTransaction(f,"setApprovalForAll",[this.address,!0]);case 35:return t.next=37,this.sendTransaction("list",[e,r,n,a,i,o,u,c]);case 37:return m=this.parseEventLogs("NewListing",null==(h=t.sent)?void 0:h.logs),y=null==m?void 0:m.listing,t.next=42,this.transformResultToListing(y);case 42:return t.abrupt("return",t.sent);case 45:return t.prev=45,t.t2=t.catch(3),t.next=49,this.getSignerAddress();case 49:return x=t.sent,t.next=52,this.sdk.getNFTModule(e).ownerOf(r);case 52:if(t.t3=t.sent,t.t4=x,t.t3===t.t4){t.next=58;break}throw new W;case 58:return t.next=60,this.readOnlyContract.restrictedListerRoleOnly();case 60:if(t.t6=t.sent,!t.t6){t.next=67;break}return t.t7=x,t.next=65,this.getRoleMembers("lister");case 65:t.t8=t.sent,t.t6=!(t.t7 in t.t8);case 67:if(t.t5=t.t6,!t.t5){t.next=74;break}return t.t9=x,t.next=72,this.getRoleMembers("admin");case 72:t.t10=t.sent,t.t5=!(t.t9 in t.t10);case 74:if(!t.t5){t.next=76;break}throw new D(x,"lister");case 76:throw t.t2;case 77:case"end":return t.stop()}}),t,this,[[3,45]])})));return function(e,r,n,a,s,i,o,u){return t.apply(this,arguments)}}(),r.unlistAll=function(){var t=k(F.mark((function t(e){var r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.get(e);case 2:return r=t.sent.quantity,t.next=5,this.unlist(e,r);case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.unlist=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("unlist",[e,r]);case 2:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.setRestrictedListerRoleOnly=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("setRestrictedListerRoleOnly",[e]);case 2:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.buy=function(){var t=k(F.mark((function t(e,r){var n,a,o,c,p,d,l,f,h;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.get(e);case 3:return n=t.sent,t.next=6,this.getSignerAddress();case 6:if(a=t.sent,o=this.address,c=n.price.mul(u.BigNumber.from(r)),!n.currencyContract||n.currencyContract===i.AddressZero){t.next=17;break}return p=s.ERC20__factory.connect(n.currencyContract,this.providerOrSigner),t.next=13,p.allowance(a,o);case 13:if(!(d=t.sent).lt(c)){t.next=17;break}return t.next=17,this.sendContractTransaction(p,"approve",[o,d.add(c)]);case 17:return t.next=19,this.sendTransaction("buy",[e,r]);case 19:return f=this.parseEventLogs("NewSale",null==(l=t.sent)?void 0:l.logs),t.next=23,this.transformResultToListing(null==f?void 0:f.listing);case 23:return t.abrupt("return",t.sent);case 26:return t.prev=26,t.t0=t.catch(0),t.next=30,this.get(e);case 30:if(h=t.sent.tokensPerBuyer.toNumber(),!(r>h)){t.next=33;break}throw new G(h.toString());case 33:throw t.t0;case 34:case"end":return t.stop()}}),t,this,[[0,26]])})));return function(e,r){return t.apply(this,arguments)}}(),r.setModuleMetadata=function(){var t=k(F.mark((function t(e){var r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sdk.getStorage().uploadMetadata(e);case 2:return r=t.sent,t.next=5,this.sendTransaction("setContractURI",[r]);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.setMarketFeeBps=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("setMarketFeeBps",[e]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e}(Yt);Ge.moduleType=exports.ModuleType.MARKET,Ge.roles=[Vt.admin,Vt.lister,Vt.pauser];var Ze=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),a=0;a=n})),void 0!==e.count&&r.length>e.count&&(r=r.slice(0,e.count)))),t.abrupt("return",r.filter((function(t){return void 0!==t})));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getAllListingsNoFilter=function(){var t=k(F.mark((function t(){var e=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=Promise,t.t1=Array,t.t2=Array,t.next=5,this.readOnlyContract.totalListings();case 5:return t.t3=t.sent.toNumber(),t.t4=(0,t.t2)(t.t3).keys(),t.t5=t.t1.from.call(t.t1,t.t4).map(function(){var t=k(F.mark((function t(r){var n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.getListing(r);case 3:n=t.sent,t.next=9;break;case 6:return t.prev=6,t.t0=t.catch(0),t.abrupt("return",void 0);case 9:if(n.type!==exports.ListingType.Auction){t.next=11;break}return t.abrupt("return",n);case 11:return t.next=13,e.isStillValidDirectListing(n);case 13:if(t.sent){t.next=16;break}return t.abrupt("return",void 0);case 16:return t.abrupt("return",n);case 17:case"end":return t.stop()}}),t,null,[[0,6]])})));return function(e){return t.apply(this,arguments)}}()),t.next=10,t.t0.all.call(t.t0,t.t5);case 10:return t.abrupt("return",t.sent.filter((function(t){return void 0!==t})));case 12:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.isRestrictedListerRoleOnly=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.readOnlyContract.restrictedListerRoleOnly());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.setRestrictedListerRoleOnly=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sendTransaction("setRestrictedListerRoleOnly",[e]);case 2:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.allowListingFromSpecificAssetOnly=function(){var t=k(F.mark((function t(e){var r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV2();case 2:if(t.sent){t.next=4;break}throw Error("Not supported in this version of the contract, please upgrade");case 4:return r=[],t.next=7,this.getRoleMembers(Vt.asset);case 7:return i.AddressZero in t.sent&&r.push(this.contract.interface.encodeFunctionData("revokeRole",[qt(Vt.asset),i.AddressZero])),r.push(this.contract.interface.encodeFunctionData("grantRole",[qt(Vt.asset),e])),t.next=12,this.sendTransaction("multicall",[r]);case 12:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.allowListingFromAnyAsset=function(){var t=k(F.mark((function t(){var e,r;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isV2();case 2:if(t.sent){t.next=4;break}throw Error("Not supported in this version of the contract, please upgrade");case 4:return e=[],t.next=7,this.getRoleMembers(Vt.asset);case 7:for(r in t.sent)e.push(this.contract.interface.encodeFunctionData("revokeRole",[qt(Vt.asset),r]));return e.push(this.contract.interface.encodeFunctionData("grantRole",[qt(Vt.asset),i.AddressZero])),t.next=12,this.sendTransaction("multicall",[e]);case 12:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.isV2=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.readOnlyContract.VERSION();case 2:return t.abrupt("return",2===t.sent.toNumber());case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.isNewBuy=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.checkVersion();case 2:return t.abrupt("return",this._isNewBuy);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.checkVersion=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._shouldCheckVersion){t.next=11;break}return t.prev=1,t.next=4,this.readOnlyContract.VERSION();case 4:this._isNewBuy=!0,t.next=10;break;case 7:t.prev=7,t.t0=t.catch(1),this._isNewBuy=!1;case 10:this._shouldCheckVersion=!1;case 11:case"end":return t.stop()}}),t,this,[[1,7]])})));return function(){return t.apply(this,arguments)}}(),e}(Yt);Ze.moduleType=exports.ModuleType.MARKETPLACE,Ze.roles=[Vt.admin,Vt.lister,Vt.asset];var ze,He=[{name:"to",type:"address"},{name:"uri",type:"string"},{name:"price",type:"uint256"},{name:"currency",type:"address"},{name:"validityStartTimestamp",type:"uint128"},{name:"validityEndTimestamp",type:"uint128"},{name:"uid",type:"bytes32"}],Ke=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),a=0;a-1&&(s=t.name.substring(u))}r=""+(e+n)+s}else t instanceof Buffer||"string"==typeof t?r=""+(e+n):t&&t.name&&null!=t&&t.data?(a=null==t?void 0:t.data,r=""+t.name):r=""+(e+n);var c="files/"+r;if(o.indexOf(r)>-1)throw new q(r);o.push(r),"undefined"==typeof window?i.append("file",a,{filepath:c}):i.append("file",new Blob([a]),c)})),i.append("pinataMetadata",JSON.stringify(s)),t.next=11,fetch("https://api.pinata.cloud/pinning/pinFileToIPFS",{method:"POST",headers:{Authorization:"Bearer "+a},body:i});case 11:return u=t.sent,t.next=14,u.json();case 14:if(c=t.sent,u.ok){t.next=18;break}throw console.log(c),new V("Failed to upload files to IPFS");case 18:return t.abrupt("return",{cid:c.IpfsHash,fileNames:o});case 19:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.getUploadToken=function(){var t=k(F.mark((function t(e){var r,n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={"X-App-Name":"CONSOLE-TS-SDK-"+e},t.next=3,fetch("https://upload.nftlabs.co/grant",{method:"GET",headers:r});case 3:if((n=t.sent).ok){t.next=6;break}throw new Z("Failed to get upload token");case 6:return t.next=8,n.text();case 8:return t.abrupt("return",t.sent);case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),e.get=function(){var t=k(F.mark((function t(e){var r,n;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e,e&&(r=this.resolveFullUrl(e)),t.next=4,fetch(r);case 4:if((n=t.sent).ok){t.next=7;break}throw new Error("Status code (!= 200) ="+n.status);case 7:return t.next=9,n.text();case 9:return t.abrupt("return",t.sent);case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.buildFilePropertiesMap=function(t,e){var r=Object.keys(t).sort();for(var n in r){var a=t[r[n]];(a instanceof File||a instanceof Buffer)&&e.push(a),"object"==typeof a&&this.buildFilePropertiesMap(a,e)}return e},e.batchUploadProperties=function(){var t=k(F.mark((function t(e){var r,n,a,s,i,o;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof e){t.next=2;break}return t.abrupt("return",e);case 2:if(0!==(r=this.buildFilePropertiesMap(e,[])).length){t.next=5;break}return t.abrupt("return",e);case 5:return t.next=7,this.uploadBatchWithCid(r,"",0);case 7:for(a=(n=t.sent).cid,s=[],i=E(n.fileNames);!(o=i()).done;)s.push(a+"/"+o.value);return t.next=14,this.replaceFilePropertiesWithHashes(e,s);case 14:return t.abrupt("return",t.sent);case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.replaceFilePropertiesWithHashes=function(){var t=k(F.mark((function t(e,r){var n,a,s,i;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=Object.keys(e).sort(),t.t0=F.keys(n);case 2:if((t.t1=t.t0()).done){t.next=15;break}if(i=(s=e[n[a=t.t1.value]])instanceof File||s instanceof Buffer,"object"!=typeof s||i){t.next=10;break}return t.next=9,this.replaceFilePropertiesWithHashes(s,r);case 9:return t.abrupt("continue",2);case 10:if(i){t.next=12;break}return t.abrupt("continue",2);case 12:e[n[a]]="ipfs://"+r.splice(0,1)[0],t.next=2;break;case 15:return t.abrupt("return",e);case 16:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.uploadMetadata=function(){var t=k(F.mark((function t(e,r,n){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof e){t.next=2;break}return t.abrupt("return",e);case 2:return t.next=4,this.uploadMetadataBatch([e],r,0);case 4:return t.abrupt("return",t.sent.metadataUris[0]);case 7:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.uploadMetadataBatch=function(){var t=k(F.mark((function t(e,r,n){var a,s,i,o,u,c,p,d,l;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.filter((function(t){return"string"!=typeof t})),t.next=3,this.batchUploadProperties(a);case 3:if(0!==(s=t.sent.map((function(t){return JSON.stringify(t)}))).length){t.next=6;break}return t.abrupt("return",{baseUri:"",metadataUris:e.filter((function(t){return"string"==typeof t}))});case 6:return t.next=8,this.uploadBatchWithCid(s,r,n);case 8:for(o=(i=t.sent).fileNames,u="ipfs://"+i.cid+"/",c=[],p=E(e);!(d=p()).done;)c.push("string"==typeof(l=d.value)?l:""+u+o.splice(0,1)[0]);return t.abrupt("return",{baseUri:u,metadataUris:c});case 15:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.resolveFullUrl=function(t){return"string"!=typeof t?"":t&&t.toLowerCase().includes("ipfs://")?t.replace("ipfs://",this.gatewayUrl):t},e.canResolve=function(t){return this.resolveFullUrl(t).toLowerCase()!==t.toLowerCase()},t}(),tr=function(t){function e(){return t.apply(this,arguments)||this}S(e,t);var r=e.prototype;return r.connectContract=function(){return s.Registry__factory.connect(this.address,this.providerOrSigner)},r.getProtocolContracts=function(){var t=k(F.mark((function t(e){var r,n,a,s,i=this;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=e,t.t0){t.next=5;break}return t.next=4,this.getSignerAddress();case 4:t.t0=t.sent;case 5:return r=t.t0,t.next=8,this.readOnlyContract.getProtocolControlCount(r);case 8:return n=Array.from(Array(t.sent.toNumber()).keys()).reverse(),t.next=12,Promise.all(n.map((function(t){return i.readOnlyContract.getProtocolControl(r,(t+1).toString())})));case 12:return a=t.sent,t.next=15,Promise.all(a.map((function(t){return pt(i.providerOrSigner,t,i.sdk.getStorage()).catch((function(){}))})));case 15:return s=t.sent,t.abrupt("return",n.map((function(t,e){return{address:a[e],version:t,metadata:s[e]}})));case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e}(Qt),er=function(){function t(t,e){this.options=void 0,this.defaultOptions={ipfsGatewayUrl:"https://cloudflare-ipfs.com/ipfs/",registryContractAddress:"",maxGasPriceInGwei:300,gasSpeed:"fastest",transactionRelayerUrl:"",transactionRelayerSendFunction:this.defaultRelayerSendFunction.bind(this),transactionRelayerForwarderAddress:"0xc82BbE41f2cF04e3a8efA18F7032BDD7f6d98a81",readOnlyRpcUrl:"",gasless:{biconomy:{apiId:"",apiKey:"",deadlineSeconds:3600,gasTier:"RAPID"}},gaslessSendFunction:this.defaultGaslessSendFunction.bind(this)},this.modules=new Map,this.providerOrSigner=void 0,this._signer=null,this._jsonConvert=new m.JsonConvert,this.storage=void 0,this.event=new h.EventEmitter2,this._registry=null,this.providerOrSigner=this.setProviderOrSigner(t),this.options=M({},this.defaultOptions,e),this.storage=new $e(this.options.ipfsGatewayUrl)}var r=t.prototype;return r.updateModuleSigners=function(){for(var t,e=E(this.modules);!(t=e()).done;){var r=t.value[1];this.isReadOnly()&&r.clearSigner(),r.setProviderOrSigner(this.providerOrSigner)}},r.getProvider=function(){return f.Provider.isProvider(this.providerOrSigner)?this.providerOrSigner:this.providerOrSigner.provider},r.getSigner=function(){if(u.Signer.isSigner(this.providerOrSigner))return this.providerOrSigner},r.getChainID=function(){var t=k(F.mark((function t(){var e;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(e=this.getProvider())||Zt(!1),t.next=4,e.getNetwork();case 4:return t.abrupt("return",t.sent.chainId);case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getRegistryAddress=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.options.registryContractAddress){t.next=2;break}return t.abrupt("return",this.options.registryContractAddress);case 2:return t.t0=ee,t.next=5,this.getChainID();case 5:return t.t1=t.sent,t.abrupt("return",(0,t.t0)(t.t1));case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getRegistryModule=function(){var t=k(F.mark((function t(){var e;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getRegistryAddress();case 2:return(e=t.sent)||Zt(!1),t.abrupt("return",this.registry=this.getOrCreateModule(e,tr));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getOrCreateModule=function(t,e){if(this.modules.has(t))return this.modules.get(t);var r=new e(this.providerOrSigner,t,this.options,this);return this.modules.set(t,r),r},r.getForwarderAddress=function(){var t=k(F.mark((function t(){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=this.registry,t.t0){t.next=5;break}return t.next=4,this.getRegistryModule();case 4:t.t0=t.sent;case 5:return t.next=7,t.t0.readOnlyContract.forwarder();case 7:return t.abrupt("return",t.sent);case 8:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getApps=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=this.registry,t.t0){t.next=5;break}return t.next=4,this.getRegistryModule();case 4:t.t0=t.sent;case 5:return t.abrupt("return",t.t0.getProtocolContracts(e));case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.createApp=function(){var t=k(F.mark((function t(e){var r,n,a,s,i,u;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=this.registry,t.t0){t.next=5;break}return t.next=4,this.getRegistryModule();case 4:t.t0=t.sent;case 5:return n=t.t0.contract,t.next=8,this.getGasPrice();case 8:return s={},"number"==typeof(a=t.sent)&&(s.gasPrice=o.parseUnits(a.toString(),"gwei")),t.t1=at,t.t2=e,t.t3=n.address,t.next=16,null==(r=this.signer)?void 0:r.getAddress();case 16:if(t.t4=t.sent,t.t4){t.next=19;break}t.t4=void 0;case 19:return t.t5=t.t4,t.next=22,(0,t.t1)(t.t2,t.t3,t.t5);case 22:return i=t.sent,t.next=25,n.deployProtocol(i,s);case 25:return u=t.sent,t.next=28,u.wait();case 28:return t.abrupt("return",t.sent);case 29:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getGasPrice=function(){var t=k(F.mark((function t(e,r){var n,a;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e||this.options.gasSpeed,a=r||this.options.maxGasPriceInGwei,t.t0=Wt,t.next=5,this.getChainID();case 5:return t.t1=t.sent,t.t2=n,t.t3=a,t.next=10,(0,t.t0)(t.t1,t.t2,t.t3);case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.setProviderOrSigner=function(t){return this.providerOrSigner=f.Provider.isProvider(t)||u.Signer.isSigner(t)?t:u.ethers.getDefaultProvider(t),this.signer=u.Signer.isSigner(t)?t:null,this.updateModuleSigners(),this.providerOrSigner},r.isReadOnly=function(){return!u.Signer.isSigner(this.signer)},r.getContractMetadata=function(){var t=k(F.mark((function t(e){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=M,t.t1={},t.next=4,pt(this.providerOrSigner,e,this.getStorage(),!0);case 4:return t.t2=t.sent,t.t3={address:e},t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t3));case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getAppModule=function(t){return this.getOrCreateModule(t,Oe)},r.getNFTModule=function(t){return this.getOrCreateModule(t,Ke)},r.getCollectionModule=function(t){return this.getBundleModule(t)},r.getBundleModule=function(t){return this.getOrCreateModule(t,Ne)},r.getPackModule=function(t){return this.getOrCreateModule(t,Qe)},r.getCurrencyModule=function(t){return this.getOrCreateModule(t,Ae)},r.getTokenModule=function(t){return this.getOrCreateModule(t,Se)},r.getDatastoreModule=function(t){return this.getOrCreateModule(t,Ve)},r.getMarketModule=function(t){return this.getOrCreateModule(t,Ge)},r.getDropModule=function(t){return this.getOrCreateModule(t,Je)},r.getBundleDropModule=function(t){return this.getOrCreateModule(t,Ue)},r.getMarketplaceModule=function(t){return this.getOrCreateModule(t,Ze)},r.getSplitsModule=function(t){return this.getOrCreateModule(t,Ye)},r.getVoteModule=function(t){return this.getOrCreateModule(t,Xe)},r.getBundleSignatureModule=function(t){return this.getOrCreateModule(t,$t)},r.invokeRoute=function(t,e){var r=t.split(".");if(r.length>0&&"thirdweb"===r[0]){if(4===r.length){var n,a=r[3];return(n=this.getModuleByName(r[1],r[2]))[a].apply(n,e.arguments||[])}if(3===r.length)throw new Error("reserved for thirdweb.bridge.function_name");if(2===r.length)return this[r[1]].apply(this,e.arguments||[])}throw new Error("uknown route")},r.getModuleByName=function(t,e){if("currency"===t)return this.getCurrencyModule(e);if("nft"===t)return this.getNFTModule(e);if("market"===t)return this.getMarketModule(e);if("bundle"===t||"collection"===t)return this.getCollectionModule(e);if("drop"===t)return this.getDropModule(e);if("splits"===t)return this.getSplitsModule(e);if("pack"===t)return this.getPackModule(e);if("datastore"===t)return this.getDatastoreModule(e);if("app"===t||"project"===t)return this.getAppModule(e);throw new Error("unsupported module")},r.defaultGaslessSendFunction=function(){var t=k(F.mark((function t(e,r){return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.options.gasless.biconomy.apiId||!this.options.gasless.biconomy.apiKey){t.next=2;break}return t.abrupt("return",this.biconomySendFunction(e,r));case 2:return t.abrupt("return",this.defenderSendFunction(e,r));case 3:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.biconomySendFunction=function(){var t=k(F.mark((function t(e,r){var n,a,s,i,o,c,p,d,l,f,h;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=this.getSigner(),s=this.getProvider(),a&&s||Zt(!1),i=new u.ethers.Contract(ee(r.chainId,"biconomyForwarder"),ne,s),o=0,t.next=7,ie(i,"getNonce",[r.from,o]);case 7:return c=t.sent,p={from:r.from,to:r.to,token:u.ethers.constants.AddressZero,txGas:r.gasLimit.toNumber(),tokenGasPrice:"0",batchId:o,batchNonce:c.toNumber(),deadline:Math.floor(Date.now()/1e3+(null!=(n=this.options.gasless.biconomy.deadlineSeconds)?n:3600)),data:r.data},d=u.ethers.utils.arrayify(u.ethers.utils.solidityKeccak256(["address","address","address","uint256","uint256","uint256","uint256","uint256","bytes32"],[p.from,p.to,p.token,p.txGas,p.tokenGasPrice,p.batchId,p.batchNonce,p.deadline,u.ethers.utils.keccak256(p.data)])),this.event.emit(Ut.Signature,{status:"submitted",message:d,signature:""}),t.next=13,a.signMessage(d);case 13:return this.event.emit(Ut.Signature,{status:"completed",message:d,signature:l=t.sent}),t.next=17,fetch(this.options.transactionRelayerUrl||"https://api.biconomy.io/api/v2/meta-tx/native",{method:"POST",body:JSON.stringify({from:r.from,apiId:this.options.gasless.biconomy.apiId,params:[p,l],to:r.to,gasLimit:r.gasLimit.toHexString(),gasType:this.options.gasless.biconomy.gasTier}),headers:{"x-api-key":this.options.gasless.biconomy.apiKey,"Content-Type":"application/json;charset=utf-8"}});case 17:if(!(f=t.sent).ok){t.next=25;break}return t.next=21,f.json();case 21:if((h=t.sent).txHash){t.next=24;break}throw new Error("relay transaction failed: "+(h.log||h.message));case 24:return t.abrupt("return",h.txHash);case 25:throw new Error("relay transaction failed");case 26:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.defenderSendFunction=function(){var t=k(F.mark((function t(e,r){var n,a,i,o,c,p,d,l,f,h,m,y,x,v,g,b,w,k;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.getSigner(),a=this.getProvider(),n||Zt(!1),a||Zt(!1),o=s.Forwarder__factory.connect(i=this.options.transactionRelayerForwarderAddress,a),t.next=8,ie(o,"getNonce",[r.from]);case 8:if(c=t.sent,p={name:"GSNv2 Forwarder",version:"0.0.1",chainId:r.chainId,verifyingContract:i},d={ForwardRequest:re},l={from:r.from,to:r.to,value:u.BigNumber.from(0).toString(),gas:u.BigNumber.from(r.gasLimit).toString(),nonce:u.BigNumber.from(c).toString(),data:r.data},this.event.emit(Ut.Signature,{status:"submitted",message:l,signature:""}),"approve"!==r.functionName||2!==r.functionArgs.length){t.next=26;break}return h=r.functionArgs[0],m=r.functionArgs[1],t.next=18,ge(n,e.address,r.from,h,m);case 18:x=(y=t.sent).message,g=u.ethers.utils.splitSignature(v=y.signature),b=g.r,w=g.s,k=g.v,l={to:e.address,owner:x.owner,spender:x.spender,value:u.BigNumber.from(x.value).toString(),nonce:u.BigNumber.from(x.nonce).toString(),deadline:u.BigNumber.from(x.deadline).toString(),r:b,s:w,v:k},f=v,t.next=31;break;case 26:return t.next=28,zt(n,p,d,l);case 28:f=t.sent.signature;case 31:return this.event.emit(Ut.Signature,{status:"completed",message:l,signature:f}),t.next=34,this.options.transactionRelayerSendFunction(l,f);case 34:return t.abrupt("return",t.sent);case 36:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.defaultRelayerSendFunction=function(){var t=k(F.mark((function t(e,r){var n,a,s,i;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="forward",null!=e&&e.owner&&(n="permit"),a=JSON.stringify({request:e,signature:r,type:n}),t.next=5,fetch(this.options.transactionRelayerUrl,{method:"POST",body:a});case 5:if(!(s=t.sent).ok){t.next=12;break}return t.next=9,s.json();case 9:return i=JSON.parse(t.sent.result),t.abrupt("return",i.txHash);case 12:throw new Error("relay transaction failed");case 13:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.createSnapshot=function(){var t=k(F.mark((function t(r){var n,a,s,i,o,u;return F.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(new Set(r).size