@ledgerhq/connect-kit 1.1.1-beta.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +3 -0
- package/dist/umd/index.js +2 -2
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
package/dist/umd/index.js
CHANGED
@@ -170,7 +170,7 @@ t.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,c=u>>1,l=-7,f=n?i-1:0,h=
|
|
170
170
|
color: #BBB0FF;
|
171
171
|
cursor: pointer;
|
172
172
|
`;var gt=function(e,t){return gt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},gt(e,t)};function yt(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}gt(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var vt=function(){return vt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},vt.apply(this,arguments)};function mt(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))}function _t(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function bt(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var wt=function(){function e(){this.callbacks={}}return e.prototype.on=function(e,t){return this.callbacks[e]?this.callbacks[e].push(t):this.callbacks[e]=[t],this},e.prototype.once=function(e,t){var n=this,r=function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];n.off(e,r),t.apply(n,i)};return this.on(e,r),this},e.prototype.off=function(e,t){var n,r=(null!==(n=this.callbacks[e])&&void 0!==n?n:[]).filter((function(e){return e!==t}));return this.callbacks[e]=r,this},e.prototype.emit=function(e){for(var t,n=this,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return(null!==(t=this.callbacks[e])&&void 0!==t?t:[]).forEach((function(e){e.apply(n,r)})),this},e}(),Et=function(e,t){return Et=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Et(e,t)};function St(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Et(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var Ot=function(){return Ot=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ot.apply(this,arguments)};function xt(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))}function It(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function Rt(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}function kt(e,t,n){t.split&&(t=t.split("."));for(var r,i,o=0,s=t.length,a=e;o<s&&"__proto__"!==(i=t[o++])&&"constructor"!==i&&"prototype"!==i;)a=a[i]=o===s?n:typeof(r=a[i])==typeof t?r:0*t[o]!=0||~(""+t[o]).indexOf(".")?{}:[]}"function"==typeof SuppressedError&&SuppressedError;var Ct=function(e){function t(t,n){var r=e.call(this,"".concat(t," ").concat(n))||this;return r.field=t,r}return St(t,e),t}(Error);function Pt(e){return"string"==typeof e}function At(e){return"number"==typeof e}function Nt(e){return"function"==typeof e}function Tt(e){return null!=e}function Mt(e){return"object"===Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}var Lt="is not a string",jt="is not an object",Ut="is nil";function Dt(e,t){return new Promise((function(n,r){var i=setTimeout((function(){r(Error("Promise timed out"))}),t);e.then((function(e){return clearTimeout(i),n(e)})).catch(r)}))}function zt(e,t,n){var r;return(r=n,new Promise((function(e){return setTimeout(e,r)}))).then((function(){return Dt(function(){try{return Promise.resolve(t(e))}catch(e){return Promise.reject(e)}}(),1e3)})).catch((function(t){null==e||e.log("warn","Callback Error",{error:t}),null==e||e.stats.increment("callback_error")})).then((function(){return e}))}for(var Ft,Bt="onRemoveFromFuture",Ht=function(e){function t(t,n,r){var i=e.call(this)||this;return i.future=[],i.maxAttempts=t,i.queue=n,i.seen=null!=r?r:{},i}return St(t,e),t.prototype.push=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.map((function(t){return!(e.updateAttempts(t)>e.maxAttempts||e.includes(t))&&(e.queue.push(t),!0)}));return this.queue=this.queue.sort((function(t,n){return e.getAttempts(t)-e.getAttempts(n)})),r},t.prototype.pushWithBackoff=function(e){var t=this;if(0===this.getAttempts(e))return this.push(e)[0];var n=this.updateAttempts(e);if(n>this.maxAttempts||this.includes(e))return!1;var r=function(e){var t=Math.random()+1,n=e.minTimeout,r=void 0===n?500:n,i=e.factor,o=void 0===i?2:i,s=e.attempt,a=e.maxTimeout,u=void 0===a?1/0:a;return Math.min(t*r*Math.pow(o,s),u)}({attempt:n-1});return setTimeout((function(){t.queue.push(e),t.future=t.future.filter((function(t){return t.id!==e.id})),t.emit(Bt)}),r),this.future.push(e),!0},t.prototype.getAttempts=function(e){var t;return null!==(t=this.seen[e.id])&&void 0!==t?t:0},t.prototype.updateAttempts=function(e){return this.seen[e.id]=this.getAttempts(e)+1,this.getAttempts(e)},t.prototype.includes=function(e){return this.queue.includes(e)||this.future.includes(e)||Boolean(this.queue.find((function(t){return t.id===e.id})))||Boolean(this.future.find((function(t){return t.id===e.id})))},t.prototype.pop=function(){return this.queue.shift()},Object.defineProperty(t.prototype,"length",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"todo",{get:function(){return this.queue.length+this.future.length},enumerable:!1,configurable:!0}),t}(wt),qt=256,Vt=[];qt--;)Vt[qt]=(qt+256).toString(16).substring(1);function $t(){var e,t=0,n="";if(!Ft||qt+16>256){for(Ft=Array(t=256);t--;)Ft[t]=256*Math.random()|0;t=qt=0}for(;t<16;t++)e=Ft[qt+t],n+=6==t?Vt[15&e|64]:8==t?Vt[63&e|128]:Vt[e],1&t&&t>1&&t<11&&(n+="-");return qt++,n}var Wt=function(){function e(){this._logs=[]}return e.prototype.log=function(e,t,n){var r=new Date;this._logs.push({level:e,message:t,time:r,extras:n})},Object.defineProperty(e.prototype,"logs",{get:function(){return this._logs},enumerable:!1,configurable:!0}),e.prototype.flush=function(){if(this.logs.length>1){var e=this._logs.reduce((function(e,t){var n,r,i,o=Ot(Ot({},t),{json:JSON.stringify(t.extras,null," "),extras:t.extras});delete o.time;var s=null!==(i=null===(r=t.time)||void 0===r?void 0:r.toISOString())&&void 0!==i?i:"";return e[s]&&(s="".concat(s,"-").concat(Math.random())),Ot(Ot({},e),((n={})[s]=o,n))}),{});console.table?console.table(e):console.log(e)}else this.logs.forEach((function(e){var t=e.level,n=e.message,r=e.extras;"info"===t||"debug"===t?console.log(n,null!=r?r:""):console[t](n,null!=r?r:"")}));this._logs=[]},e}(),Kt=function(){function e(){this.metrics=[]}return e.prototype.increment=function(e,t,n){void 0===t&&(t=1),this.metrics.push({metric:e,value:t,tags:null!=n?n:[],type:"counter",timestamp:Date.now()})},e.prototype.gauge=function(e,t,n){this.metrics.push({metric:e,value:t,tags:null!=n?n:[],type:"gauge",timestamp:Date.now()})},e.prototype.flush=function(){var e=this.metrics.map((function(e){return Ot(Ot({},e),{tags:e.tags.join(",")})}));console.table?console.table(e):console.log(e),this.metrics=[]},e.prototype.serialize=function(){return this.metrics.map((function(e){return{m:e.metric,v:e.value,t:e.tags,k:(t=e.type,{gauge:"g",counter:"c"}[t]),e:e.timestamp};var t}))},e}(),Gt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return St(t,e),t.prototype.gauge=function(){},t.prototype.increment=function(){},t.prototype.flush=function(){},t.prototype.serialize=function(){return[]},t}(Kt),Yt=function(e){var t,n,r;this.retry=null===(t=e.retry)||void 0===t||t,this.type=null!==(n=e.type)&&void 0!==n?n:"plugin Error",this.reason=null!==(r=e.reason)&&void 0!==r?r:""},Qt=function(){function e(e,t,n,r){void 0===t&&(t=$t()),void 0===n&&(n=new Gt),void 0===r&&(r=new Wt),this.attempts=0,this.event=e,this._id=t,this.logger=r,this.stats=n}return e.system=function(){},e.prototype.isSame=function(e){return e.id===this.id},e.prototype.cancel=function(e){if(e)throw e;throw new Yt({reason:"Context Cancel"})},e.prototype.log=function(e,t,n){this.logger.log(e,t,n)},Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),e.prototype.updateEvent=function(e,t){var n;if("integrations"===e.split(".")[0]){var r=e.split(".")[1];if(!1===(null===(n=this.event.integrations)||void 0===n?void 0:n[r]))return this.event}return kt(this.event,e,t),this.event},e.prototype.failedDelivery=function(){return this._failedDelivery},e.prototype.setFailedDelivery=function(e){this._failedDelivery=e},e.prototype.logs=function(){return this.logger.logs},e.prototype.flush=function(){this.logger.flush(),this.stats.flush()},e.prototype.toJSON=function(){return{id:this._id,event:this.event,logs:this.logger.logs,metrics:this.stats.metrics}},e}();function Jt(e,t){e.log("debug","plugin",{plugin:t.name});var n=(new Date).getTime(),r=t[e.event.type];if(void 0===r)return Promise.resolve(e);var i=function(e){return xt(this,void 0,void 0,(function(){var t;return It(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e()];case 1:return[2,n.sent()];case 2:return t=n.sent(),[2,Promise.reject(t)];case 3:return[2]}}))}))}((function(){return r.apply(t,[e])})).then((function(e){var r=(new Date).getTime()-n;return e.stats.gauge("plugin_time",r,["plugin:".concat(t.name)]),e})).catch((function(n){if(n instanceof Yt&&"middleware_cancellation"===n.type)throw n;return n instanceof Yt?(e.log("warn",n.type,{plugin:t.name,error:n}),n):(e.log("error","plugin Error",{plugin:t.name,error:n}),e.stats.increment("plugin_error",1,["plugin:".concat(t.name)]),n)}));return i}function Xt(e,t){return Jt(e,t).then((function(t){if(t instanceof Qt)return t;e.log("debug","Context canceled"),e.stats.increment("context_canceled"),e.cancel(t)}))}var Zt=function(e){function t(t){var n,r,i,o=e.call(this)||this;return o.criticalTasks=(i=0,{done:function(){return n},run:function(e){var t,o=e();return"object"==typeof(t=o)&&null!==t&&"then"in t&&"function"==typeof t.then&&(1==++i&&(n=new Promise((function(e){return r=e}))),o.finally((function(){return 0==--i&&r()}))),o}}),o.plugins=[],o.failedInitializations=[],o.flushing=!1,o.queue=t,o.queue.on(Bt,(function(){o.scheduleFlush(0)})),o}return St(t,e),t.prototype.register=function(e,t,n){return xt(this,void 0,void 0,(function(){var r=this;return It(this,(function(i){switch(i.label){case 0:return[4,Promise.resolve(t.load(e,n)).then((function(){r.plugins.push(t)})).catch((function(n){if("destination"===t.type)return r.failedInitializations.push(t.name),console.warn(t.name,n),void e.log("warn","Failed to load destination",{plugin:t.name,error:n});throw n}))];case 1:return i.sent(),[2]}}))}))},t.prototype.deregister=function(e,t,n){return xt(this,void 0,void 0,(function(){var r;return It(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),t.unload?[4,Promise.resolve(t.unload(e,n))]:[3,2];case 1:i.sent(),i.label=2;case 2:return this.plugins=this.plugins.filter((function(e){return e.name!==t.name})),[3,4];case 3:return r=i.sent(),e.log("warn","Failed to unload destination",{plugin:t.name,error:r}),[3,4];case 4:return[2]}}))}))},t.prototype.dispatch=function(e){return xt(this,void 0,void 0,(function(){var t;return It(this,(function(n){return e.log("debug","Dispatching"),e.stats.increment("message_dispatched"),this.queue.push(e),t=this.subscribeToDelivery(e),this.scheduleFlush(0),[2,t]}))}))},t.prototype.subscribeToDelivery=function(e){return xt(this,void 0,void 0,(function(){var t=this;return It(this,(function(n){return[2,new Promise((function(n){var r=function(i,o){i.isSame(e)&&(t.off("flush",r),n(i))};t.on("flush",r)}))]}))}))},t.prototype.dispatchSingle=function(e){return xt(this,void 0,void 0,(function(){var t=this;return It(this,(function(n){return e.log("debug","Dispatching"),e.stats.increment("message_dispatched"),this.queue.updateAttempts(e),e.attempts=1,[2,this.deliver(e).catch((function(n){return t.enqueuRetry(n,e)?t.subscribeToDelivery(e):(e.setFailedDelivery({reason:n}),e)}))]}))}))},t.prototype.isEmpty=function(){return 0===this.queue.length},t.prototype.scheduleFlush=function(e){var t=this;void 0===e&&(e=500),this.flushing||(this.flushing=!0,setTimeout((function(){t.flush().then((function(){setTimeout((function(){t.flushing=!1,t.queue.length&&t.scheduleFlush(0)}),0)}))}),e))},t.prototype.deliver=function(e){return xt(this,void 0,void 0,(function(){var t,n,r,i;return It(this,(function(o){switch(o.label){case 0:return[4,this.criticalTasks.done()];case 1:o.sent(),t=Date.now(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,this.flushOne(e)];case 3:return e=o.sent(),n=Date.now()-t,this.emit("delivery_success",e),e.stats.gauge("delivered",n),e.log("debug","Delivered",e.event),[2,e];case 4:throw r=o.sent(),i=r,e.log("error","Failed to deliver",i),this.emit("delivery_failure",e,i),e.stats.increment("delivery_failed"),r;case 5:return[2]}}))}))},t.prototype.enqueuRetry=function(e,t){return!(e instanceof Yt&&!e.retry)&&this.queue.pushWithBackoff(t)},t.prototype.flush=function(){return xt(this,void 0,void 0,(function(){var e,t;return It(this,(function(n){switch(n.label){case 0:if(0===this.queue.length)return[2,[]];if(!(e=this.queue.pop()))return[2,[]];e.attempts=this.queue.getAttempts(e),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.deliver(e)];case 2:return e=n.sent(),this.emit("flush",e,!0),[3,4];case 3:return t=n.sent(),this.enqueuRetry(t,e)||(e.setFailedDelivery({reason:t}),this.emit("flush",e,!1)),[2,[]];case 4:return[2,[e]]}}))}))},t.prototype.isReady=function(){return!0},t.prototype.availableExtensions=function(e){var t,n,r=this.plugins.filter((function(t){var n,r,i;if("destination"!==t.type&&"Segment.io"!==t.name)return!0;var o=void 0;return null===(n=t.alternativeNames)||void 0===n||n.forEach((function(t){void 0!==e[t]&&(o=e[t])})),null!==(i=null!==(r=e[t.name])&&void 0!==r?r:o)&&void 0!==i?i:!1!==("Segment.io"===t.name||e.All)})),i=(t="type",n={},r.forEach((function(e){var r,i=void 0;if("string"==typeof t){var o=e[t];i="string"!=typeof o?JSON.stringify(o):o}else t instanceof Function&&(i=t(e));void 0!==i&&(n[i]=Rt(Rt([],null!==(r=n[i])&&void 0!==r?r:[],!0),[e],!1))})),n),o=i.before,s=void 0===o?[]:o,a=i.enrichment,u=void 0===a?[]:a,c=i.destination,l=void 0===c?[]:c,f=i.after;return{before:s,enrichment:u,destinations:l,after:void 0===f?[]:f}},t.prototype.flushOne=function(e){var t,n;return xt(this,void 0,void 0,(function(){var r,i,o,s,a,u,c,l,f,h,d,p,g,y;return It(this,(function(v){switch(v.label){case 0:if(!this.isReady())throw new Error("Not ready");e.attempts>1&&this.emit("delivery_retry",e),r=this.availableExtensions(null!==(t=e.event.integrations)&&void 0!==t?t:{}),i=r.before,o=r.enrichment,s=0,a=i,v.label=1;case 1:return s<a.length?(u=a[s],[4,Xt(e,u)]):[3,4];case 2:(h=v.sent())instanceof Qt&&(e=h),this.emit("message_enriched",e,u),v.label=3;case 3:return s++,[3,1];case 4:c=0,l=o,v.label=5;case 5:return c<l.length?(f=l[c],[4,Jt(e,f)]):[3,8];case 6:(h=v.sent())instanceof Qt&&(e=h),this.emit("message_enriched",e,f),v.label=7;case 7:return c++,[3,5];case 8:return d=this.availableExtensions(null!==(n=e.event.integrations)&&void 0!==n?n:{}),p=d.destinations,g=d.after,[4,new Promise((function(t,n){setTimeout((function(){var r=p.map((function(t){return Jt(e,t)}));Promise.all(r).then(t).catch(n)}),0)}))];case 9:return v.sent(),e.stats.increment("message_delivered"),this.emit("message_delivered",e),y=g.map((function(t){return Jt(e,t)})),[4,Promise.all(y)];case 10:return v.sent(),[2,e]}}))}))},t}(wt);function en(e,t,n,r){return xt(this,void 0,void 0,(function(){var i,o;return It(this,(function(s){switch(s.label){case 0:return n.emit("dispatch_start",e),i=Date.now(),t.isEmpty()?[4,t.dispatchSingle(e)]:[3,2];case 1:return o=s.sent(),[3,4];case 2:return[4,t.dispatch(e)];case 3:o=s.sent(),s.label=4;case 4:return(null==r?void 0:r.callback)?[4,zt(o,r.callback,(a=i,u=r.timeout,c=Date.now()-a,Math.max((null!=u?u:300)-c,0)))]:[3,6];case 5:o=s.sent(),s.label=6;case 6:return(null==r?void 0:r.debug)&&o.flush(),[2,o]}var a,u,c}))}))}function tn(e,t,n,r){var i,o=[e,t,n,r],s=Mt(e)?e.event:e;if(!s||!Pt(s))throw new Error("Event missing");var a=Mt(e)?null!==(i=e.properties)&&void 0!==i?i:{}:Mt(t)?t:{},u={};return Nt(n)||(u=null!=n?n:{}),Mt(e)&&!Nt(t)&&(u=null!=t?t:{}),[s,a,u,o.find(Nt)]}function nn(e,t,n,r,i){var o,s,a=null,u=null,c=[e,t,n,r,i],l=c.filter(Pt);void 0!==l[0]&&void 0!==l[1]&&(a=l[0],u=l[1]),1===l.length&&(a=null,u=l[0]);var f=c.find(Nt),h=c.filter((function(e){return null===u?Mt(e):Mt(e)||null===e})),d=null!==(o=h[0])&&void 0!==o?o:{},p=null!==(s=h[1])&&void 0!==s?s:{};return[a,u,d,p,f]}var rn=function(e){return function(){for(var t,n,r,i,o,s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];var u;u=null!==(r=null!==(t=s.find(Pt))&&void 0!==t?t:null===(n=s.find(At))||void 0===n?void 0:n.toString())&&void 0!==r?r:e.id();var c=s.filter((function(e){return null===u?Mt(e):Mt(e)||null===e})),l=null!==(i=c[0])&&void 0!==i?i:{},f=null!==(o=c[1])&&void 0!==o?o:{},h=s.find(Nt);return[u,l,f,h]}};function on(e,t,n,r){At(e)&&(e=e.toString()),At(t)&&(t=t.toString());var i=[e,t,n,r],o=i.filter(Pt),s=o[0],a=void 0===s?e:s,u=o[1],c=void 0===u?null:u,l=i.filter(Mt)[0];return[a,c,void 0===l?{}:l,i.find(Nt)]}function sn(){return"undefined"!=typeof window}function an(){return!sn()}function un(){return!sn()||window.navigator.onLine}function cn(){return!un()}function ln(e,t){return t=t||{},new Promise((function(n,r){var i=new XMLHttpRequest,o=[],s=[],a={},u=function(){return{ok:2==(i.status/100|0),statusText:i.statusText,status:i.status,url:i.responseURL,text:function(){return Promise.resolve(i.responseText)},json:function(){return Promise.resolve(i.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([i.response]))},clone:u,headers:{keys:function(){return o},entries:function(){return s},get:function(e){return a[e.toLowerCase()]},has:function(e){return e.toLowerCase()in a}}}};for(var c in i.open(t.method||"get",e,!0),i.onload=function(){i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(e,t,n){o.push(t=t.toLowerCase()),s.push([t,n]),a[t]=a[t]?a[t]+","+n:n})),n(u())},i.onerror=r,i.withCredentials="include"==t.credentials,t.headers)i.setRequestHeader(c,t.headers[c]);i.send(t.body||null)}))}var fn=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:null},hn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=fn();return(n&&n.fetch||ln).apply(void 0,e)},dn="1.53.2";/*! js-cookie v3.0.1 | MIT */
|
173
|
-
function pn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var gn=function e(t,n){function r(e,r,i){if("undefined"!=typeof document){"number"==typeof(i=pn({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o="";for(var s in i)i[s]&&(o+="; "+s,!0!==i[s]&&(o+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+o}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},i=0;i<n.length;i++){var o=n[i].split("="),s=o.slice(1).join("=");try{var a=decodeURIComponent(o[0]);if(r[a]=t.read(s,a),e===a)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",pn({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,pn({},this.attributes,t))},withConverter:function(t){return e(pn({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});function yn(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(t){return e}}function vn(e){var t=function(e){try{return new URL(e)}catch(e){return}}(e);if(t)for(var n=function(e){var t=e.hostname.split("."),n=t[t.length-1],r=[];if(4===t.length&&parseInt(n,10)>0)return r;if(t.length<=1)return r;for(var i=t.length-2;i>=0;--i)r.push(t.slice(i).join("."));return r}(t),r=0;r<n.length;++r){var i="__tld__",o=n[r],s={domain:"."+o};try{if(gn.set(i,"1",s),gn.get(i))return gn.remove(i,s),o}catch(e){return}}}function mn(e){for(var t=e.constructor.prototype,n=0,r=Object.getOwnPropertyNames(t);n<r.length;n++){var i=r[n];if("constructor"!==i){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,i);o&&"function"==typeof o.value&&(e[i]=e[i].bind(e))}}return e}var _n={persist:!0,cookie:{key:"ajs_user_id",oldKey:"ajs_user"},localStorage:{key:"ajs_user_traits"}},bn=function(){function e(){this.cache={}}return e.prototype.get=function(e){return this.cache[e]},e.prototype.set=function(e,t){this.cache[e]=t},e.prototype.remove=function(e){delete this.cache[e]},Object.defineProperty(e.prototype,"type",{get:function(){return"memory"},enumerable:!1,configurable:!0}),e}(),wn=function(e){function t(n){void 0===n&&(n=t.defaults);var r=e.call(this)||this;return r.options=vt(vt({},t.defaults),n),r}return yt(t,e),t.available=function(){try{var e="ajs_cookies_check";gn.set(e,"test");var t=document.cookie.includes(e);return gn.remove(e),t}catch(e){return!1}},Object.defineProperty(t,"defaults",{get:function(){return{maxage:365,domain:vn(window.location.href),path:"/",sameSite:"Lax"}},enumerable:!1,configurable:!0}),t.prototype.opts=function(){return{sameSite:this.options.sameSite,expires:this.options.maxage,domain:this.options.domain,path:this.options.path,secure:this.options.secure}},t.prototype.get=function(e){try{var t=gn.get(e);if(!t)return null;try{return JSON.parse(t)}catch(e){return t}}catch(e){return null}},t.prototype.set=function(e,t){"string"==typeof t?gn.set(e,t,this.opts()):null===t?gn.remove(e,this.opts()):gn.set(e,JSON.stringify(t),this.opts())},t.prototype.remove=function(e){return gn.remove(e,this.opts())},Object.defineProperty(t.prototype,"type",{get:function(){return"cookie"},enumerable:!1,configurable:!0}),t}(bn),En=function(e,t){console.warn("Unable to access ".concat(e,", localStorage may be ").concat(t))},Sn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return yt(t,e),t.available=function(){var e="test";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}},t.prototype.get=function(e){try{var t=localStorage.getItem(e);if(null===t)return null;try{return JSON.parse(t)}catch(e){return t}}catch(t){return En(e,"unavailable"),null}},t.prototype.set=function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(t){En(e,"full")}},t.prototype.remove=function(e){try{return localStorage.removeItem(e)}catch(t){En(e,"unavailable")}},Object.defineProperty(t.prototype,"type",{get:function(){return"localStorage"},enumerable:!1,configurable:!0}),t}(bn),On=function(){function e(e,t){this.storageOptions=t,this.enabledStores=e}return e.prototype.getStores=function(e){var t=this,n=[];return this.enabledStores.filter((function(t){return!e||(null==e?void 0:e.includes(t))})).forEach((function(e){var r=t.storageOptions[e];void 0!==r&&n.push(r)})),n},e.prototype.getAndSync=function(e,t){var n=this.get(e,t),r="number"==typeof n?n.toString():n;return this.set(e,r,t),r},e.prototype.get=function(e,t){for(var n=null,r=0,i=this.getStores(t);r<i.length;r++){if(n=i[r].get(e))return n}return null},e.prototype.set=function(e,t,n){for(var r=0,i=this.getStores(n);r<i.length;r++){i[r].set(e,t)}},e.prototype.clear=function(e,t){for(var n=0,r=this.getStores(t);n<r.length;n++){r[n].remove(e)}},e}();function xn(e){return{cookie:wn.available()?new wn(e):void 0,localStorage:Sn.available()?new Sn:void 0,memory:new bn}}var In,Rn=function(){function e(e,t){void 0===e&&(e=_n);var n,r,i,o,s=this;this.options={},this.id=function(e){if(s.options.disable)return null;var t=s.identityStore.getAndSync(s.idKey);void 0!==e&&(s.identityStore.set(s.idKey,e),e!==t&&null!==t&&null!==e&&s.anonymousId(null));var n=s.identityStore.getAndSync(s.idKey);if(n)return n;var r=s.legacyUserStore.get(_n.cookie.oldKey);return r?"object"==typeof r?r.id:r:null},this.anonymousId=function(e){var t,n;if(s.options.disable)return null;if(void 0===e){var r=null!==(t=s.identityStore.getAndSync(s.anonKey))&&void 0!==t?t:null===(n=s.legacySIO())||void 0===n?void 0:n[0];if(r)return r}return null===e?(s.identityStore.set(s.anonKey,null),s.identityStore.getAndSync(s.anonKey)):(s.identityStore.set(s.anonKey,null!=e?e:$t()),s.identityStore.getAndSync(s.anonKey))},this.traits=function(e){var t;if(!s.options.disable)return null===e&&(e={}),e&&s.traitsStore.set(s.traitsKey,null!=e?e:{}),null!==(t=s.traitsStore.get(s.traitsKey))&&void 0!==t?t:{}},this.options=e,this.cookieOptions=t,this.idKey=null!==(r=null===(n=e.cookie)||void 0===n?void 0:n.key)&&void 0!==r?r:_n.cookie.key,this.traitsKey=null!==(o=null===(i=e.localStorage)||void 0===i?void 0:i.key)&&void 0!==o?o:_n.localStorage.key,this.anonKey="ajs_anonymous_id";var a=!0===e.disable,u=!1!==e.persist,c=a?[]:u?["localStorage","cookie","memory"]:["memory"],l=xn(t);e.localStorageFallbackDisabled&&(c=c.filter((function(e){return"localStorage"!==e}))),this.identityStore=new On(c,l),this.legacyUserStore=new On(c.filter((function(e){return"localStorage"!==e&&"memory"!==e})),l),this.traitsStore=new On(c.filter((function(e){return"cookie"!==e})),l);var f=this.legacyUserStore.get(_n.cookie.oldKey);f&&"object"==typeof f&&(f.id&&this.id(f.id),f.traits&&this.traits(f.traits)),mn(this)}return e.prototype.legacySIO=function(){var e=this.legacyUserStore.get("_sio");if(!e)return null;var t=e.split("----");return[t[0],t[1]]},e.prototype.identify=function(e,t){if(!this.options.disable){t=null!=t?t:{};var n=this.id();null!==n&&n!==e||(t=vt(vt({},this.traits()),t)),e&&this.id(e),this.traits(t)}},e.prototype.logout=function(){this.anonymousId(null),this.id(null),this.traits({})},e.prototype.reset=function(){this.logout(),this.identityStore.clear(this.idKey),this.identityStore.clear(this.anonKey),this.traitsStore.clear(this.traitsKey)},e.prototype.load=function(){return new e(this.options,this.cookieOptions)},e.prototype.save=function(){return!0},e.defaults=_n,e}(),kn={persist:!0,cookie:{key:"ajs_group_id"},localStorage:{key:"ajs_group_properties"}},Cn=function(e){function t(t,n){void 0===t&&(t=kn);var r=e.call(this,t,n)||this;return r.anonymousId=function(e){},mn(r),r}return yt(t,e),t}(Rn);var Pn="npm";function An(){return Pn}function Nn(e,t,n){var r=new On(n?[]:["cookie"],xn(function(){if(In)return In;var e=vn(window.location.href);return In={expires:31536e6,secure:!1,path:"/"},e&&(In.domain=e),In}())),i=r.get("s:context.referrer"),o=function(e){var t={btid:"dataxu",urid:"millennial-media"};e.startsWith("?")&&(e=e.substring(1));for(var n=0,r=(e=e.replace(/\?/g,"&")).split("&");n<r.length;n++){var i=r[n].split("="),o=i[0],s=i[1];if(t[o])return{id:s,type:t[o]}}}(e);(o=null!=o?o:i)&&(t&&(t.referrer=vt(vt({},t.referrer),o)),r.set("s:context.referrer",o))}function Tn(e,t,n,r){var i,o,s,a,u,c,l=e.user();t.context=null!==(o=null!==(i=t.context)&&void 0!==i?i:t.options)&&void 0!==o?o:{};var f=t.context,h="string"==typeof(null===(s=f.page)||void 0===s?void 0:s.search)?null===(a=f.page)||void 0===a?void 0:a.search:"";delete t.options,t.writeKey=null==n?void 0:n.apiKey,f.userAgent=navigator.userAgent;var d=navigator.userLanguage||navigator.language;if(void 0===f.locale&&void 0!==d&&(f.locale=d),!f.library){var p=An();f.library="web"===p?{name:"analytics.js",version:"next-".concat(dn)}:{name:"analytics.js",version:"npm:next-".concat(dn)}}h&&!f.campaign&&(f.campaign=function(e){return e.startsWith("?")&&(e=e.substring(1)),(e=e.replace(/\?/g,"&")).split("&").reduce((function(e,t){var n=t.split("="),r=n[0],i=n[1],o=void 0===i?"":i;if(r.includes("utm_")&&r.length>4){var s=r.substr(4);"campaign"===s&&(s="name"),e[s]=yn(o)}return e}),{})}(h)),Nn(h,f,null!==(u=e.options.disableClientPersistence)&&void 0!==u&&u),t.userId=t.userId||l.id(),t.anonymousId=t.anonymousId||l.anonymousId(),t.sentAt=new Date;var g=e.queue.failedInitializations||[];g.length>0&&(t._metadata={failedInitializations:g});var y=[],v=[];for(var m in r){var _=r[m];"Segment.io"===m&&y.push(m),"bundled"===_.bundlingStatus&&y.push(m),"unbundled"===_.bundlingStatus&&v.push(m)}for(var b=0,w=(null==n?void 0:n.unbundledIntegrations)||[];b<w.length;b++){var E=w[b];v.includes(E)||v.push(E)}var S=null!==(c=null==n?void 0:n.maybeBundledConfigIds)&&void 0!==c?c:{},O=[];y.sort().forEach((function(e){var t;(null!==(t=S[e])&&void 0!==t?t:[]).forEach((function(e){O.push(e)}))})),!1!==(null==n?void 0:n.addBundledMetadata)&&(t._metadata=vt(vt({},t._metadata),{bundled:y.sort(),unbundled:v.sort(),bundledIds:O}));var x=function(){var e=gn.get("_ga");if(e&&e.startsWith("amp"))return e}();return x&&(f.amp={id:x}),t}var Mn="api.segment.io/v1";function Ln(e){console.error("Error sending segment performance metrics",e)}var jn,Un=function(){function e(e){var t,n,r,i,o=this;if(this.host=null!==(t=null==e?void 0:e.host)&&void 0!==t?t:Mn,this.sampleRate=null!==(n=null==e?void 0:e.sampleRate)&&void 0!==n?n:1,this.flushTimer=null!==(r=null==e?void 0:e.flushTimer)&&void 0!==r?r:3e4,this.maxQueueSize=null!==(i=null==e?void 0:e.maxQueueSize)&&void 0!==i?i:20,this.queue=[],this.sampleRate>0){var s=!1,a=function(){s||(s=!0,o.flush().catch(Ln),s=!1,setTimeout(a,o.flushTimer))};a()}}return e.prototype.increment=function(e,t){if(e.includes("analytics_js.")&&0!==t.length&&!(Math.random()>this.sampleRate||this.queue.length>=this.maxQueueSize)){var n=function(e,t,n){var r=t.reduce((function(e,t){var n=t.split(":"),r=n[0],i=n[1];return e[r]=i,e}),{});return{type:"Counter",metric:e,value:1,tags:vt(vt({},r),{library:"analytics.js",library_version:"web"===n?"next-".concat(dn):"npm:next-".concat(dn)})}}(e,t,An());this.queue.push(n),e.includes("error")&&this.flush().catch(Ln)}},e.prototype.flush=function(){return mt(this,void 0,void 0,(function(){var e=this;return _t(this,(function(t){switch(t.label){case 0:return this.queue.length<=0?[2]:[4,this.send().catch((function(t){Ln(t),e.sampleRate=0}))];case 1:return t.sent(),[2]}}))}))},e.prototype.send=function(){return mt(this,void 0,void 0,(function(){var e,t,n;return _t(this,(function(r){return e={series:this.queue},this.queue=[],t={"Content-Type":"text/plain"},n="https://".concat(this.host,"/m"),[2,hn(n,{headers:t,body:JSON.stringify(e),method:"POST"})]}))}))},e}(),Dn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return yt(t,e),t.initRemoteMetrics=function(e){jn=new Un(e)},t.prototype.increment=function(t,n,r){e.prototype.increment.call(this,t,n,r),null==jn||jn.increment(t,null!=r?r:[])},t}(Kt),zn=function(e){function t(t,n){return e.call(this,t,n,new Dn)||this}return yt(t,e),t.system=function(){return new this({type:"track",event:"system"})},t}(Qt),Fn={exports:{}};!function(e,t){e.exports=function(e){var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(e,t){var n=e[0],r=e[1],i=e[2],o=e[3];r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[0]-680876936|0)<<7|n>>>25)+r|0)&r|~n&i)+t[1]-389564586|0)<<12|o>>>20)+n|0)&n|~o&r)+t[2]+606105819|0)<<17|i>>>15)+o|0)&o|~i&n)+t[3]-1044525330|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[4]-176418897|0)<<7|n>>>25)+r|0)&r|~n&i)+t[5]+1200080426|0)<<12|o>>>20)+n|0)&n|~o&r)+t[6]-1473231341|0)<<17|i>>>15)+o|0)&o|~i&n)+t[7]-45705983|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[8]+1770035416|0)<<7|n>>>25)+r|0)&r|~n&i)+t[9]-1958414417|0)<<12|o>>>20)+n|0)&n|~o&r)+t[10]-42063|0)<<17|i>>>15)+o|0)&o|~i&n)+t[11]-1990404162|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[12]+1804603682|0)<<7|n>>>25)+r|0)&r|~n&i)+t[13]-40341101|0)<<12|o>>>20)+n|0)&n|~o&r)+t[14]-1502002290|0)<<17|i>>>15)+o|0)&o|~i&n)+t[15]+1236535329|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[1]-165796510|0)<<5|n>>>27)+r|0)&i|r&~i)+t[6]-1069501632|0)<<9|o>>>23)+n|0)&r|n&~r)+t[11]+643717713|0)<<14|i>>>18)+o|0)&n|o&~n)+t[0]-373897302|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[5]-701558691|0)<<5|n>>>27)+r|0)&i|r&~i)+t[10]+38016083|0)<<9|o>>>23)+n|0)&r|n&~r)+t[15]-660478335|0)<<14|i>>>18)+o|0)&n|o&~n)+t[4]-405537848|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[9]+568446438|0)<<5|n>>>27)+r|0)&i|r&~i)+t[14]-1019803690|0)<<9|o>>>23)+n|0)&r|n&~r)+t[3]-187363961|0)<<14|i>>>18)+o|0)&n|o&~n)+t[8]+1163531501|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[13]-1444681467|0)<<5|n>>>27)+r|0)&i|r&~i)+t[2]-51403784|0)<<9|o>>>23)+n|0)&r|n&~r)+t[7]+1735328473|0)<<14|i>>>18)+o|0)&n|o&~n)+t[12]-1926607734|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[5]-378558|0)<<4|n>>>28)+r|0)^r^i)+t[8]-2022574463|0)<<11|o>>>21)+n|0)^n^r)+t[11]+1839030562|0)<<16|i>>>16)+o|0)^o^n)+t[14]-35309556|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[1]-1530992060|0)<<4|n>>>28)+r|0)^r^i)+t[4]+1272893353|0)<<11|o>>>21)+n|0)^n^r)+t[7]-155497632|0)<<16|i>>>16)+o|0)^o^n)+t[10]-1094730640|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[13]+681279174|0)<<4|n>>>28)+r|0)^r^i)+t[0]-358537222|0)<<11|o>>>21)+n|0)^n^r)+t[3]-722521979|0)<<16|i>>>16)+o|0)^o^n)+t[6]+76029189|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[9]-640364487|0)<<4|n>>>28)+r|0)^r^i)+t[12]-421815835|0)<<11|o>>>21)+n|0)^n^r)+t[15]+530742520|0)<<16|i>>>16)+o|0)^o^n)+t[2]-995338651|0)<<23|r>>>9)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[0]-198630844|0)<<6|n>>>26)+r|0)|~i))+t[7]+1126891415|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[14]-1416354905|0)<<15|i>>>17)+o|0)|~n))+t[5]-57434055|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[12]+1700485571|0)<<6|n>>>26)+r|0)|~i))+t[3]-1894986606|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[10]-1051523|0)<<15|i>>>17)+o|0)|~n))+t[1]-2054922799|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[8]+1873313359|0)<<6|n>>>26)+r|0)|~i))+t[15]-30611744|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[6]-1560198380|0)<<15|i>>>17)+o|0)|~n))+t[13]+1309151649|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[4]-145523070|0)<<6|n>>>26)+r|0)|~i))+t[11]-1120210379|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[2]+718787259|0)<<15|i>>>17)+o|0)|~n))+t[9]-343485551|0)<<21|r>>>11)+i|0,e[0]=n+e[0]|0,e[1]=r+e[1]|0,e[2]=i+e[2]|0,e[3]=o+e[3]|0}function r(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}function i(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n}function o(e){var t,i,o,s,a,u,c=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(l,r(e.substring(t-64,t)));for(i=(e=e.substring(t-64)).length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)o[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(l,o),t=0;t<16;t+=1)o[t]=0;return s=(s=8*c).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(s[2],16),u=parseInt(s[1],16)||0,o[14]=a,o[15]=u,n(l,o),l}function s(e){var t,r,o,s,a,u,c=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(l,i(e.subarray(t-64,t)));for(r=(e=t-64<c?e.subarray(t-64):new Uint8Array(0)).length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<r;t+=1)o[t>>2]|=e[t]<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(l,o),t=0;t<16;t+=1)o[t]=0;return s=(s=8*c).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(s[2],16),u=parseInt(s[1],16)||0,o[14]=a,o[15]=u,n(l,o),l}function a(e){var n,r="";for(n=0;n<4;n+=1)r+=t[e>>8*n+4&15]+t[e>>8*n&15];return r}function u(e){var t;for(t=0;t<e.length;t+=1)e[t]=a(e[t]);return e.join("")}function c(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function l(e,t){var n,r=e.length,i=new ArrayBuffer(r),o=new Uint8Array(i);for(n=0;n<r;n+=1)o[n]=e.charCodeAt(n);return t?o:i}function f(e){return String.fromCharCode.apply(null,new Uint8Array(e))}function h(e,t,n){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e)),r.set(new Uint8Array(t),e.byteLength),n?r:r.buffer}function d(e){var t,n=[],r=e.length;for(t=0;t<r-1;t+=2)n.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,n)}function p(){this.reset()}return u(o("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(n,r){var i,o,s,a,u=this.byteLength,c=t(n,u),l=u;return r!==e&&(l=t(r,u)),c>l?new ArrayBuffer(0):(i=l-c,o=new ArrayBuffer(i),s=new Uint8Array(o),a=new Uint8Array(this,c,i),s.set(a),o)}}(),p.prototype.append=function(e){return this.appendBinary(c(e)),this},p.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,i=this._buff.length;for(t=64;t<=i;t+=64)n(this._hash,r(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},p.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(o,i),n=u(this._hash),e&&(n=d(n)),this.reset(),n},p.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},p.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},p.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},p.prototype._finish=function(e,t){var r,i,o,s=t;if(e[s>>2]|=128<<(s%4<<3),s>55)for(n(this._hash,e),s=0;s<16;s+=1)e[s]=0;r=(r=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(r[2],16),o=parseInt(r[1],16)||0,e[14]=i,e[15]=o,n(this._hash,e)},p.hash=function(e,t){return p.hashBinary(c(e),t)},p.hashBinary=function(e,t){var n=u(o(e));return t?d(n):n},p.ArrayBuffer=function(){this.reset()},p.ArrayBuffer.prototype.append=function(e){var t,r=h(this._buff.buffer,e,!0),o=r.length;for(this._length+=e.byteLength,t=64;t<=o;t+=64)n(this._hash,i(r.subarray(t-64,t)));return this._buff=t-64<o?new Uint8Array(r.buffer.slice(t-64)):new Uint8Array(0),this},p.ArrayBuffer.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r[t]<<(t%4<<3);return this._finish(o,i),n=u(this._hash),e&&(n=d(n)),this.reset(),n},p.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.ArrayBuffer.prototype.getState=function(){var e=p.prototype.getState.call(this);return e.buff=f(e.buff),e},p.ArrayBuffer.prototype.setState=function(e){return e.buff=l(e.buff,!0),p.prototype.setState.call(this,e)},p.ArrayBuffer.prototype.destroy=p.prototype.destroy,p.ArrayBuffer.prototype._finish=p.prototype._finish,p.ArrayBuffer.hash=function(e,t){var n=u(s(new Uint8Array(e)));return t?d(n):n},p}()}(Fn);var Bn=Fn.exports,Hn=function(){function e(e){this.user=e}return e.prototype.track=function(e,t,n,r){return this.normalize(vt(vt({},this.baseEvent()),{event:e,type:"track",properties:t,options:vt({},n),integrations:vt({},r)}))},e.prototype.page=function(e,t,n,r,i){var o,s={type:"page",properties:vt({},n),options:vt({},r),integrations:vt({},i)};return null!==e&&(s.category=e,s.properties=null!==(o=s.properties)&&void 0!==o?o:{},s.properties.category=e),null!==t&&(s.name=t),this.normalize(vt(vt({},this.baseEvent()),s))},e.prototype.screen=function(e,t,n,r,i){var o={type:"screen",properties:vt({},n),options:vt({},r),integrations:vt({},i)};return null!==e&&(o.category=e),null!==t&&(o.name=t),this.normalize(vt(vt({},this.baseEvent()),o))},e.prototype.identify=function(e,t,n,r){return this.normalize(vt(vt({},this.baseEvent()),{type:"identify",userId:e,traits:t,options:vt({},n),integrations:vt({},r)}))},e.prototype.group=function(e,t,n,r){return this.normalize(vt(vt({},this.baseEvent()),{type:"group",traits:t,options:vt({},n),integrations:vt({},r),groupId:e}))},e.prototype.alias=function(e,t,n,r){var i={userId:e,type:"alias",options:vt({},n),integrations:vt({},r)};return null!==t&&(i.previousId=t),void 0===e?this.normalize(vt(vt({},i),this.baseEvent())):this.normalize(vt(vt({},this.baseEvent()),i))},e.prototype.baseEvent=function(){var e={integrations:{},options:{}},t=this.user;return t.id()&&(e.userId=t.id()),t.anonymousId()&&(e.anonymousId=t.anonymousId()),e},e.prototype.context=function(e){var t,n,r,i=["integrations","anonymousId","timestamp","userId"],o=null!==(t=e.options)&&void 0!==t?t:{};delete o.integrations;var s=Object.keys(o),a=null!==(r=null===(n=e.options)||void 0===n?void 0:n.context)&&void 0!==r?r:{},u={};return s.forEach((function(e){"context"!==e&&(i.includes(e)?kt(u,e,o[e]):kt(a,e,o[e]))})),[a,u]},e.prototype.normalize=function(e){var t,n,r;(null===(t=e.options)||void 0===t?void 0:t.anonymousId)&&this.user.anonymousId(e.options.anonymousId);var i=Object.keys(null!==(n=e.integrations)&&void 0!==n?n:{}).reduce((function(t,n){var r,i;return vt(vt({},t),((r={})[n]=Boolean(null===(i=e.integrations)||void 0===i?void 0:i[n]),r))}),{}),o=vt(vt({},i),null===(r=e.options)||void 0===r?void 0:r.integrations),s=this.context(e),a=s[0],u=s[1];e.options;var c=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(e,["options"]),l=vt(vt(vt({timestamp:new Date},c),{context:a,integrations:o}),u),f="ajs-next-"+Bn.hash(JSON.stringify(l)+$t());return vt(vt({},l),{messageId:f})},e}(),qn={getItem:function(){},setItem:function(){},removeItem:function(){}};try{qn=sn()&&window.localStorage?window.localStorage:qn}catch(e){console.warn("Unable to access localStorage",e)}function Vn(e){var t=qn.getItem(e);return(t?JSON.parse(t):[]).map((function(e){return new zn(e.event,e.id)}))}function $n(e){var t=qn.getItem(e);return t?JSON.parse(t):{}}function Wn(e){qn.removeItem(e)}function Kn(e,t,n){void 0===n&&(n=0);var r="persisted-queue:v1:".concat(e,":lock"),i=qn.getItem(r),o=i?JSON.parse(i):null,s=null===o||function(e){return(new Date).getTime()>e}(o);if(s)return qn.setItem(r,JSON.stringify((new Date).getTime()+50)),t(),void qn.removeItem(r);!s&&n<3?setTimeout((function(){Kn(e,t,n+1)}),50):console.error("Unable to retrieve lock")}var Gn=function(e){function t(t,n){var r=e.call(this,t,[])||this,i="persisted-queue:v1:".concat(n,":items"),o="persisted-queue:v1:".concat(n,":seen"),s=[],a={};return Kn(n,(function(){try{s=Vn(i),a=$n(o),Wn(i),Wn(o),r.queue=bt(bt([],s,!0),r.queue,!0),r.seen=vt(vt({},a),r.seen)}catch(e){console.error(e)}})),window.addEventListener("pagehide",(function(){if(r.todo>0){var e=bt(bt([],r.queue,!0),r.future,!0);try{Kn(n,(function(){!function(e,t){var n=Vn(e),r=bt(bt([],t,!0),n,!0).reduce((function(e,t){var n;return vt(vt({},e),((n={})[t.id]=t,n))}),{});qn.setItem(e,JSON.stringify(Object.values(r)))}(i,e),function(e,t){var n=$n(e);qn.setItem(e,JSON.stringify(vt(vt({},n),t)))}(o,r.seen)}))}catch(e){console.error(e)}}})),r}return yt(t,e),t}(Ht),Yn=function(e){function t(t){return e.call(this,"string"==typeof t?new Gn(4,t):t)||this}return yt(t,e),t.prototype.flush=function(){return mt(this,void 0,void 0,(function(){return _t(this,(function(t){return cn()?[2,[]]:[2,e.prototype.flush.call(this)]}))}))},t}(Zt),Qn="This is being deprecated and will be not be available in future releases of Analytics JS",Jn=fn(),Xn=null==Jn?void 0:Jn.analytics;function Zn(){console.warn(Qn)}var er=function(e){function t(t,n,r,i,o){var s,a,u,c=this;(c=e.call(this)||this)._debug=!1,c.initialized=!1,c.user=function(){return c._user},c.init=c.initialize.bind(c),c.log=Zn,c.addIntegrationMiddleware=Zn,c.listeners=Zn,c.addEventListener=Zn,c.removeAllListeners=Zn,c.removeListener=Zn,c.removeEventListener=Zn,c.hasListeners=Zn,c.add=Zn,c.addIntegration=Zn;var l=null==n?void 0:n.cookie,f=null!==(s=null==n?void 0:n.disableClientPersistence)&&void 0!==s&&s;return c.settings=t,c.settings.timeout=null!==(a=c.settings.timeout)&&void 0!==a?a:300,c.queue=null!=r?r:function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1);var r=t?4:1,i=n?new Ht(r,[]):new Gn(r,e);return new Yn(i)}("".concat(t.writeKey,":event-queue"),null==n?void 0:n.retryQueue,f),c._universalStorage=new On(f?["memory"]:["localStorage","cookie","memory"],xn(l)),c._user=null!=i?i:new Rn(f?vt(vt({},null==n?void 0:n.user),{persist:!1}):null==n?void 0:n.user,l).load(),c._group=null!=o?o:new Cn(f?vt(vt({},null==n?void 0:n.group),{persist:!1}):null==n?void 0:n.group,l).load(),c.eventFactory=new Hn(c._user),c.integrations=null!==(u=null==n?void 0:n.integrations)&&void 0!==u?u:{},c.options=null!=n?n:{},mn(c),c}return yt(t,e),Object.defineProperty(t.prototype,"storage",{get:function(){return this._universalStorage},enumerable:!1,configurable:!0}),t.prototype.track=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r,i,o,s,a=this;return _t(this,(function(u){return t=tn.apply(void 0,e),n=t[0],r=t[1],i=t[2],o=t[3],s=this.eventFactory.track(n,r,i,this.integrations),[2,this._dispatch(s,o).then((function(e){return a.emit("track",n,e.event.properties,e.event.options),e}))]}))}))},t.prototype.page=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,u=this;return _t(this,(function(c){return t=nn.apply(void 0,e),n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],a=this.eventFactory.page(n,r,i,o,this.integrations),[2,this._dispatch(a,s).then((function(e){return u.emit("page",n,r,e.event.properties,e.event.options),e}))]}))}))},t.prototype.identify=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r,i,o,s,a=this;return _t(this,(function(u){return t=rn(this._user).apply(void 0,e),n=t[0],r=t[1],i=t[2],o=t[3],this._user.identify(n,r),s=this.eventFactory.identify(this._user.id(),this._user.traits(),i,this.integrations),[2,this._dispatch(s,o).then((function(e){return a.emit("identify",e.event.userId,e.event.traits,e.event.options),e}))]}))}))},t.prototype.group=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(0===t.length)return this._group;var r=rn(this._group).apply(void 0,t),i=r[0],o=r[1],s=r[2],a=r[3];this._group.identify(i,o);var u=this._group.id(),c=this._group.traits(),l=this.eventFactory.group(u,c,s,this.integrations);return this._dispatch(l,a).then((function(t){return e.emit("group",t.event.groupId,t.event.traits,t.event.options),t}))},t.prototype.alias=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r,i,o,s,a=this;return _t(this,(function(u){return t=on.apply(void 0,e),n=t[0],r=t[1],i=t[2],o=t[3],s=this.eventFactory.alias(n,r,i,this.integrations),[2,this._dispatch(s,o).then((function(e){return a.emit("alias",n,r,e.event.options),e}))]}))}))},t.prototype.screen=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,u=this;return _t(this,(function(c){return t=nn.apply(void 0,e),n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],a=this.eventFactory.screen(n,r,i,o,this.integrations),[2,this._dispatch(a,s).then((function(e){return u.emit("screen",n,r,e.event.properties,e.event.options),e}))]}))}))},t.prototype.trackClick=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n;return _t(this,(function(r){switch(r.label){case 0:return[4,Promise.resolve().then((function(){return sl}))];case 1:return t=r.sent(),[2,(n=t.link).call.apply(n,bt([this],e,!1))]}}))}))},t.prototype.trackLink=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n;return _t(this,(function(r){switch(r.label){case 0:return[4,Promise.resolve().then((function(){return sl}))];case 1:return t=r.sent(),[2,(n=t.link).call.apply(n,bt([this],e,!1))]}}))}))},t.prototype.trackSubmit=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n;return _t(this,(function(r){switch(r.label){case 0:return[4,Promise.resolve().then((function(){return sl}))];case 1:return t=r.sent(),[2,(n=t.form).call.apply(n,bt([this],e,!1))]}}))}))},t.prototype.trackForm=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n;return _t(this,(function(r){switch(r.label){case 0:return[4,Promise.resolve().then((function(){return sl}))];case 1:return t=r.sent(),[2,(n=t.form).call.apply(n,bt([this],e,!1))]}}))}))},t.prototype.register=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r=this;return _t(this,(function(i){switch(i.label){case 0:return t=zn.system(),n=e.map((function(e){return r.queue.register(t,e,r)})),[4,Promise.all(n)];case 1:return i.sent(),[2,t]}}))}))},t.prototype.deregister=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r=this;return _t(this,(function(i){switch(i.label){case 0:return t=zn.system(),n=e.map((function(e){var n=r.queue.plugins.find((function(t){return t.name===e}));if(n)return r.queue.deregister(t,n,r);t.log("warn","plugin ".concat(e," not found"))})),[4,Promise.all(n)];case 1:return i.sent(),[2,t]}}))}))},t.prototype.debug=function(e){return!1===e&&localStorage.getItem("debug")&&localStorage.removeItem("debug"),this._debug=e,this},t.prototype.reset=function(){this._user.reset(),this._group.reset(),this.emit("reset")},t.prototype.timeout=function(e){this.settings.timeout=e},t.prototype._dispatch=function(e,t){return mt(this,void 0,void 0,(function(){var n;return _t(this,(function(r){return n=new zn(e),cn()&&!this.options.retryQueue?[2,n]:[2,en(n,this.queue,this,{callback:t,debug:this._debug,timeout:this.settings.timeout})]}))}))},t.prototype.addSourceMiddleware=function(e){return mt(this,void 0,void 0,(function(){var t=this;return _t(this,(function(n){switch(n.label){case 0:return[4,this.queue.criticalTasks.run((function(){return mt(t,void 0,void 0,(function(){var t,n,r;return _t(this,(function(i){switch(i.label){case 0:return[4,Promise.resolve().then((function(){return Ji}))];case 1:return t=i.sent().sourceMiddlewarePlugin,n={},this.queue.plugins.forEach((function(e){if("destination"===e.type)return n[e.name]=!0})),r=t(e,n),[4,this.register(r)];case 2:return i.sent(),[2]}}))}))}))];case 1:return n.sent(),[2,this]}}))}))},t.prototype.addDestinationMiddleware=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return this.queue.plugins.filter((function(t){return t.name.toLowerCase()===e.toLowerCase()})).forEach((function(e){e.addMiddleware.apply(e,t)})),Promise.resolve(this)},t.prototype.setAnonymousId=function(e){return this._user.anonymousId(e)},t.prototype.queryString=function(e){return mt(this,void 0,void 0,(function(){return _t(this,(function(t){switch(t.label){case 0:return!1===this.options.useQueryString?[2,[]]:[4,Promise.resolve().then((function(){return ul}))];case 1:return[2,(0,t.sent().queryString)(this,e)]}}))}))},t.prototype.use=function(e){return e(this),this},t.prototype.ready=function(e){return void 0===e&&(e=function(e){return e}),mt(this,void 0,void 0,(function(){return _t(this,(function(t){return[2,Promise.all(this.queue.plugins.map((function(e){return e.ready?e.ready():Promise.resolve()}))).then((function(t){return e(t),t}))]}))}))},t.prototype.noConflict=function(){return console.warn(Qn),window.analytics=null!=Xn?Xn:this,this},t.prototype.normalize=function(e){return console.warn(Qn),this.eventFactory.normalize(e)},Object.defineProperty(t.prototype,"failedInitializations",{get:function(){return console.warn(Qn),this.queue.failedInitializations},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"VERSION",{get:function(){return dn},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e,t){return mt(this,void 0,void 0,(function(){return _t(this,(function(e){return console.warn(Qn),[2,Promise.resolve(this)]}))}))},t.prototype.pageview=function(e){return mt(this,void 0,void 0,(function(){return _t(this,(function(t){switch(t.label){case 0:return console.warn(Qn),[4,this.page({path:e})];case 1:return t.sent(),[2,this]}}))}))},Object.defineProperty(t.prototype,"plugins",{get:function(){var e;return console.warn(Qn),null!==(e=this._plugins)&&void 0!==e?e:{}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"Integrations",{get:function(){console.warn(Qn);var e=this.queue.plugins.filter((function(e){return"destination"===e.type})).reduce((function(e,t){var n="".concat(t.name.toLowerCase().replace(".","").split(" ").join("-"),"Integration"),r=window[n];if(!r)return e;var i=r.Integration;return i?(e[t.name]=i,e):(e[t.name]=r,e)}),{});return e},enumerable:!1,configurable:!0}),t.prototype.push=function(e){var t=e.shift();t&&!this[t]||this[t].apply(this,e)},t}(wt);function tr(){return"undefined"!=typeof process&&process.env?process.env:{}}try{window.analyticsWriteKey="__WRITE_KEY__"}catch(J){}var nr,rr=/(https:\/\/.*)\/analytics\.js\/v1\/(?:.*?)\/(?:platform|analytics.*)?/,ir=function(){var e=function(){var e;return null!=nr?nr:null===(e=window.analytics)||void 0===e?void 0:e._cdn}();if(e)return e;var t,n=(Array.prototype.slice.call(document.querySelectorAll("script")).forEach((function(e){var n,r=null!==(n=e.getAttribute("src"))&&void 0!==n?n:"",i=rr.exec(r);i&&i[1]&&(t=i[1])})),t);return n||"https://cdn.segment.com"},or=function(){var e=ir();return"".concat(e,"/next-integrations")};function sr(e,t){var n,r=Object.entries(null!==(n=t.integrations)&&void 0!==n?n:{}).reduce((function(e,t){var n,r,i=t[0],o=t[1];return vt(vt({},e),"object"==typeof o?((n={})[i]=o,n):((r={})[i]={},r))}),{});return Object.entries(e.integrations).reduce((function(e,t){var n,i=t[0],o=t[1];return vt(vt({},e),((n={})[i]=vt(vt({},o),r[i]),n))}),{})}function ar(){var e=document.querySelector("link[rel='canonical']");if(e)return e.getAttribute("href")||void 0}function ur(){var e=ar();if(!e)return window.location.pathname;var t=document.createElement("a");return t.href=e,t.pathname.startsWith("/")?t.pathname:"/"+t.pathname}function cr(e){void 0===e&&(e="");var t=ar();if(t)return t.includes("?")?t:"".concat(t).concat(e);var n=window.location.href,r=n.indexOf("#");return-1===r?n:n.slice(0,r)}function lr(e){var t=e.event;t.context=t.context||{};var n,r,i={path:ur(),referrer:document.referrer,search:location.search,title:document.title,url:cr(location.search)},o=void 0;return"page"===t.type&&(o=t.properties&&(n=t.properties,r=Object.keys(i),Object.assign.apply(Object,bt([{}],r.map((function(e){var t;if(n&&Object.prototype.hasOwnProperty.call(n,e))return(t={})[e]=n[e],t})),!1))),t.properties=vt(vt(vt({},i),t.properties),t.name?{name:t.name}:{})),t.context.page=vt(vt(vt({},i),o),t.context.page),e}var fr={name:"Page Enrichment",version:"0.1.0",isLoaded:function(){return!0},load:function(){return Promise.resolve()},type:"before",page:lr,alias:lr,track:lr,identify:lr,group:lr};function hr(e){return Array.prototype.slice.call(window.document.querySelectorAll("script")).find((function(t){return t.src===e}))}function dr(e,t){var n=hr(e);if(void 0!==n){var r=null==n?void 0:n.getAttribute("status");if("loaded"===r)return Promise.resolve(n);if("loading"===r)return new Promise((function(e,t){n.addEventListener("load",(function(){return e(n)})),n.addEventListener("error",(function(e){return t(e)}))}))}return new Promise((function(n,r){var i,o=window.document.createElement("script");o.type="text/javascript",o.src=e,o.async=!0,o.setAttribute("status","loading");for(var s=0,a=Object.entries(null!=t?t:{});s<a.length;s++){var u=a[s],c=u[0],l=u[1];o.setAttribute(c,l)}o.onload=function(){o.onerror=o.onload=null,o.setAttribute("status","loaded"),n(o)},o.onerror=function(){o.onerror=o.onload=null,o.setAttribute("status","error"),r(new Error("Failed to load ".concat(e)))};var f=window.document.getElementsByTagName("script")[0];null===(i=f.parentElement)||void 0===i||i.insertBefore(o,f)}))}function pr(e){var t=hr(e);return void 0!==t&&t.remove(),Promise.resolve()}var gr={},yr={},vr={},mr={exports:{}};!function(e){function t(e){return function(t,n,r,o){var s,a=o&&function(e){return"function"==typeof e}(o.normalizer)?o.normalizer:i;n=a(n);for(var u=!1;!u;)c();function c(){for(s in t){var e=a(s);if(0===n.indexOf(e)){var r=n.substr(e.length);if("."===r.charAt(0)||0===r.length){n=r.substr(1);var i=t[s];return null==i?void(u=!0):n.length?void(t=i):void(u=!0)}}}s=void 0,u=!0}if(s)return null==t?t:e(t,s,r)}}function n(e,t){return e.hasOwnProperty(t)&&delete e[t],e}function r(e,t,n){return e.hasOwnProperty(t)&&(e[t]=n),e}function i(e){return e.replace(/[^a-zA-Z0-9\.]+/g,"").toLowerCase()}e.exports=t((function(e,t){if(e.hasOwnProperty(t))return e[t]})),e.exports.find=e.exports,e.exports.replace=function(e,n,i,o){return t(r).call(this,e,n,i,o),e},e.exports.del=function(e,r,i){return t(n).call(this,e,r,null,i),e}}(mr);var _r=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(vr,"__esModule",{value:!0});var br=_r(mr.exports);function wr(e,t){return function(){var n=this.traits(),r=this.properties?this.properties():{};return br.default(n,"address."+e)||br.default(n,e)||(t?br.default(n,"address."+t):null)||(t?br.default(n,t):null)||br.default(r,"address."+e)||br.default(r,e)||(t?br.default(r,"address."+t):null)||(t?br.default(r,t):null)}}vr.default=function(e){e.zip=wr("postalCode","zip"),e.country=wr("country"),e.street=wr("street"),e.state=wr("state"),e.city=wr("city"),e.region=wr("region")};var Er={};Object.defineProperty(Er,"__esModule",{value:!0}),Er.clone=void 0,Er.clone=function e(t){if("object"!=typeof t)return t;if("[object Object]"===Object.prototype.toString.call(t)){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=e(t[r]));return n}return Array.isArray(t)?t.map(e):t};var Sr={};Object.defineProperty(Sr,"__esModule",{value:!0});var Or={Salesforce:!0};Sr.default=function(e){return!Or[e]};var xr={},Ir=/^(\d{4})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:([ T])(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;xr.parse=function(e){var t=[1,5,6,7,11,12],n=Ir.exec(e),r=0;if(!n)return new Date(e);for(var i,o=0;i=t[o];o++)n[i]=parseInt(n[i],10)||0;n[2]=parseInt(n[2],10)||1,n[3]=parseInt(n[3],10)||1,n[2]--,n[8]=n[8]?(n[8]+"00").substring(0,3):0," "===n[4]?r=(new Date).getTimezoneOffset():"Z"!==n[9]&&n[10]&&(r=60*n[11]+n[12],"+"===n[10]&&(r=0-r));var s=Date.UTC(n[1],n[2],n[3],n[5],n[6]+r,n[7],n[8]);return new Date(s)},xr.is=function(e,t){return"string"==typeof e&&((!t||!1!==/^\d{4}-\d{2}-\d{2}/.test(e))&&Ir.test(e))};var Rr={},kr=/\d{13}/;Rr.is=function(e){return kr.test(e)},Rr.parse=function(e){return e=parseInt(e,10),new Date(e)};var Cr={},Pr=/\d{10}/;Cr.is=function(e){return Pr.test(e)},Cr.parse=function(e){var t=1e3*parseInt(e,10);return new Date(t)};var Ar=xr,Nr=Rr,Tr=Cr,Mr=Object.prototype.toString;var Lr=function(e){return t=e,"[object Date]"===Mr.call(t)?e:function(e){return"[object Number]"===Mr.call(e)}(e)?new Date((n=e)<315576e5?1e3*n:n):Ar.is(e)?Ar.parse(e):Nr.is(e)?Nr.parse(e):Tr.is(e)?Tr.parse(e):new Date(e);var t,n};var jr=xr,Ur=Dr;function Dr(e,t){return void 0===t&&(t=!0),e&&"object"==typeof e?function(e,t){return Object.keys(e).forEach((function(n){e[n]=Dr(e[n],t)})),e}(e,t):Array.isArray(e)?function(e,t){return e.forEach((function(n,r){e[r]=Dr(n,t)})),e}(e,t):jr.is(e,t)?jr.parse(e):e}var zr=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(yr,"__esModule",{value:!0}),yr.Facade=void 0;var Fr=zr(vr),Br=Er,Hr=zr(Sr),qr=zr(Lr),Vr=zr(mr.exports),$r=zr(Ur);function Wr(e,t){t=t||{},this.raw=Br.clone(e),"clone"in t||(t.clone=!0),t.clone&&(e=Br.clone(e)),"traverse"in t||(t.traverse=!0),e.timestamp="timestamp"in e?qr.default(e.timestamp):new Date,t.traverse&&$r.default(e),this.opts=t,this.obj=e}yr.Facade=Wr;var Kr=Wr.prototype;function Gr(e){return Br.clone(e)}Kr.proxy=function(e){var t=e.split("."),n=this[e=t.shift()]||this.obj[e];return n?("function"==typeof n&&(n=n.call(this)||{}),0===t.length||(n=Vr.default(n,t.join("."))),this.opts.clone?Gr(n):n):n},Kr.field=function(e){var t=this.obj[e];return this.opts.clone?Gr(t):t},Wr.proxy=function(e){return function(){return this.proxy(e)}},Wr.field=function(e){return function(){return this.field(e)}},Wr.multi=function(e){return function(){var t=this.proxy(e+"s");if(Array.isArray(t))return t;var n=this.proxy(e);return n&&(n=[this.opts.clone?Br.clone(n):n]),n||[]}},Wr.one=function(e){return function(){var t=this.proxy(e);if(t)return t;var n=this.proxy(e+"s");return Array.isArray(n)?n[0]:void 0}},Kr.json=function(){var e=this.opts.clone?Br.clone(this.obj):this.obj;return this.type&&(e.type=this.type()),e},Kr.rawEvent=function(){return this.raw},Kr.options=function(e){var t=this.obj.options||this.obj.context||{},n=this.opts.clone?Br.clone(t):t;if(!e)return n;if(this.enabled(e)){var r=this.integrations(),i=r[e]||Vr.default(r,e);return"object"!=typeof i&&(i=Vr.default(this.options(),e)),"object"==typeof i?i:{}}},Kr.context=Kr.options,Kr.enabled=function(e){var t=this.proxy("options.providers.all");"boolean"!=typeof t&&(t=this.proxy("options.all")),"boolean"!=typeof t&&(t=this.proxy("integrations.all")),"boolean"!=typeof t&&(t=!0);var n=t&&Hr.default(e),r=this.integrations();if(r.providers&&r.providers.hasOwnProperty(e)&&(n=r.providers[e]),r.hasOwnProperty(e)){var i=r[e];n="boolean"!=typeof i||i}return!!n},Kr.integrations=function(){return this.obj.integrations||this.proxy("options.providers")||this.options()},Kr.active=function(){var e=this.proxy("options.active");return null==e&&(e=!0),e},Kr.anonymousId=function(){return this.field("anonymousId")||this.field("sessionId")},Kr.sessionId=Kr.anonymousId,Kr.groupId=Wr.proxy("options.groupId"),Kr.traits=function(e){var t=this.proxy("options.traits")||{},n=this.userId();for(var r in e=e||{},n&&(t.id=n),e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=null==this[r]?this.proxy("options.traits."+r):this[r]();if(null==i)continue;t[e[r]]=i,delete t[r]}return t},Kr.library=function(){var e=this.proxy("options.library");return e?"string"==typeof e?{name:e,version:null}:e:{name:"unknown",version:null}},Kr.device=function(){var e=this.proxy("context.device");"object"==typeof e&&null!==e||(e={});var t=this.library().name;return e.type||(t.indexOf("ios")>-1&&(e.type="ios"),t.indexOf("android")>-1&&(e.type="android")),e},Kr.userAgent=Wr.proxy("context.userAgent"),Kr.timezone=Wr.proxy("context.timezone"),Kr.timestamp=Wr.field("timestamp"),Kr.channel=Wr.field("channel"),Kr.ip=Wr.proxy("context.ip"),Kr.userId=Wr.field("userId"),Fr.default(Kr);var Yr={},Qr={exports:{}};"function"==typeof Object.create?Qr.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Qr.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}};var Jr=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Yr,"__esModule",{value:!0}),Yr.Alias=void 0;var Xr=Jr(Qr.exports),Zr=yr;function ei(e,t){Zr.Facade.call(this,e,t)}Yr.Alias=ei,Xr.default(ei,Zr.Facade),ei.prototype.action=function(){return"alias"},ei.prototype.type=ei.prototype.action,ei.prototype.previousId=function(){return this.field("previousId")||this.field("from")},ei.prototype.from=ei.prototype.previousId,ei.prototype.userId=function(){return this.field("userId")||this.field("to")},ei.prototype.to=ei.prototype.userId;var ti={},ni={};Object.defineProperty(ni,"__esModule",{value:!0});var ri=/.+\@.+\..+/;ni.default=function(e){return ri.test(e)};var ii=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ti,"__esModule",{value:!0}),ti.Group=void 0;var oi=ii(Qr.exports),si=ii(ni),ai=ii(Lr),ui=yr;function ci(e,t){ui.Facade.call(this,e,t)}ti.Group=ci,oi.default(ci,ui.Facade);var li=ci.prototype;li.action=function(){return"group"},li.type=li.action,li.groupId=ui.Facade.field("groupId"),li.created=function(){var e=this.proxy("traits.createdAt")||this.proxy("traits.created")||this.proxy("properties.createdAt")||this.proxy("properties.created");if(e)return ai.default(e)},li.email=function(){var e=this.proxy("traits.email");if(e)return e;var t=this.groupId();return si.default(t)?t:void 0},li.traits=function(e){var t=this.properties(),n=this.groupId();for(var r in e=e||{},n&&(t.id=n),e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=null==this[r]?this.proxy("traits."+r):this[r]();if(null==i)continue;t[e[r]]=i,delete t[r]}return t},li.name=ui.Facade.proxy("traits.name"),li.industry=ui.Facade.proxy("traits.industry"),li.employees=ui.Facade.proxy("traits.employees"),li.properties=function(){return this.field("traits")||this.field("properties")||{}};var fi={},hi=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(fi,"__esModule",{value:!0}),fi.Identify=void 0;var di=yr,pi=hi(mr.exports),gi=hi(Qr.exports),yi=hi(ni),vi=hi(Lr),mi=function(e){return e.trim()};function _i(e,t){di.Facade.call(this,e,t)}fi.Identify=_i,gi.default(_i,di.Facade);var bi=_i.prototype;bi.action=function(){return"identify"},bi.type=bi.action,bi.traits=function(e){var t=this.field("traits")||{},n=this.userId();for(var r in e=e||{},n&&(t.id=n),e){var i=null==this[r]?this.proxy("traits."+r):this[r]();null!=i&&(t[e[r]]=i,r!==e[r]&&delete t[r])}return t},bi.email=function(){var e=this.proxy("traits.email");if(e)return e;var t=this.userId();return yi.default(t)?t:void 0},bi.created=function(){var e=this.proxy("traits.created")||this.proxy("traits.createdAt");if(e)return vi.default(e)},bi.companyCreated=function(){var e=this.proxy("traits.company.created")||this.proxy("traits.company.createdAt");if(e)return vi.default(e)},bi.companyName=function(){return this.proxy("traits.company.name")},bi.name=function(){var e=this.proxy("traits.name");if("string"==typeof e)return mi(e);var t=this.firstName(),n=this.lastName();return t&&n?mi(t+" "+n):void 0},bi.firstName=function(){var e=this.proxy("traits.firstName");if("string"==typeof e)return mi(e);var t=this.proxy("traits.name");return"string"==typeof t?mi(t).split(" ")[0]:void 0},bi.lastName=function(){var e=this.proxy("traits.lastName");if("string"==typeof e)return mi(e);var t=this.proxy("traits.name");if("string"==typeof t){var n=mi(t).indexOf(" ");if(-1!==n)return mi(t.substr(n+1))}},bi.uid=function(){return this.userId()||this.username()||this.email()},bi.description=function(){return this.proxy("traits.description")||this.proxy("traits.background")},bi.age=function(){var e=this.birthday(),t=pi.default(this.traits(),"age");return null!=t?t:e instanceof Date?(new Date).getFullYear()-e.getFullYear():void 0},bi.avatar=function(){var e=this.traits();return pi.default(e,"avatar")||pi.default(e,"photoUrl")||pi.default(e,"avatarUrl")},bi.position=function(){var e=this.traits();return pi.default(e,"position")||pi.default(e,"jobTitle")},bi.username=di.Facade.proxy("traits.username"),bi.website=di.Facade.one("traits.website"),bi.websites=di.Facade.multi("traits.website"),bi.phone=di.Facade.one("traits.phone"),bi.phones=di.Facade.multi("traits.phone"),bi.address=di.Facade.proxy("traits.address"),bi.gender=di.Facade.proxy("traits.gender"),bi.birthday=di.Facade.proxy("traits.birthday");var wi={},Ei=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(wi,"__esModule",{value:!0}),wi.Track=void 0;var Si=Ei(Qr.exports),Oi=yr,xi=fi,Ii=Ei(ni),Ri=Ei(mr.exports);function ki(e,t){Oi.Facade.call(this,e,t)}wi.Track=ki,Si.default(ki,Oi.Facade);var Ci=ki.prototype;Ci.action=function(){return"track"},Ci.type=Ci.action,Ci.event=Oi.Facade.field("event"),Ci.value=Oi.Facade.proxy("properties.value"),Ci.category=Oi.Facade.proxy("properties.category"),Ci.id=Oi.Facade.proxy("properties.id"),Ci.productId=function(){return this.proxy("properties.product_id")||this.proxy("properties.productId")},Ci.promotionId=function(){return this.proxy("properties.promotion_id")||this.proxy("properties.promotionId")},Ci.cartId=function(){return this.proxy("properties.cart_id")||this.proxy("properties.cartId")},Ci.checkoutId=function(){return this.proxy("properties.checkout_id")||this.proxy("properties.checkoutId")},Ci.paymentId=function(){return this.proxy("properties.payment_id")||this.proxy("properties.paymentId")},Ci.couponId=function(){return this.proxy("properties.coupon_id")||this.proxy("properties.couponId")},Ci.wishlistId=function(){return this.proxy("properties.wishlist_id")||this.proxy("properties.wishlistId")},Ci.reviewId=function(){return this.proxy("properties.review_id")||this.proxy("properties.reviewId")},Ci.orderId=function(){return this.proxy("properties.id")||this.proxy("properties.order_id")||this.proxy("properties.orderId")},Ci.sku=Oi.Facade.proxy("properties.sku"),Ci.tax=Oi.Facade.proxy("properties.tax"),Ci.name=Oi.Facade.proxy("properties.name"),Ci.price=Oi.Facade.proxy("properties.price"),Ci.total=Oi.Facade.proxy("properties.total"),Ci.repeat=Oi.Facade.proxy("properties.repeat"),Ci.coupon=Oi.Facade.proxy("properties.coupon"),Ci.shipping=Oi.Facade.proxy("properties.shipping"),Ci.discount=Oi.Facade.proxy("properties.discount"),Ci.shippingMethod=function(){return this.proxy("properties.shipping_method")||this.proxy("properties.shippingMethod")},Ci.paymentMethod=function(){return this.proxy("properties.payment_method")||this.proxy("properties.paymentMethod")},Ci.description=Oi.Facade.proxy("properties.description"),Ci.plan=Oi.Facade.proxy("properties.plan"),Ci.subtotal=function(){var e=Ri.default(this.properties(),"subtotal"),t=this.total()||this.revenue();if(e)return e;if(!t)return 0;if(this.total()){var n=this.tax();n&&(t-=n),(n=this.shipping())&&(t-=n),(n=this.discount())&&(t+=n)}return t},Ci.products=function(){var e=this.properties(),t=Ri.default(e,"products");return Array.isArray(t)?t.filter((function(e){return null!==e})):[]},Ci.quantity=function(){return(this.obj.properties||{}).quantity||1},Ci.currency=function(){return(this.obj.properties||{}).currency||"USD"},Ci.referrer=function(){return this.proxy("context.referrer.url")||this.proxy("context.page.referrer")||this.proxy("properties.referrer")},Ci.query=Oi.Facade.proxy("options.query"),Ci.properties=function(e){var t=this.field("properties")||{};for(var n in e=e||{})if(Object.prototype.hasOwnProperty.call(e,n)){var r=null==this[n]?this.proxy("properties."+n):this[n]();if(null==r)continue;t[e[n]]=r,delete t[n]}return t},Ci.username=function(){return this.proxy("traits.username")||this.proxy("properties.username")||this.userId()||this.sessionId()},Ci.email=function(){var e=this.proxy("traits.email")||this.proxy("properties.email")||this.proxy("options.traits.email");if(e)return e;var t=this.userId();return Ii.default(t)?t:void 0},Ci.revenue=function(){var e=this.proxy("properties.revenue"),t=this.event();return!e&&t&&t.match(/^[ _]?completed[ _]?order[ _]?|^[ _]?order[ _]?completed[ _]?$/i)&&(e=this.proxy("properties.total")),function(e){if(!e)return;if("number"==typeof e)return e;if("string"!=typeof e)return;if(e=e.replace(/\$/g,""),e=parseFloat(e),!isNaN(e))return e}(e)},Ci.cents=function(){var e=this.revenue();return"number"!=typeof e?this.value()||0:100*e},Ci.identify=function(){var e=this.json();return e.traits=this.traits(),new xi.Identify(e,this.opts)};var Pi={},Ai=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Pi,"__esModule",{value:!0}),Pi.Page=void 0;var Ni=Ai(Qr.exports),Ti=yr,Mi=wi,Li=Ai(ni);function ji(e,t){Ti.Facade.call(this,e,t)}Pi.Page=ji,Ni.default(ji,Ti.Facade);var Ui=ji.prototype;Ui.action=function(){return"page"},Ui.type=Ui.action,Ui.category=Ti.Facade.field("category"),Ui.name=Ti.Facade.field("name"),Ui.title=Ti.Facade.proxy("properties.title"),Ui.path=Ti.Facade.proxy("properties.path"),Ui.url=Ti.Facade.proxy("properties.url"),Ui.referrer=function(){return this.proxy("context.referrer.url")||this.proxy("context.page.referrer")||this.proxy("properties.referrer")},Ui.properties=function(e){var t=this.field("properties")||{},n=this.category(),r=this.name();for(var i in e=e||{},n&&(t.category=n),r&&(t.name=r),e)if(Object.prototype.hasOwnProperty.call(e,i)){var o=null==this[i]?this.proxy("properties."+i):this[i]();if(null==o)continue;t[e[i]]=o,i!==e[i]&&delete t[i]}return t},Ui.email=function(){var e=this.proxy("context.traits.email")||this.proxy("properties.email");if(e)return e;var t=this.userId();return Li.default(t)?t:void 0},Ui.fullName=function(){var e=this.category(),t=this.name();return t&&e?e+" "+t:t},Ui.event=function(e){return e?"Viewed "+e+" Page":"Loaded a Page"},Ui.track=function(e){var t=this.json();return t.event=this.event(e),t.timestamp=this.timestamp(),t.properties=this.properties(),new Mi.Track(t,this.opts)};var Di={},zi=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Di,"__esModule",{value:!0}),Di.Screen=void 0;var Fi=zi(Qr.exports),Bi=Pi,Hi=wi;function qi(e,t){Bi.Page.call(this,e,t)}Di.Screen=qi,Fi.default(qi,Bi.Page),qi.prototype.action=function(){return"screen"},qi.prototype.type=qi.prototype.action,qi.prototype.event=function(e){return e?"Viewed "+e+" Screen":"Loaded a Screen"},qi.prototype.track=function(e){var t=this.json();return t.event=this.event(e),t.timestamp=this.timestamp(),t.properties=this.properties(),new Hi.Track(t,this.opts)};var Vi={},$i=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.Delete=void 0;var Wi=$i(Qr.exports),Ki=yr;function Gi(e,t){Ki.Facade.call(this,e,t)}function Yi(e,t){var n=new gr.Facade(e,t);return"track"===e.type&&(n=new gr.Track(e,t)),"identify"===e.type&&(n=new gr.Identify(e,t)),"page"===e.type&&(n=new gr.Page(e,t)),"alias"===e.type&&(n=new gr.Alias(e,t)),"group"===e.type&&(n=new gr.Group(e,t)),"screen"===e.type&&(n=new gr.Screen(e,t)),Object.defineProperty(n,"obj",{value:e,writable:!0}),n}function Qi(e,t,n){return mt(this,void 0,void 0,(function(){function r(t,n){return mt(this,void 0,void 0,(function(){var r,i,o;return _t(this,(function(s){switch(s.label){case 0:return r=!1,i=null,[4,n({payload:Yi(t,{clone:!0,traverse:!1}),integration:e,next:function(e){r=!0,null===e&&(i=null),e&&(i=e.obj)}})];case 1:return s.sent(),r||null===i||(i.integrations=vt(vt({},t.integrations),((o={})[e]=!1,o))),[2,i]}}))}))}var i,o,s,a,u;return _t(this,(function(e){switch(e.label){case 0:i=Yi(t,{clone:!0,traverse:!1}).rawEvent(),o=0,s=n,e.label=1;case 1:return o<s.length?(a=s[o],[4,r(i,a)]):[3,4];case 2:if(null===(u=e.sent()))return[2,null];i=u,e.label=3;case 3:return o++,[3,1];case 4:return[2,i]}}))}))}Vi.Delete=Gi,Wi.default(Gi,Ki.Facade),Gi.prototype.type=function(){return"delete"},function(e){var t=l&&l.__assign||function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.Delete=e.Screen=e.Page=e.Track=e.Identify=e.Group=e.Alias=e.Facade=void 0;var n=yr;Object.defineProperty(e,"Facade",{enumerable:!0,get:function(){return n.Facade}});var r=Yr;Object.defineProperty(e,"Alias",{enumerable:!0,get:function(){return r.Alias}});var i=ti;Object.defineProperty(e,"Group",{enumerable:!0,get:function(){return i.Group}});var o=fi;Object.defineProperty(e,"Identify",{enumerable:!0,get:function(){return o.Identify}});var s=wi;Object.defineProperty(e,"Track",{enumerable:!0,get:function(){return s.Track}});var a=Pi;Object.defineProperty(e,"Page",{enumerable:!0,get:function(){return a.Page}});var u=Di;Object.defineProperty(e,"Screen",{enumerable:!0,get:function(){return u.Screen}});var c=Vi;Object.defineProperty(e,"Delete",{enumerable:!0,get:function(){return c.Delete}}),e.default=t(t({},n.Facade),{Alias:r.Alias,Group:i.Group,Identify:o.Identify,Track:s.Track,Page:a.Page,Screen:u.Screen,Delete:c.Delete})}(gr);var Ji=Object.freeze({__proto__:null,applyDestinationMiddleware:Qi,sourceMiddlewarePlugin:function(e,t){function n(n){return mt(this,void 0,void 0,(function(){var r;return _t(this,(function(i){switch(i.label){case 0:return r=!1,[4,e({payload:Yi(n.event,{clone:!0,traverse:!1}),integrations:null!=t?t:{},next:function(e){r=!0,e&&(n.event=e.obj)}})];case 1:if(i.sent(),!r)throw new Yt({retry:!1,type:"middleware_cancellation",reason:"Middleware `next` function skipped"});return[2,n]}}))}))}return{name:"Source Middleware ".concat(e.name),type:"before",version:"0.1.0",isLoaded:function(){return!0},load:function(e){return Promise.resolve(e)},track:n,page:n,identify:n,alias:n,group:n}}}),Xi=function(){function e(e,t){this.version="1.0.0",this.alternativeNames=[],this.middleware=[],this.alias=this._createMethod("alias"),this.group=this._createMethod("group"),this.identify=this._createMethod("identify"),this.page=this._createMethod("page"),this.screen=this._createMethod("screen"),this.track=this._createMethod("track"),this.action=t,this.name=e,this.type=t.type,this.alternativeNames.push(t.name)}return e.prototype.addMiddleware=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];"destination"===this.type&&(e=this.middleware).push.apply(e,t)},e.prototype.transform=function(e){return mt(this,void 0,void 0,(function(){var t;return _t(this,(function(n){switch(n.label){case 0:return[4,Qi(this.name,e.event,this.middleware)];case 1:return null===(t=n.sent())&&e.cancel(new Yt({retry:!1,reason:"dropped by destination middleware"})),[2,new zn(t)]}}))}))},e.prototype._createMethod=function(e){var t=this;return function(n){return mt(t,void 0,void 0,(function(){var t;return _t(this,(function(r){switch(r.label){case 0:return this.action[e]?(t=n,"destination"!==this.type?[3,2]:[4,this.transform(n)]):[2,n];case 1:t=r.sent(),r.label=2;case 2:return[4,this.action[e](t)];case 3:return r.sent(),[2,n]}}))}))}},e.prototype.isLoaded=function(){return this.action.isLoaded()},e.prototype.ready=function(){return this.action.ready?this.action.ready():Promise.resolve()},e.prototype.load=function(e,t){return this.action.load(e,t)},e.prototype.unload=function(e,t){var n,r;return null===(r=(n=this.action).unload)||void 0===r?void 0:r.call(n,e,t)},e}();function Zi(e,t,n,r,i){var o,s,a;return mt(this,void 0,void 0,(function(){var u,c,l,f,h=this;return _t(this,(function(d){switch(d.label){case 0:return u=[],c=ir(),l=null!==(s=null===(o=e.middlewareSettings)||void 0===o?void 0:o.routingRules)&&void 0!==s?s:[],f=(null!==(a=e.remotePlugins)&&void 0!==a?a:[]).map((function(e){return mt(h,void 0,void 0,(function(){var o,s,a,f,h,d,p,g,y;return _t(this,(function(v){switch(v.label){case 0:if(function(e,t){var n=e[t.creationName],r=e[t.name];return!1===e.All&&!n&&!r||!1===n||!1===r}(t,e))return[2];v.label=1;case 1:if(v.trys.push([1,12,,13]),o=new RegExp("https://cdn.segment.(com|build)"),!r)return[3,7];s=e.url.split("/"),a=s[s.length-2],f=e.url.replace(a,btoa(a).replace(/=/g,"")),v.label=2;case 2:return v.trys.push([2,4,,6]),[4,dr(f.replace(o,c))];case 3:return v.sent(),[3,6];case 4:return v.sent(),[4,dr(e.url.replace(o,c))];case 5:return v.sent(),[3,6];case 6:return[3,9];case 7:return[4,dr(e.url.replace(o,c))];case 8:v.sent(),v.label=9;case 9:return h=e.libraryName,"function"!=typeof window[h]?[3,11]:[4,(0,window[h])(vt(vt({},e.settings),n[e.name]))];case 10:d=v.sent(),function(e){if(!Array.isArray(e))throw new Error("Not a valid list of plugins");var t=["load","isLoaded","name","version","type"];e.forEach((function(e){t.forEach((function(t){var n;if(void 0===e[t])throw new Error("Plugin: ".concat(null!==(n=e.name)&&void 0!==n?n:"unknown"," missing required function ").concat(t))}))}))}(p=Array.isArray(d)?d:[d]),g=l.filter((function(t){return t.destinationName===e.creationName})),p.forEach((function(t){var n=new Xi(e.creationName,t);g.length&&i&&"destination"===t.type&&n.addMiddleware(i),u.push(n)})),v.label=11;case 11:return[3,13];case 12:return y=v.sent(),console.warn("Failed to load Remote Plugin",y),[3,13];case 13:return[2]}}))}))})),[4,Promise.all(f)];case 1:return d.sent(),[2,u.filter(Boolean)]}}))}))}var eo=function(e){var t=!1;window.addEventListener("pagehide",(function(){t||(t=!0,e())})),document.addEventListener("visibilitychange",(function(){if("hidden"==document.visibilityState){if(t)return;t=!0,e()}else t=!1}))},to=500;function no(e){return(encodeURI(JSON.stringify(e)).split(/%..|./).length-1)/1024}function ro(e,t){var n,r,i,o=[],s=!1,a=null!==(n=null==t?void 0:t.size)&&void 0!==n?n:10,u=null!==(r=null==t?void 0:t.timeout)&&void 0!==r?r:5e3;function c(t){var n;if(0!==t.length){var r=null===(n=t[0])||void 0===n?void 0:n.writeKey;return hn("https://".concat(e,"/b"),{keepalive:s,headers:{"Content-Type":"text/plain"},method:"post",body:JSON.stringify({batch:t,writeKey:r})})}}function l(){return mt(this,void 0,void 0,(function(){var e;return _t(this,(function(t){return o.length?(e=o,o=[],[2,c(e)]):[2]}))}))}return eo((function(){if(s=!0,o.length){var e=function(e){var t=[],n=0;return e.forEach((function(e){no(t[n])>=64&&n++,t[n]?t[n].push(e):t[n]=[e]})),t}(o).map(c);Promise.all(e).catch(console.error)}})),{dispatch:function(e,t){return mt(this,void 0,void 0,(function(){var e;return _t(this,(function(n){return o.push(t),e=o.length>=a||function(e){return no(e)>=to-50}(o),[2,e||s?l():void(i||(i=setTimeout((function(){i=void 0,l().catch(console.error)}),u)))]}))}))}}}var io=function(e,t){return mt(void 0,void 0,void 0,(function(){var n;return _t(this,(function(r){return n=function(r){return mt(void 0,void 0,void 0,(function(){var i;return _t(this,(function(o){switch(o.label){case 0:return e(r)?(i=n,[4,t()]):[3,2];case 1:return[2,i.apply(void 0,[o.sent()])];case 2:return[2]}}))}))},[2,n(void 0)]}))}))};function oo(e,t){return mt(this,void 0,void 0,(function(){var n,r=this;return _t(this,(function(i){switch(i.label){case 0:return n=[],cn()?[2,t]:[4,io((function(){return t.length>0&&!cn()}),(function(){return mt(r,void 0,void 0,(function(){var r,i;return _t(this,(function(o){switch(o.label){case 0:return(r=t.pop())?[4,Jt(r,e)]:[2];case 1:return i=o.sent(),i instanceof zn||n.push(r),[2]}}))}))}))];case 1:return i.sent(),n.map((function(e){return t.pushWithBackoff(e)})),[2,t]}}))}))}function so(e,t,n,r){var i=this;e||setTimeout((function(){return mt(i,void 0,void 0,(function(){var e,i;return _t(this,(function(o){switch(o.label){case 0:return e=!0,[4,oo(n,t)];case 1:return i=o.sent(),e=!1,t.todo>0&&r(e,i,n,r),[2]}}))}))}),5e3*Math.random())}function ao(e){return mt(this,void 0,void 0,(function(){var t;return _t(this,(function(n){return(t=navigator.userAgentData)?e?[2,t.getHighEntropyValues(e).catch((function(){return t.toJSON()}))]:[2,t.toJSON()]:[2,void 0]}))}))}function uo(e,t,n){var r,i,o;return mt(this,void 0,void 0,(function(){function s(r){return mt(this,void 0,void 0,(function(){var i,o;return _t(this,(function(s){return cn()?(u.push(r),so(l,u,v,so),[2,r]):(c.add(r),i=r.event.type.charAt(0),y&&r.event.context&&(r.event.context.userAgentData=y),o=Yi(r.event).json(),"track"===r.event.type&&delete o.traits,"alias"===r.event.type&&(o=function(e,t){var n,r,i,o,s=e.user();return t.previousId=null!==(i=null!==(r=null!==(n=t.previousId)&&void 0!==n?n:t.from)&&void 0!==r?r:s.id())&&void 0!==i?i:s.anonymousId(),t.userId=null!==(o=t.userId)&&void 0!==o?o:t.to,delete t.from,delete t.to,t}(e,o)),[2,g.dispatch("".concat(d,"/").concat(i),Tn(e,o,t,n)).then((function(){return r})).catch((function(){return u.pushWithBackoff(r),so(l,u,v,so),r})).finally((function(){c.delete(r)}))])}))}))}var a,u,c,l,f,h,d,p,g,y,v;return _t(this,(function(n){switch(n.label){case 0:window.addEventListener("pagehide",(function(){u.push.apply(u,Array.from(c)),c.clear()})),a=null!==(r=null==t?void 0:t.apiKey)&&void 0!==r?r:"",u=e.options.disableClientPersistence?new Ht(e.queue.queue.maxAttempts,[]):new Gn(e.queue.queue.maxAttempts,"".concat(a,":dest-Segment.io")),c=new Set,l=!1,f=null!==(i=null==t?void 0:t.apiHost)&&void 0!==i?i:Mn,h=null!==(o=null==t?void 0:t.protocol)&&void 0!==o?o:"https",d="".concat(h,"://").concat(f),p=null==t?void 0:t.deliveryStrategy,g="batching"===(null==p?void 0:p.strategy)?ro(f,p.config):(m=null==p?void 0:p.config,{dispatch:function(e,t){return hn(e,{keepalive:null==m?void 0:m.keepalive,headers:{"Content-Type":"text/plain"},method:"post",body:JSON.stringify(t)})}}),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,ao(e.options.highEntropyValuesClientHints)];case 2:return y=n.sent(),[3,4];case 3:return n.sent(),y=void 0,[3,4];case 4:return v={name:"Segment.io",type:"after",version:"0.1.0",isLoaded:function(){return!0},load:function(){return Promise.resolve()},track:s,identify:s,page:s,alias:s,group:s,screen:s},u.todo&&so(l,u,v,so),[2,v]}var m}))}))}function co(e){var t,n=e.event;!function(e){if(!Tt(e))throw new Ct("Event",Ut);if("object"!=typeof e)throw new Ct("Event",jt)}(n),function(e){if(!Pt(e.type))throw new Ct(".type",Lt)}(n),"track"===n.type&&function(e){if(!Pt(e.event))throw new Ct(".event",Lt)}(n);var r=null!==(t=n.properties)&&void 0!==t?t:n.traits;if("alias"!==n.type&&!Mt(r))throw new Ct(".properties","is not an object");return function(e){var t=".userId/anonymousId/previousId/groupId",n=function(e){var t,n,r;return null!==(r=null!==(n=null!==(t=e.userId)&&void 0!==t?t:e.anonymousId)&&void 0!==n?n:e.groupId)&&void 0!==r?r:e.previousId}(e);if(!Tt(n))throw new Ct(t,Ut);if(!Pt(n))throw new Ct(t,Lt)}(n),e}var lo={name:"Event Validation",type:"before",version:"1.0.0",isLoaded:function(){return!0},load:function(){return Promise.resolve()},track:co,identify:co,page:co,alias:co,group:co,screen:co},fo=function(e,t,n){n.getCalls(e).forEach((function(e){mo(t,e).catch(console.error)}))},ho=function(e,t){return mt(void 0,void 0,void 0,(function(){var n,r,i;return _t(this,(function(o){switch(o.label){case 0:n=0,r=t.getCalls("addSourceMiddleware"),o.label=1;case 1:return n<r.length?(i=r[n],[4,mo(e,i).catch(console.error)]):[3,4];case 2:o.sent(),o.label=3;case 3:return n++,[3,1];case 4:return[2]}}))}))},po=fo.bind(void 0,"on"),go=fo.bind(void 0,"setAnonymousId"),yo=function(e,t){t.toArray().forEach((function(t){setTimeout((function(){mo(e,t).catch(console.error)}),0)}))},vo=function(){function e(){this._value={}}return e.prototype.toArray=function(){var e;return(e=[]).concat.apply(e,Object.values(this._value))},e.prototype.getCalls=function(e){var t;return null!==(t=this._value[e])&&void 0!==t?t:[]},e.prototype.push=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.forEach((function(t){e._value[t.method]?e._value[t.method].push(t):e._value[t.method]=[t]})),this},e.prototype.clear=function(){return this._value={},this},e}();function mo(e,t){return mt(this,void 0,void 0,(function(){var n,r;return _t(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),t.called?[2,void 0]:(t.called=!0,n=e[t.method].apply(e,t.args),"object"==typeof(o=n)&&null!==o&&"then"in o&&"function"==typeof o.then?[4,n]:[3,2]);case 1:i.sent(),i.label=2;case 2:return t.resolve(n),[3,4];case 3:return r=i.sent(),t.reject(r),[3,4];case 4:return[2]}var o}))}))}var _o=function(){function e(e){var t=this;this._preInitBuffer=new vo,this.trackSubmit=this._createMethod("trackSubmit"),this.trackClick=this._createMethod("trackClick"),this.trackLink=this._createMethod("trackLink"),this.pageView=this._createMethod("pageview"),this.identify=this._createMethod("identify"),this.reset=this._createMethod("reset"),this.group=this._createMethod("group"),this.track=this._createMethod("track"),this.ready=this._createMethod("ready"),this.alias=this._createMethod("alias"),this.debug=this._createChainableMethod("debug"),this.page=this._createMethod("page"),this.once=this._createChainableMethod("once"),this.off=this._createChainableMethod("off"),this.on=this._createChainableMethod("on"),this.addSourceMiddleware=this._createMethod("addSourceMiddleware"),this.setAnonymousId=this._createMethod("setAnonymousId"),this.addDestinationMiddleware=this._createMethod("addDestinationMiddleware"),this.screen=this._createMethod("screen"),this.register=this._createMethod("register"),this.deregister=this._createMethod("deregister"),this.user=this._createMethod("user"),this.VERSION=dn,this._promise=e(this._preInitBuffer),this._promise.then((function(e){var n=e[0],r=e[1];t.instance=n,t.ctx=r})).catch((function(){}))}return e.prototype.then=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(e=this._promise).then.apply(e,t)},e.prototype.catch=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(e=this._promise).catch.apply(e,t)},e.prototype.finally=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(e=this._promise).finally.apply(e,t)},e.prototype._createMethod=function(e){var t=this;return function(){for(var n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];if(t.instance){var o=(n=t.instance)[e].apply(n,r);return Promise.resolve(o)}return new Promise((function(n,i){t._preInitBuffer.push({method:e,args:r,resolve:n,reject:i,called:!1})}))}},e.prototype._createChainableMethod=function(e){var t=this;return function(){for(var n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return t.instance?((n=t.instance)[e].apply(n,r),t):(t._preInitBuffer.push({method:e,args:r,resolve:function(){},reject:console.error,called:!1}),t)}},e}();function bo(e){var t=e[0],n=e.slice(1);return{method:t,resolve:function(){},reject:console.error,args:n,called:!1}}var wo,Eo,So=function(){var e=window.analytics;if(!Array.isArray(e))return[];var t=e.splice(0,e.length);return t.map(bo)},Oo=null!==(wo=(Eo=fn()).__SEGMENT_INSPECTOR__)&&void 0!==wo?wo:Eo.__SEGMENT_INSPECTOR__={};function xo(e,t){return mt(this,void 0,void 0,(function(){return _t(this,(function(n){switch(n.label){case 0:return t.push.apply(t,So()),[4,ho(e,t)];case 1:return n.sent(),t.push.apply(t,So()),yo(e,t),t.clear(),[2]}}))}))}function Io(e,t,n,r,i,o,s){var a,u,c;return mt(this,void 0,void 0,(function(){var l,f,h,d,p,g,y,v,m,_,b,w,E=this;return _t(this,(function(S){switch(S.label){case 0:return function(e){var t,n,r;return"test"!==tr().NODE_ENV&&(null!==(r=null===(n=null===(t=e.middlewareSettings)||void 0===t?void 0:t.routingRules)||void 0===n?void 0:n.length)&&void 0!==r?r:0)>0}(t)?[4,Promise.resolve().then((function(){return pd})).then((function(e){return e.tsubMiddleware(t.middlewareSettings.routingRules)}))]:[3,2];case 1:return f=S.sent(),[3,3];case 2:f=void 0,S.label=3;case 3:return l=f,O=t,"test"!==tr().NODE_ENV&&Object.keys(O.integrations).length>1||s.length>0?[4,Promise.resolve().then((function(){return wd})).then((function(i){return i.ajsDestinations(e,t,n.integrations,r,l,s)}))]:[3,5];case 4:return d=S.sent(),[3,6];case 5:d=[],S.label=6;case 6:return h=d,t.legacyVideoPluginsEnabled?[4,Promise.resolve().then((function(){return Ed})).then((function(e){return e.loadLegacyVideoPlugins(n)}))]:[3,8];case 7:S.sent(),S.label=8;case 8:return(null===(a=r.plan)||void 0===a?void 0:a.track)?[4,Promise.resolve().then((function(){return Sd})).then((function(e){var n;return e.schemaFilter(null===(n=r.plan)||void 0===n?void 0:n.track,t)}))]:[3,10];case 9:return g=S.sent(),[3,11];case 10:g=void 0,S.label=11;case 11:return p=g,y=sr(t,i),[4,Zi(t,n.integrations,y,i.obfuscate,l).catch((function(){return[]}))];case 12:return v=S.sent(),m=bt(bt(bt([lo,fr],o,!0),h,!0),v,!0),p&&m.push(p),!1===(null===(u=r.integrations)||void 0===u?void 0:u.All)&&!r.integrations["Segment.io"]||r.integrations&&!1===r.integrations["Segment.io"]?[3,14]:(b=(_=m).push,[4,uo(n,y["Segment.io"],t.integrations)]);case 13:b.apply(_,[S.sent()]),S.label=14;case 14:return[4,n.register.apply(n,m)];case 15:return w=S.sent(),Object.entries(null!==(c=t.enabledMiddleware)&&void 0!==c?c:{}).some((function(e){return e[1]}))?[4,Promise.resolve().then((function(){return Od})).then((function(e){var r=e.remoteMiddlewares;return mt(E,void 0,void 0,(function(){var e,o;return _t(this,(function(s){switch(s.label){case 0:return[4,r(w,t,i.obfuscate)];case 1:return e=s.sent(),o=e.map((function(e){return n.addSourceMiddleware(e)})),[2,Promise.all(o)]}}))}))}))]:[3,17];case 16:S.sent(),S.label=17;case 17:return[2,w]}var O}))}))}function Ro(e,t,n){var r,i,o,s,a,u,c;return void 0===t&&(t={}),mt(this,void 0,void 0,(function(){var l,f,h,d,p,g,y,v,m,_,b;return _t(this,(function(w){switch(w.label){case 0:return e.cdnURL&&(x=e.cdnURL,window.analytics&&(window.analytics._cdn=x),nr=x),null===(r=e.cdnSettings)||void 0===r?[3,1]:(f=r,[3,3]);case 1:return[4,(E=e.writeKey,S=e.cdnURL,O=null!=S?S:ir(),hn("".concat(O,"/v1/projects/").concat(E,"/settings")).then((function(e){return e.ok?e.json():e.text().then((function(e){throw new Error(e)}))})).catch((function(e){throw console.error(e.message),e})))];case 2:f=w.sent(),w.label=3;case 3:return l=f,t.updateCDNSettings&&(l=t.updateCDNSettings(l)),h=null===(o=null===(i=l.integrations["Segment.io"])||void 0===i?void 0:i.retryQueue)||void 0===o||o,d=vt({retryQueue:h},t),function(e){var t;null===(t=Oo.attach)||void 0===t||t.call(Oo,e)}(p=new er(e,d)),g=null!==(s=e.plugins)&&void 0!==s?s:[],y=null!==(a=e.classicIntegrations)&&void 0!==a?a:[],Dn.initRemoteMetrics(l.metrics),function(e,t){t.push.apply(t,So()),go(e,t),po(e,t)}(p,n),[4,Io(e.writeKey,l,p,d,t,g,y)];case 4:return v=w.sent(),m=null!==(u=window.location.search)&&void 0!==u?u:"",_=null!==(c=window.location.hash)&&void 0!==c?c:"",(b=m.length?m:_.replace(/(?=#).*(?=\?)/,"")).includes("ajs_")?[4,p.queryString(b).catch(console.error)]:[3,6];case 5:w.sent(),w.label=6;case 6:return p.initialized=!0,p.emit("initialize",e,t),t.initialPageview&&p.page().catch(console.error),[4,xo(p,n)];case 7:return w.sent(),[2,[p,v]]}var E,S,O,x}))}))}var ko=function(e){function t(){var t,n,r,i=this,o=(r=new Promise((function(e,r){t=e,n=r})),{resolve:t,reject:n,promise:r}),s=o.promise,a=o.resolve;return i=e.call(this,(function(e){return s.then((function(t){return Ro(t[0],t[1],e)}))}))||this,i._resolveLoadStart=function(e,t){return a([e,t])},i}return yt(t,e),t.prototype.load=function(e,t){return void 0===t&&(t={}),this._resolveLoadStart(e,t),this},t.load=function(e,n){return void 0===n&&(n={}),(new t).load(e,n)},t.standalone=function(e,n){return t.load({writeKey:e},n).then((function(e){return e[0]}))},t}(_o);let Co;const Po=new Uint8Array(16);function Ao(){if(!Co&&(Co="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Co))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Co(Po)}var No=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;const To=[];for(let e=0;e<256;++e)To.push((e+256).toString(16).slice(1));function Mo(e,t=0){return(To[e[t+0]]+To[e[t+1]]+To[e[t+2]]+To[e[t+3]]+"-"+To[e[t+4]]+To[e[t+5]]+"-"+To[e[t+6]]+To[e[t+7]]+"-"+To[e[t+8]]+To[e[t+9]]+"-"+To[e[t+10]]+To[e[t+11]]+To[e[t+12]]+To[e[t+13]]+To[e[t+14]]+To[e[t+15]]).toLowerCase()}function Lo(e){if(!function(e){return"string"==typeof e&&No.test(e)}(e))throw TypeError("Invalid UUID");let t;const n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}function jo(e,t,n){function r(e,r,i,o){var s;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));const t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=Lo(r)),16!==(null===(s=r)||void 0===s?void 0:s.length))throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let a=new Uint8Array(16+e.length);if(a.set(r),a.set(e,r.length),a=n(a),a[6]=15&a[6]|t,a[8]=63&a[8]|128,i){o=o||0;for(let e=0;e<16;++e)i[o+e]=a[e];return i}return Mo(a)}try{r.name=e}catch(e){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r}function Uo(e){return 14+(e+64>>>9<<4)+1}function Do(e,t){const n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function zo(e,t,n,r,i,o){return Do((s=Do(Do(t,e),Do(r,o)))<<(a=i)|s>>>32-a,n);var s,a}function Fo(e,t,n,r,i,o,s){return zo(t&n|~t&r,e,t,i,o,s)}function Bo(e,t,n,r,i,o,s){return zo(t&r|n&~r,e,t,i,o,s)}function Ho(e,t,n,r,i,o,s){return zo(t^n^r,e,t,i,o,s)}function qo(e,t,n,r,i,o,s){return zo(n^(t|~r),e,t,i,o,s)}jo("v3",48,(function(e){if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(let n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){const t=[],n=32*e.length,r="0123456789abcdef";for(let i=0;i<n;i+=8){const n=e[i>>5]>>>i%32&255,o=parseInt(r.charAt(n>>>4&15)+r.charAt(15&n),16);t.push(o)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[Uo(t)-1]=t;let n=1732584193,r=-271733879,i=-1732584194,o=271733878;for(let t=0;t<e.length;t+=16){const s=n,a=r,u=i,c=o;n=Fo(n,r,i,o,e[t],7,-680876936),o=Fo(o,n,r,i,e[t+1],12,-389564586),i=Fo(i,o,n,r,e[t+2],17,606105819),r=Fo(r,i,o,n,e[t+3],22,-1044525330),n=Fo(n,r,i,o,e[t+4],7,-176418897),o=Fo(o,n,r,i,e[t+5],12,1200080426),i=Fo(i,o,n,r,e[t+6],17,-1473231341),r=Fo(r,i,o,n,e[t+7],22,-45705983),n=Fo(n,r,i,o,e[t+8],7,1770035416),o=Fo(o,n,r,i,e[t+9],12,-1958414417),i=Fo(i,o,n,r,e[t+10],17,-42063),r=Fo(r,i,o,n,e[t+11],22,-1990404162),n=Fo(n,r,i,o,e[t+12],7,1804603682),o=Fo(o,n,r,i,e[t+13],12,-40341101),i=Fo(i,o,n,r,e[t+14],17,-1502002290),r=Fo(r,i,o,n,e[t+15],22,1236535329),n=Bo(n,r,i,o,e[t+1],5,-165796510),o=Bo(o,n,r,i,e[t+6],9,-1069501632),i=Bo(i,o,n,r,e[t+11],14,643717713),r=Bo(r,i,o,n,e[t],20,-373897302),n=Bo(n,r,i,o,e[t+5],5,-701558691),o=Bo(o,n,r,i,e[t+10],9,38016083),i=Bo(i,o,n,r,e[t+15],14,-660478335),r=Bo(r,i,o,n,e[t+4],20,-405537848),n=Bo(n,r,i,o,e[t+9],5,568446438),o=Bo(o,n,r,i,e[t+14],9,-1019803690),i=Bo(i,o,n,r,e[t+3],14,-187363961),r=Bo(r,i,o,n,e[t+8],20,1163531501),n=Bo(n,r,i,o,e[t+13],5,-1444681467),o=Bo(o,n,r,i,e[t+2],9,-51403784),i=Bo(i,o,n,r,e[t+7],14,1735328473),r=Bo(r,i,o,n,e[t+12],20,-1926607734),n=Ho(n,r,i,o,e[t+5],4,-378558),o=Ho(o,n,r,i,e[t+8],11,-2022574463),i=Ho(i,o,n,r,e[t+11],16,1839030562),r=Ho(r,i,o,n,e[t+14],23,-35309556),n=Ho(n,r,i,o,e[t+1],4,-1530992060),o=Ho(o,n,r,i,e[t+4],11,1272893353),i=Ho(i,o,n,r,e[t+7],16,-155497632),r=Ho(r,i,o,n,e[t+10],23,-1094730640),n=Ho(n,r,i,o,e[t+13],4,681279174),o=Ho(o,n,r,i,e[t],11,-358537222),i=Ho(i,o,n,r,e[t+3],16,-722521979),r=Ho(r,i,o,n,e[t+6],23,76029189),n=Ho(n,r,i,o,e[t+9],4,-640364487),o=Ho(o,n,r,i,e[t+12],11,-421815835),i=Ho(i,o,n,r,e[t+15],16,530742520),r=Ho(r,i,o,n,e[t+2],23,-995338651),n=qo(n,r,i,o,e[t],6,-198630844),o=qo(o,n,r,i,e[t+7],10,1126891415),i=qo(i,o,n,r,e[t+14],15,-1416354905),r=qo(r,i,o,n,e[t+5],21,-57434055),n=qo(n,r,i,o,e[t+12],6,1700485571),o=qo(o,n,r,i,e[t+3],10,-1894986606),i=qo(i,o,n,r,e[t+10],15,-1051523),r=qo(r,i,o,n,e[t+1],21,-2054922799),n=qo(n,r,i,o,e[t+8],6,1873313359),o=qo(o,n,r,i,e[t+15],10,-30611744),i=qo(i,o,n,r,e[t+6],15,-1560198380),r=qo(r,i,o,n,e[t+13],21,1309151649),n=qo(n,r,i,o,e[t+4],6,-145523070),o=qo(o,n,r,i,e[t+11],10,-1120210379),i=qo(i,o,n,r,e[t+2],15,718787259),r=qo(r,i,o,n,e[t+9],21,-343485551),n=Do(n,s),r=Do(r,a),i=Do(i,u),o=Do(o,c)}return[n,r,i,o]}(function(e){if(0===e.length)return[];const t=8*e.length,n=new Uint32Array(Uo(t));for(let r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))}));var Vo={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function $o(e,t,n){if(Vo.randomUUID&&!t&&!e)return Vo.randomUUID();const r=(e=e||{}).random||(e.rng||Ao)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return Mo(r)}function Wo(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function Ko(e,t){return e<<t|e>>>32-t}jo("v5",80,(function(e){const t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);const r=e.length/4+2,i=Math.ceil(r/16),o=new Array(i);for(let t=0;t<i;++t){const n=new Uint32Array(16);for(let r=0;r<16;++r)n[r]=e[64*t+4*r]<<24|e[64*t+4*r+1]<<16|e[64*t+4*r+2]<<8|e[64*t+4*r+3];o[t]=n}o[i-1][14]=8*(e.length-1)/Math.pow(2,32),o[i-1][14]=Math.floor(o[i-1][14]),o[i-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<i;++e){const r=new Uint32Array(80);for(let t=0;t<16;++t)r[t]=o[e][t];for(let e=16;e<80;++e)r[e]=Ko(r[e-3]^r[e-8]^r[e-14]^r[e-16],1);let i=n[0],s=n[1],a=n[2],u=n[3],c=n[4];for(let e=0;e<80;++e){const n=Math.floor(e/20),o=Ko(i,5)+Wo(n,s,a,u)+c+t[n]+r[e]>>>0;c=u,u=a,a=Ko(s,30)>>>0,s=i,i=o}n[0]=n[0]+i>>>0,n[1]=n[1]+s>>>0,n[2]=n[2]+a>>>0,n[3]=n[3]+u>>>0,n[4]=n[4]+c>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}));let Go=null;const Yo={};function Qo(){const e=m.exports.useCallback(((e={},t={})=>c(this,void 0,void 0,(function*(){if(Go)return;{const n=ko.load({writeKey:"TA4NjQhF2P4PqA3iRdhSGzdnl5Pinj2g"});yield n.identify($o()),Go={analytics:n,globalOptions:t,globalProperties:e}}}))),[]),t=m.exports.useCallback((e=>c(this,void 0,void 0,(function*(){Go&&(Yo[Object.keys(Yo).length]=e)}))),[]),n=m.exports.useCallback((()=>c(this,void 0,void 0,(function*(){0!=Object.keys(Yo).length&&Go&&(yield Go.analytics.track("userFlow",Yo))}))),[]);return{init:e,track:m.exports.useCallback(((e,t={})=>c(this,void 0,void 0,(function*(){if(!Go)return;const n=Object.assign(Object.assign({},Go.globalProperties),t);yield Go.analytics.track(e,n,Go.globalOptions)}))),[]),page:m.exports.useCallback(((e,t={})=>c(this,void 0,void 0,(function*(){if(!Go)return;const n=Object.assign(Object.assign({},Go.globalProperties),t);yield Go.analytics.page(e,n,Go.globalOptions)}))),[]),addStepToFlow:t,sendUserFlow:n}}let Jo=e=>{};const Xo=({onClose:e,children:t})=>{const{sendUserFlow:n,addStepToFlow:r}=Qo(),[i,o]=m.exports.useState(!0);Jo=o;const s=()=>{Jo(!1),r("Close"),n(),e&&e()},a=e=>{var t;"ModalWrapper"===(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.id)&&s()};return i?y.exports.jsxs(y.exports.Fragment,{children:[y.exports.jsx(tt,{}),y.exports.jsx(ot,Object.assign({id:"ModalWrapper",onClick:a},{children:y.exports.jsxs(st,{children:[y.exports.jsxs(ct,{children:[y.exports.jsx("img",{src:"data:image/svg+xml,%3csvg width='72' height='24' viewBox='0 0 72 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M61.3616 22.4887V23.9996H71.7318V17.1853H70.2208V22.4887H61.3616ZM61.3616 0V1.51096H70.2208V6.81473H71.7318V0H61.3616ZM56.0137 11.689V8.17796H58.3842C59.5398 8.17796 59.9546 8.56305 59.9546 9.61506V10.2372C59.9546 11.3186 59.5545 11.689 58.3842 11.689H56.0137ZM59.7764 12.311C60.8578 12.0296 61.6133 11.022 61.6133 9.82231C61.6133 9.06683 61.3172 8.38521 60.7542 7.83698C60.0432 7.15536 59.0948 6.81473 57.8653 6.81473H54.5322V17.1849H56.0137V13.0518H58.2361C59.3767 13.0518 59.836 13.5258 59.836 14.7112V17.1853H61.3469V14.9482C61.3469 13.3186 60.9618 12.6965 59.7764 12.5187V12.311ZM47.303 12.6517H51.866V11.2888H47.303V8.17761H52.3102V6.81473H45.7916V17.1849H52.5325V15.822H47.303V12.6517ZM42.3398 13.1999V13.9109C42.3398 15.4072 41.7916 15.8963 40.414 15.8963H40.0881C38.7102 15.8963 38.0436 15.4516 38.0436 13.3925V10.6072C38.0436 8.53329 38.7399 8.10338 40.1175 8.10338H40.4137C41.7618 8.10338 42.1914 8.60716 42.2061 9.99979H43.8357C43.6876 7.9553 42.3248 6.66665 40.2803 6.66665C39.2878 6.66665 38.4581 6.97787 37.836 7.57021C36.9027 8.44437 36.3842 9.92593 36.3842 11.9998C36.3842 13.9999 36.8288 15.4814 37.7471 16.3997C38.3692 17.0071 39.2286 17.333 40.073 17.333C40.9619 17.333 41.7769 16.9773 42.1914 16.2071H42.3986V17.1849H43.7615V11.837H39.7467V13.1999H42.3398ZM29.2737 8.17761H30.8886C32.4146 8.17761 33.2443 8.5627 33.2443 10.6369V13.3627C33.2443 15.4366 32.4146 15.822 30.8886 15.822H29.2737V8.17761ZM31.0216 17.1853C33.8513 17.1853 34.903 15.0372 34.903 12.0002C34.903 8.91874 33.7771 6.81509 30.9919 6.81509H27.7917V17.1853H31.0216ZM20.6367 12.6517H25.1997V11.2888H20.6367V8.17761H25.644V6.81473H19.1254V17.1849H25.8663V15.822H20.6367V12.6517ZM11.8962 6.81473H10.3852V17.1849H17.2V15.822H11.8962V6.81473ZM0 17.1853V24H10.3702V22.4887H1.51096V17.1853H0ZM0 0V6.81473H1.51096V1.51096H10.3702V0H0Z' fill='white'/%3e%3c/svg%3e"}),y.exports.jsx(at,Object.assign({onClick:s},{children:y.exports.jsx("img",{src:"data:image/svg+xml,%3csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M22 2L2 22' stroke='white' stroke-width='3'/%3e%3cpath d='M2 2L22 22' stroke='white' stroke-width='3'/%3e%3c/svg%3e"})}))]}),y.exports.jsx(y.exports.Fragment,{children:t})]})}))]}):null};var Zo,es,ts,ns,rs={exports:{}},is={},os={exports:{}},ss={};function as(){return es||(es=1,function(e){e.exports=(Zo||(Zo=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,o=e[r];if(!(0<i(o,t)))break e;e[r]=t,e[n]=o,n=r}}function n(e){return 0===e.length?null:e[0]}function r(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,o=e.length,s=o>>>1;r<s;){var a=2*(r+1)-1,u=e[a],c=a+1,l=e[c];if(0>i(u,n))c<o&&0>i(l,u)?(e[r]=l,e[c]=n,r=c):(e[r]=u,e[a]=n,r=a);else{if(!(c<o&&0>i(l,n)))break e;e[r]=l,e[c]=n,r=c}}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var s=Date,a=s.now();e.unstable_now=function(){return s.now()-a}}var u=[],c=[],l=1,f=null,h=3,d=!1,p=!1,g=!1,y="function"==typeof setTimeout?setTimeout:null,v="function"==typeof clearTimeout?clearTimeout:null,m="undefined"!=typeof setImmediate?setImmediate:null;function _(e){for(var i=n(c);null!==i;){if(null===i.callback)r(c);else{if(!(i.startTime<=e))break;r(c),i.sortIndex=i.expirationTime,t(u,i)}i=n(c)}}function b(e){if(g=!1,_(e),!p)if(null!==n(u))p=!0,N(w);else{var t=n(c);null!==t&&T(b,t.startTime-e)}}function w(t,i){p=!1,g&&(g=!1,v(x),x=-1),d=!0;var o=h;try{for(_(i),f=n(u);null!==f&&(!(f.expirationTime>i)||t&&!k());){var s=f.callback;if("function"==typeof s){f.callback=null,h=f.priorityLevel;var a=s(f.expirationTime<=i);i=e.unstable_now(),"function"==typeof a?f.callback=a:f===n(u)&&r(u),_(i)}else r(u);f=n(u)}if(null!==f)var l=!0;else{var y=n(c);null!==y&&T(b,y.startTime-i),l=!1}return l}finally{f=null,h=o,d=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var E,S=!1,O=null,x=-1,I=5,R=-1;function k(){return!(e.unstable_now()-R<I)}function C(){if(null!==O){var t=e.unstable_now();R=t;var n=!0;try{n=O(!0,t)}finally{n?E():(S=!1,O=null)}}else S=!1}if("function"==typeof m)E=function(){m(C)};else if("undefined"!=typeof MessageChannel){var P=new MessageChannel,A=P.port2;P.port1.onmessage=C,E=function(){A.postMessage(null)}}else E=function(){y(C,0)};function N(e){O=e,S||(S=!0,E())}function T(t,n){x=y((function(){t(e.unstable_now())}),n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){p||d||(p=!0,N(w))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(e){switch(h){case 1:case 2:case 3:var t=3;break;default:t=h}var n=h;h=t;try{return e()}finally{h=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=h;h=e;try{return t()}finally{h=n}},e.unstable_scheduleCallback=function(r,i,o){var s=e.unstable_now();switch(o="object"==typeof o&&null!==o&&"number"==typeof(o=o.delay)&&0<o?s+o:s,r){case 1:var a=-1;break;case 2:a=250;break;case 5:a=1073741823;break;case 4:a=1e4;break;default:a=5e3}return r={id:l++,callback:i,priorityLevel:r,startTime:o,expirationTime:a=o+a,sortIndex:-1},o>s?(r.sortIndex=o,t(c,r),null===n(u)&&r===n(c)&&(g?(v(x),x=-1):g=!0,T(b,o-s))):(r.sortIndex=a,t(u,r),p||d||(p=!0,N(w))),r},e.unstable_shouldYield=k,e.unstable_wrapCallback=function(e){var t=h;return function(){var n=h;h=t;try{return e.apply(this,arguments)}finally{h=n}}}}(ss)),ss)}(os)),os.exports}
|
173
|
+
function pn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var gn=function e(t,n){function r(e,r,i){if("undefined"!=typeof document){"number"==typeof(i=pn({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o="";for(var s in i)i[s]&&(o+="; "+s,!0!==i[s]&&(o+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+o}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},i=0;i<n.length;i++){var o=n[i].split("="),s=o.slice(1).join("=");try{var a=decodeURIComponent(o[0]);if(r[a]=t.read(s,a),e===a)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",pn({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,pn({},this.attributes,t))},withConverter:function(t){return e(pn({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});function yn(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(t){return e}}function vn(e){var t=function(e){try{return new URL(e)}catch(e){return}}(e);if(t)for(var n=function(e){var t=e.hostname.split("."),n=t[t.length-1],r=[];if(4===t.length&&parseInt(n,10)>0)return r;if(t.length<=1)return r;for(var i=t.length-2;i>=0;--i)r.push(t.slice(i).join("."));return r}(t),r=0;r<n.length;++r){var i="__tld__",o=n[r],s={domain:"."+o};try{if(gn.set(i,"1",s),gn.get(i))return gn.remove(i,s),o}catch(e){return}}}function mn(e){for(var t=e.constructor.prototype,n=0,r=Object.getOwnPropertyNames(t);n<r.length;n++){var i=r[n];if("constructor"!==i){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,i);o&&"function"==typeof o.value&&(e[i]=e[i].bind(e))}}return e}var _n={persist:!0,cookie:{key:"ajs_user_id",oldKey:"ajs_user"},localStorage:{key:"ajs_user_traits"}},bn=function(){function e(){this.cache={}}return e.prototype.get=function(e){return this.cache[e]},e.prototype.set=function(e,t){this.cache[e]=t},e.prototype.remove=function(e){delete this.cache[e]},Object.defineProperty(e.prototype,"type",{get:function(){return"memory"},enumerable:!1,configurable:!0}),e}(),wn=function(e){function t(n){void 0===n&&(n=t.defaults);var r=e.call(this)||this;return r.options=vt(vt({},t.defaults),n),r}return yt(t,e),t.available=function(){try{var e="ajs_cookies_check";gn.set(e,"test");var t=document.cookie.includes(e);return gn.remove(e),t}catch(e){return!1}},Object.defineProperty(t,"defaults",{get:function(){return{maxage:365,domain:vn(window.location.href),path:"/",sameSite:"Lax"}},enumerable:!1,configurable:!0}),t.prototype.opts=function(){return{sameSite:this.options.sameSite,expires:this.options.maxage,domain:this.options.domain,path:this.options.path,secure:this.options.secure}},t.prototype.get=function(e){try{var t=gn.get(e);if(!t)return null;try{return JSON.parse(t)}catch(e){return t}}catch(e){return null}},t.prototype.set=function(e,t){"string"==typeof t?gn.set(e,t,this.opts()):null===t?gn.remove(e,this.opts()):gn.set(e,JSON.stringify(t),this.opts())},t.prototype.remove=function(e){return gn.remove(e,this.opts())},Object.defineProperty(t.prototype,"type",{get:function(){return"cookie"},enumerable:!1,configurable:!0}),t}(bn),En=function(e,t){console.warn("Unable to access ".concat(e,", localStorage may be ").concat(t))},Sn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return yt(t,e),t.available=function(){var e="test";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}},t.prototype.get=function(e){try{var t=localStorage.getItem(e);if(null===t)return null;try{return JSON.parse(t)}catch(e){return t}}catch(t){return En(e,"unavailable"),null}},t.prototype.set=function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(t){En(e,"full")}},t.prototype.remove=function(e){try{return localStorage.removeItem(e)}catch(t){En(e,"unavailable")}},Object.defineProperty(t.prototype,"type",{get:function(){return"localStorage"},enumerable:!1,configurable:!0}),t}(bn),On=function(){function e(e,t){this.storageOptions=t,this.enabledStores=e}return e.prototype.getStores=function(e){var t=this,n=[];return this.enabledStores.filter((function(t){return!e||(null==e?void 0:e.includes(t))})).forEach((function(e){var r=t.storageOptions[e];void 0!==r&&n.push(r)})),n},e.prototype.getAndSync=function(e,t){var n=this.get(e,t),r="number"==typeof n?n.toString():n;return this.set(e,r,t),r},e.prototype.get=function(e,t){for(var n=null,r=0,i=this.getStores(t);r<i.length;r++){if(n=i[r].get(e))return n}return null},e.prototype.set=function(e,t,n){for(var r=0,i=this.getStores(n);r<i.length;r++){i[r].set(e,t)}},e.prototype.clear=function(e,t){for(var n=0,r=this.getStores(t);n<r.length;n++){r[n].remove(e)}},e}();function xn(e){return{cookie:wn.available()?new wn(e):void 0,localStorage:Sn.available()?new Sn:void 0,memory:new bn}}var In,Rn=function(){function e(e,t){void 0===e&&(e=_n);var n,r,i,o,s=this;this.options={},this.id=function(e){if(s.options.disable)return null;var t=s.identityStore.getAndSync(s.idKey);void 0!==e&&(s.identityStore.set(s.idKey,e),e!==t&&null!==t&&null!==e&&s.anonymousId(null));var n=s.identityStore.getAndSync(s.idKey);if(n)return n;var r=s.legacyUserStore.get(_n.cookie.oldKey);return r?"object"==typeof r?r.id:r:null},this.anonymousId=function(e){var t,n;if(s.options.disable)return null;if(void 0===e){var r=null!==(t=s.identityStore.getAndSync(s.anonKey))&&void 0!==t?t:null===(n=s.legacySIO())||void 0===n?void 0:n[0];if(r)return r}return null===e?(s.identityStore.set(s.anonKey,null),s.identityStore.getAndSync(s.anonKey)):(s.identityStore.set(s.anonKey,null!=e?e:$t()),s.identityStore.getAndSync(s.anonKey))},this.traits=function(e){var t;if(!s.options.disable)return null===e&&(e={}),e&&s.traitsStore.set(s.traitsKey,null!=e?e:{}),null!==(t=s.traitsStore.get(s.traitsKey))&&void 0!==t?t:{}},this.options=e,this.cookieOptions=t,this.idKey=null!==(r=null===(n=e.cookie)||void 0===n?void 0:n.key)&&void 0!==r?r:_n.cookie.key,this.traitsKey=null!==(o=null===(i=e.localStorage)||void 0===i?void 0:i.key)&&void 0!==o?o:_n.localStorage.key,this.anonKey="ajs_anonymous_id";var a=!0===e.disable,u=!1!==e.persist,c=a?[]:u?["localStorage","cookie","memory"]:["memory"],l=xn(t);e.localStorageFallbackDisabled&&(c=c.filter((function(e){return"localStorage"!==e}))),this.identityStore=new On(c,l),this.legacyUserStore=new On(c.filter((function(e){return"localStorage"!==e&&"memory"!==e})),l),this.traitsStore=new On(c.filter((function(e){return"cookie"!==e})),l);var f=this.legacyUserStore.get(_n.cookie.oldKey);f&&"object"==typeof f&&(f.id&&this.id(f.id),f.traits&&this.traits(f.traits)),mn(this)}return e.prototype.legacySIO=function(){var e=this.legacyUserStore.get("_sio");if(!e)return null;var t=e.split("----");return[t[0],t[1]]},e.prototype.identify=function(e,t){if(!this.options.disable){t=null!=t?t:{};var n=this.id();null!==n&&n!==e||(t=vt(vt({},this.traits()),t)),e&&this.id(e),this.traits(t)}},e.prototype.logout=function(){this.anonymousId(null),this.id(null),this.traits({})},e.prototype.reset=function(){this.logout(),this.identityStore.clear(this.idKey),this.identityStore.clear(this.anonKey),this.traitsStore.clear(this.traitsKey)},e.prototype.load=function(){return new e(this.options,this.cookieOptions)},e.prototype.save=function(){return!0},e.defaults=_n,e}(),kn={persist:!0,cookie:{key:"ajs_group_id"},localStorage:{key:"ajs_group_properties"}},Cn=function(e){function t(t,n){void 0===t&&(t=kn);var r=e.call(this,t,n)||this;return r.anonymousId=function(e){},mn(r),r}return yt(t,e),t}(Rn);var Pn="npm";function An(){return Pn}function Nn(e,t,n){var r=new On(n?[]:["cookie"],xn(function(){if(In)return In;var e=vn(window.location.href);return In={expires:31536e6,secure:!1,path:"/"},e&&(In.domain=e),In}())),i=r.get("s:context.referrer"),o=function(e){var t={btid:"dataxu",urid:"millennial-media"};e.startsWith("?")&&(e=e.substring(1));for(var n=0,r=(e=e.replace(/\?/g,"&")).split("&");n<r.length;n++){var i=r[n].split("="),o=i[0],s=i[1];if(t[o])return{id:s,type:t[o]}}}(e);(o=null!=o?o:i)&&(t&&(t.referrer=vt(vt({},t.referrer),o)),r.set("s:context.referrer",o))}function Tn(e,t,n,r){var i,o,s,a,u,c,l=e.user();t.context=null!==(o=null!==(i=t.context)&&void 0!==i?i:t.options)&&void 0!==o?o:{};var f=t.context,h="string"==typeof(null===(s=f.page)||void 0===s?void 0:s.search)?null===(a=f.page)||void 0===a?void 0:a.search:"";delete t.options,t.writeKey=null==n?void 0:n.apiKey,f.userAgent=navigator.userAgent;var d=navigator.userLanguage||navigator.language;if(void 0===f.locale&&void 0!==d&&(f.locale=d),!f.library){var p=An();f.library="web"===p?{name:"analytics.js",version:"next-".concat(dn)}:{name:"analytics.js",version:"npm:next-".concat(dn)}}h&&!f.campaign&&(f.campaign=function(e){return e.startsWith("?")&&(e=e.substring(1)),(e=e.replace(/\?/g,"&")).split("&").reduce((function(e,t){var n=t.split("="),r=n[0],i=n[1],o=void 0===i?"":i;if(r.includes("utm_")&&r.length>4){var s=r.substr(4);"campaign"===s&&(s="name"),e[s]=yn(o)}return e}),{})}(h)),Nn(h,f,null!==(u=e.options.disableClientPersistence)&&void 0!==u&&u),t.userId=t.userId||l.id(),t.anonymousId=t.anonymousId||l.anonymousId(),t.sentAt=new Date;var g=e.queue.failedInitializations||[];g.length>0&&(t._metadata={failedInitializations:g});var y=[],v=[];for(var m in r){var _=r[m];"Segment.io"===m&&y.push(m),"bundled"===_.bundlingStatus&&y.push(m),"unbundled"===_.bundlingStatus&&v.push(m)}for(var b=0,w=(null==n?void 0:n.unbundledIntegrations)||[];b<w.length;b++){var E=w[b];v.includes(E)||v.push(E)}var S=null!==(c=null==n?void 0:n.maybeBundledConfigIds)&&void 0!==c?c:{},O=[];y.sort().forEach((function(e){var t;(null!==(t=S[e])&&void 0!==t?t:[]).forEach((function(e){O.push(e)}))})),!1!==(null==n?void 0:n.addBundledMetadata)&&(t._metadata=vt(vt({},t._metadata),{bundled:y.sort(),unbundled:v.sort(),bundledIds:O}));var x=function(){var e=gn.get("_ga");if(e&&e.startsWith("amp"))return e}();return x&&(f.amp={id:x}),t}var Mn="api.segment.io/v1";function Ln(e){console.error("Error sending segment performance metrics",e)}var jn,Un=function(){function e(e){var t,n,r,i,o=this;if(this.host=null!==(t=null==e?void 0:e.host)&&void 0!==t?t:Mn,this.sampleRate=null!==(n=null==e?void 0:e.sampleRate)&&void 0!==n?n:1,this.flushTimer=null!==(r=null==e?void 0:e.flushTimer)&&void 0!==r?r:3e4,this.maxQueueSize=null!==(i=null==e?void 0:e.maxQueueSize)&&void 0!==i?i:20,this.queue=[],this.sampleRate>0){var s=!1,a=function(){s||(s=!0,o.flush().catch(Ln),s=!1,setTimeout(a,o.flushTimer))};a()}}return e.prototype.increment=function(e,t){if(e.includes("analytics_js.")&&0!==t.length&&!(Math.random()>this.sampleRate||this.queue.length>=this.maxQueueSize)){var n=function(e,t,n){var r=t.reduce((function(e,t){var n=t.split(":"),r=n[0],i=n[1];return e[r]=i,e}),{});return{type:"Counter",metric:e,value:1,tags:vt(vt({},r),{library:"analytics.js",library_version:"web"===n?"next-".concat(dn):"npm:next-".concat(dn)})}}(e,t,An());this.queue.push(n),e.includes("error")&&this.flush().catch(Ln)}},e.prototype.flush=function(){return mt(this,void 0,void 0,(function(){var e=this;return _t(this,(function(t){switch(t.label){case 0:return this.queue.length<=0?[2]:[4,this.send().catch((function(t){Ln(t),e.sampleRate=0}))];case 1:return t.sent(),[2]}}))}))},e.prototype.send=function(){return mt(this,void 0,void 0,(function(){var e,t,n;return _t(this,(function(r){return e={series:this.queue},this.queue=[],t={"Content-Type":"text/plain"},n="https://".concat(this.host,"/m"),[2,hn(n,{headers:t,body:JSON.stringify(e),method:"POST"})]}))}))},e}(),Dn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return yt(t,e),t.initRemoteMetrics=function(e){jn=new Un(e)},t.prototype.increment=function(t,n,r){e.prototype.increment.call(this,t,n,r),null==jn||jn.increment(t,null!=r?r:[])},t}(Kt),zn=function(e){function t(t,n){return e.call(this,t,n,new Dn)||this}return yt(t,e),t.system=function(){return new this({type:"track",event:"system"})},t}(Qt),Fn={exports:{}};!function(e,t){e.exports=function(e){var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(e,t){var n=e[0],r=e[1],i=e[2],o=e[3];r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[0]-680876936|0)<<7|n>>>25)+r|0)&r|~n&i)+t[1]-389564586|0)<<12|o>>>20)+n|0)&n|~o&r)+t[2]+606105819|0)<<17|i>>>15)+o|0)&o|~i&n)+t[3]-1044525330|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[4]-176418897|0)<<7|n>>>25)+r|0)&r|~n&i)+t[5]+1200080426|0)<<12|o>>>20)+n|0)&n|~o&r)+t[6]-1473231341|0)<<17|i>>>15)+o|0)&o|~i&n)+t[7]-45705983|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[8]+1770035416|0)<<7|n>>>25)+r|0)&r|~n&i)+t[9]-1958414417|0)<<12|o>>>20)+n|0)&n|~o&r)+t[10]-42063|0)<<17|i>>>15)+o|0)&o|~i&n)+t[11]-1990404162|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[12]+1804603682|0)<<7|n>>>25)+r|0)&r|~n&i)+t[13]-40341101|0)<<12|o>>>20)+n|0)&n|~o&r)+t[14]-1502002290|0)<<17|i>>>15)+o|0)&o|~i&n)+t[15]+1236535329|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[1]-165796510|0)<<5|n>>>27)+r|0)&i|r&~i)+t[6]-1069501632|0)<<9|o>>>23)+n|0)&r|n&~r)+t[11]+643717713|0)<<14|i>>>18)+o|0)&n|o&~n)+t[0]-373897302|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[5]-701558691|0)<<5|n>>>27)+r|0)&i|r&~i)+t[10]+38016083|0)<<9|o>>>23)+n|0)&r|n&~r)+t[15]-660478335|0)<<14|i>>>18)+o|0)&n|o&~n)+t[4]-405537848|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[9]+568446438|0)<<5|n>>>27)+r|0)&i|r&~i)+t[14]-1019803690|0)<<9|o>>>23)+n|0)&r|n&~r)+t[3]-187363961|0)<<14|i>>>18)+o|0)&n|o&~n)+t[8]+1163531501|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[13]-1444681467|0)<<5|n>>>27)+r|0)&i|r&~i)+t[2]-51403784|0)<<9|o>>>23)+n|0)&r|n&~r)+t[7]+1735328473|0)<<14|i>>>18)+o|0)&n|o&~n)+t[12]-1926607734|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[5]-378558|0)<<4|n>>>28)+r|0)^r^i)+t[8]-2022574463|0)<<11|o>>>21)+n|0)^n^r)+t[11]+1839030562|0)<<16|i>>>16)+o|0)^o^n)+t[14]-35309556|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[1]-1530992060|0)<<4|n>>>28)+r|0)^r^i)+t[4]+1272893353|0)<<11|o>>>21)+n|0)^n^r)+t[7]-155497632|0)<<16|i>>>16)+o|0)^o^n)+t[10]-1094730640|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[13]+681279174|0)<<4|n>>>28)+r|0)^r^i)+t[0]-358537222|0)<<11|o>>>21)+n|0)^n^r)+t[3]-722521979|0)<<16|i>>>16)+o|0)^o^n)+t[6]+76029189|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[9]-640364487|0)<<4|n>>>28)+r|0)^r^i)+t[12]-421815835|0)<<11|o>>>21)+n|0)^n^r)+t[15]+530742520|0)<<16|i>>>16)+o|0)^o^n)+t[2]-995338651|0)<<23|r>>>9)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[0]-198630844|0)<<6|n>>>26)+r|0)|~i))+t[7]+1126891415|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[14]-1416354905|0)<<15|i>>>17)+o|0)|~n))+t[5]-57434055|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[12]+1700485571|0)<<6|n>>>26)+r|0)|~i))+t[3]-1894986606|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[10]-1051523|0)<<15|i>>>17)+o|0)|~n))+t[1]-2054922799|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[8]+1873313359|0)<<6|n>>>26)+r|0)|~i))+t[15]-30611744|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[6]-1560198380|0)<<15|i>>>17)+o|0)|~n))+t[13]+1309151649|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[4]-145523070|0)<<6|n>>>26)+r|0)|~i))+t[11]-1120210379|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[2]+718787259|0)<<15|i>>>17)+o|0)|~n))+t[9]-343485551|0)<<21|r>>>11)+i|0,e[0]=n+e[0]|0,e[1]=r+e[1]|0,e[2]=i+e[2]|0,e[3]=o+e[3]|0}function r(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}function i(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n}function o(e){var t,i,o,s,a,u,c=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(l,r(e.substring(t-64,t)));for(i=(e=e.substring(t-64)).length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)o[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(l,o),t=0;t<16;t+=1)o[t]=0;return s=(s=8*c).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(s[2],16),u=parseInt(s[1],16)||0,o[14]=a,o[15]=u,n(l,o),l}function s(e){var t,r,o,s,a,u,c=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(l,i(e.subarray(t-64,t)));for(r=(e=t-64<c?e.subarray(t-64):new Uint8Array(0)).length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<r;t+=1)o[t>>2]|=e[t]<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(l,o),t=0;t<16;t+=1)o[t]=0;return s=(s=8*c).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(s[2],16),u=parseInt(s[1],16)||0,o[14]=a,o[15]=u,n(l,o),l}function a(e){var n,r="";for(n=0;n<4;n+=1)r+=t[e>>8*n+4&15]+t[e>>8*n&15];return r}function u(e){var t;for(t=0;t<e.length;t+=1)e[t]=a(e[t]);return e.join("")}function c(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function l(e,t){var n,r=e.length,i=new ArrayBuffer(r),o=new Uint8Array(i);for(n=0;n<r;n+=1)o[n]=e.charCodeAt(n);return t?o:i}function f(e){return String.fromCharCode.apply(null,new Uint8Array(e))}function h(e,t,n){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e)),r.set(new Uint8Array(t),e.byteLength),n?r:r.buffer}function d(e){var t,n=[],r=e.length;for(t=0;t<r-1;t+=2)n.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,n)}function p(){this.reset()}return u(o("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(n,r){var i,o,s,a,u=this.byteLength,c=t(n,u),l=u;return r!==e&&(l=t(r,u)),c>l?new ArrayBuffer(0):(i=l-c,o=new ArrayBuffer(i),s=new Uint8Array(o),a=new Uint8Array(this,c,i),s.set(a),o)}}(),p.prototype.append=function(e){return this.appendBinary(c(e)),this},p.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,i=this._buff.length;for(t=64;t<=i;t+=64)n(this._hash,r(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},p.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(o,i),n=u(this._hash),e&&(n=d(n)),this.reset(),n},p.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},p.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},p.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},p.prototype._finish=function(e,t){var r,i,o,s=t;if(e[s>>2]|=128<<(s%4<<3),s>55)for(n(this._hash,e),s=0;s<16;s+=1)e[s]=0;r=(r=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(r[2],16),o=parseInt(r[1],16)||0,e[14]=i,e[15]=o,n(this._hash,e)},p.hash=function(e,t){return p.hashBinary(c(e),t)},p.hashBinary=function(e,t){var n=u(o(e));return t?d(n):n},p.ArrayBuffer=function(){this.reset()},p.ArrayBuffer.prototype.append=function(e){var t,r=h(this._buff.buffer,e,!0),o=r.length;for(this._length+=e.byteLength,t=64;t<=o;t+=64)n(this._hash,i(r.subarray(t-64,t)));return this._buff=t-64<o?new Uint8Array(r.buffer.slice(t-64)):new Uint8Array(0),this},p.ArrayBuffer.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r[t]<<(t%4<<3);return this._finish(o,i),n=u(this._hash),e&&(n=d(n)),this.reset(),n},p.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.ArrayBuffer.prototype.getState=function(){var e=p.prototype.getState.call(this);return e.buff=f(e.buff),e},p.ArrayBuffer.prototype.setState=function(e){return e.buff=l(e.buff,!0),p.prototype.setState.call(this,e)},p.ArrayBuffer.prototype.destroy=p.prototype.destroy,p.ArrayBuffer.prototype._finish=p.prototype._finish,p.ArrayBuffer.hash=function(e,t){var n=u(s(new Uint8Array(e)));return t?d(n):n},p}()}(Fn);var Bn=Fn.exports,Hn=function(){function e(e){this.user=e}return e.prototype.track=function(e,t,n,r){return this.normalize(vt(vt({},this.baseEvent()),{event:e,type:"track",properties:t,options:vt({},n),integrations:vt({},r)}))},e.prototype.page=function(e,t,n,r,i){var o,s={type:"page",properties:vt({},n),options:vt({},r),integrations:vt({},i)};return null!==e&&(s.category=e,s.properties=null!==(o=s.properties)&&void 0!==o?o:{},s.properties.category=e),null!==t&&(s.name=t),this.normalize(vt(vt({},this.baseEvent()),s))},e.prototype.screen=function(e,t,n,r,i){var o={type:"screen",properties:vt({},n),options:vt({},r),integrations:vt({},i)};return null!==e&&(o.category=e),null!==t&&(o.name=t),this.normalize(vt(vt({},this.baseEvent()),o))},e.prototype.identify=function(e,t,n,r){return this.normalize(vt(vt({},this.baseEvent()),{type:"identify",userId:e,traits:t,options:vt({},n),integrations:vt({},r)}))},e.prototype.group=function(e,t,n,r){return this.normalize(vt(vt({},this.baseEvent()),{type:"group",traits:t,options:vt({},n),integrations:vt({},r),groupId:e}))},e.prototype.alias=function(e,t,n,r){var i={userId:e,type:"alias",options:vt({},n),integrations:vt({},r)};return null!==t&&(i.previousId=t),void 0===e?this.normalize(vt(vt({},i),this.baseEvent())):this.normalize(vt(vt({},this.baseEvent()),i))},e.prototype.baseEvent=function(){var e={integrations:{},options:{}},t=this.user;return t.id()&&(e.userId=t.id()),t.anonymousId()&&(e.anonymousId=t.anonymousId()),e},e.prototype.context=function(e){var t,n,r,i=["integrations","anonymousId","timestamp","userId"],o=null!==(t=e.options)&&void 0!==t?t:{};delete o.integrations;var s=Object.keys(o),a=null!==(r=null===(n=e.options)||void 0===n?void 0:n.context)&&void 0!==r?r:{},u={};return s.forEach((function(e){"context"!==e&&(i.includes(e)?kt(u,e,o[e]):kt(a,e,o[e]))})),[a,u]},e.prototype.normalize=function(e){var t,n,r;(null===(t=e.options)||void 0===t?void 0:t.anonymousId)&&this.user.anonymousId(e.options.anonymousId);var i=Object.keys(null!==(n=e.integrations)&&void 0!==n?n:{}).reduce((function(t,n){var r,i;return vt(vt({},t),((r={})[n]=Boolean(null===(i=e.integrations)||void 0===i?void 0:i[n]),r))}),{}),o=vt(vt({},i),null===(r=e.options)||void 0===r?void 0:r.integrations),s=this.context(e),a=s[0],u=s[1];e.options;var c=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(e,["options"]),l=vt(vt(vt({timestamp:new Date},c),{context:a,integrations:o}),u),f="ajs-next-"+Bn.hash(JSON.stringify(l)+$t());return vt(vt({},l),{messageId:f})},e}(),qn={getItem:function(){},setItem:function(){},removeItem:function(){}};try{qn=sn()&&window.localStorage?window.localStorage:qn}catch(e){console.warn("Unable to access localStorage",e)}function Vn(e){var t=qn.getItem(e);return(t?JSON.parse(t):[]).map((function(e){return new zn(e.event,e.id)}))}function $n(e){var t=qn.getItem(e);return t?JSON.parse(t):{}}function Wn(e){qn.removeItem(e)}function Kn(e,t,n){void 0===n&&(n=0);var r="persisted-queue:v1:".concat(e,":lock"),i=qn.getItem(r),o=i?JSON.parse(i):null,s=null===o||function(e){return(new Date).getTime()>e}(o);if(s)return qn.setItem(r,JSON.stringify((new Date).getTime()+50)),t(),void qn.removeItem(r);!s&&n<3?setTimeout((function(){Kn(e,t,n+1)}),50):console.error("Unable to retrieve lock")}var Gn=function(e){function t(t,n){var r=e.call(this,t,[])||this,i="persisted-queue:v1:".concat(n,":items"),o="persisted-queue:v1:".concat(n,":seen"),s=[],a={};return Kn(n,(function(){try{s=Vn(i),a=$n(o),Wn(i),Wn(o),r.queue=bt(bt([],s,!0),r.queue,!0),r.seen=vt(vt({},a),r.seen)}catch(e){console.error(e)}})),window.addEventListener("pagehide",(function(){if(r.todo>0){var e=bt(bt([],r.queue,!0),r.future,!0);try{Kn(n,(function(){!function(e,t){var n=Vn(e),r=bt(bt([],t,!0),n,!0).reduce((function(e,t){var n;return vt(vt({},e),((n={})[t.id]=t,n))}),{});qn.setItem(e,JSON.stringify(Object.values(r)))}(i,e),function(e,t){var n=$n(e);qn.setItem(e,JSON.stringify(vt(vt({},n),t)))}(o,r.seen)}))}catch(e){console.error(e)}}})),r}return yt(t,e),t}(Ht),Yn=function(e){function t(t){return e.call(this,"string"==typeof t?new Gn(4,t):t)||this}return yt(t,e),t.prototype.flush=function(){return mt(this,void 0,void 0,(function(){return _t(this,(function(t){return cn()?[2,[]]:[2,e.prototype.flush.call(this)]}))}))},t}(Zt),Qn="This is being deprecated and will be not be available in future releases of Analytics JS",Jn=fn(),Xn=null==Jn?void 0:Jn.analytics;function Zn(){console.warn(Qn)}var er=function(e){function t(t,n,r,i,o){var s,a,u,c=this;(c=e.call(this)||this)._debug=!1,c.initialized=!1,c.user=function(){return c._user},c.init=c.initialize.bind(c),c.log=Zn,c.addIntegrationMiddleware=Zn,c.listeners=Zn,c.addEventListener=Zn,c.removeAllListeners=Zn,c.removeListener=Zn,c.removeEventListener=Zn,c.hasListeners=Zn,c.add=Zn,c.addIntegration=Zn;var l=null==n?void 0:n.cookie,f=null!==(s=null==n?void 0:n.disableClientPersistence)&&void 0!==s&&s;return c.settings=t,c.settings.timeout=null!==(a=c.settings.timeout)&&void 0!==a?a:300,c.queue=null!=r?r:function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1);var r=t?4:1,i=n?new Ht(r,[]):new Gn(r,e);return new Yn(i)}("".concat(t.writeKey,":event-queue"),null==n?void 0:n.retryQueue,f),c._universalStorage=new On(f?["memory"]:["localStorage","cookie","memory"],xn(l)),c._user=null!=i?i:new Rn(f?vt(vt({},null==n?void 0:n.user),{persist:!1}):null==n?void 0:n.user,l).load(),c._group=null!=o?o:new Cn(f?vt(vt({},null==n?void 0:n.group),{persist:!1}):null==n?void 0:n.group,l).load(),c.eventFactory=new Hn(c._user),c.integrations=null!==(u=null==n?void 0:n.integrations)&&void 0!==u?u:{},c.options=null!=n?n:{},mn(c),c}return yt(t,e),Object.defineProperty(t.prototype,"storage",{get:function(){return this._universalStorage},enumerable:!1,configurable:!0}),t.prototype.track=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r,i,o,s,a=this;return _t(this,(function(u){return t=tn.apply(void 0,e),n=t[0],r=t[1],i=t[2],o=t[3],s=this.eventFactory.track(n,r,i,this.integrations),[2,this._dispatch(s,o).then((function(e){return a.emit("track",n,e.event.properties,e.event.options),e}))]}))}))},t.prototype.page=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,u=this;return _t(this,(function(c){return t=nn.apply(void 0,e),n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],a=this.eventFactory.page(n,r,i,o,this.integrations),[2,this._dispatch(a,s).then((function(e){return u.emit("page",n,r,e.event.properties,e.event.options),e}))]}))}))},t.prototype.identify=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r,i,o,s,a=this;return _t(this,(function(u){return t=rn(this._user).apply(void 0,e),n=t[0],r=t[1],i=t[2],o=t[3],this._user.identify(n,r),s=this.eventFactory.identify(this._user.id(),this._user.traits(),i,this.integrations),[2,this._dispatch(s,o).then((function(e){return a.emit("identify",e.event.userId,e.event.traits,e.event.options),e}))]}))}))},t.prototype.group=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(0===t.length)return this._group;var r=rn(this._group).apply(void 0,t),i=r[0],o=r[1],s=r[2],a=r[3];this._group.identify(i,o);var u=this._group.id(),c=this._group.traits(),l=this.eventFactory.group(u,c,s,this.integrations);return this._dispatch(l,a).then((function(t){return e.emit("group",t.event.groupId,t.event.traits,t.event.options),t}))},t.prototype.alias=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r,i,o,s,a=this;return _t(this,(function(u){return t=on.apply(void 0,e),n=t[0],r=t[1],i=t[2],o=t[3],s=this.eventFactory.alias(n,r,i,this.integrations),[2,this._dispatch(s,o).then((function(e){return a.emit("alias",n,r,e.event.options),e}))]}))}))},t.prototype.screen=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,u=this;return _t(this,(function(c){return t=nn.apply(void 0,e),n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],a=this.eventFactory.screen(n,r,i,o,this.integrations),[2,this._dispatch(a,s).then((function(e){return u.emit("screen",n,r,e.event.properties,e.event.options),e}))]}))}))},t.prototype.trackClick=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n;return _t(this,(function(r){switch(r.label){case 0:return[4,Promise.resolve().then((function(){return sl}))];case 1:return t=r.sent(),[2,(n=t.link).call.apply(n,bt([this],e,!1))]}}))}))},t.prototype.trackLink=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n;return _t(this,(function(r){switch(r.label){case 0:return[4,Promise.resolve().then((function(){return sl}))];case 1:return t=r.sent(),[2,(n=t.link).call.apply(n,bt([this],e,!1))]}}))}))},t.prototype.trackSubmit=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n;return _t(this,(function(r){switch(r.label){case 0:return[4,Promise.resolve().then((function(){return sl}))];case 1:return t=r.sent(),[2,(n=t.form).call.apply(n,bt([this],e,!1))]}}))}))},t.prototype.trackForm=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n;return _t(this,(function(r){switch(r.label){case 0:return[4,Promise.resolve().then((function(){return sl}))];case 1:return t=r.sent(),[2,(n=t.form).call.apply(n,bt([this],e,!1))]}}))}))},t.prototype.register=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r=this;return _t(this,(function(i){switch(i.label){case 0:return t=zn.system(),n=e.map((function(e){return r.queue.register(t,e,r)})),[4,Promise.all(n)];case 1:return i.sent(),[2,t]}}))}))},t.prototype.deregister=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return mt(this,void 0,void 0,(function(){var t,n,r=this;return _t(this,(function(i){switch(i.label){case 0:return t=zn.system(),n=e.map((function(e){var n=r.queue.plugins.find((function(t){return t.name===e}));if(n)return r.queue.deregister(t,n,r);t.log("warn","plugin ".concat(e," not found"))})),[4,Promise.all(n)];case 1:return i.sent(),[2,t]}}))}))},t.prototype.debug=function(e){return!1===e&&localStorage.getItem("debug")&&localStorage.removeItem("debug"),this._debug=e,this},t.prototype.reset=function(){this._user.reset(),this._group.reset(),this.emit("reset")},t.prototype.timeout=function(e){this.settings.timeout=e},t.prototype._dispatch=function(e,t){return mt(this,void 0,void 0,(function(){var n;return _t(this,(function(r){return n=new zn(e),cn()&&!this.options.retryQueue?[2,n]:[2,en(n,this.queue,this,{callback:t,debug:this._debug,timeout:this.settings.timeout})]}))}))},t.prototype.addSourceMiddleware=function(e){return mt(this,void 0,void 0,(function(){var t=this;return _t(this,(function(n){switch(n.label){case 0:return[4,this.queue.criticalTasks.run((function(){return mt(t,void 0,void 0,(function(){var t,n,r;return _t(this,(function(i){switch(i.label){case 0:return[4,Promise.resolve().then((function(){return Ji}))];case 1:return t=i.sent().sourceMiddlewarePlugin,n={},this.queue.plugins.forEach((function(e){if("destination"===e.type)return n[e.name]=!0})),r=t(e,n),[4,this.register(r)];case 2:return i.sent(),[2]}}))}))}))];case 1:return n.sent(),[2,this]}}))}))},t.prototype.addDestinationMiddleware=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return this.queue.plugins.filter((function(t){return t.name.toLowerCase()===e.toLowerCase()})).forEach((function(e){e.addMiddleware.apply(e,t)})),Promise.resolve(this)},t.prototype.setAnonymousId=function(e){return this._user.anonymousId(e)},t.prototype.queryString=function(e){return mt(this,void 0,void 0,(function(){return _t(this,(function(t){switch(t.label){case 0:return!1===this.options.useQueryString?[2,[]]:[4,Promise.resolve().then((function(){return ul}))];case 1:return[2,(0,t.sent().queryString)(this,e)]}}))}))},t.prototype.use=function(e){return e(this),this},t.prototype.ready=function(e){return void 0===e&&(e=function(e){return e}),mt(this,void 0,void 0,(function(){return _t(this,(function(t){return[2,Promise.all(this.queue.plugins.map((function(e){return e.ready?e.ready():Promise.resolve()}))).then((function(t){return e(t),t}))]}))}))},t.prototype.noConflict=function(){return console.warn(Qn),window.analytics=null!=Xn?Xn:this,this},t.prototype.normalize=function(e){return console.warn(Qn),this.eventFactory.normalize(e)},Object.defineProperty(t.prototype,"failedInitializations",{get:function(){return console.warn(Qn),this.queue.failedInitializations},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"VERSION",{get:function(){return dn},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e,t){return mt(this,void 0,void 0,(function(){return _t(this,(function(e){return console.warn(Qn),[2,Promise.resolve(this)]}))}))},t.prototype.pageview=function(e){return mt(this,void 0,void 0,(function(){return _t(this,(function(t){switch(t.label){case 0:return console.warn(Qn),[4,this.page({path:e})];case 1:return t.sent(),[2,this]}}))}))},Object.defineProperty(t.prototype,"plugins",{get:function(){var e;return console.warn(Qn),null!==(e=this._plugins)&&void 0!==e?e:{}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"Integrations",{get:function(){console.warn(Qn);var e=this.queue.plugins.filter((function(e){return"destination"===e.type})).reduce((function(e,t){var n="".concat(t.name.toLowerCase().replace(".","").split(" ").join("-"),"Integration"),r=window[n];if(!r)return e;var i=r.Integration;return i?(e[t.name]=i,e):(e[t.name]=r,e)}),{});return e},enumerable:!1,configurable:!0}),t.prototype.push=function(e){var t=e.shift();t&&!this[t]||this[t].apply(this,e)},t}(wt);function tr(){return"undefined"!=typeof process&&process.env?process.env:{}}try{window.analyticsWriteKey="__WRITE_KEY__"}catch(J){}var nr,rr=/(https:\/\/.*)\/analytics\.js\/v1\/(?:.*?)\/(?:platform|analytics.*)?/,ir=function(){var e=function(){var e;return null!=nr?nr:null===(e=window.analytics)||void 0===e?void 0:e._cdn}();if(e)return e;var t,n=(Array.prototype.slice.call(document.querySelectorAll("script")).forEach((function(e){var n,r=null!==(n=e.getAttribute("src"))&&void 0!==n?n:"",i=rr.exec(r);i&&i[1]&&(t=i[1])})),t);return n||"https://cdn.segment.com"},or=function(){var e=ir();return"".concat(e,"/next-integrations")};function sr(e,t){var n,r=Object.entries(null!==(n=t.integrations)&&void 0!==n?n:{}).reduce((function(e,t){var n,r,i=t[0],o=t[1];return vt(vt({},e),"object"==typeof o?((n={})[i]=o,n):((r={})[i]={},r))}),{});return Object.entries(e.integrations).reduce((function(e,t){var n,i=t[0],o=t[1];return vt(vt({},e),((n={})[i]=vt(vt({},o),r[i]),n))}),{})}function ar(){var e=document.querySelector("link[rel='canonical']");if(e)return e.getAttribute("href")||void 0}function ur(){var e=ar();if(!e)return window.location.pathname;var t=document.createElement("a");return t.href=e,t.pathname.startsWith("/")?t.pathname:"/"+t.pathname}function cr(e){void 0===e&&(e="");var t=ar();if(t)return t.includes("?")?t:"".concat(t).concat(e);var n=window.location.href,r=n.indexOf("#");return-1===r?n:n.slice(0,r)}function lr(e){var t=e.event;t.context=t.context||{};var n,r,i={path:ur(),referrer:document.referrer,search:location.search,title:document.title,url:cr(location.search)},o=void 0;return"page"===t.type&&(o=t.properties&&(n=t.properties,r=Object.keys(i),Object.assign.apply(Object,bt([{}],r.map((function(e){var t;if(n&&Object.prototype.hasOwnProperty.call(n,e))return(t={})[e]=n[e],t})),!1))),t.properties=vt(vt(vt({},i),t.properties),t.name?{name:t.name}:{})),t.context.page=vt(vt(vt({},i),o),t.context.page),e}var fr={name:"Page Enrichment",version:"0.1.0",isLoaded:function(){return!0},load:function(){return Promise.resolve()},type:"before",page:lr,alias:lr,track:lr,identify:lr,group:lr};function hr(e){return Array.prototype.slice.call(window.document.querySelectorAll("script")).find((function(t){return t.src===e}))}function dr(e,t){var n=hr(e);if(void 0!==n){var r=null==n?void 0:n.getAttribute("status");if("loaded"===r)return Promise.resolve(n);if("loading"===r)return new Promise((function(e,t){n.addEventListener("load",(function(){return e(n)})),n.addEventListener("error",(function(e){return t(e)}))}))}return new Promise((function(n,r){var i,o=window.document.createElement("script");o.type="text/javascript",o.src=e,o.async=!0,o.setAttribute("status","loading");for(var s=0,a=Object.entries(null!=t?t:{});s<a.length;s++){var u=a[s],c=u[0],l=u[1];o.setAttribute(c,l)}o.onload=function(){o.onerror=o.onload=null,o.setAttribute("status","loaded"),n(o)},o.onerror=function(){o.onerror=o.onload=null,o.setAttribute("status","error"),r(new Error("Failed to load ".concat(e)))};var f=window.document.getElementsByTagName("script")[0];null===(i=f.parentElement)||void 0===i||i.insertBefore(o,f)}))}function pr(e){var t=hr(e);return void 0!==t&&t.remove(),Promise.resolve()}var gr={},yr={},vr={},mr={exports:{}};!function(e){function t(e){return function(t,n,r,o){var s,a=o&&function(e){return"function"==typeof e}(o.normalizer)?o.normalizer:i;n=a(n);for(var u=!1;!u;)c();function c(){for(s in t){var e=a(s);if(0===n.indexOf(e)){var r=n.substr(e.length);if("."===r.charAt(0)||0===r.length){n=r.substr(1);var i=t[s];return null==i?void(u=!0):n.length?void(t=i):void(u=!0)}}}s=void 0,u=!0}if(s)return null==t?t:e(t,s,r)}}function n(e,t){return e.hasOwnProperty(t)&&delete e[t],e}function r(e,t,n){return e.hasOwnProperty(t)&&(e[t]=n),e}function i(e){return e.replace(/[^a-zA-Z0-9\.]+/g,"").toLowerCase()}e.exports=t((function(e,t){if(e.hasOwnProperty(t))return e[t]})),e.exports.find=e.exports,e.exports.replace=function(e,n,i,o){return t(r).call(this,e,n,i,o),e},e.exports.del=function(e,r,i){return t(n).call(this,e,r,null,i),e}}(mr);var _r=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(vr,"__esModule",{value:!0});var br=_r(mr.exports);function wr(e,t){return function(){var n=this.traits(),r=this.properties?this.properties():{};return br.default(n,"address."+e)||br.default(n,e)||(t?br.default(n,"address."+t):null)||(t?br.default(n,t):null)||br.default(r,"address."+e)||br.default(r,e)||(t?br.default(r,"address."+t):null)||(t?br.default(r,t):null)}}vr.default=function(e){e.zip=wr("postalCode","zip"),e.country=wr("country"),e.street=wr("street"),e.state=wr("state"),e.city=wr("city"),e.region=wr("region")};var Er={};Object.defineProperty(Er,"__esModule",{value:!0}),Er.clone=void 0,Er.clone=function e(t){if("object"!=typeof t)return t;if("[object Object]"===Object.prototype.toString.call(t)){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=e(t[r]));return n}return Array.isArray(t)?t.map(e):t};var Sr={};Object.defineProperty(Sr,"__esModule",{value:!0});var Or={Salesforce:!0};Sr.default=function(e){return!Or[e]};var xr={},Ir=/^(\d{4})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:([ T])(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;xr.parse=function(e){var t=[1,5,6,7,11,12],n=Ir.exec(e),r=0;if(!n)return new Date(e);for(var i,o=0;i=t[o];o++)n[i]=parseInt(n[i],10)||0;n[2]=parseInt(n[2],10)||1,n[3]=parseInt(n[3],10)||1,n[2]--,n[8]=n[8]?(n[8]+"00").substring(0,3):0," "===n[4]?r=(new Date).getTimezoneOffset():"Z"!==n[9]&&n[10]&&(r=60*n[11]+n[12],"+"===n[10]&&(r=0-r));var s=Date.UTC(n[1],n[2],n[3],n[5],n[6]+r,n[7],n[8]);return new Date(s)},xr.is=function(e,t){return"string"==typeof e&&((!t||!1!==/^\d{4}-\d{2}-\d{2}/.test(e))&&Ir.test(e))};var Rr={},kr=/\d{13}/;Rr.is=function(e){return kr.test(e)},Rr.parse=function(e){return e=parseInt(e,10),new Date(e)};var Cr={},Pr=/\d{10}/;Cr.is=function(e){return Pr.test(e)},Cr.parse=function(e){var t=1e3*parseInt(e,10);return new Date(t)};var Ar=xr,Nr=Rr,Tr=Cr,Mr=Object.prototype.toString;var Lr=function(e){return t=e,"[object Date]"===Mr.call(t)?e:function(e){return"[object Number]"===Mr.call(e)}(e)?new Date((n=e)<315576e5?1e3*n:n):Ar.is(e)?Ar.parse(e):Nr.is(e)?Nr.parse(e):Tr.is(e)?Tr.parse(e):new Date(e);var t,n};var jr=xr,Ur=Dr;function Dr(e,t){return void 0===t&&(t=!0),e&&"object"==typeof e?function(e,t){return Object.keys(e).forEach((function(n){e[n]=Dr(e[n],t)})),e}(e,t):Array.isArray(e)?function(e,t){return e.forEach((function(n,r){e[r]=Dr(n,t)})),e}(e,t):jr.is(e,t)?jr.parse(e):e}var zr=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(yr,"__esModule",{value:!0}),yr.Facade=void 0;var Fr=zr(vr),Br=Er,Hr=zr(Sr),qr=zr(Lr),Vr=zr(mr.exports),$r=zr(Ur);function Wr(e,t){t=t||{},this.raw=Br.clone(e),"clone"in t||(t.clone=!0),t.clone&&(e=Br.clone(e)),"traverse"in t||(t.traverse=!0),e.timestamp="timestamp"in e?qr.default(e.timestamp):new Date,t.traverse&&$r.default(e),this.opts=t,this.obj=e}yr.Facade=Wr;var Kr=Wr.prototype;function Gr(e){return Br.clone(e)}Kr.proxy=function(e){var t=e.split("."),n=this[e=t.shift()]||this.obj[e];return n?("function"==typeof n&&(n=n.call(this)||{}),0===t.length||(n=Vr.default(n,t.join("."))),this.opts.clone?Gr(n):n):n},Kr.field=function(e){var t=this.obj[e];return this.opts.clone?Gr(t):t},Wr.proxy=function(e){return function(){return this.proxy(e)}},Wr.field=function(e){return function(){return this.field(e)}},Wr.multi=function(e){return function(){var t=this.proxy(e+"s");if(Array.isArray(t))return t;var n=this.proxy(e);return n&&(n=[this.opts.clone?Br.clone(n):n]),n||[]}},Wr.one=function(e){return function(){var t=this.proxy(e);if(t)return t;var n=this.proxy(e+"s");return Array.isArray(n)?n[0]:void 0}},Kr.json=function(){var e=this.opts.clone?Br.clone(this.obj):this.obj;return this.type&&(e.type=this.type()),e},Kr.rawEvent=function(){return this.raw},Kr.options=function(e){var t=this.obj.options||this.obj.context||{},n=this.opts.clone?Br.clone(t):t;if(!e)return n;if(this.enabled(e)){var r=this.integrations(),i=r[e]||Vr.default(r,e);return"object"!=typeof i&&(i=Vr.default(this.options(),e)),"object"==typeof i?i:{}}},Kr.context=Kr.options,Kr.enabled=function(e){var t=this.proxy("options.providers.all");"boolean"!=typeof t&&(t=this.proxy("options.all")),"boolean"!=typeof t&&(t=this.proxy("integrations.all")),"boolean"!=typeof t&&(t=!0);var n=t&&Hr.default(e),r=this.integrations();if(r.providers&&r.providers.hasOwnProperty(e)&&(n=r.providers[e]),r.hasOwnProperty(e)){var i=r[e];n="boolean"!=typeof i||i}return!!n},Kr.integrations=function(){return this.obj.integrations||this.proxy("options.providers")||this.options()},Kr.active=function(){var e=this.proxy("options.active");return null==e&&(e=!0),e},Kr.anonymousId=function(){return this.field("anonymousId")||this.field("sessionId")},Kr.sessionId=Kr.anonymousId,Kr.groupId=Wr.proxy("options.groupId"),Kr.traits=function(e){var t=this.proxy("options.traits")||{},n=this.userId();for(var r in e=e||{},n&&(t.id=n),e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=null==this[r]?this.proxy("options.traits."+r):this[r]();if(null==i)continue;t[e[r]]=i,delete t[r]}return t},Kr.library=function(){var e=this.proxy("options.library");return e?"string"==typeof e?{name:e,version:null}:e:{name:"unknown",version:null}},Kr.device=function(){var e=this.proxy("context.device");"object"==typeof e&&null!==e||(e={});var t=this.library().name;return e.type||(t.indexOf("ios")>-1&&(e.type="ios"),t.indexOf("android")>-1&&(e.type="android")),e},Kr.userAgent=Wr.proxy("context.userAgent"),Kr.timezone=Wr.proxy("context.timezone"),Kr.timestamp=Wr.field("timestamp"),Kr.channel=Wr.field("channel"),Kr.ip=Wr.proxy("context.ip"),Kr.userId=Wr.field("userId"),Fr.default(Kr);var Yr={},Qr={exports:{}};"function"==typeof Object.create?Qr.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Qr.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}};var Jr=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Yr,"__esModule",{value:!0}),Yr.Alias=void 0;var Xr=Jr(Qr.exports),Zr=yr;function ei(e,t){Zr.Facade.call(this,e,t)}Yr.Alias=ei,Xr.default(ei,Zr.Facade),ei.prototype.action=function(){return"alias"},ei.prototype.type=ei.prototype.action,ei.prototype.previousId=function(){return this.field("previousId")||this.field("from")},ei.prototype.from=ei.prototype.previousId,ei.prototype.userId=function(){return this.field("userId")||this.field("to")},ei.prototype.to=ei.prototype.userId;var ti={},ni={};Object.defineProperty(ni,"__esModule",{value:!0});var ri=/.+\@.+\..+/;ni.default=function(e){return ri.test(e)};var ii=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ti,"__esModule",{value:!0}),ti.Group=void 0;var oi=ii(Qr.exports),si=ii(ni),ai=ii(Lr),ui=yr;function ci(e,t){ui.Facade.call(this,e,t)}ti.Group=ci,oi.default(ci,ui.Facade);var li=ci.prototype;li.action=function(){return"group"},li.type=li.action,li.groupId=ui.Facade.field("groupId"),li.created=function(){var e=this.proxy("traits.createdAt")||this.proxy("traits.created")||this.proxy("properties.createdAt")||this.proxy("properties.created");if(e)return ai.default(e)},li.email=function(){var e=this.proxy("traits.email");if(e)return e;var t=this.groupId();return si.default(t)?t:void 0},li.traits=function(e){var t=this.properties(),n=this.groupId();for(var r in e=e||{},n&&(t.id=n),e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=null==this[r]?this.proxy("traits."+r):this[r]();if(null==i)continue;t[e[r]]=i,delete t[r]}return t},li.name=ui.Facade.proxy("traits.name"),li.industry=ui.Facade.proxy("traits.industry"),li.employees=ui.Facade.proxy("traits.employees"),li.properties=function(){return this.field("traits")||this.field("properties")||{}};var fi={},hi=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(fi,"__esModule",{value:!0}),fi.Identify=void 0;var di=yr,pi=hi(mr.exports),gi=hi(Qr.exports),yi=hi(ni),vi=hi(Lr),mi=function(e){return e.trim()};function _i(e,t){di.Facade.call(this,e,t)}fi.Identify=_i,gi.default(_i,di.Facade);var bi=_i.prototype;bi.action=function(){return"identify"},bi.type=bi.action,bi.traits=function(e){var t=this.field("traits")||{},n=this.userId();for(var r in e=e||{},n&&(t.id=n),e){var i=null==this[r]?this.proxy("traits."+r):this[r]();null!=i&&(t[e[r]]=i,r!==e[r]&&delete t[r])}return t},bi.email=function(){var e=this.proxy("traits.email");if(e)return e;var t=this.userId();return yi.default(t)?t:void 0},bi.created=function(){var e=this.proxy("traits.created")||this.proxy("traits.createdAt");if(e)return vi.default(e)},bi.companyCreated=function(){var e=this.proxy("traits.company.created")||this.proxy("traits.company.createdAt");if(e)return vi.default(e)},bi.companyName=function(){return this.proxy("traits.company.name")},bi.name=function(){var e=this.proxy("traits.name");if("string"==typeof e)return mi(e);var t=this.firstName(),n=this.lastName();return t&&n?mi(t+" "+n):void 0},bi.firstName=function(){var e=this.proxy("traits.firstName");if("string"==typeof e)return mi(e);var t=this.proxy("traits.name");return"string"==typeof t?mi(t).split(" ")[0]:void 0},bi.lastName=function(){var e=this.proxy("traits.lastName");if("string"==typeof e)return mi(e);var t=this.proxy("traits.name");if("string"==typeof t){var n=mi(t).indexOf(" ");if(-1!==n)return mi(t.substr(n+1))}},bi.uid=function(){return this.userId()||this.username()||this.email()},bi.description=function(){return this.proxy("traits.description")||this.proxy("traits.background")},bi.age=function(){var e=this.birthday(),t=pi.default(this.traits(),"age");return null!=t?t:e instanceof Date?(new Date).getFullYear()-e.getFullYear():void 0},bi.avatar=function(){var e=this.traits();return pi.default(e,"avatar")||pi.default(e,"photoUrl")||pi.default(e,"avatarUrl")},bi.position=function(){var e=this.traits();return pi.default(e,"position")||pi.default(e,"jobTitle")},bi.username=di.Facade.proxy("traits.username"),bi.website=di.Facade.one("traits.website"),bi.websites=di.Facade.multi("traits.website"),bi.phone=di.Facade.one("traits.phone"),bi.phones=di.Facade.multi("traits.phone"),bi.address=di.Facade.proxy("traits.address"),bi.gender=di.Facade.proxy("traits.gender"),bi.birthday=di.Facade.proxy("traits.birthday");var wi={},Ei=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(wi,"__esModule",{value:!0}),wi.Track=void 0;var Si=Ei(Qr.exports),Oi=yr,xi=fi,Ii=Ei(ni),Ri=Ei(mr.exports);function ki(e,t){Oi.Facade.call(this,e,t)}wi.Track=ki,Si.default(ki,Oi.Facade);var Ci=ki.prototype;Ci.action=function(){return"track"},Ci.type=Ci.action,Ci.event=Oi.Facade.field("event"),Ci.value=Oi.Facade.proxy("properties.value"),Ci.category=Oi.Facade.proxy("properties.category"),Ci.id=Oi.Facade.proxy("properties.id"),Ci.productId=function(){return this.proxy("properties.product_id")||this.proxy("properties.productId")},Ci.promotionId=function(){return this.proxy("properties.promotion_id")||this.proxy("properties.promotionId")},Ci.cartId=function(){return this.proxy("properties.cart_id")||this.proxy("properties.cartId")},Ci.checkoutId=function(){return this.proxy("properties.checkout_id")||this.proxy("properties.checkoutId")},Ci.paymentId=function(){return this.proxy("properties.payment_id")||this.proxy("properties.paymentId")},Ci.couponId=function(){return this.proxy("properties.coupon_id")||this.proxy("properties.couponId")},Ci.wishlistId=function(){return this.proxy("properties.wishlist_id")||this.proxy("properties.wishlistId")},Ci.reviewId=function(){return this.proxy("properties.review_id")||this.proxy("properties.reviewId")},Ci.orderId=function(){return this.proxy("properties.id")||this.proxy("properties.order_id")||this.proxy("properties.orderId")},Ci.sku=Oi.Facade.proxy("properties.sku"),Ci.tax=Oi.Facade.proxy("properties.tax"),Ci.name=Oi.Facade.proxy("properties.name"),Ci.price=Oi.Facade.proxy("properties.price"),Ci.total=Oi.Facade.proxy("properties.total"),Ci.repeat=Oi.Facade.proxy("properties.repeat"),Ci.coupon=Oi.Facade.proxy("properties.coupon"),Ci.shipping=Oi.Facade.proxy("properties.shipping"),Ci.discount=Oi.Facade.proxy("properties.discount"),Ci.shippingMethod=function(){return this.proxy("properties.shipping_method")||this.proxy("properties.shippingMethod")},Ci.paymentMethod=function(){return this.proxy("properties.payment_method")||this.proxy("properties.paymentMethod")},Ci.description=Oi.Facade.proxy("properties.description"),Ci.plan=Oi.Facade.proxy("properties.plan"),Ci.subtotal=function(){var e=Ri.default(this.properties(),"subtotal"),t=this.total()||this.revenue();if(e)return e;if(!t)return 0;if(this.total()){var n=this.tax();n&&(t-=n),(n=this.shipping())&&(t-=n),(n=this.discount())&&(t+=n)}return t},Ci.products=function(){var e=this.properties(),t=Ri.default(e,"products");return Array.isArray(t)?t.filter((function(e){return null!==e})):[]},Ci.quantity=function(){return(this.obj.properties||{}).quantity||1},Ci.currency=function(){return(this.obj.properties||{}).currency||"USD"},Ci.referrer=function(){return this.proxy("context.referrer.url")||this.proxy("context.page.referrer")||this.proxy("properties.referrer")},Ci.query=Oi.Facade.proxy("options.query"),Ci.properties=function(e){var t=this.field("properties")||{};for(var n in e=e||{})if(Object.prototype.hasOwnProperty.call(e,n)){var r=null==this[n]?this.proxy("properties."+n):this[n]();if(null==r)continue;t[e[n]]=r,delete t[n]}return t},Ci.username=function(){return this.proxy("traits.username")||this.proxy("properties.username")||this.userId()||this.sessionId()},Ci.email=function(){var e=this.proxy("traits.email")||this.proxy("properties.email")||this.proxy("options.traits.email");if(e)return e;var t=this.userId();return Ii.default(t)?t:void 0},Ci.revenue=function(){var e=this.proxy("properties.revenue"),t=this.event();return!e&&t&&t.match(/^[ _]?completed[ _]?order[ _]?|^[ _]?order[ _]?completed[ _]?$/i)&&(e=this.proxy("properties.total")),function(e){if(!e)return;if("number"==typeof e)return e;if("string"!=typeof e)return;if(e=e.replace(/\$/g,""),e=parseFloat(e),!isNaN(e))return e}(e)},Ci.cents=function(){var e=this.revenue();return"number"!=typeof e?this.value()||0:100*e},Ci.identify=function(){var e=this.json();return e.traits=this.traits(),new xi.Identify(e,this.opts)};var Pi={},Ai=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Pi,"__esModule",{value:!0}),Pi.Page=void 0;var Ni=Ai(Qr.exports),Ti=yr,Mi=wi,Li=Ai(ni);function ji(e,t){Ti.Facade.call(this,e,t)}Pi.Page=ji,Ni.default(ji,Ti.Facade);var Ui=ji.prototype;Ui.action=function(){return"page"},Ui.type=Ui.action,Ui.category=Ti.Facade.field("category"),Ui.name=Ti.Facade.field("name"),Ui.title=Ti.Facade.proxy("properties.title"),Ui.path=Ti.Facade.proxy("properties.path"),Ui.url=Ti.Facade.proxy("properties.url"),Ui.referrer=function(){return this.proxy("context.referrer.url")||this.proxy("context.page.referrer")||this.proxy("properties.referrer")},Ui.properties=function(e){var t=this.field("properties")||{},n=this.category(),r=this.name();for(var i in e=e||{},n&&(t.category=n),r&&(t.name=r),e)if(Object.prototype.hasOwnProperty.call(e,i)){var o=null==this[i]?this.proxy("properties."+i):this[i]();if(null==o)continue;t[e[i]]=o,i!==e[i]&&delete t[i]}return t},Ui.email=function(){var e=this.proxy("context.traits.email")||this.proxy("properties.email");if(e)return e;var t=this.userId();return Li.default(t)?t:void 0},Ui.fullName=function(){var e=this.category(),t=this.name();return t&&e?e+" "+t:t},Ui.event=function(e){return e?"Viewed "+e+" Page":"Loaded a Page"},Ui.track=function(e){var t=this.json();return t.event=this.event(e),t.timestamp=this.timestamp(),t.properties=this.properties(),new Mi.Track(t,this.opts)};var Di={},zi=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Di,"__esModule",{value:!0}),Di.Screen=void 0;var Fi=zi(Qr.exports),Bi=Pi,Hi=wi;function qi(e,t){Bi.Page.call(this,e,t)}Di.Screen=qi,Fi.default(qi,Bi.Page),qi.prototype.action=function(){return"screen"},qi.prototype.type=qi.prototype.action,qi.prototype.event=function(e){return e?"Viewed "+e+" Screen":"Loaded a Screen"},qi.prototype.track=function(e){var t=this.json();return t.event=this.event(e),t.timestamp=this.timestamp(),t.properties=this.properties(),new Hi.Track(t,this.opts)};var Vi={},$i=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.Delete=void 0;var Wi=$i(Qr.exports),Ki=yr;function Gi(e,t){Ki.Facade.call(this,e,t)}function Yi(e,t){var n=new gr.Facade(e,t);return"track"===e.type&&(n=new gr.Track(e,t)),"identify"===e.type&&(n=new gr.Identify(e,t)),"page"===e.type&&(n=new gr.Page(e,t)),"alias"===e.type&&(n=new gr.Alias(e,t)),"group"===e.type&&(n=new gr.Group(e,t)),"screen"===e.type&&(n=new gr.Screen(e,t)),Object.defineProperty(n,"obj",{value:e,writable:!0}),n}function Qi(e,t,n){return mt(this,void 0,void 0,(function(){function r(t,n){return mt(this,void 0,void 0,(function(){var r,i,o;return _t(this,(function(s){switch(s.label){case 0:return r=!1,i=null,[4,n({payload:Yi(t,{clone:!0,traverse:!1}),integration:e,next:function(e){r=!0,null===e&&(i=null),e&&(i=e.obj)}})];case 1:return s.sent(),r||null===i||(i.integrations=vt(vt({},t.integrations),((o={})[e]=!1,o))),[2,i]}}))}))}var i,o,s,a,u;return _t(this,(function(e){switch(e.label){case 0:i=Yi(t,{clone:!0,traverse:!1}).rawEvent(),o=0,s=n,e.label=1;case 1:return o<s.length?(a=s[o],[4,r(i,a)]):[3,4];case 2:if(null===(u=e.sent()))return[2,null];i=u,e.label=3;case 3:return o++,[3,1];case 4:return[2,i]}}))}))}Vi.Delete=Gi,Wi.default(Gi,Ki.Facade),Gi.prototype.type=function(){return"delete"},function(e){var t=l&&l.__assign||function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.Delete=e.Screen=e.Page=e.Track=e.Identify=e.Group=e.Alias=e.Facade=void 0;var n=yr;Object.defineProperty(e,"Facade",{enumerable:!0,get:function(){return n.Facade}});var r=Yr;Object.defineProperty(e,"Alias",{enumerable:!0,get:function(){return r.Alias}});var i=ti;Object.defineProperty(e,"Group",{enumerable:!0,get:function(){return i.Group}});var o=fi;Object.defineProperty(e,"Identify",{enumerable:!0,get:function(){return o.Identify}});var s=wi;Object.defineProperty(e,"Track",{enumerable:!0,get:function(){return s.Track}});var a=Pi;Object.defineProperty(e,"Page",{enumerable:!0,get:function(){return a.Page}});var u=Di;Object.defineProperty(e,"Screen",{enumerable:!0,get:function(){return u.Screen}});var c=Vi;Object.defineProperty(e,"Delete",{enumerable:!0,get:function(){return c.Delete}}),e.default=t(t({},n.Facade),{Alias:r.Alias,Group:i.Group,Identify:o.Identify,Track:s.Track,Page:a.Page,Screen:u.Screen,Delete:c.Delete})}(gr);var Ji=Object.freeze({__proto__:null,applyDestinationMiddleware:Qi,sourceMiddlewarePlugin:function(e,t){function n(n){return mt(this,void 0,void 0,(function(){var r;return _t(this,(function(i){switch(i.label){case 0:return r=!1,[4,e({payload:Yi(n.event,{clone:!0,traverse:!1}),integrations:null!=t?t:{},next:function(e){r=!0,e&&(n.event=e.obj)}})];case 1:if(i.sent(),!r)throw new Yt({retry:!1,type:"middleware_cancellation",reason:"Middleware `next` function skipped"});return[2,n]}}))}))}return{name:"Source Middleware ".concat(e.name),type:"before",version:"0.1.0",isLoaded:function(){return!0},load:function(e){return Promise.resolve(e)},track:n,page:n,identify:n,alias:n,group:n}}}),Xi=function(){function e(e,t){this.version="1.0.0",this.alternativeNames=[],this.middleware=[],this.alias=this._createMethod("alias"),this.group=this._createMethod("group"),this.identify=this._createMethod("identify"),this.page=this._createMethod("page"),this.screen=this._createMethod("screen"),this.track=this._createMethod("track"),this.action=t,this.name=e,this.type=t.type,this.alternativeNames.push(t.name)}return e.prototype.addMiddleware=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];"destination"===this.type&&(e=this.middleware).push.apply(e,t)},e.prototype.transform=function(e){return mt(this,void 0,void 0,(function(){var t;return _t(this,(function(n){switch(n.label){case 0:return[4,Qi(this.name,e.event,this.middleware)];case 1:return null===(t=n.sent())&&e.cancel(new Yt({retry:!1,reason:"dropped by destination middleware"})),[2,new zn(t)]}}))}))},e.prototype._createMethod=function(e){var t=this;return function(n){return mt(t,void 0,void 0,(function(){var t;return _t(this,(function(r){switch(r.label){case 0:return this.action[e]?(t=n,"destination"!==this.type?[3,2]:[4,this.transform(n)]):[2,n];case 1:t=r.sent(),r.label=2;case 2:return[4,this.action[e](t)];case 3:return r.sent(),[2,n]}}))}))}},e.prototype.isLoaded=function(){return this.action.isLoaded()},e.prototype.ready=function(){return this.action.ready?this.action.ready():Promise.resolve()},e.prototype.load=function(e,t){return this.action.load(e,t)},e.prototype.unload=function(e,t){var n,r;return null===(r=(n=this.action).unload)||void 0===r?void 0:r.call(n,e,t)},e}();function Zi(e,t,n,r,i){var o,s,a;return mt(this,void 0,void 0,(function(){var u,c,l,f,h=this;return _t(this,(function(d){switch(d.label){case 0:return u=[],c=ir(),l=null!==(s=null===(o=e.middlewareSettings)||void 0===o?void 0:o.routingRules)&&void 0!==s?s:[],f=(null!==(a=e.remotePlugins)&&void 0!==a?a:[]).map((function(e){return mt(h,void 0,void 0,(function(){var o,s,a,f,h,d,p,g,y;return _t(this,(function(v){switch(v.label){case 0:if(function(e,t){var n=e[t.creationName],r=e[t.name];return!1===e.All&&!n&&!r||!1===n||!1===r}(t,e))return[2];v.label=1;case 1:if(v.trys.push([1,12,,13]),o=new RegExp("https://cdn.segment.(com|build)"),!r)return[3,7];s=e.url.split("/"),a=s[s.length-2],f=e.url.replace(a,btoa(a).replace(/=/g,"")),v.label=2;case 2:return v.trys.push([2,4,,6]),[4,dr(f.replace(o,c))];case 3:return v.sent(),[3,6];case 4:return v.sent(),[4,dr(e.url.replace(o,c))];case 5:return v.sent(),[3,6];case 6:return[3,9];case 7:return[4,dr(e.url.replace(o,c))];case 8:v.sent(),v.label=9;case 9:return h=e.libraryName,"function"!=typeof window[h]?[3,11]:[4,(0,window[h])(vt(vt({},e.settings),n[e.name]))];case 10:d=v.sent(),function(e){if(!Array.isArray(e))throw new Error("Not a valid list of plugins");var t=["load","isLoaded","name","version","type"];e.forEach((function(e){t.forEach((function(t){var n;if(void 0===e[t])throw new Error("Plugin: ".concat(null!==(n=e.name)&&void 0!==n?n:"unknown"," missing required function ").concat(t))}))}))}(p=Array.isArray(d)?d:[d]),g=l.filter((function(t){return t.destinationName===e.creationName})),p.forEach((function(t){var n=new Xi(e.creationName,t);g.length&&i&&"destination"===t.type&&n.addMiddleware(i),u.push(n)})),v.label=11;case 11:return[3,13];case 12:return y=v.sent(),console.warn("Failed to load Remote Plugin",y),[3,13];case 13:return[2]}}))}))})),[4,Promise.all(f)];case 1:return d.sent(),[2,u.filter(Boolean)]}}))}))}var eo=function(e){var t=!1;window.addEventListener("pagehide",(function(){t||(t=!0,e())})),document.addEventListener("visibilitychange",(function(){if("hidden"==document.visibilityState){if(t)return;t=!0,e()}else t=!1}))},to=500;function no(e){return(encodeURI(JSON.stringify(e)).split(/%..|./).length-1)/1024}function ro(e,t){var n,r,i,o=[],s=!1,a=null!==(n=null==t?void 0:t.size)&&void 0!==n?n:10,u=null!==(r=null==t?void 0:t.timeout)&&void 0!==r?r:5e3;function c(t){var n;if(0!==t.length){var r=null===(n=t[0])||void 0===n?void 0:n.writeKey;return hn("https://".concat(e,"/b"),{keepalive:s,headers:{"Content-Type":"text/plain"},method:"post",body:JSON.stringify({batch:t,writeKey:r})})}}function l(){return mt(this,void 0,void 0,(function(){var e;return _t(this,(function(t){return o.length?(e=o,o=[],[2,c(e)]):[2]}))}))}return eo((function(){if(s=!0,o.length){var e=function(e){var t=[],n=0;return e.forEach((function(e){no(t[n])>=64&&n++,t[n]?t[n].push(e):t[n]=[e]})),t}(o).map(c);Promise.all(e).catch(console.error)}})),{dispatch:function(e,t){return mt(this,void 0,void 0,(function(){var e;return _t(this,(function(n){return o.push(t),e=o.length>=a||function(e){return no(e)>=to-50}(o),[2,e||s?l():void(i||(i=setTimeout((function(){i=void 0,l().catch(console.error)}),u)))]}))}))}}}var io=function(e,t){return mt(void 0,void 0,void 0,(function(){var n;return _t(this,(function(r){return n=function(r){return mt(void 0,void 0,void 0,(function(){var i;return _t(this,(function(o){switch(o.label){case 0:return e(r)?(i=n,[4,t()]):[3,2];case 1:return[2,i.apply(void 0,[o.sent()])];case 2:return[2]}}))}))},[2,n(void 0)]}))}))};function oo(e,t){return mt(this,void 0,void 0,(function(){var n,r=this;return _t(this,(function(i){switch(i.label){case 0:return n=[],cn()?[2,t]:[4,io((function(){return t.length>0&&!cn()}),(function(){return mt(r,void 0,void 0,(function(){var r,i;return _t(this,(function(o){switch(o.label){case 0:return(r=t.pop())?[4,Jt(r,e)]:[2];case 1:return i=o.sent(),i instanceof zn||n.push(r),[2]}}))}))}))];case 1:return i.sent(),n.map((function(e){return t.pushWithBackoff(e)})),[2,t]}}))}))}function so(e,t,n,r){var i=this;e||setTimeout((function(){return mt(i,void 0,void 0,(function(){var e,i;return _t(this,(function(o){switch(o.label){case 0:return e=!0,[4,oo(n,t)];case 1:return i=o.sent(),e=!1,t.todo>0&&r(e,i,n,r),[2]}}))}))}),5e3*Math.random())}function ao(e){return mt(this,void 0,void 0,(function(){var t;return _t(this,(function(n){return(t=navigator.userAgentData)?e?[2,t.getHighEntropyValues(e).catch((function(){return t.toJSON()}))]:[2,t.toJSON()]:[2,void 0]}))}))}function uo(e,t,n){var r,i,o;return mt(this,void 0,void 0,(function(){function s(r){return mt(this,void 0,void 0,(function(){var i,o;return _t(this,(function(s){return cn()?(u.push(r),so(l,u,v,so),[2,r]):(c.add(r),i=r.event.type.charAt(0),y&&r.event.context&&(r.event.context.userAgentData=y),o=Yi(r.event).json(),"track"===r.event.type&&delete o.traits,"alias"===r.event.type&&(o=function(e,t){var n,r,i,o,s=e.user();return t.previousId=null!==(i=null!==(r=null!==(n=t.previousId)&&void 0!==n?n:t.from)&&void 0!==r?r:s.id())&&void 0!==i?i:s.anonymousId(),t.userId=null!==(o=t.userId)&&void 0!==o?o:t.to,delete t.from,delete t.to,t}(e,o)),[2,g.dispatch("".concat(d,"/").concat(i),Tn(e,o,t,n)).then((function(){return r})).catch((function(){return u.pushWithBackoff(r),so(l,u,v,so),r})).finally((function(){c.delete(r)}))])}))}))}var a,u,c,l,f,h,d,p,g,y,v;return _t(this,(function(n){switch(n.label){case 0:window.addEventListener("pagehide",(function(){u.push.apply(u,Array.from(c)),c.clear()})),a=null!==(r=null==t?void 0:t.apiKey)&&void 0!==r?r:"",u=e.options.disableClientPersistence?new Ht(e.queue.queue.maxAttempts,[]):new Gn(e.queue.queue.maxAttempts,"".concat(a,":dest-Segment.io")),c=new Set,l=!1,f=null!==(i=null==t?void 0:t.apiHost)&&void 0!==i?i:Mn,h=null!==(o=null==t?void 0:t.protocol)&&void 0!==o?o:"https",d="".concat(h,"://").concat(f),p=null==t?void 0:t.deliveryStrategy,g="batching"===(null==p?void 0:p.strategy)?ro(f,p.config):(m=null==p?void 0:p.config,{dispatch:function(e,t){return hn(e,{keepalive:null==m?void 0:m.keepalive,headers:{"Content-Type":"text/plain"},method:"post",body:JSON.stringify(t)})}}),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,ao(e.options.highEntropyValuesClientHints)];case 2:return y=n.sent(),[3,4];case 3:return n.sent(),y=void 0,[3,4];case 4:return v={name:"Segment.io",type:"after",version:"0.1.0",isLoaded:function(){return!0},load:function(){return Promise.resolve()},track:s,identify:s,page:s,alias:s,group:s,screen:s},u.todo&&so(l,u,v,so),[2,v]}var m}))}))}function co(e){var t,n=e.event;!function(e){if(!Tt(e))throw new Ct("Event",Ut);if("object"!=typeof e)throw new Ct("Event",jt)}(n),function(e){if(!Pt(e.type))throw new Ct(".type",Lt)}(n),"track"===n.type&&function(e){if(!Pt(e.event))throw new Ct(".event",Lt)}(n);var r=null!==(t=n.properties)&&void 0!==t?t:n.traits;if("alias"!==n.type&&!Mt(r))throw new Ct(".properties","is not an object");return function(e){var t=".userId/anonymousId/previousId/groupId",n=function(e){var t,n,r;return null!==(r=null!==(n=null!==(t=e.userId)&&void 0!==t?t:e.anonymousId)&&void 0!==n?n:e.groupId)&&void 0!==r?r:e.previousId}(e);if(!Tt(n))throw new Ct(t,Ut);if(!Pt(n))throw new Ct(t,Lt)}(n),e}var lo={name:"Event Validation",type:"before",version:"1.0.0",isLoaded:function(){return!0},load:function(){return Promise.resolve()},track:co,identify:co,page:co,alias:co,group:co,screen:co},fo=function(e,t,n){n.getCalls(e).forEach((function(e){mo(t,e).catch(console.error)}))},ho=function(e,t){return mt(void 0,void 0,void 0,(function(){var n,r,i;return _t(this,(function(o){switch(o.label){case 0:n=0,r=t.getCalls("addSourceMiddleware"),o.label=1;case 1:return n<r.length?(i=r[n],[4,mo(e,i).catch(console.error)]):[3,4];case 2:o.sent(),o.label=3;case 3:return n++,[3,1];case 4:return[2]}}))}))},po=fo.bind(void 0,"on"),go=fo.bind(void 0,"setAnonymousId"),yo=function(e,t){t.toArray().forEach((function(t){setTimeout((function(){mo(e,t).catch(console.error)}),0)}))},vo=function(){function e(){this._value={}}return e.prototype.toArray=function(){var e;return(e=[]).concat.apply(e,Object.values(this._value))},e.prototype.getCalls=function(e){var t;return null!==(t=this._value[e])&&void 0!==t?t:[]},e.prototype.push=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.forEach((function(t){e._value[t.method]?e._value[t.method].push(t):e._value[t.method]=[t]})),this},e.prototype.clear=function(){return this._value={},this},e}();function mo(e,t){return mt(this,void 0,void 0,(function(){var n,r;return _t(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),t.called?[2,void 0]:(t.called=!0,n=e[t.method].apply(e,t.args),"object"==typeof(o=n)&&null!==o&&"then"in o&&"function"==typeof o.then?[4,n]:[3,2]);case 1:i.sent(),i.label=2;case 2:return t.resolve(n),[3,4];case 3:return r=i.sent(),t.reject(r),[3,4];case 4:return[2]}var o}))}))}var _o=function(){function e(e){var t=this;this._preInitBuffer=new vo,this.trackSubmit=this._createMethod("trackSubmit"),this.trackClick=this._createMethod("trackClick"),this.trackLink=this._createMethod("trackLink"),this.pageView=this._createMethod("pageview"),this.identify=this._createMethod("identify"),this.reset=this._createMethod("reset"),this.group=this._createMethod("group"),this.track=this._createMethod("track"),this.ready=this._createMethod("ready"),this.alias=this._createMethod("alias"),this.debug=this._createChainableMethod("debug"),this.page=this._createMethod("page"),this.once=this._createChainableMethod("once"),this.off=this._createChainableMethod("off"),this.on=this._createChainableMethod("on"),this.addSourceMiddleware=this._createMethod("addSourceMiddleware"),this.setAnonymousId=this._createMethod("setAnonymousId"),this.addDestinationMiddleware=this._createMethod("addDestinationMiddleware"),this.screen=this._createMethod("screen"),this.register=this._createMethod("register"),this.deregister=this._createMethod("deregister"),this.user=this._createMethod("user"),this.VERSION=dn,this._promise=e(this._preInitBuffer),this._promise.then((function(e){var n=e[0],r=e[1];t.instance=n,t.ctx=r})).catch((function(){}))}return e.prototype.then=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(e=this._promise).then.apply(e,t)},e.prototype.catch=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(e=this._promise).catch.apply(e,t)},e.prototype.finally=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(e=this._promise).finally.apply(e,t)},e.prototype._createMethod=function(e){var t=this;return function(){for(var n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];if(t.instance){var o=(n=t.instance)[e].apply(n,r);return Promise.resolve(o)}return new Promise((function(n,i){t._preInitBuffer.push({method:e,args:r,resolve:n,reject:i,called:!1})}))}},e.prototype._createChainableMethod=function(e){var t=this;return function(){for(var n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return t.instance?((n=t.instance)[e].apply(n,r),t):(t._preInitBuffer.push({method:e,args:r,resolve:function(){},reject:console.error,called:!1}),t)}},e}();function bo(e){var t=e[0],n=e.slice(1);return{method:t,resolve:function(){},reject:console.error,args:n,called:!1}}var wo,Eo,So=function(){var e=window.analytics;if(!Array.isArray(e))return[];var t=e.splice(0,e.length);return t.map(bo)},Oo=null!==(wo=(Eo=fn()).__SEGMENT_INSPECTOR__)&&void 0!==wo?wo:Eo.__SEGMENT_INSPECTOR__={};function xo(e,t){return mt(this,void 0,void 0,(function(){return _t(this,(function(n){switch(n.label){case 0:return t.push.apply(t,So()),[4,ho(e,t)];case 1:return n.sent(),t.push.apply(t,So()),yo(e,t),t.clear(),[2]}}))}))}function Io(e,t,n,r,i,o,s){var a,u,c;return mt(this,void 0,void 0,(function(){var l,f,h,d,p,g,y,v,m,_,b,w,E=this;return _t(this,(function(S){switch(S.label){case 0:return function(e){var t,n,r;return"test"!==tr().NODE_ENV&&(null!==(r=null===(n=null===(t=e.middlewareSettings)||void 0===t?void 0:t.routingRules)||void 0===n?void 0:n.length)&&void 0!==r?r:0)>0}(t)?[4,Promise.resolve().then((function(){return pd})).then((function(e){return e.tsubMiddleware(t.middlewareSettings.routingRules)}))]:[3,2];case 1:return f=S.sent(),[3,3];case 2:f=void 0,S.label=3;case 3:return l=f,O=t,"test"!==tr().NODE_ENV&&Object.keys(O.integrations).length>1||s.length>0?[4,Promise.resolve().then((function(){return wd})).then((function(i){return i.ajsDestinations(e,t,n.integrations,r,l,s)}))]:[3,5];case 4:return d=S.sent(),[3,6];case 5:d=[],S.label=6;case 6:return h=d,t.legacyVideoPluginsEnabled?[4,Promise.resolve().then((function(){return Ed})).then((function(e){return e.loadLegacyVideoPlugins(n)}))]:[3,8];case 7:S.sent(),S.label=8;case 8:return(null===(a=r.plan)||void 0===a?void 0:a.track)?[4,Promise.resolve().then((function(){return Sd})).then((function(e){var n;return e.schemaFilter(null===(n=r.plan)||void 0===n?void 0:n.track,t)}))]:[3,10];case 9:return g=S.sent(),[3,11];case 10:g=void 0,S.label=11;case 11:return p=g,y=sr(t,i),[4,Zi(t,n.integrations,y,i.obfuscate,l).catch((function(){return[]}))];case 12:return v=S.sent(),m=bt(bt(bt([lo,fr],o,!0),h,!0),v,!0),p&&m.push(p),!1===(null===(u=r.integrations)||void 0===u?void 0:u.All)&&!r.integrations["Segment.io"]||r.integrations&&!1===r.integrations["Segment.io"]?[3,14]:(b=(_=m).push,[4,uo(n,y["Segment.io"],t.integrations)]);case 13:b.apply(_,[S.sent()]),S.label=14;case 14:return[4,n.register.apply(n,m)];case 15:return w=S.sent(),Object.entries(null!==(c=t.enabledMiddleware)&&void 0!==c?c:{}).some((function(e){return e[1]}))?[4,Promise.resolve().then((function(){return Od})).then((function(e){var r=e.remoteMiddlewares;return mt(E,void 0,void 0,(function(){var e,o;return _t(this,(function(s){switch(s.label){case 0:return[4,r(w,t,i.obfuscate)];case 1:return e=s.sent(),o=e.map((function(e){return n.addSourceMiddleware(e)})),[2,Promise.all(o)]}}))}))}))]:[3,17];case 16:S.sent(),S.label=17;case 17:return[2,w]}var O}))}))}function Ro(e,t,n){var r,i,o,s,a,u,c;return void 0===t&&(t={}),mt(this,void 0,void 0,(function(){var l,f,h,d,p,g,y,v,m,_,b;return _t(this,(function(w){switch(w.label){case 0:return e.cdnURL&&(x=e.cdnURL,window.analytics&&(window.analytics._cdn=x),nr=x),null===(r=e.cdnSettings)||void 0===r?[3,1]:(f=r,[3,3]);case 1:return[4,(E=e.writeKey,S=e.cdnURL,O=null!=S?S:ir(),hn("".concat(O,"/v1/projects/").concat(E,"/settings")).then((function(e){return e.ok?e.json():e.text().then((function(e){throw new Error(e)}))})).catch((function(e){throw console.error(e.message),e})))];case 2:f=w.sent(),w.label=3;case 3:return l=f,t.updateCDNSettings&&(l=t.updateCDNSettings(l)),h=null===(o=null===(i=l.integrations["Segment.io"])||void 0===i?void 0:i.retryQueue)||void 0===o||o,d=vt({retryQueue:h},t),function(e){var t;null===(t=Oo.attach)||void 0===t||t.call(Oo,e)}(p=new er(e,d)),g=null!==(s=e.plugins)&&void 0!==s?s:[],y=null!==(a=e.classicIntegrations)&&void 0!==a?a:[],Dn.initRemoteMetrics(l.metrics),function(e,t){t.push.apply(t,So()),go(e,t),po(e,t)}(p,n),[4,Io(e.writeKey,l,p,d,t,g,y)];case 4:return v=w.sent(),m=null!==(u=window.location.search)&&void 0!==u?u:"",_=null!==(c=window.location.hash)&&void 0!==c?c:"",(b=m.length?m:_.replace(/(?=#).*(?=\?)/,"")).includes("ajs_")?[4,p.queryString(b).catch(console.error)]:[3,6];case 5:w.sent(),w.label=6;case 6:return p.initialized=!0,p.emit("initialize",e,t),t.initialPageview&&p.page().catch(console.error),[4,xo(p,n)];case 7:return w.sent(),[2,[p,v]]}var E,S,O,x}))}))}var ko=function(e){function t(){var t,n,r,i=this,o=(r=new Promise((function(e,r){t=e,n=r})),{resolve:t,reject:n,promise:r}),s=o.promise,a=o.resolve;return i=e.call(this,(function(e){return s.then((function(t){return Ro(t[0],t[1],e)}))}))||this,i._resolveLoadStart=function(e,t){return a([e,t])},i}return yt(t,e),t.prototype.load=function(e,t){return void 0===t&&(t={}),this._resolveLoadStart(e,t),this},t.load=function(e,n){return void 0===n&&(n={}),(new t).load(e,n)},t.standalone=function(e,n){return t.load({writeKey:e},n).then((function(e){return e[0]}))},t}(_o);let Co;const Po=new Uint8Array(16);function Ao(){if(!Co&&(Co="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Co))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Co(Po)}var No=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;const To=[];for(let e=0;e<256;++e)To.push((e+256).toString(16).slice(1));function Mo(e,t=0){return(To[e[t+0]]+To[e[t+1]]+To[e[t+2]]+To[e[t+3]]+"-"+To[e[t+4]]+To[e[t+5]]+"-"+To[e[t+6]]+To[e[t+7]]+"-"+To[e[t+8]]+To[e[t+9]]+"-"+To[e[t+10]]+To[e[t+11]]+To[e[t+12]]+To[e[t+13]]+To[e[t+14]]+To[e[t+15]]).toLowerCase()}function Lo(e){if(!function(e){return"string"==typeof e&&No.test(e)}(e))throw TypeError("Invalid UUID");let t;const n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}function jo(e,t,n){function r(e,r,i,o){var s;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));const t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=Lo(r)),16!==(null===(s=r)||void 0===s?void 0:s.length))throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let a=new Uint8Array(16+e.length);if(a.set(r),a.set(e,r.length),a=n(a),a[6]=15&a[6]|t,a[8]=63&a[8]|128,i){o=o||0;for(let e=0;e<16;++e)i[o+e]=a[e];return i}return Mo(a)}try{r.name=e}catch(e){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r}function Uo(e){return 14+(e+64>>>9<<4)+1}function Do(e,t){const n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function zo(e,t,n,r,i,o){return Do((s=Do(Do(t,e),Do(r,o)))<<(a=i)|s>>>32-a,n);var s,a}function Fo(e,t,n,r,i,o,s){return zo(t&n|~t&r,e,t,i,o,s)}function Bo(e,t,n,r,i,o,s){return zo(t&r|n&~r,e,t,i,o,s)}function Ho(e,t,n,r,i,o,s){return zo(t^n^r,e,t,i,o,s)}function qo(e,t,n,r,i,o,s){return zo(n^(t|~r),e,t,i,o,s)}jo("v3",48,(function(e){if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(let n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){const t=[],n=32*e.length,r="0123456789abcdef";for(let i=0;i<n;i+=8){const n=e[i>>5]>>>i%32&255,o=parseInt(r.charAt(n>>>4&15)+r.charAt(15&n),16);t.push(o)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[Uo(t)-1]=t;let n=1732584193,r=-271733879,i=-1732584194,o=271733878;for(let t=0;t<e.length;t+=16){const s=n,a=r,u=i,c=o;n=Fo(n,r,i,o,e[t],7,-680876936),o=Fo(o,n,r,i,e[t+1],12,-389564586),i=Fo(i,o,n,r,e[t+2],17,606105819),r=Fo(r,i,o,n,e[t+3],22,-1044525330),n=Fo(n,r,i,o,e[t+4],7,-176418897),o=Fo(o,n,r,i,e[t+5],12,1200080426),i=Fo(i,o,n,r,e[t+6],17,-1473231341),r=Fo(r,i,o,n,e[t+7],22,-45705983),n=Fo(n,r,i,o,e[t+8],7,1770035416),o=Fo(o,n,r,i,e[t+9],12,-1958414417),i=Fo(i,o,n,r,e[t+10],17,-42063),r=Fo(r,i,o,n,e[t+11],22,-1990404162),n=Fo(n,r,i,o,e[t+12],7,1804603682),o=Fo(o,n,r,i,e[t+13],12,-40341101),i=Fo(i,o,n,r,e[t+14],17,-1502002290),r=Fo(r,i,o,n,e[t+15],22,1236535329),n=Bo(n,r,i,o,e[t+1],5,-165796510),o=Bo(o,n,r,i,e[t+6],9,-1069501632),i=Bo(i,o,n,r,e[t+11],14,643717713),r=Bo(r,i,o,n,e[t],20,-373897302),n=Bo(n,r,i,o,e[t+5],5,-701558691),o=Bo(o,n,r,i,e[t+10],9,38016083),i=Bo(i,o,n,r,e[t+15],14,-660478335),r=Bo(r,i,o,n,e[t+4],20,-405537848),n=Bo(n,r,i,o,e[t+9],5,568446438),o=Bo(o,n,r,i,e[t+14],9,-1019803690),i=Bo(i,o,n,r,e[t+3],14,-187363961),r=Bo(r,i,o,n,e[t+8],20,1163531501),n=Bo(n,r,i,o,e[t+13],5,-1444681467),o=Bo(o,n,r,i,e[t+2],9,-51403784),i=Bo(i,o,n,r,e[t+7],14,1735328473),r=Bo(r,i,o,n,e[t+12],20,-1926607734),n=Ho(n,r,i,o,e[t+5],4,-378558),o=Ho(o,n,r,i,e[t+8],11,-2022574463),i=Ho(i,o,n,r,e[t+11],16,1839030562),r=Ho(r,i,o,n,e[t+14],23,-35309556),n=Ho(n,r,i,o,e[t+1],4,-1530992060),o=Ho(o,n,r,i,e[t+4],11,1272893353),i=Ho(i,o,n,r,e[t+7],16,-155497632),r=Ho(r,i,o,n,e[t+10],23,-1094730640),n=Ho(n,r,i,o,e[t+13],4,681279174),o=Ho(o,n,r,i,e[t],11,-358537222),i=Ho(i,o,n,r,e[t+3],16,-722521979),r=Ho(r,i,o,n,e[t+6],23,76029189),n=Ho(n,r,i,o,e[t+9],4,-640364487),o=Ho(o,n,r,i,e[t+12],11,-421815835),i=Ho(i,o,n,r,e[t+15],16,530742520),r=Ho(r,i,o,n,e[t+2],23,-995338651),n=qo(n,r,i,o,e[t],6,-198630844),o=qo(o,n,r,i,e[t+7],10,1126891415),i=qo(i,o,n,r,e[t+14],15,-1416354905),r=qo(r,i,o,n,e[t+5],21,-57434055),n=qo(n,r,i,o,e[t+12],6,1700485571),o=qo(o,n,r,i,e[t+3],10,-1894986606),i=qo(i,o,n,r,e[t+10],15,-1051523),r=qo(r,i,o,n,e[t+1],21,-2054922799),n=qo(n,r,i,o,e[t+8],6,1873313359),o=qo(o,n,r,i,e[t+15],10,-30611744),i=qo(i,o,n,r,e[t+6],15,-1560198380),r=qo(r,i,o,n,e[t+13],21,1309151649),n=qo(n,r,i,o,e[t+4],6,-145523070),o=qo(o,n,r,i,e[t+11],10,-1120210379),i=qo(i,o,n,r,e[t+2],15,718787259),r=qo(r,i,o,n,e[t+9],21,-343485551),n=Do(n,s),r=Do(r,a),i=Do(i,u),o=Do(o,c)}return[n,r,i,o]}(function(e){if(0===e.length)return[];const t=8*e.length,n=new Uint32Array(Uo(t));for(let r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))}));var Vo={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function $o(e,t,n){if(Vo.randomUUID&&!t&&!e)return Vo.randomUUID();const r=(e=e||{}).random||(e.rng||Ao)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return Mo(r)}function Wo(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function Ko(e,t){return e<<t|e>>>32-t}jo("v5",80,(function(e){const t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);const r=e.length/4+2,i=Math.ceil(r/16),o=new Array(i);for(let t=0;t<i;++t){const n=new Uint32Array(16);for(let r=0;r<16;++r)n[r]=e[64*t+4*r]<<24|e[64*t+4*r+1]<<16|e[64*t+4*r+2]<<8|e[64*t+4*r+3];o[t]=n}o[i-1][14]=8*(e.length-1)/Math.pow(2,32),o[i-1][14]=Math.floor(o[i-1][14]),o[i-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<i;++e){const r=new Uint32Array(80);for(let t=0;t<16;++t)r[t]=o[e][t];for(let e=16;e<80;++e)r[e]=Ko(r[e-3]^r[e-8]^r[e-14]^r[e-16],1);let i=n[0],s=n[1],a=n[2],u=n[3],c=n[4];for(let e=0;e<80;++e){const n=Math.floor(e/20),o=Ko(i,5)+Wo(n,s,a,u)+c+t[n]+r[e]>>>0;c=u,u=a,a=Ko(s,30)>>>0,s=i,i=o}n[0]=n[0]+i>>>0,n[1]=n[1]+s>>>0,n[2]=n[2]+a>>>0,n[3]=n[3]+u>>>0,n[4]=n[4]+c>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}));let Go=null;const Yo={};function Qo(){const e=m.exports.useCallback(((e={},t={})=>c(this,void 0,void 0,(function*(){if(Go)return;{const n=ko.load({writeKey:"q3dbZMDYOGQbk5GPl7eY7zWaAmNS5wk9"});yield n.identify($o()),Go={analytics:n,globalOptions:t,globalProperties:e}}}))),[]),t=m.exports.useCallback((e=>c(this,void 0,void 0,(function*(){Go&&(Yo[Object.keys(Yo).length]=e)}))),[]),n=m.exports.useCallback((()=>c(this,void 0,void 0,(function*(){0!=Object.keys(Yo).length&&Go&&(yield Go.analytics.track("userFlow",Yo))}))),[]);return{init:e,track:m.exports.useCallback(((e,t={})=>c(this,void 0,void 0,(function*(){if(!Go)return;const n=Object.assign(Object.assign({},Go.globalProperties),t);yield Go.analytics.track(e,n,Go.globalOptions)}))),[]),page:m.exports.useCallback(((e,t={})=>c(this,void 0,void 0,(function*(){if(!Go)return;const n=Object.assign(Object.assign({},Go.globalProperties),t);yield Go.analytics.page(e,n,Go.globalOptions)}))),[]),addStepToFlow:t,sendUserFlow:n}}let Jo=e=>{};const Xo=({onClose:e,children:t})=>{const{sendUserFlow:n,addStepToFlow:r}=Qo(),[i,o]=m.exports.useState(!0);Jo=o;const s=()=>{Jo(!1),r("Close"),n(),e&&e()},a=e=>{var t;"ModalWrapper"===(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.id)&&s()};return i?y.exports.jsxs(y.exports.Fragment,{children:[y.exports.jsx(tt,{}),y.exports.jsx(ot,Object.assign({id:"ModalWrapper",onClick:a},{children:y.exports.jsxs(st,{children:[y.exports.jsxs(ct,{children:[y.exports.jsx("img",{src:"data:image/svg+xml,%3csvg width='72' height='24' viewBox='0 0 72 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M61.3616 22.4887V23.9996H71.7318V17.1853H70.2208V22.4887H61.3616ZM61.3616 0V1.51096H70.2208V6.81473H71.7318V0H61.3616ZM56.0137 11.689V8.17796H58.3842C59.5398 8.17796 59.9546 8.56305 59.9546 9.61506V10.2372C59.9546 11.3186 59.5545 11.689 58.3842 11.689H56.0137ZM59.7764 12.311C60.8578 12.0296 61.6133 11.022 61.6133 9.82231C61.6133 9.06683 61.3172 8.38521 60.7542 7.83698C60.0432 7.15536 59.0948 6.81473 57.8653 6.81473H54.5322V17.1849H56.0137V13.0518H58.2361C59.3767 13.0518 59.836 13.5258 59.836 14.7112V17.1853H61.3469V14.9482C61.3469 13.3186 60.9618 12.6965 59.7764 12.5187V12.311ZM47.303 12.6517H51.866V11.2888H47.303V8.17761H52.3102V6.81473H45.7916V17.1849H52.5325V15.822H47.303V12.6517ZM42.3398 13.1999V13.9109C42.3398 15.4072 41.7916 15.8963 40.414 15.8963H40.0881C38.7102 15.8963 38.0436 15.4516 38.0436 13.3925V10.6072C38.0436 8.53329 38.7399 8.10338 40.1175 8.10338H40.4137C41.7618 8.10338 42.1914 8.60716 42.2061 9.99979H43.8357C43.6876 7.9553 42.3248 6.66665 40.2803 6.66665C39.2878 6.66665 38.4581 6.97787 37.836 7.57021C36.9027 8.44437 36.3842 9.92593 36.3842 11.9998C36.3842 13.9999 36.8288 15.4814 37.7471 16.3997C38.3692 17.0071 39.2286 17.333 40.073 17.333C40.9619 17.333 41.7769 16.9773 42.1914 16.2071H42.3986V17.1849H43.7615V11.837H39.7467V13.1999H42.3398ZM29.2737 8.17761H30.8886C32.4146 8.17761 33.2443 8.5627 33.2443 10.6369V13.3627C33.2443 15.4366 32.4146 15.822 30.8886 15.822H29.2737V8.17761ZM31.0216 17.1853C33.8513 17.1853 34.903 15.0372 34.903 12.0002C34.903 8.91874 33.7771 6.81509 30.9919 6.81509H27.7917V17.1853H31.0216ZM20.6367 12.6517H25.1997V11.2888H20.6367V8.17761H25.644V6.81473H19.1254V17.1849H25.8663V15.822H20.6367V12.6517ZM11.8962 6.81473H10.3852V17.1849H17.2V15.822H11.8962V6.81473ZM0 17.1853V24H10.3702V22.4887H1.51096V17.1853H0ZM0 0V6.81473H1.51096V1.51096H10.3702V0H0Z' fill='white'/%3e%3c/svg%3e"}),y.exports.jsx(at,Object.assign({onClick:s},{children:y.exports.jsx("img",{src:"data:image/svg+xml,%3csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M22 2L2 22' stroke='white' stroke-width='3'/%3e%3cpath d='M2 2L22 22' stroke='white' stroke-width='3'/%3e%3c/svg%3e"})}))]}),y.exports.jsx(y.exports.Fragment,{children:t})]})}))]}):null};var Zo,es,ts,ns,rs={exports:{}},is={},os={exports:{}},ss={};function as(){return es||(es=1,function(e){e.exports=(Zo||(Zo=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,o=e[r];if(!(0<i(o,t)))break e;e[r]=t,e[n]=o,n=r}}function n(e){return 0===e.length?null:e[0]}function r(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,o=e.length,s=o>>>1;r<s;){var a=2*(r+1)-1,u=e[a],c=a+1,l=e[c];if(0>i(u,n))c<o&&0>i(l,u)?(e[r]=l,e[c]=n,r=c):(e[r]=u,e[a]=n,r=a);else{if(!(c<o&&0>i(l,n)))break e;e[r]=l,e[c]=n,r=c}}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var s=Date,a=s.now();e.unstable_now=function(){return s.now()-a}}var u=[],c=[],l=1,f=null,h=3,d=!1,p=!1,g=!1,y="function"==typeof setTimeout?setTimeout:null,v="function"==typeof clearTimeout?clearTimeout:null,m="undefined"!=typeof setImmediate?setImmediate:null;function _(e){for(var i=n(c);null!==i;){if(null===i.callback)r(c);else{if(!(i.startTime<=e))break;r(c),i.sortIndex=i.expirationTime,t(u,i)}i=n(c)}}function b(e){if(g=!1,_(e),!p)if(null!==n(u))p=!0,N(w);else{var t=n(c);null!==t&&T(b,t.startTime-e)}}function w(t,i){p=!1,g&&(g=!1,v(x),x=-1),d=!0;var o=h;try{for(_(i),f=n(u);null!==f&&(!(f.expirationTime>i)||t&&!k());){var s=f.callback;if("function"==typeof s){f.callback=null,h=f.priorityLevel;var a=s(f.expirationTime<=i);i=e.unstable_now(),"function"==typeof a?f.callback=a:f===n(u)&&r(u),_(i)}else r(u);f=n(u)}if(null!==f)var l=!0;else{var y=n(c);null!==y&&T(b,y.startTime-i),l=!1}return l}finally{f=null,h=o,d=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var E,S=!1,O=null,x=-1,I=5,R=-1;function k(){return!(e.unstable_now()-R<I)}function C(){if(null!==O){var t=e.unstable_now();R=t;var n=!0;try{n=O(!0,t)}finally{n?E():(S=!1,O=null)}}else S=!1}if("function"==typeof m)E=function(){m(C)};else if("undefined"!=typeof MessageChannel){var P=new MessageChannel,A=P.port2;P.port1.onmessage=C,E=function(){A.postMessage(null)}}else E=function(){y(C,0)};function N(e){O=e,S||(S=!0,E())}function T(t,n){x=y((function(){t(e.unstable_now())}),n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){p||d||(p=!0,N(w))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(e){switch(h){case 1:case 2:case 3:var t=3;break;default:t=h}var n=h;h=t;try{return e()}finally{h=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=h;h=e;try{return t()}finally{h=n}},e.unstable_scheduleCallback=function(r,i,o){var s=e.unstable_now();switch(o="object"==typeof o&&null!==o&&"number"==typeof(o=o.delay)&&0<o?s+o:s,r){case 1:var a=-1;break;case 2:a=250;break;case 5:a=1073741823;break;case 4:a=1e4;break;default:a=5e3}return r={id:l++,callback:i,priorityLevel:r,startTime:o,expirationTime:a=o+a,sortIndex:-1},o>s?(r.sortIndex=o,t(c,r),null===n(u)&&r===n(c)&&(g?(v(x),x=-1):g=!0,T(b,o-s))):(r.sortIndex=a,t(u,r),p||d||(p=!0,N(w))),r},e.unstable_shouldYield=k,e.unstable_wrapCallback=function(e){var t=h;return function(){var n=h;h=t;try{return e.apply(this,arguments)}finally{h=n}}}}(ss)),ss)}(os)),os.exports}
|
174
174
|
/**
|
175
175
|
* @license React
|
176
176
|
* react-dom.production.min.js
|
@@ -318,7 +318,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
318
318
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
319
319
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
320
320
|
PERFORMANCE OF THIS SOFTWARE.
|
321
|
-
***************************************************************************** */function ul(e,t){function n(){this.constructor=e}al(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var cl=function(){return cl=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},cl.apply(this,arguments)};function ll(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function fl(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}function hl(e,t){return function(n,r){t(n,r,e)}}function dl(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function pl(e,t,n,r){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?n(e.value):i(e.value).then(s,a)}u((r=r.apply(e,t||[])).next())}))}function gl(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(e){return function(t){return u([e,t])}}function u(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}function yl(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}function vl(e,t){for(var n in e)"default"!==n&&!t.hasOwnProperty(n)&&(t[n]=e[n])}function ml(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function _l(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function bl(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(_l(arguments[t]));return e}function wl(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}function El(e){return this instanceof El?(this.v=e,this):new El(e)}function Sl(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(e,t||[]),o=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(e){i[e]&&(r[e]=function(t){return new Promise((function(n,r){o.push([e,t,n,r])>1||a(e,t)}))})}function a(e,t){try{u(i[e](t))}catch(e){f(o[0][3],e)}}function u(e){e.value instanceof El?Promise.resolve(e.value.v).then(c,l):f(o[0][2],e)}function c(e){a("next",e)}function l(e){a("throw",e)}function f(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}}function Ol(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:El(e[r](t)),done:"return"===r}:i?i(t):t}:i}}function xl(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof ml?ml(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){i(r,o,(t=e[n](t)).done,t.value)}))}}function i(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}}function Il(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Rl(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function kl(e){return e&&e.__esModule?e:{default:e}}function Cl(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function Pl(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}var Al,Nl=r(Object.freeze({__proto__:null,__extends:ul,get __assign(){return cl},__rest:ll,__decorate:fl,__param:hl,__metadata:dl,__awaiter:pl,__generator:gl,__createBinding:yl,__exportStar:vl,__values:ml,__read:_l,__spread:bl,__spreadArrays:wl,__await:El,__asyncGenerator:Sl,__asyncDelegator:Ol,__asyncValues:xl,__makeTemplateObject:Il,__importStar:Rl,__importDefault:kl,__classPrivateFieldGet:Cl,__classPrivateFieldSet:Pl})),Tl={};function Ml(){if(Al)return Tl;function e(){return t?.crypto||t?.msCrypto||{}}function n(){const t=e();return t.subtle||t.webkitSubtle}function r(){return!!e()&&!!n()}return Al=1,Object.defineProperty(Tl,"__esModule",{value:!0}),Tl.isBrowserCryptoAvailable=Tl.getSubtleCrypto=Tl.getBrowerCrypto=void 0,Tl.getBrowerCrypto=e,Tl.getSubtleCrypto=n,Tl.isBrowserCryptoAvailable=r,Tl}var Ll,jl={};function Ul(){if(Ll)return jl;function e(){return typeof document>"u"&&typeof navigator<"u"&&"ReactNative"===navigator.product}function t(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function n(){return!e()&&!t()}return Ll=1,Object.defineProperty(jl,"__esModule",{value:!0}),jl.isBrowser=jl.isNode=jl.isReactNative=void 0,jl.isReactNative=e,jl.isNode=t,jl.isBrowser=n,jl}function Dl(e=3){return Date.now()*Math.pow(10,e)+Math.floor(Math.random()*Math.pow(10,e))}function zl(e=6){return BigInt(Dl(e))}function Fl(e,t,n){return{id:n||Dl(),jsonrpc:"2.0",method:e,params:t}}function Bl(e,t){return{id:e,jsonrpc:"2.0",result:t}}function Hl(e,t,n){return{id:e,jsonrpc:"2.0",error:ql(t,n)}}function ql(e,t){return typeof e>"u"?rl(Jc):("string"==typeof e&&(e=Object.assign(Object.assign({},rl(Xc)),{message:e})),typeof t<"u"&&(e.data=t),nl(e.code)&&(e=il(e.code)),e)}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Nl;t.__exportStar(Ml(),e),t.__exportStar(Ul(),e)}(sl);class Vl{}class $l extends Vl{constructor(){super()}}class Wl extends $l{constructor(e){super()}}const Kl="^https?:",Gl="^wss?:";function Yl(e){const t=e.match(new RegExp(/^\w+:/,"gi"));if(t&&t.length)return t[0]}function Ql(e,t){const n=Yl(e);return!(typeof n>"u")&&new RegExp(t).test(n)}function Jl(e){return Ql(e,Kl)}function Xl(e){return Ql(e,Gl)}function Zl(e){return new RegExp("wss?://localhost(:d{2,5})?").test(e)}function ef(e){return"object"==typeof e&&"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function tf(e){return ef(e)&&"method"in e}function nf(e){return ef(e)&&(rf(e)||of(e))}function rf(e){return"result"in e}function of(e){return"error"in e}class sf extends Wl{constructor(e){super(e),this.events=new o.exports.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(Fl(e.method,e.params||[],e.id||zl().toString()),t)}async requestStrict(e,t){return new Promise((async(n,r)=>{if(!this.connection.connected)try{await this.open()}catch(e){r(e)}this.events.on(`${e.id}`,(e=>{of(e)?r(e.error):n(e.result)}));try{await this.connection.send(e,t)}catch(e){r(e)}}))}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),nf(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&3e3===e.code&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),"string"==typeof e&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",(e=>this.onPayload(e))),this.connection.on("close",(e=>this.onClose(e))),this.connection.on("error",(e=>this.events.emit("error",e))),this.connection.on("register_error",(e=>this.onClose())),this.hasRegisteredEventListeners=!0)}}const af=()=>typeof WebSocket<"u"||typeof l<"u"&&typeof l.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",uf=e=>e.split("?")[0],cf=10,lf=typeof WebSocket<"u"?WebSocket:typeof l<"u"&&typeof l.WebSocket<"u"?l.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:kc?Rc:(kc=1,Rc=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")});class ff{constructor(e){if(this.url=e,this.events=new o.exports.EventEmitter,this.registering=!1,!Xl(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise(((e,t)=>{typeof this.socket>"u"?t(new Error("Connection already closed")):(this.socket.onclose=t=>{this.onClose(t),e()},this.socket.close())}))}async send(e,t){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(sr(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!Xl(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise(((e,t)=>{this.events.once("register_error",(e=>{this.resetMaxListeners(),t(e)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return t(new Error("WebSocket connection is missing or invalid"));e(this.socket)}))}))}return this.url=e,this.registering=!0,new Promise(((t,n)=>{const r=sl.isReactNative()?void 0:{rejectUnauthorized:!Zl(e)},i=new lf(e,[],r);af()?i.onerror=e=>{const t=e;n(this.emitError(t.error))}:i.on("error",(e=>{n(this.emitError(e))})),i.onopen=()=>{this.onOpen(i),t(i)}}))}onOpen(e){e.onmessage=e=>this.onPayload(e),e.onclose=e=>this.onClose(e),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const t="string"==typeof e.data?or(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const n=this.parseError(t),r=Hl(e,n.message||n.toString());this.events.emit("payload",r)}parseError(e,t=this.url){return ol(e,uf(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>cf&&this.events.setMaxListeners(cf)}emitError(e){const t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${uf(this.url)}`));return this.events.emit("register_error",t),t}}var hf={exports:{}};!function(e,n){var r=200,i="__lodash_hash_undefined__",o=1,s=2,a=9007199254740991,u="[object Arguments]",c="[object Array]",l="[object AsyncFunction]",f="[object Boolean]",h="[object Date]",d="[object Error]",p="[object Function]",g="[object GeneratorFunction]",y="[object Map]",v="[object Number]",m="[object Null]",_="[object Object]",b="[object Promise]",w="[object Proxy]",E="[object RegExp]",S="[object Set]",O="[object String]",x="[object Symbol]",I="[object Undefined]",R="[object WeakMap]",k="[object ArrayBuffer]",C="[object DataView]",P="[object Float64Array]",A="[object Int8Array]",N="[object Int16Array]",T="[object Int32Array]",M="[object Uint8Array]",L="[object Uint8ClampedArray]",j="[object Uint16Array]",U="[object Uint32Array]",D=/[\\^$.*+?()[\]{}|]/g,z=/^\[object .+?Constructor\]$/,F=/^(?:0|[1-9]\d*)$/,B={};B["[object Float32Array]"]=B[P]=B[A]=B[N]=B[T]=B[M]=B[L]=B[j]=B[U]=!0,B[u]=B[c]=B[k]=B[f]=B[C]=B[h]=B[d]=B[p]=B[y]=B[v]=B[_]=B[E]=B[S]=B[O]=B[R]=!1;var H="object"==typeof t&&t&&t.Object===Object&&t,q="object"==typeof self&&self&&self.Object===Object&&self,V=H||q||Function("return this")(),$=n&&!n.nodeType&&n,W=$&&e&&!e.nodeType&&e,K=W&&W.exports===$,G=K&&H.process,Y=function(){try{return G&&G.binding&&G.binding("util")}catch{}}(),Q=Y&&Y.isTypedArray;function J(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var s=e[n];t(s,n,e)&&(o[i++]=s)}return o}function X(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function Z(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function ee(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function te(e){return function(t){return e(t)}}function ne(e,t){return e.has(t)}function re(e,t){return e?.[t]}function ie(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function oe(e,t){return function(n){return e(t(n))}}function se(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var ae=Array.prototype,ue=Function.prototype,ce=Object.prototype,le=V["__core-js_shared__"],fe=ue.toString,he=ce.hasOwnProperty,de=function(){var e=/[^.]+$/.exec(le&&le.keys&&le.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),pe=ce.toString,ge=RegExp("^"+fe.call(he).replace(D,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ye=K?V.Buffer:void 0,ve=V.Symbol,me=V.Uint8Array,_e=ce.propertyIsEnumerable,be=ae.splice,we=ve?ve.toStringTag:void 0,Ee=Object.getOwnPropertySymbols,Se=ye?ye.isBuffer:void 0,Oe=oe(Object.keys,Object),xe=It(V,"DataView"),Ie=It(V,"Map"),Re=It(V,"Promise"),ke=It(V,"Set"),Ce=It(V,"WeakMap"),Pe=It(Object,"create"),Ae=Lt(xe),Ne=Lt(Ie),Te=Lt(Re),Me=Lt(ke),Le=Lt(Ce),je=ve?ve.prototype:void 0,Ue=je?je.valueOf:void 0;function De(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ze(){this.__data__=Pe?Pe(null):{},this.size=0}function Fe(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function Be(e){var t=this.__data__;if(Pe){var n=t[e];return n===i?void 0:n}return he.call(t,e)?t[e]:void 0}function He(e){var t=this.__data__;return Pe?void 0!==t[e]:he.call(t,e)}function qe(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Pe&&void 0===t?i:t,this}function Ve(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function $e(){this.__data__=[],this.size=0}function We(e){var t=this.__data__,n=ht(t,e);return!(n<0||(n==t.length-1?t.pop():be.call(t,n,1),--this.size,0))}function Ke(e){var t=this.__data__,n=ht(t,e);return n<0?void 0:t[n][1]}function Ge(e){return ht(this.__data__,e)>-1}function Ye(e,t){var n=this.__data__,r=ht(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Qe(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Je(){this.size=0,this.__data__={hash:new De,map:new(Ie||Ve),string:new De}}function Xe(e){var t=xt(this,e).delete(e);return this.size-=t?1:0,t}function Ze(e){return xt(this,e).get(e)}function et(e){return xt(this,e).has(e)}function tt(e,t){var n=xt(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function nt(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Qe;++t<n;)this.add(e[t])}function rt(e){return this.__data__.set(e,i),this}function it(e){return this.__data__.has(e)}function ot(e){var t=this.__data__=new Ve(e);this.size=t.size}function st(){this.__data__=new Ve,this.size=0}function at(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function ut(e){return this.__data__.get(e)}function ct(e){return this.__data__.has(e)}function lt(e,t){var n=this.__data__;if(n instanceof Ve){var i=n.__data__;if(!Ie||i.length<r-1)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new Qe(i)}return n.set(e,t),this.size=n.size,this}function ft(e,t){var n=Dt(e),r=!n&&Ut(e),i=!n&&!r&&Ft(e),o=!n&&!r&&!i&&Wt(e),s=n||r||i||o,a=s?ee(e.length,String):[],u=a.length;for(var c in e)(t||he.call(e,c))&&(!s||!("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Pt(c,u)))&&a.push(c);return a}function ht(e,t){for(var n=e.length;n--;)if(jt(e[n][0],t))return n;return-1}function dt(e,t,n){var r=t(e);return Dt(e)?r:X(r,n(e))}function pt(e){return null==e?void 0===e?I:m:we&&we in Object(e)?Rt(e):Mt(e)}function gt(e){return $t(e)&&pt(e)==u}function yt(e,t,n,r,i){return e===t||(null==e||null==t||!$t(e)&&!$t(t)?e!=e&&t!=t:vt(e,t,n,r,yt,i))}function vt(e,t,n,r,i,s){var a=Dt(e),l=Dt(t),f=a?c:Ct(e),h=l?c:Ct(t),d=(f=f==u?_:f)==_,p=(h=h==u?_:h)==_,g=f==h;if(g&&Ft(e)){if(!Ft(t))return!1;a=!0,d=!1}if(g&&!d)return s||(s=new ot),a||Wt(e)?wt(e,t,n,r,i,s):Et(e,t,f,n,r,i,s);if(!(n&o)){var y=d&&he.call(e,"__wrapped__"),v=p&&he.call(t,"__wrapped__");if(y||v){var m=y?e.value():e,b=v?t.value():t;return s||(s=new ot),i(m,b,n,r,s)}}return!!g&&(s||(s=new ot),St(e,t,n,r,i,s))}function mt(e){return!(!Vt(e)||Nt(e))&&(Ht(e)?ge:z).test(Lt(e))}function _t(e){return $t(e)&&qt(e.length)&&!!B[pt(e)]}function bt(e){if(!Tt(e))return Oe(e);var t=[];for(var n in Object(e))he.call(e,n)&&"constructor"!=n&&t.push(n);return t}function wt(e,t,n,r,i,a){var u=n&o,c=e.length,l=t.length;if(c!=l&&!(u&&l>c))return!1;var f=a.get(e);if(f&&a.get(t))return f==t;var h=-1,d=!0,p=n&s?new nt:void 0;for(a.set(e,t),a.set(t,e);++h<c;){var g=e[h],y=t[h];if(r)var v=u?r(y,g,h,t,e,a):r(g,y,h,e,t,a);if(void 0!==v){if(v)continue;d=!1;break}if(p){if(!Z(t,(function(e,t){if(!ne(p,t)&&(g===e||i(g,e,n,r,a)))return p.push(t)}))){d=!1;break}}else if(g!==y&&!i(g,y,n,r,a)){d=!1;break}}return a.delete(e),a.delete(t),d}function Et(e,t,n,r,i,a,u){switch(n){case C:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case k:return!(e.byteLength!=t.byteLength||!a(new me(e),new me(t)));case f:case h:case v:return jt(+e,+t);case d:return e.name==t.name&&e.message==t.message;case E:case O:return e==t+"";case y:var c=ie;case S:var l=r&o;if(c||(c=se),e.size!=t.size&&!l)return!1;var p=u.get(e);if(p)return p==t;r|=s,u.set(e,t);var g=wt(c(e),c(t),r,i,a,u);return u.delete(e),g;case x:if(Ue)return Ue.call(e)==Ue.call(t)}return!1}function St(e,t,n,r,i,s){var a=n&o,u=Ot(e),c=u.length;if(c!=Ot(t).length&&!a)return!1;for(var l=c;l--;){var f=u[l];if(!(a?f in t:he.call(t,f)))return!1}var h=s.get(e);if(h&&s.get(t))return h==t;var d=!0;s.set(e,t),s.set(t,e);for(var p=a;++l<c;){var g=e[f=u[l]],y=t[f];if(r)var v=a?r(y,g,f,t,e,s):r(g,y,f,e,t,s);if(!(void 0===v?g===y||i(g,y,n,r,s):v)){d=!1;break}p||(p="constructor"==f)}if(d&&!p){var m=e.constructor,_=t.constructor;m!=_&&"constructor"in e&&"constructor"in t&&!("function"==typeof m&&m instanceof m&&"function"==typeof _&&_ instanceof _)&&(d=!1)}return s.delete(e),s.delete(t),d}function Ot(e){return dt(e,Kt,kt)}function xt(e,t){var n=e.__data__;return At(t)?n["string"==typeof t?"string":"hash"]:n.map}function It(e,t){var n=re(e,t);return mt(n)?n:void 0}function Rt(e){var t=he.call(e,we),n=e[we];try{e[we]=void 0;var r=!0}catch{}var i=pe.call(e);return r&&(t?e[we]=n:delete e[we]),i}De.prototype.clear=ze,De.prototype.delete=Fe,De.prototype.get=Be,De.prototype.has=He,De.prototype.set=qe,Ve.prototype.clear=$e,Ve.prototype.delete=We,Ve.prototype.get=Ke,Ve.prototype.has=Ge,Ve.prototype.set=Ye,Qe.prototype.clear=Je,Qe.prototype.delete=Xe,Qe.prototype.get=Ze,Qe.prototype.has=et,Qe.prototype.set=tt,nt.prototype.add=nt.prototype.push=rt,nt.prototype.has=it,ot.prototype.clear=st,ot.prototype.delete=at,ot.prototype.get=ut,ot.prototype.has=ct,ot.prototype.set=lt;var kt=Ee?function(e){return null==e?[]:(e=Object(e),J(Ee(e),(function(t){return _e.call(e,t)})))}:Gt,Ct=pt;function Pt(e,t){return!!(t=t??a)&&("number"==typeof e||F.test(e))&&e>-1&&e%1==0&&e<t}function At(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}function Nt(e){return!!de&&de in e}function Tt(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||ce)}function Mt(e){return pe.call(e)}function Lt(e){if(null!=e){try{return fe.call(e)}catch{}try{return e+""}catch{}}return""}function jt(e,t){return e===t||e!=e&&t!=t}(xe&&Ct(new xe(new ArrayBuffer(1)))!=C||Ie&&Ct(new Ie)!=y||Re&&Ct(Re.resolve())!=b||ke&&Ct(new ke)!=S||Ce&&Ct(new Ce)!=R)&&(Ct=function(e){var t=pt(e),n=t==_?e.constructor:void 0,r=n?Lt(n):"";if(r)switch(r){case Ae:return C;case Ne:return y;case Te:return b;case Me:return S;case Le:return R}return t});var Ut=gt(function(){return arguments}())?gt:function(e){return $t(e)&&he.call(e,"callee")&&!_e.call(e,"callee")},Dt=Array.isArray;function zt(e){return null!=e&&qt(e.length)&&!Ht(e)}var Ft=Se||Yt;function Bt(e,t){return yt(e,t)}function Ht(e){if(!Vt(e))return!1;var t=pt(e);return t==p||t==g||t==l||t==w}function qt(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=a}function Vt(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function $t(e){return null!=e&&"object"==typeof e}var Wt=Q?te(Q):_t;function Kt(e){return zt(e)?ft(e):bt(e)}function Gt(){return[]}function Yt(){return!1}e.exports=Bt}(hf,hf.exports);var df=hf.exports,pf=Object.defineProperty,gf=Object.getOwnPropertySymbols,yf=Object.prototype.hasOwnProperty,vf=Object.prototype.propertyIsEnumerable,mf=(e,t,n)=>t in e?pf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_f=(e,t)=>{for(var n in t||(t={}))yf.call(t,n)&&mf(e,n,t[n]);if(gf)for(var n of gf(t))vf.call(t,n)&&mf(e,n,t[n]);return e};function bf(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==n[s])throw new TypeError(o+" is ambiguous");n[s]=i}var a=e.length,u=e.charAt(0),c=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var n=0,r=0,i=0,o=t.length;i!==o&&0===t[i];)i++,n++;for(var s=(o-i)*l+1>>>0,c=new Uint8Array(s);i!==o;){for(var f=t[i],h=0,d=s-1;(0!==f||h<r)&&-1!==d;d--,h++)f+=256*c[d]>>>0,c[d]=f%a>>>0,f=f/a>>>0;if(0!==f)throw new Error("Non-zero carry");r=h,i++}for(var p=s-r;p!==s&&0===c[p];)p++;for(var g=u.repeat(n);p<s;++p)g+=e.charAt(c[p]);return g}function h(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var r=0,i=0;e[t]===u;)r++,t++;for(var o=(e.length-t)*c+1>>>0,s=new Uint8Array(o);e[t];){var l=n[e.charCodeAt(t)];if(255===l)return;for(var f=0,h=o-1;(0!==l||f<i)&&-1!==h;h--,f++)l+=a*s[h]>>>0,s[h]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=f,t++}if(" "!==e[t]){for(var d=o-i;d!==o&&0===s[d];)d++;for(var p=new Uint8Array(r+(o-d)),g=r;d!==o;)p[g++]=s[d++];return p}}}function d(e){var n=h(e);if(n)return n;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:h,decode:d}}var wf=bf;const Ef=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},Sf=e=>(new TextEncoder).encode(e),Of=e=>(new TextDecoder).decode(e);class xf{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class If{constructor(e,t,n){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return kf(this,e)}}class Rf{constructor(e){this.decoders=e}or(e){return kf(this,e)}decode(e){const t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const kf=(e,t)=>new Rf(_f(_f({},e.decoders||{[e.prefix]:e}),t.decoders||{[t.prefix]:t}));class Cf{constructor(e,t,n,r){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=r,this.encoder=new xf(e,t,n),this.decoder=new If(e,t,r)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Pf=({name:e,prefix:t,encode:n,decode:r})=>new Cf(e,t,n,r),Af=({prefix:e,name:t,alphabet:n})=>{const{encode:r,decode:i}=wf(n,t);return Pf({prefix:e,name:t,encode:r,decode:e=>Ef(i(e))})},Nf=(e,t,n,r)=>{const i={};for(let e=0;e<t.length;++e)i[t[e]]=e;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*n/8|0);let a=0,u=0,c=0;for(let t=0;t<o;++t){const o=i[e[t]];if(void 0===o)throw new SyntaxError(`Non-${r} character`);u=u<<n|o,a+=n,a>=8&&(a-=8,s[c++]=255&u>>a)}if(a>=n||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return s},Tf=(e,t,n)=>{const r="="===t[t.length-1],i=(1<<n)-1;let o="",s=0,a=0;for(let r=0;r<e.length;++r)for(a=a<<8|e[r],s+=8;s>n;)s-=n,o+=t[i&a>>s];if(s&&(o+=t[i&a<<n-s]),r)for(;o.length*n&7;)o+="=";return o},Mf=({name:e,prefix:t,bitsPerChar:n,alphabet:r})=>Pf({prefix:t,name:e,encode:e=>Tf(e,r,n),decode:t=>Nf(t,r,n,e)}),Lf=Pf({prefix:"\0",name:"identity",encode:e=>Of(e),decode:e=>Sf(e)});var jf=Object.freeze({__proto__:null,identity:Lf});const Uf=Mf({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Df=Object.freeze({__proto__:null,base2:Uf});const zf=Mf({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ff=Object.freeze({__proto__:null,base8:zf});const Bf=Af({prefix:"9",name:"base10",alphabet:"0123456789"});var Hf=Object.freeze({__proto__:null,base10:Bf});const qf=Mf({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Vf=Mf({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var $f=Object.freeze({__proto__:null,base16:qf,base16upper:Vf});const Wf=Mf({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Kf=Mf({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Gf=Mf({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Yf=Mf({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Qf=Mf({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Jf=Mf({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Xf=Mf({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zf=Mf({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),eh=Mf({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var th=Object.freeze({__proto__:null,base32:Wf,base32upper:Kf,base32pad:Gf,base32padupper:Yf,base32hex:Qf,base32hexupper:Jf,base32hexpad:Xf,base32hexpadupper:Zf,base32z:eh});const nh=Af({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),rh=Af({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ih=Object.freeze({__proto__:null,base36:nh,base36upper:rh});const oh=Af({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),sh=Af({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ah=Object.freeze({__proto__:null,base58btc:oh,base58flickr:sh});const uh=Mf({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ch=Mf({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),lh=Mf({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),fh=Mf({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var hh=Object.freeze({__proto__:null,base64:uh,base64pad:ch,base64url:lh,base64urlpad:fh});const dh=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),ph=dh.reduce(((e,t,n)=>(e[n]=t,e)),[]),gh=dh.reduce(((e,t,n)=>(e[t.codePointAt(0)]=n,e)),[]);function yh(e){return e.reduce(((e,t)=>e+=ph[t]),"")}function vh(e){const t=[];for(const n of e){const e=gh[n.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${n}`);t.push(e)}return new Uint8Array(t)}const mh=Pf({prefix:"🚀",name:"base256emoji",encode:yh,decode:vh});var _h=Object.freeze({__proto__:null,base256emoji:mh}),bh=Oh,wh=128,Eh=-128,Sh=Math.pow(2,31);function Oh(e,t,n){t=t||[];for(var r=n=n||0;e>=Sh;)t[n++]=255&e|wh,e/=128;for(;e&Eh;)t[n++]=255&e|wh,e>>>=7;return t[n]=0|e,Oh.bytes=n-r+1,t}var xh=kh,Ih=128,Rh=127;function kh(e,t){var n,r=0,i=0,o=t=t||0,s=e.length;do{if(o>=s)throw kh.bytes=0,new RangeError("Could not decode varint");n=e[o++],r+=i<28?(n&Rh)<<i:(n&Rh)*Math.pow(2,i),i+=7}while(n>=Ih);return kh.bytes=o-t,r}var Ch=Math.pow(2,7),Ph=Math.pow(2,14),Ah=Math.pow(2,21),Nh=Math.pow(2,28),Th=Math.pow(2,35),Mh=Math.pow(2,42),Lh=Math.pow(2,49),jh=Math.pow(2,56),Uh=Math.pow(2,63),Dh={encode:bh,decode:xh,encodingLength:function(e){return e<Ch?1:e<Ph?2:e<Ah?3:e<Nh?4:e<Th?5:e<Mh?6:e<Lh?7:e<jh?8:e<Uh?9:10}};const zh=(e,t,n=0)=>(Dh.encode(e,t,n),t),Fh=e=>Dh.encodingLength(e),Bh=(e,t)=>{const n=t.byteLength,r=Fh(e),i=r+Fh(n),o=new Uint8Array(i+n);return zh(e,o,0),zh(n,o,r),o.set(t,i),new Hh(e,n,t,o)};class Hh{constructor(e,t,n,r){this.code=e,this.size=t,this.digest=n,this.bytes=r}}const qh=({name:e,code:t,encode:n})=>new Vh(e,t,n);class Vh{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Bh(this.code,t):t.then((e=>Bh(this.code,e)))}throw Error("Unknown type, must be binary type")}}const $h=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Wh=qh({name:"sha2-256",code:18,encode:$h("SHA-256")}),Kh=qh({name:"sha2-512",code:19,encode:$h("SHA-512")});var Gh=Object.freeze({__proto__:null,sha256:Wh,sha512:Kh});const Yh=0,Qh="identity",Jh=Ef;var Xh=Object.freeze({__proto__:null,identity:{code:Yh,name:Qh,encode:Jh,digest:e=>Bh(Yh,Jh(e))}});new TextEncoder,new TextDecoder;const Zh=_f(_f(_f(_f(_f(_f(_f(_f(_f(_f({},jf),Df),Ff),Hf),$f),th),ih),ah),hh),_h);function ed(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function td(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?ed(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function nd(e,t,n,r){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:n},decoder:{decode:r}}}_f(_f({},Gh),Xh);const rd=nd("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),id=nd("ascii","a",(e=>{let t="a";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}),(e=>{const t=td((e=e.substring(1)).length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t})),od=_f({utf8:rd,"utf-8":rd,hex:Zh.base16,latin1:id,ascii:id,binary:id},Zh);function sd(e,t="utf8"){const n=od[t];if(!n)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?n.decoder.decode(`${n.prefix}${e}`):ed(globalThis.Buffer.from(e,"utf-8"))}const ad="wc",ud=2,cd="core",ld=`${ad}@2:${cd}:`,fd={name:cd,logger:"error"},hd={database:":memory:"},dd="crypto",pd="client_ed25519_seed",gd=We.ONE_DAY,yd="keychain",vd="0.3",md="messages",_d="0.3",bd=We.SIX_HOURS,wd="publisher",Ed="irn",Sd="error",Od="wss://relay.walletconnect.com",xd="wss://relay.walletconnect.org",Id="relayer",Rd={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},kd="_subscription",Cd={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Pd=We.ONE_SECOND/2,Ad="2.9.1",Nd=1e4,Td="0.3",Md="WALLETCONNECT_CLIENT_ID",Ld={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},jd="subscription",Ud="0.3",Dd=1e3*We.FIVE_SECONDS,zd="pairing",Fd="0.3",Bd={wc_pairingDelete:{req:{ttl:We.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:We.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:We.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:We.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:We.ONE_DAY,prompt:!1,tag:0},res:{ttl:We.ONE_DAY,prompt:!1,tag:0}}},Hd={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},qd="history",Vd="0.3",$d="expirer",Wd={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Kd="0.3",Gd="verify-api",Yd="https://verify.walletconnect.com";class Qd{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=yd,this.version=vd,this.initialized=!1,this.storagePrefix=ld,this.init=async()=>{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}},this.has=e=>(this.isInitialized(),this.keychain.has(e)),this.set=async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()},this.get=e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=lc("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t},this.del=async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()},this.core=e,this.logger=un.generateChildLogger(t,this.name)}get context(){return un.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,ku(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Cu(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Jd{constructor(e,t,n){this.core=e,this.logger=t,this.name=dd,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=e=>(this.isInitialized(),this.keychain.has(e)),this.getClientId=async()=>(this.isInitialized(),as(fs(await this.getClientSeed()).publicKey)),this.generateKeyPair=()=>{this.isInitialized();const e=Ga();return this.setPrivateKey(e.publicKey,e.privateKey)},this.signJWT=async e=>{this.isInitialized();const t=fs(await this.getClientSeed()),n=Ya();return await hs(n,e,gd,t)},this.generateSharedKey=(e,t,n)=>{this.isInitialized();const r=Qa(this.getPrivateKey(e),t);return this.setSymKey(r,n)},this.setSymKey=async(e,t)=>{this.isInitialized();const n=t||Ja(e);return await this.keychain.set(n,e),n},this.deleteKeyPair=async e=>{this.isInitialized(),await this.keychain.del(e)},this.deleteSymKey=async e=>{this.isInitialized(),await this.keychain.del(e)},this.encode=async(e,t,n)=>{this.isInitialized();const r=su(n),i=sr(t);if(au(r)){const t=r.senderPublicKey,n=r.receiverPublicKey;e=await this.generateSharedKey(t,n)}const o=this.getSymKey(e),{type:s,senderPublicKey:a}=r;return tu({type:s,symKey:o,message:i,senderPublicKey:a})},this.decode=async(e,t,n)=>{this.isInitialized();const r=ou(t,n);if(au(r)){const t=r.receiverPublicKey,n=r.senderPublicKey;e=await this.generateSharedKey(t,n)}try{const n=this.getSymKey(e);return or(nu({symKey:n,encoded:t}))}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}},this.getPayloadType=e=>eu(iu(e).type),this.getPayloadSenderPublicKey=e=>{const t=iu(e);return t.senderPublicKey?is(t.senderPublicKey,za):void 0},this.core=e,this.logger=un.generateChildLogger(t,this.name),this.keychain=n||new Qd(this.core,this.logger)}get context(){return un.getLoggerContext(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(pd)}catch{e=Ya(),await this.keychain.set(pd,e)}return sd(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Xd extends Gn{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=md,this.version=_d,this.initialized=!1,this.storagePrefix=ld,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}},this.set=async(e,t)=>{this.isInitialized();const n=Xa(t);let r=this.messages.get(e);return typeof r>"u"&&(r={}),typeof r[n]<"u"||(r[n]=t,this.messages.set(e,r),await this.persist()),n},this.get=e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t},this.has=(e,t)=>(this.isInitialized(),typeof this.get(e)[Xa(t)]<"u"),this.del=async e=>{this.isInitialized(),this.messages.delete(e),await this.persist()},this.logger=un.generateChildLogger(e,this.name),this.core=t}get context(){return un.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,ku(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Cu(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Zd extends Yn{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new o.exports.EventEmitter,this.name=wd,this.queue=new Map,this.publishTimeout=We.toMiliseconds(We.TEN_SECONDS),this.queueTimeout=We.toMiliseconds(We.FIVE_SECONDS),this.needsTransportRestart=!1,this.publish=async(e,t,n)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:n}});try{const r=n?.ttl||bd,i=Hu(n),o=n?.prompt||!1,s=n?.tag||0,a=n?.id||zl().toString(),u={topic:e,message:t,opts:{ttl:r,relay:i,prompt:o,tag:s,id:a}},c=setTimeout((()=>this.queue.set(a,u)),this.queueTimeout);try{await await Au(this.rpcPublish(e,t,r,i,o,s,a),this.publishTimeout),clearTimeout(c),this.relayer.events.emit(Rd.publish,u)}catch{return this.logger.debug("Publishing Payload stalled"),void(this.needsTransportRestart=!0)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:n}})}catch(e){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(e),e}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.relayer=e,this.logger=un.generateChildLogger(t,this.name),this.registerEventListeners()}get context(){return un.getLoggerContext(this.logger)}rpcPublish(e,t,n,r,i,o,s){var a,u,c,l;const f={method:qu(r.protocol).publish,params:{topic:e,message:t,ttl:n,prompt:i,tag:o},id:s};return pc(null==(a=f.params)?void 0:a.prompt)&&(null==(u=f.params)||delete u.prompt),pc(null==(c=f.params)?void 0:c.tag)&&(null==(l=f.params)||delete l.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:f}),this.relayer.request(f)}onPublish(e){this.queue.delete(e)}checkQueue(){this.queue.forEach((async e=>{const{topic:t,message:n,opts:r}=e;await this.publish(t,n,r)}))}registerEventListeners(){this.relayer.core.heartbeat.on(_e.HEARTBEAT_EVENTS.pulse,(()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(Rd.connection_stalled);this.checkQueue()})),this.relayer.on(Rd.message_ack,(e=>{this.onPublish(e.id.toString())}))}}class ep{constructor(){this.map=new Map,this.set=(e,t)=>{const n=this.get(e);this.exists(e,t)||this.map.set(e,[...n,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const n=this.get(e);if(!this.exists(e,t))return;const r=n.filter((e=>e!==t));r.length?this.map.set(e,r):this.map.delete(e)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var tp=Object.defineProperty,np=Object.defineProperties,rp=Object.getOwnPropertyDescriptors,ip=Object.getOwnPropertySymbols,op=Object.prototype.hasOwnProperty,sp=Object.prototype.propertyIsEnumerable,ap=(e,t,n)=>t in e?tp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,up=(e,t)=>{for(var n in t||(t={}))op.call(t,n)&&ap(e,n,t[n]);if(ip)for(var n of ip(t))sp.call(t,n)&&ap(e,n,t[n]);return e},cp=(e,t)=>np(e,rp(t));class lp extends Xn{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new ep,this.events=new o.exports.EventEmitter,this.name=jd,this.version=Ud,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ld,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const n=Hu(t),r={topic:e,relay:n};this.pending.set(e,r);const i=await this.rpcSubscribe(e,n);return this.onSubscribe(i,r),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}}),i}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}},this.unsubscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)},this.isSubscribed=async e=>!!this.topics.includes(e)||await new Promise(((t,n)=>{const r=new We.Watch;r.start(this.pendingSubscriptionWatchLabel);const i=setInterval((()=>{!this.pending.has(e)&&this.topics.includes(e)&&(clearInterval(i),r.stop(this.pendingSubscriptionWatchLabel),t(!0)),r.elapsed(this.pendingSubscriptionWatchLabel)>=Dd&&(clearInterval(i),r.stop(this.pendingSubscriptionWatchLabel),n(new Error("Subscription resolution timeout")))}),this.pollingInterval)})).catch((()=>!1)),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=un.generateChildLogger(t,this.name),this.clientId=""}get context(){return un.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let n=!1;try{n=this.getSubscription(e).topic===t}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const n=this.topicMap.get(e);await Promise.all(n.map((async n=>await this.unsubscribeById(e,n,t))))}async unsubscribeById(e,t,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:n}});try{const r=Hu(n);await this.rpcUnsubscribe(e,t,r);const i=fc("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,i),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:n}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t){const n={method:qu(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{await await Au(this.relayer.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Rd.connection_stalled)}return Xa(e+this.clientId)}async rpcBatchSubscribe(e){if(!e.length)return;const t={method:qu(e[0].relay.protocol).batchSubscribe,params:{topics:e.map((e=>e.topic))}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{return await await Au(this.relayer.request(t),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(Rd.connection_stalled)}}rpcUnsubscribe(e,t,n){const r={method:qu(n.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r}),this.relayer.request(r)}onSubscribe(e,t){this.setSubscription(e,cp(up({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach((e=>{this.setSubscription(e.id,up({},e)),this.pending.delete(e.topic)}))}async onUnsubscribe(e,t,n){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,n),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t))}addSubscription(e,t){this.subscriptions.set(e,up({},t)),this.topicMap.set(t.topic,e),this.events.emit(Ld.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:t}=lc("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(Ld.deleted,cp(up({},n),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Ld.sync)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t<e;t++){const e=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(e)}}this.events.emit(Ld.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=lc("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);hc(t)&&this.onBatchSubscribe(t.map(((t,n)=>cp(up({},e[n]),{id:t}))))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(this.relayer.transportExplicitlyClosed)return;const e=[];this.pending.forEach((t=>{e.push(t)})),await this.batchSubscribe(e)}registerEventListeners(){this.relayer.core.heartbeat.on(_e.HEARTBEAT_EVENTS.pulse,(async()=>{await this.checkPending()})),this.relayer.on(Rd.connect,(async()=>{await this.onConnect()})),this.relayer.on(Rd.disconnect,(()=>{this.onDisconnect()})),this.events.on(Ld.created,(async e=>{const t=Ld.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})),this.events.on(Ld.deleted,(async e=>{const t=Ld.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){this.restartInProgress&&await new Promise((e=>{const t=setInterval((()=>{this.restartInProgress||(clearInterval(t),e())}),this.pollingInterval)}))}}var fp=Object.defineProperty,hp=Object.getOwnPropertySymbols,dp=Object.prototype.hasOwnProperty,pp=Object.prototype.propertyIsEnumerable,gp=(e,t,n)=>t in e?fp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yp=(e,t)=>{for(var n in t||(t={}))dp.call(t,n)&&gp(e,n,t[n]);if(hp)for(var n of hp(t))pp.call(t,n)&&gp(e,n,t[n]);return e};class vp extends Qn{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new o.exports.EventEmitter,this.name=Id,this.transportExplicitlyClosed=!1,this.initialized=!1,this.reconnecting=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.request=async e=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(e)}catch(e){throw this.logger.debug("Failed to Publish Request"),this.logger.error(e),e}},this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?un.generateChildLogger(e.logger,this.name):un.pino(un.getDefaultLoggerOptions({level:e.logger||Sd})),this.messages=new Xd(this.logger,e.core),this.subscriber=new lp(this,this.logger),this.publisher=new Zd(this,this.logger),this.relayUrl=e?.relayUrl||Od,this.projectId=e.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${xd}...`),await this.restartTransport(xd)}this.registerEventListeners(),this.initialized=!0,setTimeout((async()=>{0===this.subscriber.topics.length&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)}),Nd)}get context(){return un.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,t,n){this.isInitialized(),await this.publisher.publish(e,t,n),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now()})}async subscribe(e,t){var n;this.isInitialized();let r=(null==(n=this.subscriber.topicMap.get(e))?void 0:n[0])||"";return r||(await Promise.all([new Promise((t=>{this.subscriber.once(Ld.created,(n=>{n.topic===e&&t()}))})),new Promise((async n=>{r=await this.subscriber.subscribe(e,t),n()}))]),r)}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportClose(){this.transportExplicitlyClosed=!0,this.connected&&(await this.provider.disconnect(),this.events.emit(Rd.transport_closed))}async transportOpen(e){if(this.transportExplicitlyClosed=!1,!this.reconnecting){this.relayUrl=e||this.relayUrl,this.reconnecting=!0;try{await Promise.all([new Promise((e=>{this.initialized||e(),this.subscriber.once(Ld.resubscribed,(()=>{e()}))})),await Promise.race([new Promise((async(e,t)=>{await Au(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`).catch((e=>t(e))).then((()=>e())).finally((()=>this.removeListener(Rd.transport_closed,this.rejectTransportOpen)))})),new Promise((e=>this.once(Rd.transport_closed,this.rejectTransportOpen)))])])}catch(e){this.logger.error(e);const t=e;if(!this.isConnectionStalled(t.message))throw e;this.events.emit(Rd.transport_closed)}finally{this.reconnecting=!1}}}async restartTransport(e){this.transportExplicitlyClosed||this.reconnecting||(this.relayUrl=e||this.relayUrl,this.connected&&await Promise.all([new Promise((e=>{this.provider.once(Cd.disconnect,(()=>{e()}))})),this.transportClose()]),await this.createProvider(),await this.transportOpen())}isConnectionStalled(e){return this.staleConnectionErrors.some((t=>e.includes(t)))}rejectTransportOpen(){throw new Error("Attempt to connect to relay via `transportOpen` has stalled. Retrying...")}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new sf(new ff(Iu({sdkVersion:Ad,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:n}=e;await this.messages.set(t,n)}async shouldIgnoreMessageEvent(e){const{topic:t,message:n}=e;if(!n||0===n.length)return this.logger.debug(`Ignoring invalid/empty message: ${n}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;const r=this.messages.has(t,n);return r&&this.logger.debug(`Ignoring duplicate message: ${n}`),r}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),tf(e)){if(!e.method.endsWith(kd))return;const t=e.params,{topic:n,message:r,publishedAt:i}=t.data,o={topic:n,message:r,publishedAt:i};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(yp({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else nf(e)&&this.events.emit(Rd.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Rd.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=Bl(e.id,!0);await this.provider.connection.send(t)}registerProviderListeners(){this.provider.on(Cd.payload,(e=>this.onProviderPayload(e))),this.provider.on(Cd.connect,(()=>{this.events.emit(Rd.connect)})),this.provider.on(Cd.disconnect,(()=>{this.onProviderDisconnect()})),this.provider.on(Cd.error,(e=>{this.logger.error(e),this.events.emit(Rd.error,e)}))}registerEventListeners(){this.events.on(Rd.connection_stalled,(async()=>{await this.restartTransport()}))}onProviderDisconnect(){this.events.emit(Rd.disconnect),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout((async()=>{await this.restartTransport()}),We.toMiliseconds(Pd))}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(!this.connected){if(this.connecting)return await new Promise((e=>{const t=setInterval((()=>{this.connected&&(clearInterval(t),e())}),this.connectionStatusPollingInterval)}));await this.restartTransport()}}}var mp=Object.defineProperty,_p=Object.getOwnPropertySymbols,bp=Object.prototype.hasOwnProperty,wp=Object.prototype.propertyIsEnumerable,Ep=(e,t,n)=>t in e?mp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sp=(e,t)=>{for(var n in t||(t={}))bp.call(t,n)&&Ep(e,n,t[n]);if(_p)for(var n of _p(t))wp.call(t,n)&&Ep(e,n,t[n]);return e};class Op extends Jn{constructor(e,t,n,r=ld,i=void 0){super(e,t,n,r),this.core=e,this.logger=t,this.name=n,this.map=new Map,this.version=Td,this.cached=[],this.initialized=!1,this.storagePrefix=ld,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>{this.getKey&&null!==e&&!pc(e)?this.map.set(this.getKey(e),e):wc(e)?this.map.set(e.id,e):Ec(e)&&this.map.set(e.topic,e)})),this.cached=[],this.initialized=!0)},this.set=async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())},this.get=e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e)),this.getAll=e=>(this.isInitialized(),e?this.values.filter((t=>Object.keys(e).every((n=>df(t[n],e[n]))))):this.values),this.update=async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const n=Sp(Sp({},this.getData(e)),t);this.map.set(e,n),await this.persist()},this.delete=async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),await this.persist())},this.logger=un.generateChildLogger(t,this.name),this.storagePrefix=r,this.getKey=i}get context(){return un.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){const{message:t}=lc("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:e}=lc("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}}class xp{constructor(e,t){this.core=e,this.logger=t,this.name=zd,this.version=Fd,this.events=new o.exports,this.initialized=!1,this.storagePrefix=ld,this.ignoredPayloadTypes=[qa],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]},this.create=async()=>{this.isInitialized();const e=Ya(),t=await this.core.crypto.setSymKey(e),n=ju(We.FIVE_MINUTES),r={protocol:Ed},i={topic:t,expiry:n,relay:r,active:!1},o=ec({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:e,relay:r});return await this.pairings.set(t,i),await this.core.relayer.subscribe(t),this.core.expirer.set(t,n),{topic:t,uri:o}},this.pair=async e=>{this.isInitialized(),this.isValidPair(e);const{topic:t,symKey:n,relay:r}=Ju(e.uri);if(this.pairings.keys.includes(t))throw new Error(`Pairing already exists: ${t}`);if(this.core.crypto.hasKeys(t))throw new Error(`Keychain already exists: ${t}`);const i=ju(We.FIVE_MINUTES),o={topic:t,relay:r,expiry:i,active:!1};return await this.pairings.set(t,o),await this.core.crypto.setSymKey(n,t),await this.core.relayer.subscribe(t,{relay:r}),this.core.expirer.set(t,i),e.activatePairing&&await this.activate({topic:t}),o},this.activate=async({topic:e})=>{this.isInitialized();const t=ju(We.THIRTY_DAYS);await this.pairings.update(e,{active:!0,expiry:t}),this.core.expirer.set(e,t)},this.ping=async e=>{this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:n,resolve:r,reject:i}=Pu();this.events.once(Du("pairing_ping",e),(({error:e})=>{e?i(e):r()})),await n()}},this.updateExpiry=async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})},this.updateMetadata=async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",fc("USER_DISCONNECTED")),await this.deletePairing(t))},this.sendRequest=async(e,t,n)=>{const r=Fl(t,n),i=await this.core.crypto.encode(e,r),o=Bd[t].req;return this.core.history.set(e,r),this.core.relayer.publish(e,i,o),r.id},this.sendResult=async(e,t,n)=>{const r=Bl(e,n),i=await this.core.crypto.encode(t,r),o=await this.core.history.get(t,e),s=Bd[o.request.method].res;await this.core.relayer.publish(t,i,s),await this.core.history.resolve(r)},this.sendError=async(e,t,n)=>{const r=Hl(e,n),i=await this.core.crypto.encode(t,r),o=await this.core.history.get(t,e),s=Bd[o.request.method]?Bd[o.request.method].res:Bd.unregistered_method.res;await this.core.relayer.publish(t,i,s),await this.core.history.resolve(r)},this.deletePairing=async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,fc("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])},this.cleanup=async()=>{const e=this.pairings.getAll().filter((e=>Uu(e.expiry)));await Promise.all(e.map((e=>this.deletePairing(e.topic))))},this.onRelayEventRequest=e=>{const{topic:t,payload:n}=e;switch(n.method){case"wc_pairingPing":return this.onPairingPingRequest(t,n);case"wc_pairingDelete":return this.onPairingDeleteRequest(t,n);default:return this.onUnknownRpcMethodRequest(t,n)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:n}=e,r=(await this.core.history.get(t,n.id)).request.method;return"wc_pairingPing"===r?this.onPairingPingResponse(t,n):this.onUnknownRpcMethodResponse(r)},this.onPairingPingRequest=async(e,t)=>{const{id:n}=t;try{this.isValidPing({topic:e}),await this.sendResult(n,e,!0),this.events.emit("pairing_ping",{id:n,topic:e})}catch(t){await this.sendError(n,e,t),this.logger.error(t)}},this.onPairingPingResponse=(e,t)=>{const{id:n}=t;setTimeout((()=>{rf(t)?this.events.emit(Du("pairing_ping",n),{}):of(t)&&this.events.emit(Du("pairing_ping",n),{error:t.error})}),500)},this.onPairingDeleteRequest=async(e,t)=>{const{id:n}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit("pairing_delete",{id:n,topic:e})}catch(t){await this.sendError(n,e,t),this.logger.error(t)}},this.onUnknownRpcMethodRequest=async(e,t)=>{const{id:n,method:r}=t;try{if(this.registeredMethods.includes(r))return;const t=fc("WC_METHOD_UNSUPPORTED",r);await this.sendError(n,e,t),this.logger.error(t)}catch(t){await this.sendError(n,e,t),this.logger.error(t)}},this.onUnknownRpcMethodResponse=e=>{this.registeredMethods.includes(e)||this.logger.error(fc("WC_METHOD_UNSUPPORTED",e))},this.isValidPair=e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`pair() params: ${e}`);throw new Error(t)}if(!bc(e.uri)){const{message:t}=lc("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw new Error(t)}},this.isValidPing=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidDisconnect=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidPairingTopic=async e=>{if(!gc(e,!1)){const{message:t}=lc("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=lc("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Uu(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=lc("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}},this.core=e,this.logger=un.generateChildLogger(t,this.name),this.pairings=new Op(this.core,this.logger,this.name,this.storagePrefix)}get context(){return un.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Rd.message,(async e=>{const{topic:t,message:n}=e;if(!this.pairings.keys.includes(t)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;const r=await this.core.crypto.decode(t,n);tf(r)?(this.core.history.set(t,r),this.onRelayEventRequest({topic:t,payload:r})):nf(r)&&(await this.core.history.resolve(r),await this.onRelayEventResponse({topic:t,payload:r}),this.core.history.delete(t,r.id))}))}registerExpirerEvents(){this.core.expirer.on(Wd.expired,(async e=>{const{topic:t}=Lu(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit("pairing_expire",{topic:t}))}))}}class Ip extends Kn{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new o.exports.EventEmitter,this.name=qd,this.version=Vd,this.cached=[],this.initialized=!1,this.storagePrefix=ld,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.records.set(e.id,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(e,t,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:n}),this.records.has(t.id))return;const r={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:n,expiry:ju(We.THIRTY_DAYS)};this.records.set(r.id,r),this.events.emit(Hd.created,r)},this.resolve=async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=of(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.events.emit(Hd.updated,t))},this.get=async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t)),this.delete=(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach((n=>{if(n.topic===e){if(typeof t<"u"&&n.id!==t)return;this.records.delete(n.id),this.events.emit(Hd.deleted,n)}}))},this.exists=async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=un.generateChildLogger(t,this.name)}get context(){return un.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach((t=>{if(typeof t.response<"u")return;const n={topic:t.topic,request:Fl(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(n)})),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:t}=lc("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Hd.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=lc("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Hd.created,(e=>{const t=Hd.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(Hd.updated,(e=>{const t=Hd.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(Hd.deleted,(e=>{const t=Hd.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.core.heartbeat.on(_e.HEARTBEAT_EVENTS.pulse,(()=>{this.cleanup()}))}cleanup(){try{this.records.forEach((e=>{We.toMiliseconds(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.delete(e.topic,e.id))}))}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Rp extends Zn{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new o.exports.EventEmitter,this.name=$d,this.version=Kd,this.cached=[],this.initialized=!1,this.storagePrefix=ld,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.expirations.set(e.target,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}},this.set=(e,t)=>{this.isInitialized();const n=this.formatTarget(e),r={target:n,expiry:t};this.expirations.set(n,r),this.checkExpiry(n,r),this.events.emit(Wd.created,{target:n,expiration:r})},this.get=e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)},this.del=e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),n=this.getExpiration(t);this.expirations.delete(t),this.events.emit(Wd.deleted,{target:t,expiration:n})}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=un.generateChildLogger(t,this.name)}get context(){return un.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return Tu(e);if("number"==typeof e)return Mu(e);const{message:t}=lc("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Wd.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=lc("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=lc("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:n}=t;We.toMiliseconds(n)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Wd.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach(((e,t)=>this.checkExpiry(t,e)))}registerEventListeners(){this.core.heartbeat.on(_e.HEARTBEAT_EVENTS.pulse,(()=>this.checkExpirations())),this.events.on(Wd.created,(e=>{const t=Wd.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(Wd.expired,(e=>{const t=Wd.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(Wd.deleted,(e=>{const t=Wd.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}}class kp extends er{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.name=Gd,this.initialized=!1,this.init=async e=>{mu()||!_u()||(this.verifyUrl=e?.verifyUrl||Yd,await this.createIframe())},this.register=async e=>{var t;if(this.initialized||await this.init(),this.iframe)try{null==(t=this.iframe.contentWindow)||t.postMessage(e.attestationId,this.verifyUrl),this.logger.info(`postMessage sent: ${e.attestationId} ${this.verifyUrl}`)}catch{}},this.resolve=async e=>{var t;if(this.isDevEnv)return"";this.logger.info(`resolving attestation: ${e.attestationId}`);const n=this.startAbortTimer(We.FIVE_SECONDS),r=await fetch(`${this.verifyUrl}/attestation/${e.attestationId}`,{signal:this.abortController.signal});return clearTimeout(n),200===r.status?null==(t=await r.json())?void 0:t.origin:""},this.createIframe=async()=>{try{await Promise.race([new Promise(((e,t)=>{if(document.getElementById(Gd))return e();const n=document.createElement("iframe");n.setAttribute("id",Gd),n.setAttribute("src",`${this.verifyUrl}/${this.projectId}`),n.style.display="none",n.addEventListener("load",(()=>{this.initialized=!0,e()})),n.addEventListener("error",(e=>{t(e)})),document.body.append(n),this.iframe=n})),new Promise((e=>{setTimeout((()=>e("iframe load timeout")),We.toMiliseconds(We.ONE_SECOND/2))}))])}catch(e){this.logger.error(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.error(e)}},this.logger=un.generateChildLogger(t,this.name),this.verifyUrl=Yd,this.abortController=new AbortController,this.isDevEnv=vu()&&process.env.IS_VITEST}get context(){return un.getLoggerContext(this.logger)}startAbortTimer(e){return setTimeout((()=>this.abortController.abort()),We.toMiliseconds(e))}}var Cp=Object.defineProperty,Pp=Object.getOwnPropertySymbols,Ap=Object.prototype.hasOwnProperty,Np=Object.prototype.propertyIsEnumerable,Tp=(e,t,n)=>t in e?Cp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mp=(e,t)=>{for(var n in t||(t={}))Ap.call(t,n)&&Tp(e,n,t[n]);if(Pp)for(var n of Pp(t))Np.call(t,n)&&Tp(e,n,t[n]);return e};class Lp extends Wn{constructor(e){super(e),this.protocol=ad,this.version=ud,this.name=cd,this.events=new o.exports.EventEmitter,this.initialized=!1,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Od;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:un.pino(un.getDefaultLoggerOptions({level:e?.logger||fd.logger}));this.logger=un.generateChildLogger(t,this.name),this.heartbeat=new _e.HeartBeat,this.crypto=new Jd(this,this.logger,e?.keychain),this.history=new Ip(this,this.logger),this.expirer=new Rp(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new me(Mp(Mp({},hd),e?.storageOptions)),this.relayer=new vp({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new xp(this,this.logger),this.verify=new kp(this.projectId||"",this.logger)}static async init(e){const t=new Lp(e);await t.initialize();const n=await t.crypto.getClientId();return await t.storage.setItem(Md,n),t}get context(){return un.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const jp=Lp,Up="wc",Dp=2,zp="client",Fp=`${Up}@${Dp}:${zp}:`,Bp={name:zp,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},Hp="WALLETCONNECT_DEEPLINK_CHOICE",qp="proposal",Vp="Proposal expired",$p="session",Wp=We.SEVEN_DAYS,Kp="engine",Gp={wc_sessionPropose:{req:{ttl:We.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:We.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:We.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:We.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:We.ONE_DAY,prompt:!1,tag:1104},res:{ttl:We.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:We.ONE_DAY,prompt:!1,tag:1106},res:{ttl:We.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:We.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:We.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:We.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:We.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:We.ONE_DAY,prompt:!1,tag:1112},res:{ttl:We.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:We.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:We.THIRTY_SECONDS,prompt:!1,tag:1115}}},Yp={min:We.FIVE_MINUTES,max:We.SEVEN_DAYS},Qp={idle:"idle",active:"active"},Jp="request",Xp=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var Zp=Object.defineProperty,eg=Object.defineProperties,tg=Object.getOwnPropertyDescriptors,ng=Object.getOwnPropertySymbols,rg=Object.prototype.hasOwnProperty,ig=Object.prototype.propertyIsEnumerable,og=(e,t,n)=>t in e?Zp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sg=(e,t)=>{for(var n in t||(t={}))rg.call(t,n)&&og(e,n,t[n]);if(ng)for(var n of ng(t))ig.call(t,n)&&og(e,n,t[n]);return e},ag=(e,t)=>eg(e,tg(t));class ug extends nr{constructor(e){super(e),this.name=Kp,this.events=new o.exports,this.initialized=!1,this.ignoredPayloadTypes=[qa],this.requestQueue={state:Qp.idle,requests:[]},this.requestQueueDelay=We.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(Gp)}),this.initialized=!0,setTimeout((()=>{this.requestQueue.requests=this.getPendingSessionRequests(),this.processRequestQueue()}),We.toMiliseconds(this.requestQueueDelay)))},this.connect=async e=>{this.isInitialized();const t=ag(sg({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:n,requiredNamespaces:r,optionalNamespaces:i,sessionProperties:o,relays:s}=t;let a,u=n,c=!1;if(u&&(c=this.client.core.pairing.pairings.get(u).active),!u||!c){const{topic:e,uri:t}=await this.client.core.pairing.create();u=e,a=t}const l=await this.client.core.crypto.generateKeyPair(),f=sg({requiredNamespaces:r,optionalNamespaces:i,relays:s??[{protocol:Ed}],proposer:{publicKey:l,metadata:this.client.metadata}},o&&{sessionProperties:o}),{reject:h,resolve:d,done:p}=Pu(We.FIVE_MINUTES,Vp);if(this.events.once(Du("session_connect"),(async({error:e,session:t})=>{if(e)h(e);else if(t){t.self.publicKey=l;const e=ag(sg({},t),{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces});await this.client.session.set(t.topic,e),await this.setExpiry(t.topic,t.expiry),u&&await this.client.core.pairing.updateMetadata({topic:u,metadata:t.peer.metadata}),d(e)}})),!u){const{message:e}=lc("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(e)}const g=await this.sendRequest(u,"wc_sessionPropose",f),y=ju(We.FIVE_MINUTES);return await this.setProposal(g,sg({id:g,expiry:y},f)),{uri:a,approval:p}},this.pair=async e=>(this.isInitialized(),await this.client.core.pairing.pair(e)),this.approve=async e=>{this.isInitialized(),await this.isValidApprove(e);const{id:t,relayProtocol:n,namespaces:r,sessionProperties:i}=e,o=this.client.proposal.get(t);let{pairingTopic:s,proposer:a,requiredNamespaces:u,optionalNamespaces:c}=o;s=s||"",dc(u)||(u=oc(r,"approve()"));const l=await this.client.core.crypto.generateKeyPair(),f=a.publicKey,h=await this.client.core.crypto.generateSharedKey(l,f);s&&t&&(await this.client.core.pairing.updateMetadata({topic:s,metadata:a.metadata}),await this.sendResult(t,s,{relay:{protocol:n??"irn"},responderPublicKey:l}),await this.client.proposal.delete(t,fc("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:s}));const d=sg({relay:{protocol:n??"irn"},namespaces:r,requiredNamespaces:u,optionalNamespaces:c,pairingTopic:s,controller:{publicKey:l,metadata:this.client.metadata},expiry:ju(Wp)},i&&{sessionProperties:i});await this.client.core.relayer.subscribe(h),await this.sendRequest(h,"wc_sessionSettle",d);const p=ag(sg({},d),{topic:h,pairingTopic:s,acknowledged:!1,self:d.controller,peer:{publicKey:a.publicKey,metadata:a.metadata},controller:l});return await this.client.session.set(h,p),await this.setExpiry(h,ju(Wp)),{topic:h,acknowledged:()=>new Promise((e=>setTimeout((()=>e(this.client.session.get(h))),500)))}},this.reject=async e=>{this.isInitialized(),await this.isValidReject(e);const{id:t,reason:n}=e,{pairingTopic:r}=this.client.proposal.get(t);r&&(await this.sendError(t,r,n),await this.client.proposal.delete(t,fc("USER_DISCONNECTED")))},this.update=async e=>{this.isInitialized(),await this.isValidUpdate(e);const{topic:t,namespaces:n}=e,r=await this.sendRequest(t,"wc_sessionUpdate",{namespaces:n}),{done:i,resolve:o,reject:s}=Pu();return this.events.once(Du("session_update",r),(({error:e})=>{e?s(e):o()})),await this.client.session.update(t,{namespaces:n}),{acknowledged:i}},this.extend=async e=>{this.isInitialized(),await this.isValidExtend(e);const{topic:t}=e,n=await this.sendRequest(t,"wc_sessionExtend",{}),{done:r,resolve:i,reject:o}=Pu();return this.events.once(Du("session_extend",n),(({error:e})=>{e?o(e):i()})),await this.setExpiry(t,ju(Wp)),{acknowledged:r}},this.request=async e=>{this.isInitialized(),await this.isValidRequest(e);const{chainId:t,request:n,topic:r,expiry:i}=e,o=await this.sendRequest(r,"wc_sessionRequest",{request:n,chainId:t},i),{done:s,resolve:a,reject:u}=Pu(i);return this.events.once(Du("session_request",o),(({error:e,result:t})=>{e?u(e):a(t)})),this.client.events.emit("session_request_sent",{topic:r,request:n,chainId:t,id:o}),Fu({id:o,topic:r,wcDeepLink:await this.client.core.storage.getItem(Hp)}),await s()},this.respond=async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:n}=e,{id:r}=n;rf(n)?await this.sendResult(r,t,n.result):of(n)&&await this.sendError(r,t,n.error),this.cleanupAfterResponse(e)},this.ping=async e=>{this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=await this.sendRequest(t,"wc_sessionPing",{}),{done:n,resolve:r,reject:i}=Pu();this.events.once(Du("session_ping",e),(({error:e})=>{e?i(e):r()})),await n()}else this.client.core.pairing.pairings.keys.includes(t)&&await this.client.core.pairing.ping({topic:t})},this.emit=async e=>{this.isInitialized(),await this.isValidEmit(e);const{topic:t,event:n,chainId:r}=e;await this.sendRequest(t,"wc_sessionEvent",{event:n,chainId:r})},this.disconnect=async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=zl().toString();let n;const r=t=>{t?.id.toString()===e&&(this.client.core.relayer.events.removeListener(Rd.message_ack,r),n())};await Promise.all([new Promise((e=>{n=e,this.client.core.relayer.on(Rd.message_ack,r)})),this.sendRequest(t,"wc_sessionDelete",fc("USER_DISCONNECTED"),void 0,e)]),await this.deleteSession(t)}else await this.client.core.pairing.disconnect({topic:t})},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter((t=>vc(t,e)))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter((n=>{var r,i;return(null==(r=n.peerMetadata)?void 0:r.url)&&(null==(i=n.peerMetadata)?void 0:i.url)===e.peer.metadata.url&&n.topic&&n.topic!==t.topic}));if(0===n.length)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map((e=>this.client.core.pairing.disconnect({topic:e.topic})))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}},this.deleteSession=async(e,t)=>{const{self:n}=this.client.session.get(e);await this.client.core.relayer.unsubscribe(e),this.client.session.delete(e,fc("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(n.publicKey)&&await this.client.core.crypto.deleteKeyPair(n.publicKey),this.client.core.crypto.keychain.has(e)&&await this.client.core.crypto.deleteSymKey(e),t||this.client.core.expirer.del(e)},this.deleteProposal=async(e,t)=>{await Promise.all([this.client.proposal.delete(e,fc("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)])},this.deletePendingSessionRequest=async(e,t,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),n?Promise.resolve():this.client.core.expirer.del(e)]),this.requestQueue.requests=this.requestQueue.requests.filter((t=>t.id!==e)),n&&(this.requestQueue.state=Qp.idle)},this.setExpiry=async(e,t)=>{this.client.session.keys.includes(e)&&await this.client.session.update(e,{expiry:t}),this.client.core.expirer.set(e,t)},this.setProposal=async(e,t)=>{await this.client.proposal.set(e,t),this.client.core.expirer.set(e,t.expiry)},this.setPendingSessionRequest=async e=>{const t=Gp.wc_sessionRequest.req.ttl,{id:n,topic:r,params:i}=e;await this.client.pendingRequest.set(n,{id:n,topic:r,params:i}),t&&this.client.core.expirer.set(n,ju(t))},this.sendRequest=async(e,t,n,r,i)=>{const o=Fl(t,n);if(_u()&&Xp.includes(t)){const e=Xa(JSON.stringify(o));await this.client.core.verify.register({attestationId:e})}const s=await this.client.core.crypto.encode(e,o),a=Gp[t].req;return r&&(a.ttl=r),i&&(a.id=i),this.client.core.history.set(e,o),this.client.core.relayer.publish(e,s,a),o.id},this.sendResult=async(e,t,n)=>{const r=Bl(e,n),i=await this.client.core.crypto.encode(t,r),o=await this.client.core.history.get(t,e),s=Gp[o.request.method].res;this.client.core.relayer.publish(t,i,s),await this.client.core.history.resolve(r)},this.sendError=async(e,t,n)=>{const r=Hl(e,n),i=await this.client.core.crypto.encode(t,r),o=await this.client.core.history.get(t,e),s=Gp[o.request.method].res;this.client.core.relayer.publish(t,i,s),await this.client.core.history.resolve(r)},this.cleanup=async()=>{const e=[],t=[];this.client.session.getAll().forEach((t=>{Uu(t.expiry)&&e.push(t.topic)})),this.client.proposal.getAll().forEach((e=>{Uu(e.expiry)&&t.push(e.id)})),await Promise.all([...e.map((e=>this.deleteSession(e))),...t.map((e=>this.deleteProposal(e)))])},this.onRelayEventRequest=e=>{const{topic:t,payload:n}=e,r=n.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeRequest(t,n);case"wc_sessionSettle":return this.onSessionSettleRequest(t,n);case"wc_sessionUpdate":return this.onSessionUpdateRequest(t,n);case"wc_sessionExtend":return this.onSessionExtendRequest(t,n);case"wc_sessionPing":return this.onSessionPingRequest(t,n);case"wc_sessionDelete":return this.onSessionDeleteRequest(t,n);case"wc_sessionRequest":return this.onSessionRequest(t,n);case"wc_sessionEvent":return this.onSessionEventRequest(t,n);default:return this.client.logger.info(`Unsupported request method ${r}`)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:n}=e,r=(await this.client.core.history.get(t,n.id)).request.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeResponse(t,n);case"wc_sessionSettle":return this.onSessionSettleResponse(t,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,n);case"wc_sessionExtend":return this.onSessionExtendResponse(t,n);case"wc_sessionPing":return this.onSessionPingResponse(t,n);case"wc_sessionRequest":return this.onSessionRequestResponse(t,n);default:return this.client.logger.info(`Unsupported response method ${r}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:t}=e,{message:n}=lc("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.onSessionProposeRequest=async(e,t)=>{const{params:n,id:r}=t;try{this.isValidConnect(sg({},t.params));const i=ju(We.FIVE_MINUTES),o=sg({id:r,pairingTopic:e,expiry:i},n);await this.setProposal(r,o);const s=Xa(JSON.stringify(t)),a=await this.getVerifyContext(s,o.proposer.metadata);this.client.events.emit("session_proposal",{id:r,params:o,verifyContext:a})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionProposeResponse=async(e,t)=>{const{id:n}=t;if(rf(t)){const{result:r}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:r});const i=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:i});const o=i.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const s=r.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:s});const a=await this.client.core.crypto.generateSharedKey(o,s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:a});const u=await this.client.core.relayer.subscribe(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:u}),await this.client.core.pairing.activate({topic:e})}else of(t)&&(await this.client.proposal.delete(n,fc("USER_DISCONNECTED")),this.events.emit(Du("session_connect"),{error:t.error}))},this.onSessionSettleRequest=async(e,t)=>{const{id:n,params:r}=t;try{this.isValidSessionSettleRequest(r);const{relay:n,controller:i,expiry:o,namespaces:s,requiredNamespaces:a,optionalNamespaces:u,sessionProperties:c,pairingTopic:l}=t.params,f=sg({topic:e,relay:n,expiry:o,namespaces:s,acknowledged:!0,pairingTopic:l,requiredNamespaces:a,optionalNamespaces:u,controller:i.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:i.publicKey,metadata:i.metadata}},c&&{sessionProperties:c});await this.sendResult(t.id,e,!0),this.events.emit(Du("session_connect"),{session:f}),this.cleanupDuplicatePairings(f)}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionSettleResponse=async(e,t)=>{const{id:n}=t;rf(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(Du("session_approve",n),{})):of(t)&&(await this.client.session.delete(e,fc("USER_DISCONNECTED")),this.events.emit(Du("session_approve",n),{error:t.error}))},this.onSessionUpdateRequest=async(e,t)=>{const{params:n,id:r}=t;try{this.isValidUpdate(sg({topic:e},n)),await this.client.session.update(e,{namespaces:n.namespaces}),await this.sendResult(r,e,!0),this.client.events.emit("session_update",{id:r,topic:e,params:n})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionUpdateResponse=(e,t)=>{const{id:n}=t;rf(t)?this.events.emit(Du("session_update",n),{}):of(t)&&this.events.emit(Du("session_update",n),{error:t.error})},this.onSessionExtendRequest=async(e,t)=>{const{id:n}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,ju(Wp)),await this.sendResult(n,e,!0),this.client.events.emit("session_extend",{id:n,topic:e})}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionExtendResponse=(e,t)=>{const{id:n}=t;rf(t)?this.events.emit(Du("session_extend",n),{}):of(t)&&this.events.emit(Du("session_extend",n),{error:t.error})},this.onSessionPingRequest=async(e,t)=>{const{id:n}=t;try{this.isValidPing({topic:e}),await this.sendResult(n,e,!0),this.client.events.emit("session_ping",{id:n,topic:e})}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionPingResponse=(e,t)=>{const{id:n}=t;setTimeout((()=>{rf(t)?this.events.emit(Du("session_ping",n),{}):of(t)&&this.events.emit(Du("session_ping",n),{error:t.error})}),500)},this.onSessionDeleteRequest=async(e,t)=>{const{id:n}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),await Promise.all([new Promise((t=>{this.client.core.relayer.once(Rd.publish,(async()=>{t(await this.deleteSession(e))}))})),this.sendResult(n,e,!0)]),this.client.events.emit("session_delete",{id:n,topic:e})}catch(e){this.client.logger.error(e)}},this.onSessionRequest=async(e,t)=>{const{id:n,params:r}=t;try{this.isValidRequest(sg({topic:e},r)),await this.setPendingSessionRequest({id:n,topic:e,params:r}),this.addRequestToQueue({id:n,topic:e,params:r}),await this.processRequestQueue()}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionRequestResponse=(e,t)=>{const{id:n}=t;rf(t)?this.events.emit(Du("session_request",n),{result:t.result}):of(t)&&this.events.emit(Du("session_request",n),{error:t.error})},this.onSessionEventRequest=async(e,t)=>{const{id:n,params:r}=t;try{this.isValidEmit(sg({topic:e},r)),this.client.events.emit("session_event",{id:n,topic:e,params:r})}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.addRequestToQueue=e=>{this.requestQueue.requests.push(e)},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout((()=>{this.requestQueue.state=Qp.idle,this.processRequestQueue()}),We.toMiliseconds(this.requestQueueDelay))},this.processRequestQueue=async()=>{if(this.requestQueue.state===Qp.active)return void this.client.logger.info("session request queue is already active.");const e=this.requestQueue.requests[0];if(e)try{const{id:t,topic:n,params:r}=e,i=Xa(JSON.stringify({id:t,params:r})),o=this.client.session.get(n),s=await this.getVerifyContext(i,o.peer.metadata);this.requestQueue.state=Qp.active,this.client.events.emit("session_request",{id:t,topic:n,params:r,verifyContext:s})}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")},this.isValidConnect=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:n,optionalNamespaces:r,sessionProperties:i,relays:o}=e;if(pc(t)||await this.isValidPairingTopic(t),!jc(o,!0)){const{message:e}=lc("MISSING_OR_INVALID",`connect() relays: ${o}`);throw new Error(e)}!pc(n)&&0!==dc(n)&&this.validateNamespaces(n,"requiredNamespaces"),!pc(r)&&0!==dc(r)&&this.validateNamespaces(r,"optionalNamespaces"),pc(i)||this.validateSessionProps(i,"sessionProperties")},this.validateNamespaces=(e,t)=>{const n=Tc(e,"connect()",t);if(n)throw new Error(n.message)},this.isValidApprove=async e=>{if(!Dc(e))throw new Error(lc("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:n,relayProtocol:r,sessionProperties:i}=e;await this.isValidProposalId(t);const o=this.client.proposal.get(t),s=Mc(n,"approve()");if(s)throw new Error(s.message);const a=Wc(o.requiredNamespaces,n,"approve()");if(a)throw new Error(a.message);if(!gc(r,!0)){const{message:e}=lc("MISSING_OR_INVALID",`approve() relayProtocol: ${r}`);throw new Error(e)}pc(i)||this.validateSessionProps(i,"sessionProperties")},this.isValidReject=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:n}=e;if(await this.isValidProposalId(t),!zc(n)){const{message:e}=lc("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(e)}},this.isValidSessionSettleRequest=e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:n,namespaces:r,expiry:i}=e;if(!Lc(t)){const{message:e}=lc("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const o=Sc(n,"onSessionSettleRequest()");if(o)throw new Error(o.message);const s=Mc(r,"onSessionSettleRequest()");if(s)throw new Error(s.message);if(Uu(i)){const{message:e}=lc("EXPIRED","onSessionSettleRequest()");throw new Error(e)}},this.isValidUpdate=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:n}=e;await this.isValidSessionTopic(t);const r=this.client.session.get(t),i=Mc(n,"update()");if(i)throw new Error(i.message);const o=Wc(r.requiredNamespaces,n,"update()");if(o)throw new Error(o.message)},this.isValidExtend=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionTopic(t)},this.isValidRequest=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:n,chainId:r,expiry:i}=e;await this.isValidSessionTopic(t);const{namespaces:o}=this.client.session.get(t);if(!qc(o,r)){const{message:e}=lc("MISSING_OR_INVALID",`request() chainId: ${r}`);throw new Error(e)}if(!Fc(n)){const{message:e}=lc("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(e)}if(!Vc(o,r,n.method)){const{message:e}=lc("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(e)}if(i&&!Qc(i,Yp)){const{message:e}=lc("MISSING_OR_INVALID",`request() expiry: ${i}. Expiry must be a number (in seconds) between ${Yp.min} and ${Yp.max}`);throw new Error(e)}},this.isValidRespond=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:t,response:n}=e;if(await this.isValidSessionTopic(t),!Bc(n)){const{message:e}=lc("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(e)}},this.isValidPing=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.isValidEmit=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:n,chainId:r}=e;await this.isValidSessionTopic(t);const{namespaces:i}=this.client.session.get(t);if(!qc(i,r)){const{message:e}=lc("MISSING_OR_INVALID",`emit() chainId: ${r}`);throw new Error(e)}if(!Hc(n)){const{message:e}=lc("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(e)}if(!$c(i,r,n.name)){const{message:e}=lc("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(e)}},this.isValidDisconnect=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.getVerifyContext=async(e,t)=>{const n={verified:{verifyUrl:t.verifyUrl||"",validation:"UNKNOWN",origin:t.url||""}};try{const r=await this.client.core.verify.resolve({attestationId:e,verifyUrl:t.verifyUrl});r&&(n.verified.origin=r,n.verified.validation=r===t.url?"VALID":"INVALID")}catch(e){this.client.logger.error(e)}return this.client.logger.info(`Verify context: ${JSON.stringify(n)}`),n},this.validateSessionProps=(e,t)=>{Object.values(e).forEach((e=>{if(!gc(e,!1)){const{message:n}=lc("MISSING_OR_INVALID",`${t} must be in Record<string, string> format. Received: ${JSON.stringify(e)}`);throw new Error(n)}}))}}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(Rd.message,(async e=>{const{topic:t,message:n}=e;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(n)))return;const r=await this.client.core.crypto.decode(t,n);tf(r)?(this.client.core.history.set(t,r),this.onRelayEventRequest({topic:t,payload:r})):nf(r)?(await this.client.core.history.resolve(r),await this.onRelayEventResponse({topic:t,payload:r}),this.client.core.history.delete(t,r.id)):this.onRelayEventUnknownPayload({topic:t,payload:r})}))}registerExpirerEvents(){this.client.core.expirer.on(Wd.expired,(async e=>{const{topic:t,id:n}=Lu(e.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,lc("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession(t,!0),this.client.events.emit("session_expire",{topic:t})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n}))}))}isValidPairingTopic(e){if(!gc(e,!1)){const{message:t}=lc("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=lc("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Uu(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=lc("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!gc(e,!1)){const{message:t}=lc("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(!this.client.session.keys.includes(e)){const{message:t}=lc("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Uu(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:t}=lc("EXPIRED",`session topic: ${e}`);throw new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if(gc(e,!1)){const{message:t}=lc("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=lc("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if(!Uc(e)){const{message:t}=lc("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=lc("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Uu(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:t}=lc("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class cg extends Op{constructor(e,t){super(e,t,qp,Fp),this.core=e,this.logger=t}}class lg extends Op{constructor(e,t){super(e,t,$p,Fp),this.core=e,this.logger=t}}class fg extends Op{constructor(e,t){super(e,t,Jp,Fp,(e=>e.id)),this.core=e,this.logger=t}}class hg extends tr{constructor(e){super(e),this.protocol=Up,this.version=Dp,this.name=Bp.name,this.events=new o.exports.EventEmitter,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.removeAllListeners=e=>this.events.removeAllListeners(e),this.connect=async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}},this.pair=async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}},this.approve=async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}},this.reject=async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}},this.update=async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}},this.extend=async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}},this.request=async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}},this.respond=async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}},this.ping=async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}},this.emit=async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}},this.disconnect=async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}},this.find=e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.name=e?.name||Bp.name,this.metadata=e?.metadata||Eu();const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:un.pino(un.getDefaultLoggerOptions({level:e?.logger||Bp.logger}));this.core=e?.core||new jp(e),this.logger=un.generateChildLogger(t,this.name),this.session=new lg(this.core,this.logger),this.proposal=new cg(this.core,this.logger),this.pendingRequest=new fg(this.core,this.logger),this.engine=new ug(this)}static async init(e){const t=new hg(e);return await t.initialize(),t}get context(){return un.getLoggerContext(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const dg="error",pg="wss://relay.walletconnect.com",gg="wc@2:universal_provider:",yg="https://rpc.walletconnect.com/v1",vg={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var mg,_g,bg={exports:{}};
|
321
|
+
***************************************************************************** */function ul(e,t){function n(){this.constructor=e}al(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var cl=function(){return cl=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},cl.apply(this,arguments)};function ll(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function fl(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}function hl(e,t){return function(n,r){t(n,r,e)}}function dl(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function pl(e,t,n,r){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?n(e.value):i(e.value).then(s,a)}u((r=r.apply(e,t||[])).next())}))}function gl(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(e){return function(t){return u([e,t])}}function u(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}function yl(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}function vl(e,t){for(var n in e)"default"!==n&&!t.hasOwnProperty(n)&&(t[n]=e[n])}function ml(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function _l(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function bl(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(_l(arguments[t]));return e}function wl(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}function El(e){return this instanceof El?(this.v=e,this):new El(e)}function Sl(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(e,t||[]),o=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(e){i[e]&&(r[e]=function(t){return new Promise((function(n,r){o.push([e,t,n,r])>1||a(e,t)}))})}function a(e,t){try{u(i[e](t))}catch(e){f(o[0][3],e)}}function u(e){e.value instanceof El?Promise.resolve(e.value.v).then(c,l):f(o[0][2],e)}function c(e){a("next",e)}function l(e){a("throw",e)}function f(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}}function Ol(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:El(e[r](t)),done:"return"===r}:i?i(t):t}:i}}function xl(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof ml?ml(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){i(r,o,(t=e[n](t)).done,t.value)}))}}function i(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}}function Il(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Rl(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function kl(e){return e&&e.__esModule?e:{default:e}}function Cl(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function Pl(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}var Al,Nl=r(Object.freeze({__proto__:null,__extends:ul,get __assign(){return cl},__rest:ll,__decorate:fl,__param:hl,__metadata:dl,__awaiter:pl,__generator:gl,__createBinding:yl,__exportStar:vl,__values:ml,__read:_l,__spread:bl,__spreadArrays:wl,__await:El,__asyncGenerator:Sl,__asyncDelegator:Ol,__asyncValues:xl,__makeTemplateObject:Il,__importStar:Rl,__importDefault:kl,__classPrivateFieldGet:Cl,__classPrivateFieldSet:Pl})),Tl={};function Ml(){if(Al)return Tl;function e(){return t?.crypto||t?.msCrypto||{}}function n(){const t=e();return t.subtle||t.webkitSubtle}function r(){return!!e()&&!!n()}return Al=1,Object.defineProperty(Tl,"__esModule",{value:!0}),Tl.isBrowserCryptoAvailable=Tl.getSubtleCrypto=Tl.getBrowerCrypto=void 0,Tl.getBrowerCrypto=e,Tl.getSubtleCrypto=n,Tl.isBrowserCryptoAvailable=r,Tl}var Ll,jl={};function Ul(){if(Ll)return jl;function e(){return typeof document>"u"&&typeof navigator<"u"&&"ReactNative"===navigator.product}function t(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function n(){return!e()&&!t()}return Ll=1,Object.defineProperty(jl,"__esModule",{value:!0}),jl.isBrowser=jl.isNode=jl.isReactNative=void 0,jl.isReactNative=e,jl.isNode=t,jl.isBrowser=n,jl}function Dl(e=3){return Date.now()*Math.pow(10,e)+Math.floor(Math.random()*Math.pow(10,e))}function zl(e=6){return BigInt(Dl(e))}function Fl(e,t,n){return{id:n||Dl(),jsonrpc:"2.0",method:e,params:t}}function Bl(e,t){return{id:e,jsonrpc:"2.0",result:t}}function Hl(e,t,n){return{id:e,jsonrpc:"2.0",error:ql(t,n)}}function ql(e,t){return typeof e>"u"?rl(Jc):("string"==typeof e&&(e=Object.assign(Object.assign({},rl(Xc)),{message:e})),typeof t<"u"&&(e.data=t),nl(e.code)&&(e=il(e.code)),e)}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Nl;t.__exportStar(Ml(),e),t.__exportStar(Ul(),e)}(sl);class Vl{}class $l extends Vl{constructor(){super()}}class Wl extends $l{constructor(e){super()}}const Kl="^https?:",Gl="^wss?:";function Yl(e){const t=e.match(new RegExp(/^\w+:/,"gi"));if(t&&t.length)return t[0]}function Ql(e,t){const n=Yl(e);return!(typeof n>"u")&&new RegExp(t).test(n)}function Jl(e){return Ql(e,Kl)}function Xl(e){return Ql(e,Gl)}function Zl(e){return new RegExp("wss?://localhost(:d{2,5})?").test(e)}function ef(e){return"object"==typeof e&&"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function tf(e){return ef(e)&&"method"in e}function nf(e){return ef(e)&&(rf(e)||of(e))}function rf(e){return"result"in e}function of(e){return"error"in e}class sf extends Wl{constructor(e){super(e),this.events=new o.exports.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(Fl(e.method,e.params||[],e.id||zl().toString()),t)}async requestStrict(e,t){return new Promise((async(n,r)=>{if(!this.connection.connected)try{await this.open()}catch(e){r(e)}this.events.on(`${e.id}`,(e=>{of(e)?r(e.error):n(e.result)}));try{await this.connection.send(e,t)}catch(e){r(e)}}))}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),nf(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&3e3===e.code&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),"string"==typeof e&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",(e=>this.onPayload(e))),this.connection.on("close",(e=>this.onClose(e))),this.connection.on("error",(e=>this.events.emit("error",e))),this.connection.on("register_error",(e=>this.onClose())),this.hasRegisteredEventListeners=!0)}}const af=()=>typeof WebSocket<"u"||typeof l<"u"&&typeof l.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",uf=e=>e.split("?")[0],cf=10,lf=typeof WebSocket<"u"?WebSocket:typeof l<"u"&&typeof l.WebSocket<"u"?l.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:kc?Rc:(kc=1,Rc=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")});class ff{constructor(e){if(this.url=e,this.events=new o.exports.EventEmitter,this.registering=!1,!Xl(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise(((e,t)=>{typeof this.socket>"u"?t(new Error("Connection already closed")):(this.socket.onclose=t=>{this.onClose(t),e()},this.socket.close())}))}async send(e,t){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(sr(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!Xl(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise(((e,t)=>{this.events.once("register_error",(e=>{this.resetMaxListeners(),t(e)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return t(new Error("WebSocket connection is missing or invalid"));e(this.socket)}))}))}return this.url=e,this.registering=!0,new Promise(((t,n)=>{const r=sl.isReactNative()?void 0:{rejectUnauthorized:!Zl(e)},i=new lf(e,[],r);af()?i.onerror=e=>{const t=e;n(this.emitError(t.error))}:i.on("error",(e=>{n(this.emitError(e))})),i.onopen=()=>{this.onOpen(i),t(i)}}))}onOpen(e){e.onmessage=e=>this.onPayload(e),e.onclose=e=>this.onClose(e),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const t="string"==typeof e.data?or(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const n=this.parseError(t),r=Hl(e,n.message||n.toString());this.events.emit("payload",r)}parseError(e,t=this.url){return ol(e,uf(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>cf&&this.events.setMaxListeners(cf)}emitError(e){const t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${uf(this.url)}`));return this.events.emit("register_error",t),t}}var hf={exports:{}};!function(e,n){var r=200,i="__lodash_hash_undefined__",o=1,s=2,a=9007199254740991,u="[object Arguments]",c="[object Array]",l="[object AsyncFunction]",f="[object Boolean]",h="[object Date]",d="[object Error]",p="[object Function]",g="[object GeneratorFunction]",y="[object Map]",v="[object Number]",m="[object Null]",_="[object Object]",b="[object Promise]",w="[object Proxy]",E="[object RegExp]",S="[object Set]",O="[object String]",x="[object Symbol]",I="[object Undefined]",R="[object WeakMap]",k="[object ArrayBuffer]",C="[object DataView]",P="[object Float64Array]",A="[object Int8Array]",N="[object Int16Array]",T="[object Int32Array]",M="[object Uint8Array]",L="[object Uint8ClampedArray]",j="[object Uint16Array]",U="[object Uint32Array]",D=/[\\^$.*+?()[\]{}|]/g,z=/^\[object .+?Constructor\]$/,F=/^(?:0|[1-9]\d*)$/,B={};B["[object Float32Array]"]=B[P]=B[A]=B[N]=B[T]=B[M]=B[L]=B[j]=B[U]=!0,B[u]=B[c]=B[k]=B[f]=B[C]=B[h]=B[d]=B[p]=B[y]=B[v]=B[_]=B[E]=B[S]=B[O]=B[R]=!1;var H="object"==typeof t&&t&&t.Object===Object&&t,q="object"==typeof self&&self&&self.Object===Object&&self,V=H||q||Function("return this")(),$=n&&!n.nodeType&&n,W=$&&e&&!e.nodeType&&e,K=W&&W.exports===$,G=K&&H.process,Y=function(){try{return G&&G.binding&&G.binding("util")}catch{}}(),Q=Y&&Y.isTypedArray;function J(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var s=e[n];t(s,n,e)&&(o[i++]=s)}return o}function X(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function Z(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function ee(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function te(e){return function(t){return e(t)}}function ne(e,t){return e.has(t)}function re(e,t){return e?.[t]}function ie(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function oe(e,t){return function(n){return e(t(n))}}function se(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var ae=Array.prototype,ue=Function.prototype,ce=Object.prototype,le=V["__core-js_shared__"],fe=ue.toString,he=ce.hasOwnProperty,de=function(){var e=/[^.]+$/.exec(le&&le.keys&&le.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),pe=ce.toString,ge=RegExp("^"+fe.call(he).replace(D,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ye=K?V.Buffer:void 0,ve=V.Symbol,me=V.Uint8Array,_e=ce.propertyIsEnumerable,be=ae.splice,we=ve?ve.toStringTag:void 0,Ee=Object.getOwnPropertySymbols,Se=ye?ye.isBuffer:void 0,Oe=oe(Object.keys,Object),xe=It(V,"DataView"),Ie=It(V,"Map"),Re=It(V,"Promise"),ke=It(V,"Set"),Ce=It(V,"WeakMap"),Pe=It(Object,"create"),Ae=Lt(xe),Ne=Lt(Ie),Te=Lt(Re),Me=Lt(ke),Le=Lt(Ce),je=ve?ve.prototype:void 0,Ue=je?je.valueOf:void 0;function De(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ze(){this.__data__=Pe?Pe(null):{},this.size=0}function Fe(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function Be(e){var t=this.__data__;if(Pe){var n=t[e];return n===i?void 0:n}return he.call(t,e)?t[e]:void 0}function He(e){var t=this.__data__;return Pe?void 0!==t[e]:he.call(t,e)}function qe(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Pe&&void 0===t?i:t,this}function Ve(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function $e(){this.__data__=[],this.size=0}function We(e){var t=this.__data__,n=ht(t,e);return!(n<0||(n==t.length-1?t.pop():be.call(t,n,1),--this.size,0))}function Ke(e){var t=this.__data__,n=ht(t,e);return n<0?void 0:t[n][1]}function Ge(e){return ht(this.__data__,e)>-1}function Ye(e,t){var n=this.__data__,r=ht(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Qe(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Je(){this.size=0,this.__data__={hash:new De,map:new(Ie||Ve),string:new De}}function Xe(e){var t=xt(this,e).delete(e);return this.size-=t?1:0,t}function Ze(e){return xt(this,e).get(e)}function et(e){return xt(this,e).has(e)}function tt(e,t){var n=xt(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function nt(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Qe;++t<n;)this.add(e[t])}function rt(e){return this.__data__.set(e,i),this}function it(e){return this.__data__.has(e)}function ot(e){var t=this.__data__=new Ve(e);this.size=t.size}function st(){this.__data__=new Ve,this.size=0}function at(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function ut(e){return this.__data__.get(e)}function ct(e){return this.__data__.has(e)}function lt(e,t){var n=this.__data__;if(n instanceof Ve){var i=n.__data__;if(!Ie||i.length<r-1)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new Qe(i)}return n.set(e,t),this.size=n.size,this}function ft(e,t){var n=Dt(e),r=!n&&Ut(e),i=!n&&!r&&Ft(e),o=!n&&!r&&!i&&Wt(e),s=n||r||i||o,a=s?ee(e.length,String):[],u=a.length;for(var c in e)(t||he.call(e,c))&&(!s||!("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Pt(c,u)))&&a.push(c);return a}function ht(e,t){for(var n=e.length;n--;)if(jt(e[n][0],t))return n;return-1}function dt(e,t,n){var r=t(e);return Dt(e)?r:X(r,n(e))}function pt(e){return null==e?void 0===e?I:m:we&&we in Object(e)?Rt(e):Mt(e)}function gt(e){return $t(e)&&pt(e)==u}function yt(e,t,n,r,i){return e===t||(null==e||null==t||!$t(e)&&!$t(t)?e!=e&&t!=t:vt(e,t,n,r,yt,i))}function vt(e,t,n,r,i,s){var a=Dt(e),l=Dt(t),f=a?c:Ct(e),h=l?c:Ct(t),d=(f=f==u?_:f)==_,p=(h=h==u?_:h)==_,g=f==h;if(g&&Ft(e)){if(!Ft(t))return!1;a=!0,d=!1}if(g&&!d)return s||(s=new ot),a||Wt(e)?wt(e,t,n,r,i,s):Et(e,t,f,n,r,i,s);if(!(n&o)){var y=d&&he.call(e,"__wrapped__"),v=p&&he.call(t,"__wrapped__");if(y||v){var m=y?e.value():e,b=v?t.value():t;return s||(s=new ot),i(m,b,n,r,s)}}return!!g&&(s||(s=new ot),St(e,t,n,r,i,s))}function mt(e){return!(!Vt(e)||Nt(e))&&(Ht(e)?ge:z).test(Lt(e))}function _t(e){return $t(e)&&qt(e.length)&&!!B[pt(e)]}function bt(e){if(!Tt(e))return Oe(e);var t=[];for(var n in Object(e))he.call(e,n)&&"constructor"!=n&&t.push(n);return t}function wt(e,t,n,r,i,a){var u=n&o,c=e.length,l=t.length;if(c!=l&&!(u&&l>c))return!1;var f=a.get(e);if(f&&a.get(t))return f==t;var h=-1,d=!0,p=n&s?new nt:void 0;for(a.set(e,t),a.set(t,e);++h<c;){var g=e[h],y=t[h];if(r)var v=u?r(y,g,h,t,e,a):r(g,y,h,e,t,a);if(void 0!==v){if(v)continue;d=!1;break}if(p){if(!Z(t,(function(e,t){if(!ne(p,t)&&(g===e||i(g,e,n,r,a)))return p.push(t)}))){d=!1;break}}else if(g!==y&&!i(g,y,n,r,a)){d=!1;break}}return a.delete(e),a.delete(t),d}function Et(e,t,n,r,i,a,u){switch(n){case C:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case k:return!(e.byteLength!=t.byteLength||!a(new me(e),new me(t)));case f:case h:case v:return jt(+e,+t);case d:return e.name==t.name&&e.message==t.message;case E:case O:return e==t+"";case y:var c=ie;case S:var l=r&o;if(c||(c=se),e.size!=t.size&&!l)return!1;var p=u.get(e);if(p)return p==t;r|=s,u.set(e,t);var g=wt(c(e),c(t),r,i,a,u);return u.delete(e),g;case x:if(Ue)return Ue.call(e)==Ue.call(t)}return!1}function St(e,t,n,r,i,s){var a=n&o,u=Ot(e),c=u.length;if(c!=Ot(t).length&&!a)return!1;for(var l=c;l--;){var f=u[l];if(!(a?f in t:he.call(t,f)))return!1}var h=s.get(e);if(h&&s.get(t))return h==t;var d=!0;s.set(e,t),s.set(t,e);for(var p=a;++l<c;){var g=e[f=u[l]],y=t[f];if(r)var v=a?r(y,g,f,t,e,s):r(g,y,f,e,t,s);if(!(void 0===v?g===y||i(g,y,n,r,s):v)){d=!1;break}p||(p="constructor"==f)}if(d&&!p){var m=e.constructor,_=t.constructor;m!=_&&"constructor"in e&&"constructor"in t&&!("function"==typeof m&&m instanceof m&&"function"==typeof _&&_ instanceof _)&&(d=!1)}return s.delete(e),s.delete(t),d}function Ot(e){return dt(e,Kt,kt)}function xt(e,t){var n=e.__data__;return At(t)?n["string"==typeof t?"string":"hash"]:n.map}function It(e,t){var n=re(e,t);return mt(n)?n:void 0}function Rt(e){var t=he.call(e,we),n=e[we];try{e[we]=void 0;var r=!0}catch{}var i=pe.call(e);return r&&(t?e[we]=n:delete e[we]),i}De.prototype.clear=ze,De.prototype.delete=Fe,De.prototype.get=Be,De.prototype.has=He,De.prototype.set=qe,Ve.prototype.clear=$e,Ve.prototype.delete=We,Ve.prototype.get=Ke,Ve.prototype.has=Ge,Ve.prototype.set=Ye,Qe.prototype.clear=Je,Qe.prototype.delete=Xe,Qe.prototype.get=Ze,Qe.prototype.has=et,Qe.prototype.set=tt,nt.prototype.add=nt.prototype.push=rt,nt.prototype.has=it,ot.prototype.clear=st,ot.prototype.delete=at,ot.prototype.get=ut,ot.prototype.has=ct,ot.prototype.set=lt;var kt=Ee?function(e){return null==e?[]:(e=Object(e),J(Ee(e),(function(t){return _e.call(e,t)})))}:Gt,Ct=pt;function Pt(e,t){return!!(t=t??a)&&("number"==typeof e||F.test(e))&&e>-1&&e%1==0&&e<t}function At(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}function Nt(e){return!!de&&de in e}function Tt(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||ce)}function Mt(e){return pe.call(e)}function Lt(e){if(null!=e){try{return fe.call(e)}catch{}try{return e+""}catch{}}return""}function jt(e,t){return e===t||e!=e&&t!=t}(xe&&Ct(new xe(new ArrayBuffer(1)))!=C||Ie&&Ct(new Ie)!=y||Re&&Ct(Re.resolve())!=b||ke&&Ct(new ke)!=S||Ce&&Ct(new Ce)!=R)&&(Ct=function(e){var t=pt(e),n=t==_?e.constructor:void 0,r=n?Lt(n):"";if(r)switch(r){case Ae:return C;case Ne:return y;case Te:return b;case Me:return S;case Le:return R}return t});var Ut=gt(function(){return arguments}())?gt:function(e){return $t(e)&&he.call(e,"callee")&&!_e.call(e,"callee")},Dt=Array.isArray;function zt(e){return null!=e&&qt(e.length)&&!Ht(e)}var Ft=Se||Yt;function Bt(e,t){return yt(e,t)}function Ht(e){if(!Vt(e))return!1;var t=pt(e);return t==p||t==g||t==l||t==w}function qt(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=a}function Vt(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function $t(e){return null!=e&&"object"==typeof e}var Wt=Q?te(Q):_t;function Kt(e){return zt(e)?ft(e):bt(e)}function Gt(){return[]}function Yt(){return!1}e.exports=Bt}(hf,hf.exports);var df=hf.exports,pf=Object.defineProperty,gf=Object.getOwnPropertySymbols,yf=Object.prototype.hasOwnProperty,vf=Object.prototype.propertyIsEnumerable,mf=(e,t,n)=>t in e?pf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_f=(e,t)=>{for(var n in t||(t={}))yf.call(t,n)&&mf(e,n,t[n]);if(gf)for(var n of gf(t))vf.call(t,n)&&mf(e,n,t[n]);return e};function bf(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==n[s])throw new TypeError(o+" is ambiguous");n[s]=i}var a=e.length,u=e.charAt(0),c=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var n=0,r=0,i=0,o=t.length;i!==o&&0===t[i];)i++,n++;for(var s=(o-i)*l+1>>>0,c=new Uint8Array(s);i!==o;){for(var f=t[i],h=0,d=s-1;(0!==f||h<r)&&-1!==d;d--,h++)f+=256*c[d]>>>0,c[d]=f%a>>>0,f=f/a>>>0;if(0!==f)throw new Error("Non-zero carry");r=h,i++}for(var p=s-r;p!==s&&0===c[p];)p++;for(var g=u.repeat(n);p<s;++p)g+=e.charAt(c[p]);return g}function h(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var r=0,i=0;e[t]===u;)r++,t++;for(var o=(e.length-t)*c+1>>>0,s=new Uint8Array(o);e[t];){var l=n[e.charCodeAt(t)];if(255===l)return;for(var f=0,h=o-1;(0!==l||f<i)&&-1!==h;h--,f++)l+=a*s[h]>>>0,s[h]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=f,t++}if(" "!==e[t]){for(var d=o-i;d!==o&&0===s[d];)d++;for(var p=new Uint8Array(r+(o-d)),g=r;d!==o;)p[g++]=s[d++];return p}}}function d(e){var n=h(e);if(n)return n;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:h,decode:d}}var wf=bf;const Ef=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},Sf=e=>(new TextEncoder).encode(e),Of=e=>(new TextDecoder).decode(e);class xf{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class If{constructor(e,t,n){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return kf(this,e)}}class Rf{constructor(e){this.decoders=e}or(e){return kf(this,e)}decode(e){const t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const kf=(e,t)=>new Rf(_f(_f({},e.decoders||{[e.prefix]:e}),t.decoders||{[t.prefix]:t}));class Cf{constructor(e,t,n,r){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=r,this.encoder=new xf(e,t,n),this.decoder=new If(e,t,r)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Pf=({name:e,prefix:t,encode:n,decode:r})=>new Cf(e,t,n,r),Af=({prefix:e,name:t,alphabet:n})=>{const{encode:r,decode:i}=wf(n,t);return Pf({prefix:e,name:t,encode:r,decode:e=>Ef(i(e))})},Nf=(e,t,n,r)=>{const i={};for(let e=0;e<t.length;++e)i[t[e]]=e;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*n/8|0);let a=0,u=0,c=0;for(let t=0;t<o;++t){const o=i[e[t]];if(void 0===o)throw new SyntaxError(`Non-${r} character`);u=u<<n|o,a+=n,a>=8&&(a-=8,s[c++]=255&u>>a)}if(a>=n||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return s},Tf=(e,t,n)=>{const r="="===t[t.length-1],i=(1<<n)-1;let o="",s=0,a=0;for(let r=0;r<e.length;++r)for(a=a<<8|e[r],s+=8;s>n;)s-=n,o+=t[i&a>>s];if(s&&(o+=t[i&a<<n-s]),r)for(;o.length*n&7;)o+="=";return o},Mf=({name:e,prefix:t,bitsPerChar:n,alphabet:r})=>Pf({prefix:t,name:e,encode:e=>Tf(e,r,n),decode:t=>Nf(t,r,n,e)}),Lf=Pf({prefix:"\0",name:"identity",encode:e=>Of(e),decode:e=>Sf(e)});var jf=Object.freeze({__proto__:null,identity:Lf});const Uf=Mf({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Df=Object.freeze({__proto__:null,base2:Uf});const zf=Mf({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ff=Object.freeze({__proto__:null,base8:zf});const Bf=Af({prefix:"9",name:"base10",alphabet:"0123456789"});var Hf=Object.freeze({__proto__:null,base10:Bf});const qf=Mf({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Vf=Mf({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var $f=Object.freeze({__proto__:null,base16:qf,base16upper:Vf});const Wf=Mf({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Kf=Mf({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Gf=Mf({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Yf=Mf({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Qf=Mf({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Jf=Mf({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Xf=Mf({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zf=Mf({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),eh=Mf({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var th=Object.freeze({__proto__:null,base32:Wf,base32upper:Kf,base32pad:Gf,base32padupper:Yf,base32hex:Qf,base32hexupper:Jf,base32hexpad:Xf,base32hexpadupper:Zf,base32z:eh});const nh=Af({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),rh=Af({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ih=Object.freeze({__proto__:null,base36:nh,base36upper:rh});const oh=Af({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),sh=Af({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ah=Object.freeze({__proto__:null,base58btc:oh,base58flickr:sh});const uh=Mf({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ch=Mf({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),lh=Mf({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),fh=Mf({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var hh=Object.freeze({__proto__:null,base64:uh,base64pad:ch,base64url:lh,base64urlpad:fh});const dh=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),ph=dh.reduce(((e,t,n)=>(e[n]=t,e)),[]),gh=dh.reduce(((e,t,n)=>(e[t.codePointAt(0)]=n,e)),[]);function yh(e){return e.reduce(((e,t)=>e+=ph[t]),"")}function vh(e){const t=[];for(const n of e){const e=gh[n.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${n}`);t.push(e)}return new Uint8Array(t)}const mh=Pf({prefix:"🚀",name:"base256emoji",encode:yh,decode:vh});var _h=Object.freeze({__proto__:null,base256emoji:mh}),bh=Oh,wh=128,Eh=-128,Sh=Math.pow(2,31);function Oh(e,t,n){t=t||[];for(var r=n=n||0;e>=Sh;)t[n++]=255&e|wh,e/=128;for(;e&Eh;)t[n++]=255&e|wh,e>>>=7;return t[n]=0|e,Oh.bytes=n-r+1,t}var xh=kh,Ih=128,Rh=127;function kh(e,t){var n,r=0,i=0,o=t=t||0,s=e.length;do{if(o>=s)throw kh.bytes=0,new RangeError("Could not decode varint");n=e[o++],r+=i<28?(n&Rh)<<i:(n&Rh)*Math.pow(2,i),i+=7}while(n>=Ih);return kh.bytes=o-t,r}var Ch=Math.pow(2,7),Ph=Math.pow(2,14),Ah=Math.pow(2,21),Nh=Math.pow(2,28),Th=Math.pow(2,35),Mh=Math.pow(2,42),Lh=Math.pow(2,49),jh=Math.pow(2,56),Uh=Math.pow(2,63),Dh={encode:bh,decode:xh,encodingLength:function(e){return e<Ch?1:e<Ph?2:e<Ah?3:e<Nh?4:e<Th?5:e<Mh?6:e<Lh?7:e<jh?8:e<Uh?9:10}};const zh=(e,t,n=0)=>(Dh.encode(e,t,n),t),Fh=e=>Dh.encodingLength(e),Bh=(e,t)=>{const n=t.byteLength,r=Fh(e),i=r+Fh(n),o=new Uint8Array(i+n);return zh(e,o,0),zh(n,o,r),o.set(t,i),new Hh(e,n,t,o)};class Hh{constructor(e,t,n,r){this.code=e,this.size=t,this.digest=n,this.bytes=r}}const qh=({name:e,code:t,encode:n})=>new Vh(e,t,n);class Vh{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Bh(this.code,t):t.then((e=>Bh(this.code,e)))}throw Error("Unknown type, must be binary type")}}const $h=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Wh=qh({name:"sha2-256",code:18,encode:$h("SHA-256")}),Kh=qh({name:"sha2-512",code:19,encode:$h("SHA-512")});var Gh=Object.freeze({__proto__:null,sha256:Wh,sha512:Kh});const Yh=0,Qh="identity",Jh=Ef;var Xh=Object.freeze({__proto__:null,identity:{code:Yh,name:Qh,encode:Jh,digest:e=>Bh(Yh,Jh(e))}});new TextEncoder,new TextDecoder;const Zh=_f(_f(_f(_f(_f(_f(_f(_f(_f(_f({},jf),Df),Ff),Hf),$f),th),ih),ah),hh),_h);function ed(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function td(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?ed(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function nd(e,t,n,r){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:n},decoder:{decode:r}}}_f(_f({},Gh),Xh);const rd=nd("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),id=nd("ascii","a",(e=>{let t="a";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}),(e=>{const t=td((e=e.substring(1)).length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t})),od=_f({utf8:rd,"utf-8":rd,hex:Zh.base16,latin1:id,ascii:id,binary:id},Zh);function sd(e,t="utf8"){const n=od[t];if(!n)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?n.decoder.decode(`${n.prefix}${e}`):ed(globalThis.Buffer.from(e,"utf-8"))}const ad="wc",ud=2,cd="core",ld=`${ad}@2:${cd}:`,fd={name:cd,logger:"error"},hd={database:":memory:"},dd="crypto",pd="client_ed25519_seed",gd=We.ONE_DAY,yd="keychain",vd="0.3",md="messages",_d="0.3",bd=We.SIX_HOURS,wd="publisher",Ed="irn",Sd="error",Od="wss://relay.walletconnect.com",xd="wss://relay.walletconnect.org",Id="relayer",Rd={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},kd="_subscription",Cd={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Pd=We.ONE_SECOND/2,Ad="2.9.2",Nd=1e4,Td="0.3",Md="WALLETCONNECT_CLIENT_ID",Ld={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},jd="subscription",Ud="0.3",Dd=1e3*We.FIVE_SECONDS,zd="pairing",Fd="0.3",Bd={wc_pairingDelete:{req:{ttl:We.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:We.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:We.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:We.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:We.ONE_DAY,prompt:!1,tag:0},res:{ttl:We.ONE_DAY,prompt:!1,tag:0}}},Hd={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},qd="history",Vd="0.3",$d="expirer",Wd={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Kd="0.3",Gd="verify-api",Yd="https://verify.walletconnect.com";class Qd{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=yd,this.version=vd,this.initialized=!1,this.storagePrefix=ld,this.init=async()=>{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}},this.has=e=>(this.isInitialized(),this.keychain.has(e)),this.set=async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()},this.get=e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=lc("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t},this.del=async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()},this.core=e,this.logger=un.generateChildLogger(t,this.name)}get context(){return un.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,ku(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Cu(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Jd{constructor(e,t,n){this.core=e,this.logger=t,this.name=dd,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=e=>(this.isInitialized(),this.keychain.has(e)),this.getClientId=async()=>(this.isInitialized(),as(fs(await this.getClientSeed()).publicKey)),this.generateKeyPair=()=>{this.isInitialized();const e=Ga();return this.setPrivateKey(e.publicKey,e.privateKey)},this.signJWT=async e=>{this.isInitialized();const t=fs(await this.getClientSeed()),n=Ya();return await hs(n,e,gd,t)},this.generateSharedKey=(e,t,n)=>{this.isInitialized();const r=Qa(this.getPrivateKey(e),t);return this.setSymKey(r,n)},this.setSymKey=async(e,t)=>{this.isInitialized();const n=t||Ja(e);return await this.keychain.set(n,e),n},this.deleteKeyPair=async e=>{this.isInitialized(),await this.keychain.del(e)},this.deleteSymKey=async e=>{this.isInitialized(),await this.keychain.del(e)},this.encode=async(e,t,n)=>{this.isInitialized();const r=su(n),i=sr(t);if(au(r)){const t=r.senderPublicKey,n=r.receiverPublicKey;e=await this.generateSharedKey(t,n)}const o=this.getSymKey(e),{type:s,senderPublicKey:a}=r;return tu({type:s,symKey:o,message:i,senderPublicKey:a})},this.decode=async(e,t,n)=>{this.isInitialized();const r=ou(t,n);if(au(r)){const t=r.receiverPublicKey,n=r.senderPublicKey;e=await this.generateSharedKey(t,n)}try{const n=this.getSymKey(e);return or(nu({symKey:n,encoded:t}))}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}},this.getPayloadType=e=>eu(iu(e).type),this.getPayloadSenderPublicKey=e=>{const t=iu(e);return t.senderPublicKey?is(t.senderPublicKey,za):void 0},this.core=e,this.logger=un.generateChildLogger(t,this.name),this.keychain=n||new Qd(this.core,this.logger)}get context(){return un.getLoggerContext(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(pd)}catch{e=Ya(),await this.keychain.set(pd,e)}return sd(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Xd extends Gn{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=md,this.version=_d,this.initialized=!1,this.storagePrefix=ld,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}},this.set=async(e,t)=>{this.isInitialized();const n=Xa(t);let r=this.messages.get(e);return typeof r>"u"&&(r={}),typeof r[n]<"u"||(r[n]=t,this.messages.set(e,r),await this.persist()),n},this.get=e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t},this.has=(e,t)=>(this.isInitialized(),typeof this.get(e)[Xa(t)]<"u"),this.del=async e=>{this.isInitialized(),this.messages.delete(e),await this.persist()},this.logger=un.generateChildLogger(e,this.name),this.core=t}get context(){return un.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,ku(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Cu(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Zd extends Yn{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new o.exports.EventEmitter,this.name=wd,this.queue=new Map,this.publishTimeout=We.toMiliseconds(We.TEN_SECONDS),this.queueTimeout=We.toMiliseconds(We.FIVE_SECONDS),this.needsTransportRestart=!1,this.publish=async(e,t,n)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:n}});try{const r=n?.ttl||bd,i=Hu(n),o=n?.prompt||!1,s=n?.tag||0,a=n?.id||zl().toString(),u={topic:e,message:t,opts:{ttl:r,relay:i,prompt:o,tag:s,id:a}},c=setTimeout((()=>this.queue.set(a,u)),this.queueTimeout);try{await await Au(this.rpcPublish(e,t,r,i,o,s,a),this.publishTimeout),clearTimeout(c),this.relayer.events.emit(Rd.publish,u)}catch{return this.logger.debug("Publishing Payload stalled"),void(this.needsTransportRestart=!0)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:n}})}catch(e){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(e),e}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.relayer=e,this.logger=un.generateChildLogger(t,this.name),this.registerEventListeners()}get context(){return un.getLoggerContext(this.logger)}rpcPublish(e,t,n,r,i,o,s){var a,u,c,l;const f={method:qu(r.protocol).publish,params:{topic:e,message:t,ttl:n,prompt:i,tag:o},id:s};return pc(null==(a=f.params)?void 0:a.prompt)&&(null==(u=f.params)||delete u.prompt),pc(null==(c=f.params)?void 0:c.tag)&&(null==(l=f.params)||delete l.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:f}),this.relayer.request(f)}onPublish(e){this.queue.delete(e)}checkQueue(){this.queue.forEach((async e=>{const{topic:t,message:n,opts:r}=e;await this.publish(t,n,r)}))}registerEventListeners(){this.relayer.core.heartbeat.on(_e.HEARTBEAT_EVENTS.pulse,(()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(Rd.connection_stalled);this.checkQueue()})),this.relayer.on(Rd.message_ack,(e=>{this.onPublish(e.id.toString())}))}}class ep{constructor(){this.map=new Map,this.set=(e,t)=>{const n=this.get(e);this.exists(e,t)||this.map.set(e,[...n,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const n=this.get(e);if(!this.exists(e,t))return;const r=n.filter((e=>e!==t));r.length?this.map.set(e,r):this.map.delete(e)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var tp=Object.defineProperty,np=Object.defineProperties,rp=Object.getOwnPropertyDescriptors,ip=Object.getOwnPropertySymbols,op=Object.prototype.hasOwnProperty,sp=Object.prototype.propertyIsEnumerable,ap=(e,t,n)=>t in e?tp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,up=(e,t)=>{for(var n in t||(t={}))op.call(t,n)&&ap(e,n,t[n]);if(ip)for(var n of ip(t))sp.call(t,n)&&ap(e,n,t[n]);return e},cp=(e,t)=>np(e,rp(t));class lp extends Xn{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new ep,this.events=new o.exports.EventEmitter,this.name=jd,this.version=Ud,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ld,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const n=Hu(t),r={topic:e,relay:n};this.pending.set(e,r);const i=await this.rpcSubscribe(e,n);return this.onSubscribe(i,r),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}}),i}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}},this.unsubscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)},this.isSubscribed=async e=>!!this.topics.includes(e)||await new Promise(((t,n)=>{const r=new We.Watch;r.start(this.pendingSubscriptionWatchLabel);const i=setInterval((()=>{!this.pending.has(e)&&this.topics.includes(e)&&(clearInterval(i),r.stop(this.pendingSubscriptionWatchLabel),t(!0)),r.elapsed(this.pendingSubscriptionWatchLabel)>=Dd&&(clearInterval(i),r.stop(this.pendingSubscriptionWatchLabel),n(new Error("Subscription resolution timeout")))}),this.pollingInterval)})).catch((()=>!1)),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=un.generateChildLogger(t,this.name),this.clientId=""}get context(){return un.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let n=!1;try{n=this.getSubscription(e).topic===t}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const n=this.topicMap.get(e);await Promise.all(n.map((async n=>await this.unsubscribeById(e,n,t))))}async unsubscribeById(e,t,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:n}});try{const r=Hu(n);await this.rpcUnsubscribe(e,t,r);const i=fc("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,i),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:n}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t){const n={method:qu(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{await await Au(this.relayer.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Rd.connection_stalled)}return Xa(e+this.clientId)}async rpcBatchSubscribe(e){if(!e.length)return;const t={method:qu(e[0].relay.protocol).batchSubscribe,params:{topics:e.map((e=>e.topic))}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{return await await Au(this.relayer.request(t),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(Rd.connection_stalled)}}rpcUnsubscribe(e,t,n){const r={method:qu(n.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r}),this.relayer.request(r)}onSubscribe(e,t){this.setSubscription(e,cp(up({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach((e=>{this.setSubscription(e.id,up({},e)),this.pending.delete(e.topic)}))}async onUnsubscribe(e,t,n){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,n),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t))}addSubscription(e,t){this.subscriptions.set(e,up({},t)),this.topicMap.set(t.topic,e),this.events.emit(Ld.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:t}=lc("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(Ld.deleted,cp(up({},n),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Ld.sync)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t<e;t++){const e=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(e)}}this.events.emit(Ld.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=lc("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);hc(t)&&this.onBatchSubscribe(t.map(((t,n)=>cp(up({},e[n]),{id:t}))))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(this.relayer.transportExplicitlyClosed)return;const e=[];this.pending.forEach((t=>{e.push(t)})),await this.batchSubscribe(e)}registerEventListeners(){this.relayer.core.heartbeat.on(_e.HEARTBEAT_EVENTS.pulse,(async()=>{await this.checkPending()})),this.relayer.on(Rd.connect,(async()=>{await this.onConnect()})),this.relayer.on(Rd.disconnect,(()=>{this.onDisconnect()})),this.events.on(Ld.created,(async e=>{const t=Ld.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})),this.events.on(Ld.deleted,(async e=>{const t=Ld.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){this.restartInProgress&&await new Promise((e=>{const t=setInterval((()=>{this.restartInProgress||(clearInterval(t),e())}),this.pollingInterval)}))}}var fp=Object.defineProperty,hp=Object.getOwnPropertySymbols,dp=Object.prototype.hasOwnProperty,pp=Object.prototype.propertyIsEnumerable,gp=(e,t,n)=>t in e?fp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yp=(e,t)=>{for(var n in t||(t={}))dp.call(t,n)&&gp(e,n,t[n]);if(hp)for(var n of hp(t))pp.call(t,n)&&gp(e,n,t[n]);return e};class vp extends Qn{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new o.exports.EventEmitter,this.name=Id,this.transportExplicitlyClosed=!1,this.initialized=!1,this.reconnecting=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.request=async e=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(e)}catch(e){throw this.logger.debug("Failed to Publish Request"),this.logger.error(e),e}},this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?un.generateChildLogger(e.logger,this.name):un.pino(un.getDefaultLoggerOptions({level:e.logger||Sd})),this.messages=new Xd(this.logger,e.core),this.subscriber=new lp(this,this.logger),this.publisher=new Zd(this,this.logger),this.relayUrl=e?.relayUrl||Od,this.projectId=e.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${xd}...`),await this.restartTransport(xd)}this.registerEventListeners(),this.initialized=!0,setTimeout((async()=>{0===this.subscriber.topics.length&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)}),Nd)}get context(){return un.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,t,n){this.isInitialized(),await this.publisher.publish(e,t,n),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now()})}async subscribe(e,t){var n;this.isInitialized();let r=(null==(n=this.subscriber.topicMap.get(e))?void 0:n[0])||"";return r||(await Promise.all([new Promise((t=>{this.subscriber.once(Ld.created,(n=>{n.topic===e&&t()}))})),new Promise((async n=>{r=await this.subscriber.subscribe(e,t),n()}))]),r)}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportClose(){this.transportExplicitlyClosed=!0,this.connected&&(await this.provider.disconnect(),this.events.emit(Rd.transport_closed))}async transportOpen(e){if(this.transportExplicitlyClosed=!1,!this.reconnecting){this.relayUrl=e||this.relayUrl,this.reconnecting=!0;try{await Promise.all([new Promise((e=>{this.initialized||e(),this.subscriber.once(Ld.resubscribed,(()=>{e()}))})),await Promise.race([new Promise((async(e,t)=>{await Au(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`).catch((e=>t(e))).then((()=>e())).finally((()=>this.removeListener(Rd.transport_closed,this.rejectTransportOpen)))})),new Promise((e=>this.once(Rd.transport_closed,this.rejectTransportOpen)))])])}catch(e){this.logger.error(e);const t=e;if(!this.isConnectionStalled(t.message))throw e;this.events.emit(Rd.transport_closed)}finally{this.reconnecting=!1}}}async restartTransport(e){this.transportExplicitlyClosed||this.reconnecting||(this.relayUrl=e||this.relayUrl,this.connected&&await Promise.all([new Promise((e=>{this.provider.once(Cd.disconnect,(()=>{e()}))})),this.transportClose()]),await this.createProvider(),await this.transportOpen())}isConnectionStalled(e){return this.staleConnectionErrors.some((t=>e.includes(t)))}rejectTransportOpen(){throw new Error("Attempt to connect to relay via `transportOpen` has stalled. Retrying...")}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new sf(new ff(Iu({sdkVersion:Ad,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:n}=e;await this.messages.set(t,n)}async shouldIgnoreMessageEvent(e){const{topic:t,message:n}=e;if(!n||0===n.length)return this.logger.debug(`Ignoring invalid/empty message: ${n}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;const r=this.messages.has(t,n);return r&&this.logger.debug(`Ignoring duplicate message: ${n}`),r}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),tf(e)){if(!e.method.endsWith(kd))return;const t=e.params,{topic:n,message:r,publishedAt:i}=t.data,o={topic:n,message:r,publishedAt:i};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(yp({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else nf(e)&&this.events.emit(Rd.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Rd.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=Bl(e.id,!0);await this.provider.connection.send(t)}registerProviderListeners(){this.provider.on(Cd.payload,(e=>this.onProviderPayload(e))),this.provider.on(Cd.connect,(()=>{this.events.emit(Rd.connect)})),this.provider.on(Cd.disconnect,(()=>{this.onProviderDisconnect()})),this.provider.on(Cd.error,(e=>{this.logger.error(e),this.events.emit(Rd.error,e)}))}registerEventListeners(){this.events.on(Rd.connection_stalled,(async()=>{await this.restartTransport()}))}onProviderDisconnect(){this.events.emit(Rd.disconnect),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout((async()=>{await this.restartTransport()}),We.toMiliseconds(Pd))}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(!this.connected){if(this.connecting)return await new Promise((e=>{const t=setInterval((()=>{this.connected&&(clearInterval(t),e())}),this.connectionStatusPollingInterval)}));await this.restartTransport()}}}var mp=Object.defineProperty,_p=Object.getOwnPropertySymbols,bp=Object.prototype.hasOwnProperty,wp=Object.prototype.propertyIsEnumerable,Ep=(e,t,n)=>t in e?mp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sp=(e,t)=>{for(var n in t||(t={}))bp.call(t,n)&&Ep(e,n,t[n]);if(_p)for(var n of _p(t))wp.call(t,n)&&Ep(e,n,t[n]);return e};class Op extends Jn{constructor(e,t,n,r=ld,i=void 0){super(e,t,n,r),this.core=e,this.logger=t,this.name=n,this.map=new Map,this.version=Td,this.cached=[],this.initialized=!1,this.storagePrefix=ld,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>{this.getKey&&null!==e&&!pc(e)?this.map.set(this.getKey(e),e):wc(e)?this.map.set(e.id,e):Ec(e)&&this.map.set(e.topic,e)})),this.cached=[],this.initialized=!0)},this.set=async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())},this.get=e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e)),this.getAll=e=>(this.isInitialized(),e?this.values.filter((t=>Object.keys(e).every((n=>df(t[n],e[n]))))):this.values),this.update=async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const n=Sp(Sp({},this.getData(e)),t);this.map.set(e,n),await this.persist()},this.delete=async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),await this.persist())},this.logger=un.generateChildLogger(t,this.name),this.storagePrefix=r,this.getKey=i}get context(){return un.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){const{message:t}=lc("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:e}=lc("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}}class xp{constructor(e,t){this.core=e,this.logger=t,this.name=zd,this.version=Fd,this.events=new o.exports,this.initialized=!1,this.storagePrefix=ld,this.ignoredPayloadTypes=[qa],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]},this.create=async()=>{this.isInitialized();const e=Ya(),t=await this.core.crypto.setSymKey(e),n=ju(We.FIVE_MINUTES),r={protocol:Ed},i={topic:t,expiry:n,relay:r,active:!1},o=ec({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:e,relay:r});return await this.pairings.set(t,i),await this.core.relayer.subscribe(t),this.core.expirer.set(t,n),{topic:t,uri:o}},this.pair=async e=>{this.isInitialized(),this.isValidPair(e);const{topic:t,symKey:n,relay:r}=Ju(e.uri);if(this.pairings.keys.includes(t))throw new Error(`Pairing already exists: ${t}`);if(this.core.crypto.hasKeys(t))throw new Error(`Keychain already exists: ${t}`);const i=ju(We.FIVE_MINUTES),o={topic:t,relay:r,expiry:i,active:!1};return await this.pairings.set(t,o),await this.core.crypto.setSymKey(n,t),await this.core.relayer.subscribe(t,{relay:r}),this.core.expirer.set(t,i),e.activatePairing&&await this.activate({topic:t}),o},this.activate=async({topic:e})=>{this.isInitialized();const t=ju(We.THIRTY_DAYS);await this.pairings.update(e,{active:!0,expiry:t}),this.core.expirer.set(e,t)},this.ping=async e=>{this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:n,resolve:r,reject:i}=Pu();this.events.once(Du("pairing_ping",e),(({error:e})=>{e?i(e):r()})),await n()}},this.updateExpiry=async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})},this.updateMetadata=async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",fc("USER_DISCONNECTED")),await this.deletePairing(t))},this.sendRequest=async(e,t,n)=>{const r=Fl(t,n),i=await this.core.crypto.encode(e,r),o=Bd[t].req;return this.core.history.set(e,r),this.core.relayer.publish(e,i,o),r.id},this.sendResult=async(e,t,n)=>{const r=Bl(e,n),i=await this.core.crypto.encode(t,r),o=await this.core.history.get(t,e),s=Bd[o.request.method].res;await this.core.relayer.publish(t,i,s),await this.core.history.resolve(r)},this.sendError=async(e,t,n)=>{const r=Hl(e,n),i=await this.core.crypto.encode(t,r),o=await this.core.history.get(t,e),s=Bd[o.request.method]?Bd[o.request.method].res:Bd.unregistered_method.res;await this.core.relayer.publish(t,i,s),await this.core.history.resolve(r)},this.deletePairing=async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,fc("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])},this.cleanup=async()=>{const e=this.pairings.getAll().filter((e=>Uu(e.expiry)));await Promise.all(e.map((e=>this.deletePairing(e.topic))))},this.onRelayEventRequest=e=>{const{topic:t,payload:n}=e;switch(n.method){case"wc_pairingPing":return this.onPairingPingRequest(t,n);case"wc_pairingDelete":return this.onPairingDeleteRequest(t,n);default:return this.onUnknownRpcMethodRequest(t,n)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:n}=e,r=(await this.core.history.get(t,n.id)).request.method;return"wc_pairingPing"===r?this.onPairingPingResponse(t,n):this.onUnknownRpcMethodResponse(r)},this.onPairingPingRequest=async(e,t)=>{const{id:n}=t;try{this.isValidPing({topic:e}),await this.sendResult(n,e,!0),this.events.emit("pairing_ping",{id:n,topic:e})}catch(t){await this.sendError(n,e,t),this.logger.error(t)}},this.onPairingPingResponse=(e,t)=>{const{id:n}=t;setTimeout((()=>{rf(t)?this.events.emit(Du("pairing_ping",n),{}):of(t)&&this.events.emit(Du("pairing_ping",n),{error:t.error})}),500)},this.onPairingDeleteRequest=async(e,t)=>{const{id:n}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit("pairing_delete",{id:n,topic:e})}catch(t){await this.sendError(n,e,t),this.logger.error(t)}},this.onUnknownRpcMethodRequest=async(e,t)=>{const{id:n,method:r}=t;try{if(this.registeredMethods.includes(r))return;const t=fc("WC_METHOD_UNSUPPORTED",r);await this.sendError(n,e,t),this.logger.error(t)}catch(t){await this.sendError(n,e,t),this.logger.error(t)}},this.onUnknownRpcMethodResponse=e=>{this.registeredMethods.includes(e)||this.logger.error(fc("WC_METHOD_UNSUPPORTED",e))},this.isValidPair=e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`pair() params: ${e}`);throw new Error(t)}if(!bc(e.uri)){const{message:t}=lc("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw new Error(t)}},this.isValidPing=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidDisconnect=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidPairingTopic=async e=>{if(!gc(e,!1)){const{message:t}=lc("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=lc("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Uu(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=lc("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}},this.core=e,this.logger=un.generateChildLogger(t,this.name),this.pairings=new Op(this.core,this.logger,this.name,this.storagePrefix)}get context(){return un.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Rd.message,(async e=>{const{topic:t,message:n}=e;if(!this.pairings.keys.includes(t)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;const r=await this.core.crypto.decode(t,n);try{tf(r)?(this.core.history.set(t,r),this.onRelayEventRequest({topic:t,payload:r})):nf(r)&&(await this.core.history.resolve(r),await this.onRelayEventResponse({topic:t,payload:r}),this.core.history.delete(t,r.id))}catch(e){this.logger.error(e)}}))}registerExpirerEvents(){this.core.expirer.on(Wd.expired,(async e=>{const{topic:t}=Lu(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit("pairing_expire",{topic:t}))}))}}class Ip extends Kn{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new o.exports.EventEmitter,this.name=qd,this.version=Vd,this.cached=[],this.initialized=!1,this.storagePrefix=ld,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.records.set(e.id,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(e,t,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:n}),this.records.has(t.id))return;const r={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:n,expiry:ju(We.THIRTY_DAYS)};this.records.set(r.id,r),this.events.emit(Hd.created,r)},this.resolve=async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=of(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.events.emit(Hd.updated,t))},this.get=async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t)),this.delete=(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach((n=>{if(n.topic===e){if(typeof t<"u"&&n.id!==t)return;this.records.delete(n.id),this.events.emit(Hd.deleted,n)}}))},this.exists=async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=un.generateChildLogger(t,this.name)}get context(){return un.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach((t=>{if(typeof t.response<"u")return;const n={topic:t.topic,request:Fl(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(n)})),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:t}=lc("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Hd.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=lc("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Hd.created,(e=>{const t=Hd.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(Hd.updated,(e=>{const t=Hd.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(Hd.deleted,(e=>{const t=Hd.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.core.heartbeat.on(_e.HEARTBEAT_EVENTS.pulse,(()=>{this.cleanup()}))}cleanup(){try{this.records.forEach((e=>{We.toMiliseconds(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.delete(e.topic,e.id))}))}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Rp extends Zn{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new o.exports.EventEmitter,this.name=$d,this.version=Kd,this.cached=[],this.initialized=!1,this.storagePrefix=ld,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.expirations.set(e.target,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}},this.set=(e,t)=>{this.isInitialized();const n=this.formatTarget(e),r={target:n,expiry:t};this.expirations.set(n,r),this.checkExpiry(n,r),this.events.emit(Wd.created,{target:n,expiration:r})},this.get=e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)},this.del=e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),n=this.getExpiration(t);this.expirations.delete(t),this.events.emit(Wd.deleted,{target:t,expiration:n})}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=un.generateChildLogger(t,this.name)}get context(){return un.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return Tu(e);if("number"==typeof e)return Mu(e);const{message:t}=lc("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Wd.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=lc("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=lc("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:n}=t;We.toMiliseconds(n)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Wd.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach(((e,t)=>this.checkExpiry(t,e)))}registerEventListeners(){this.core.heartbeat.on(_e.HEARTBEAT_EVENTS.pulse,(()=>this.checkExpirations())),this.events.on(Wd.created,(e=>{const t=Wd.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(Wd.expired,(e=>{const t=Wd.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(Wd.deleted,(e=>{const t=Wd.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}}class kp extends er{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.name=Gd,this.initialized=!1,this.init=async e=>{mu()||!_u()||(this.verifyUrl=e?.verifyUrl||Yd,await this.createIframe())},this.register=async e=>{var t;if(this.initialized||await this.init(),this.iframe)try{null==(t=this.iframe.contentWindow)||t.postMessage(e.attestationId,this.verifyUrl),this.logger.info(`postMessage sent: ${e.attestationId} ${this.verifyUrl}`)}catch{}},this.resolve=async e=>{var t;if(this.isDevEnv)return"";this.logger.info(`resolving attestation: ${e.attestationId}`);const n=this.startAbortTimer(We.FIVE_SECONDS),r=await fetch(`${this.verifyUrl}/attestation/${e.attestationId}`,{signal:this.abortController.signal});return clearTimeout(n),200===r.status?null==(t=await r.json())?void 0:t.origin:""},this.createIframe=async()=>{try{await Promise.race([new Promise(((e,t)=>{if(document.getElementById(Gd))return e();const n=document.createElement("iframe");n.setAttribute("id",Gd),n.setAttribute("src",`${this.verifyUrl}/${this.projectId}`),n.style.display="none",n.addEventListener("load",(()=>{this.initialized=!0,e()})),n.addEventListener("error",(e=>{t(e)})),document.body.append(n),this.iframe=n})),new Promise((e=>{setTimeout((()=>e("iframe load timeout")),We.toMiliseconds(We.ONE_SECOND/2))}))])}catch(e){this.logger.error(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.error(e)}},this.logger=un.generateChildLogger(t,this.name),this.verifyUrl=Yd,this.abortController=new AbortController,this.isDevEnv=vu()&&process.env.IS_VITEST}get context(){return un.getLoggerContext(this.logger)}startAbortTimer(e){return setTimeout((()=>this.abortController.abort()),We.toMiliseconds(e))}}var Cp=Object.defineProperty,Pp=Object.getOwnPropertySymbols,Ap=Object.prototype.hasOwnProperty,Np=Object.prototype.propertyIsEnumerable,Tp=(e,t,n)=>t in e?Cp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mp=(e,t)=>{for(var n in t||(t={}))Ap.call(t,n)&&Tp(e,n,t[n]);if(Pp)for(var n of Pp(t))Np.call(t,n)&&Tp(e,n,t[n]);return e};class Lp extends Wn{constructor(e){super(e),this.protocol=ad,this.version=ud,this.name=cd,this.events=new o.exports.EventEmitter,this.initialized=!1,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Od;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:un.pino(un.getDefaultLoggerOptions({level:e?.logger||fd.logger}));this.logger=un.generateChildLogger(t,this.name),this.heartbeat=new _e.HeartBeat,this.crypto=new Jd(this,this.logger,e?.keychain),this.history=new Ip(this,this.logger),this.expirer=new Rp(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new me(Mp(Mp({},hd),e?.storageOptions)),this.relayer=new vp({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new xp(this,this.logger),this.verify=new kp(this.projectId||"",this.logger)}static async init(e){const t=new Lp(e);await t.initialize();const n=await t.crypto.getClientId();return await t.storage.setItem(Md,n),t}get context(){return un.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const jp=Lp,Up="wc",Dp=2,zp="client",Fp=`${Up}@${Dp}:${zp}:`,Bp={name:zp,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},Hp="WALLETCONNECT_DEEPLINK_CHOICE",qp="proposal",Vp="Proposal expired",$p="session",Wp=We.SEVEN_DAYS,Kp="engine",Gp={wc_sessionPropose:{req:{ttl:We.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:We.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:We.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:We.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:We.ONE_DAY,prompt:!1,tag:1104},res:{ttl:We.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:We.ONE_DAY,prompt:!1,tag:1106},res:{ttl:We.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:We.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:We.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:We.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:We.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:We.ONE_DAY,prompt:!1,tag:1112},res:{ttl:We.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:We.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:We.THIRTY_SECONDS,prompt:!1,tag:1115}}},Yp={min:We.FIVE_MINUTES,max:We.SEVEN_DAYS},Qp={idle:"idle",active:"active"},Jp="request",Xp=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var Zp=Object.defineProperty,eg=Object.defineProperties,tg=Object.getOwnPropertyDescriptors,ng=Object.getOwnPropertySymbols,rg=Object.prototype.hasOwnProperty,ig=Object.prototype.propertyIsEnumerable,og=(e,t,n)=>t in e?Zp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sg=(e,t)=>{for(var n in t||(t={}))rg.call(t,n)&&og(e,n,t[n]);if(ng)for(var n of ng(t))ig.call(t,n)&&og(e,n,t[n]);return e},ag=(e,t)=>eg(e,tg(t));class ug extends nr{constructor(e){super(e),this.name=Kp,this.events=new o.exports,this.initialized=!1,this.ignoredPayloadTypes=[qa],this.requestQueue={state:Qp.idle,requests:[]},this.requestQueueDelay=We.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(Gp)}),this.initialized=!0,setTimeout((()=>{this.requestQueue.requests=this.getPendingSessionRequests(),this.processRequestQueue()}),We.toMiliseconds(this.requestQueueDelay)))},this.connect=async e=>{this.isInitialized();const t=ag(sg({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:n,requiredNamespaces:r,optionalNamespaces:i,sessionProperties:o,relays:s}=t;let a,u=n,c=!1;if(u&&(c=this.client.core.pairing.pairings.get(u).active),!u||!c){const{topic:e,uri:t}=await this.client.core.pairing.create();u=e,a=t}const l=await this.client.core.crypto.generateKeyPair(),f=sg({requiredNamespaces:r,optionalNamespaces:i,relays:s??[{protocol:Ed}],proposer:{publicKey:l,metadata:this.client.metadata}},o&&{sessionProperties:o}),{reject:h,resolve:d,done:p}=Pu(We.FIVE_MINUTES,Vp);if(this.events.once(Du("session_connect"),(async({error:e,session:t})=>{if(e)h(e);else if(t){t.self.publicKey=l;const e=ag(sg({},t),{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces});await this.client.session.set(t.topic,e),await this.setExpiry(t.topic,t.expiry),u&&await this.client.core.pairing.updateMetadata({topic:u,metadata:t.peer.metadata}),d(e)}})),!u){const{message:e}=lc("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(e)}const g=await this.sendRequest(u,"wc_sessionPropose",f),y=ju(We.FIVE_MINUTES);return await this.setProposal(g,sg({id:g,expiry:y},f)),{uri:a,approval:p}},this.pair=async e=>(this.isInitialized(),await this.client.core.pairing.pair(e)),this.approve=async e=>{this.isInitialized(),await this.isValidApprove(e);const{id:t,relayProtocol:n,namespaces:r,sessionProperties:i}=e,o=this.client.proposal.get(t);let{pairingTopic:s,proposer:a,requiredNamespaces:u,optionalNamespaces:c}=o;s=s||"",dc(u)||(u=oc(r,"approve()"));const l=await this.client.core.crypto.generateKeyPair(),f=a.publicKey,h=await this.client.core.crypto.generateSharedKey(l,f);s&&t&&(await this.client.core.pairing.updateMetadata({topic:s,metadata:a.metadata}),await this.sendResult(t,s,{relay:{protocol:n??"irn"},responderPublicKey:l}),await this.client.proposal.delete(t,fc("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:s}));const d=sg({relay:{protocol:n??"irn"},namespaces:r,requiredNamespaces:u,optionalNamespaces:c,pairingTopic:s,controller:{publicKey:l,metadata:this.client.metadata},expiry:ju(Wp)},i&&{sessionProperties:i});await this.client.core.relayer.subscribe(h),await this.sendRequest(h,"wc_sessionSettle",d);const p=ag(sg({},d),{topic:h,pairingTopic:s,acknowledged:!1,self:d.controller,peer:{publicKey:a.publicKey,metadata:a.metadata},controller:l});return await this.client.session.set(h,p),await this.setExpiry(h,ju(Wp)),{topic:h,acknowledged:()=>new Promise((e=>setTimeout((()=>e(this.client.session.get(h))),500)))}},this.reject=async e=>{this.isInitialized(),await this.isValidReject(e);const{id:t,reason:n}=e,{pairingTopic:r}=this.client.proposal.get(t);r&&(await this.sendError(t,r,n),await this.client.proposal.delete(t,fc("USER_DISCONNECTED")))},this.update=async e=>{this.isInitialized(),await this.isValidUpdate(e);const{topic:t,namespaces:n}=e,r=await this.sendRequest(t,"wc_sessionUpdate",{namespaces:n}),{done:i,resolve:o,reject:s}=Pu();return this.events.once(Du("session_update",r),(({error:e})=>{e?s(e):o()})),await this.client.session.update(t,{namespaces:n}),{acknowledged:i}},this.extend=async e=>{this.isInitialized(),await this.isValidExtend(e);const{topic:t}=e,n=await this.sendRequest(t,"wc_sessionExtend",{}),{done:r,resolve:i,reject:o}=Pu();return this.events.once(Du("session_extend",n),(({error:e})=>{e?o(e):i()})),await this.setExpiry(t,ju(Wp)),{acknowledged:r}},this.request=async e=>{this.isInitialized(),await this.isValidRequest(e);const{chainId:t,request:n,topic:r,expiry:i}=e,o=await this.sendRequest(r,"wc_sessionRequest",{request:n,chainId:t},i),{done:s,resolve:a,reject:u}=Pu(i);return this.events.once(Du("session_request",o),(({error:e,result:t})=>{e?u(e):a(t)})),this.client.events.emit("session_request_sent",{topic:r,request:n,chainId:t,id:o}),Fu({id:o,topic:r,wcDeepLink:await this.client.core.storage.getItem(Hp)}),await s()},this.respond=async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:n}=e,{id:r}=n;rf(n)?await this.sendResult(r,t,n.result):of(n)&&await this.sendError(r,t,n.error),this.cleanupAfterResponse(e)},this.ping=async e=>{this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=await this.sendRequest(t,"wc_sessionPing",{}),{done:n,resolve:r,reject:i}=Pu();this.events.once(Du("session_ping",e),(({error:e})=>{e?i(e):r()})),await n()}else this.client.core.pairing.pairings.keys.includes(t)&&await this.client.core.pairing.ping({topic:t})},this.emit=async e=>{this.isInitialized(),await this.isValidEmit(e);const{topic:t,event:n,chainId:r}=e;await this.sendRequest(t,"wc_sessionEvent",{event:n,chainId:r})},this.disconnect=async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=zl().toString();let n;const r=t=>{t?.id.toString()===e&&(this.client.core.relayer.events.removeListener(Rd.message_ack,r),n())};await Promise.all([new Promise((e=>{n=e,this.client.core.relayer.on(Rd.message_ack,r)})),this.sendRequest(t,"wc_sessionDelete",fc("USER_DISCONNECTED"),void 0,e)]),await this.deleteSession(t)}else await this.client.core.pairing.disconnect({topic:t})},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter((t=>vc(t,e)))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter((n=>{var r,i;return(null==(r=n.peerMetadata)?void 0:r.url)&&(null==(i=n.peerMetadata)?void 0:i.url)===e.peer.metadata.url&&n.topic&&n.topic!==t.topic}));if(0===n.length)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map((e=>this.client.core.pairing.disconnect({topic:e.topic})))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}},this.deleteSession=async(e,t)=>{const{self:n}=this.client.session.get(e);await this.client.core.relayer.unsubscribe(e),this.client.session.delete(e,fc("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(n.publicKey)&&await this.client.core.crypto.deleteKeyPair(n.publicKey),this.client.core.crypto.keychain.has(e)&&await this.client.core.crypto.deleteSymKey(e),t||this.client.core.expirer.del(e),this.client.core.storage.removeItem(Hp).catch((e=>this.client.logger.warn(e)))},this.deleteProposal=async(e,t)=>{await Promise.all([this.client.proposal.delete(e,fc("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)])},this.deletePendingSessionRequest=async(e,t,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),n?Promise.resolve():this.client.core.expirer.del(e)]),this.requestQueue.requests=this.requestQueue.requests.filter((t=>t.id!==e)),n&&(this.requestQueue.state=Qp.idle)},this.setExpiry=async(e,t)=>{this.client.session.keys.includes(e)&&await this.client.session.update(e,{expiry:t}),this.client.core.expirer.set(e,t)},this.setProposal=async(e,t)=>{await this.client.proposal.set(e,t),this.client.core.expirer.set(e,t.expiry)},this.setPendingSessionRequest=async e=>{const t=Gp.wc_sessionRequest.req.ttl,{id:n,topic:r,params:i}=e;await this.client.pendingRequest.set(n,{id:n,topic:r,params:i}),t&&this.client.core.expirer.set(n,ju(t))},this.sendRequest=async(e,t,n,r,i)=>{const o=Fl(t,n);if(_u()&&Xp.includes(t)){const e=Xa(JSON.stringify(o));await this.client.core.verify.register({attestationId:e})}const s=await this.client.core.crypto.encode(e,o),a=Gp[t].req;return r&&(a.ttl=r),i&&(a.id=i),this.client.core.history.set(e,o),this.client.core.relayer.publish(e,s,a),o.id},this.sendResult=async(e,t,n)=>{const r=Bl(e,n),i=await this.client.core.crypto.encode(t,r),o=await this.client.core.history.get(t,e),s=Gp[o.request.method].res;this.client.core.relayer.publish(t,i,s),await this.client.core.history.resolve(r)},this.sendError=async(e,t,n)=>{const r=Hl(e,n),i=await this.client.core.crypto.encode(t,r),o=await this.client.core.history.get(t,e),s=Gp[o.request.method].res;this.client.core.relayer.publish(t,i,s),await this.client.core.history.resolve(r)},this.cleanup=async()=>{const e=[],t=[];this.client.session.getAll().forEach((t=>{Uu(t.expiry)&&e.push(t.topic)})),this.client.proposal.getAll().forEach((e=>{Uu(e.expiry)&&t.push(e.id)})),await Promise.all([...e.map((e=>this.deleteSession(e))),...t.map((e=>this.deleteProposal(e)))])},this.onRelayEventRequest=e=>{const{topic:t,payload:n}=e,r=n.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeRequest(t,n);case"wc_sessionSettle":return this.onSessionSettleRequest(t,n);case"wc_sessionUpdate":return this.onSessionUpdateRequest(t,n);case"wc_sessionExtend":return this.onSessionExtendRequest(t,n);case"wc_sessionPing":return this.onSessionPingRequest(t,n);case"wc_sessionDelete":return this.onSessionDeleteRequest(t,n);case"wc_sessionRequest":return this.onSessionRequest(t,n);case"wc_sessionEvent":return this.onSessionEventRequest(t,n);default:return this.client.logger.info(`Unsupported request method ${r}`)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:n}=e,r=(await this.client.core.history.get(t,n.id)).request.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeResponse(t,n);case"wc_sessionSettle":return this.onSessionSettleResponse(t,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,n);case"wc_sessionExtend":return this.onSessionExtendResponse(t,n);case"wc_sessionPing":return this.onSessionPingResponse(t,n);case"wc_sessionRequest":return this.onSessionRequestResponse(t,n);default:return this.client.logger.info(`Unsupported response method ${r}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:t}=e,{message:n}=lc("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.onSessionProposeRequest=async(e,t)=>{const{params:n,id:r}=t;try{this.isValidConnect(sg({},t.params));const i=ju(We.FIVE_MINUTES),o=sg({id:r,pairingTopic:e,expiry:i},n);await this.setProposal(r,o);const s=Xa(JSON.stringify(t)),a=await this.getVerifyContext(s,o.proposer.metadata);this.client.events.emit("session_proposal",{id:r,params:o,verifyContext:a})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionProposeResponse=async(e,t)=>{const{id:n}=t;if(rf(t)){const{result:r}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:r});const i=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:i});const o=i.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const s=r.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:s});const a=await this.client.core.crypto.generateSharedKey(o,s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:a});const u=await this.client.core.relayer.subscribe(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:u}),await this.client.core.pairing.activate({topic:e})}else of(t)&&(await this.client.proposal.delete(n,fc("USER_DISCONNECTED")),this.events.emit(Du("session_connect"),{error:t.error}))},this.onSessionSettleRequest=async(e,t)=>{const{id:n,params:r}=t;try{this.isValidSessionSettleRequest(r);const{relay:n,controller:i,expiry:o,namespaces:s,requiredNamespaces:a,optionalNamespaces:u,sessionProperties:c,pairingTopic:l}=t.params,f=sg({topic:e,relay:n,expiry:o,namespaces:s,acknowledged:!0,pairingTopic:l,requiredNamespaces:a,optionalNamespaces:u,controller:i.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:i.publicKey,metadata:i.metadata}},c&&{sessionProperties:c});await this.sendResult(t.id,e,!0),this.events.emit(Du("session_connect"),{session:f}),this.cleanupDuplicatePairings(f)}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionSettleResponse=async(e,t)=>{const{id:n}=t;rf(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(Du("session_approve",n),{})):of(t)&&(await this.client.session.delete(e,fc("USER_DISCONNECTED")),this.events.emit(Du("session_approve",n),{error:t.error}))},this.onSessionUpdateRequest=async(e,t)=>{const{params:n,id:r}=t;try{this.isValidUpdate(sg({topic:e},n)),await this.client.session.update(e,{namespaces:n.namespaces}),await this.sendResult(r,e,!0),this.client.events.emit("session_update",{id:r,topic:e,params:n})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionUpdateResponse=(e,t)=>{const{id:n}=t;rf(t)?this.events.emit(Du("session_update",n),{}):of(t)&&this.events.emit(Du("session_update",n),{error:t.error})},this.onSessionExtendRequest=async(e,t)=>{const{id:n}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,ju(Wp)),await this.sendResult(n,e,!0),this.client.events.emit("session_extend",{id:n,topic:e})}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionExtendResponse=(e,t)=>{const{id:n}=t;rf(t)?this.events.emit(Du("session_extend",n),{}):of(t)&&this.events.emit(Du("session_extend",n),{error:t.error})},this.onSessionPingRequest=async(e,t)=>{const{id:n}=t;try{this.isValidPing({topic:e}),await this.sendResult(n,e,!0),this.client.events.emit("session_ping",{id:n,topic:e})}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionPingResponse=(e,t)=>{const{id:n}=t;setTimeout((()=>{rf(t)?this.events.emit(Du("session_ping",n),{}):of(t)&&this.events.emit(Du("session_ping",n),{error:t.error})}),500)},this.onSessionDeleteRequest=async(e,t)=>{const{id:n}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),await Promise.all([new Promise((t=>{this.client.core.relayer.once(Rd.publish,(async()=>{t(await this.deleteSession(e))}))})),this.sendResult(n,e,!0)]),this.client.events.emit("session_delete",{id:n,topic:e})}catch(e){this.client.logger.error(e)}},this.onSessionRequest=async(e,t)=>{const{id:n,params:r}=t;try{this.isValidRequest(sg({topic:e},r)),await this.setPendingSessionRequest({id:n,topic:e,params:r}),this.addRequestToQueue({id:n,topic:e,params:r}),await this.processRequestQueue()}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionRequestResponse=(e,t)=>{const{id:n}=t;rf(t)?this.events.emit(Du("session_request",n),{result:t.result}):of(t)&&this.events.emit(Du("session_request",n),{error:t.error})},this.onSessionEventRequest=async(e,t)=>{const{id:n,params:r}=t;try{this.isValidEmit(sg({topic:e},r)),this.client.events.emit("session_event",{id:n,topic:e,params:r})}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.addRequestToQueue=e=>{this.requestQueue.requests.push(e)},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout((()=>{this.requestQueue.state=Qp.idle,this.processRequestQueue()}),We.toMiliseconds(this.requestQueueDelay))},this.processRequestQueue=async()=>{if(this.requestQueue.state===Qp.active)return void this.client.logger.info("session request queue is already active.");const e=this.requestQueue.requests[0];if(e)try{const{id:t,topic:n,params:r}=e,i=Xa(JSON.stringify({id:t,params:r})),o=this.client.session.get(n),s=await this.getVerifyContext(i,o.peer.metadata);this.requestQueue.state=Qp.active,this.client.events.emit("session_request",{id:t,topic:n,params:r,verifyContext:s})}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")},this.isValidConnect=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:n,optionalNamespaces:r,sessionProperties:i,relays:o}=e;if(pc(t)||await this.isValidPairingTopic(t),!jc(o,!0)){const{message:e}=lc("MISSING_OR_INVALID",`connect() relays: ${o}`);throw new Error(e)}!pc(n)&&0!==dc(n)&&this.validateNamespaces(n,"requiredNamespaces"),!pc(r)&&0!==dc(r)&&this.validateNamespaces(r,"optionalNamespaces"),pc(i)||this.validateSessionProps(i,"sessionProperties")},this.validateNamespaces=(e,t)=>{const n=Tc(e,"connect()",t);if(n)throw new Error(n.message)},this.isValidApprove=async e=>{if(!Dc(e))throw new Error(lc("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:n,relayProtocol:r,sessionProperties:i}=e;await this.isValidProposalId(t);const o=this.client.proposal.get(t),s=Mc(n,"approve()");if(s)throw new Error(s.message);const a=Wc(o.requiredNamespaces,n,"approve()");if(a)throw new Error(a.message);if(!gc(r,!0)){const{message:e}=lc("MISSING_OR_INVALID",`approve() relayProtocol: ${r}`);throw new Error(e)}pc(i)||this.validateSessionProps(i,"sessionProperties")},this.isValidReject=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:n}=e;if(await this.isValidProposalId(t),!zc(n)){const{message:e}=lc("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(e)}},this.isValidSessionSettleRequest=e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:n,namespaces:r,expiry:i}=e;if(!Lc(t)){const{message:e}=lc("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const o=Sc(n,"onSessionSettleRequest()");if(o)throw new Error(o.message);const s=Mc(r,"onSessionSettleRequest()");if(s)throw new Error(s.message);if(Uu(i)){const{message:e}=lc("EXPIRED","onSessionSettleRequest()");throw new Error(e)}},this.isValidUpdate=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:n}=e;await this.isValidSessionTopic(t);const r=this.client.session.get(t),i=Mc(n,"update()");if(i)throw new Error(i.message);const o=Wc(r.requiredNamespaces,n,"update()");if(o)throw new Error(o.message)},this.isValidExtend=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionTopic(t)},this.isValidRequest=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:n,chainId:r,expiry:i}=e;await this.isValidSessionTopic(t);const{namespaces:o}=this.client.session.get(t);if(!qc(o,r)){const{message:e}=lc("MISSING_OR_INVALID",`request() chainId: ${r}`);throw new Error(e)}if(!Fc(n)){const{message:e}=lc("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(e)}if(!Vc(o,r,n.method)){const{message:e}=lc("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(e)}if(i&&!Qc(i,Yp)){const{message:e}=lc("MISSING_OR_INVALID",`request() expiry: ${i}. Expiry must be a number (in seconds) between ${Yp.min} and ${Yp.max}`);throw new Error(e)}},this.isValidRespond=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:t,response:n}=e;if(await this.isValidSessionTopic(t),!Bc(n)){const{message:e}=lc("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(e)}},this.isValidPing=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.isValidEmit=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:n,chainId:r}=e;await this.isValidSessionTopic(t);const{namespaces:i}=this.client.session.get(t);if(!qc(i,r)){const{message:e}=lc("MISSING_OR_INVALID",`emit() chainId: ${r}`);throw new Error(e)}if(!Hc(n)){const{message:e}=lc("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(e)}if(!$c(i,r,n.name)){const{message:e}=lc("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(e)}},this.isValidDisconnect=async e=>{if(!Dc(e)){const{message:t}=lc("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.getVerifyContext=async(e,t)=>{const n={verified:{verifyUrl:t.verifyUrl||"",validation:"UNKNOWN",origin:t.url||""}};try{const r=await this.client.core.verify.resolve({attestationId:e,verifyUrl:t.verifyUrl});r&&(n.verified.origin=r,n.verified.validation=r===t.url?"VALID":"INVALID")}catch(e){this.client.logger.error(e)}return this.client.logger.info(`Verify context: ${JSON.stringify(n)}`),n},this.validateSessionProps=(e,t)=>{Object.values(e).forEach((e=>{if(!gc(e,!1)){const{message:n}=lc("MISSING_OR_INVALID",`${t} must be in Record<string, string> format. Received: ${JSON.stringify(e)}`);throw new Error(n)}}))}}isInitialized(){if(!this.initialized){const{message:e}=lc("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(Rd.message,(async e=>{const{topic:t,message:n}=e;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(n)))return;const r=await this.client.core.crypto.decode(t,n);try{tf(r)?(this.client.core.history.set(t,r),this.onRelayEventRequest({topic:t,payload:r})):nf(r)?(await this.client.core.history.resolve(r),await this.onRelayEventResponse({topic:t,payload:r}),this.client.core.history.delete(t,r.id)):this.onRelayEventUnknownPayload({topic:t,payload:r})}catch(e){this.client.logger.error(e)}}))}registerExpirerEvents(){this.client.core.expirer.on(Wd.expired,(async e=>{const{topic:t,id:n}=Lu(e.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,lc("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession(t,!0),this.client.events.emit("session_expire",{topic:t})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n}))}))}isValidPairingTopic(e){if(!gc(e,!1)){const{message:t}=lc("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=lc("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Uu(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=lc("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!gc(e,!1)){const{message:t}=lc("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(!this.client.session.keys.includes(e)){const{message:t}=lc("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Uu(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:t}=lc("EXPIRED",`session topic: ${e}`);throw new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if(gc(e,!1)){const{message:t}=lc("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=lc("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if(!Uc(e)){const{message:t}=lc("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=lc("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Uu(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:t}=lc("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class cg extends Op{constructor(e,t){super(e,t,qp,Fp),this.core=e,this.logger=t}}class lg extends Op{constructor(e,t){super(e,t,$p,Fp),this.core=e,this.logger=t}}class fg extends Op{constructor(e,t){super(e,t,Jp,Fp,(e=>e.id)),this.core=e,this.logger=t}}class hg extends tr{constructor(e){super(e),this.protocol=Up,this.version=Dp,this.name=Bp.name,this.events=new o.exports.EventEmitter,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.removeAllListeners=e=>this.events.removeAllListeners(e),this.connect=async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}},this.pair=async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}},this.approve=async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}},this.reject=async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}},this.update=async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}},this.extend=async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}},this.request=async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}},this.respond=async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}},this.ping=async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}},this.emit=async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}},this.disconnect=async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}},this.find=e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.name=e?.name||Bp.name,this.metadata=e?.metadata||Eu();const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:un.pino(un.getDefaultLoggerOptions({level:e?.logger||Bp.logger}));this.core=e?.core||new jp(e),this.logger=un.generateChildLogger(t,this.name),this.session=new lg(this.core,this.logger),this.proposal=new cg(this.core,this.logger),this.pendingRequest=new fg(this.core,this.logger),this.engine=new ug(this)}static async init(e){const t=new hg(e);return await t.initialize(),t}get context(){return un.getLoggerContext(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const dg="error",pg="wss://relay.walletconnect.com",gg="wc@2:universal_provider:",yg="https://rpc.walletconnect.com/v1",vg={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var mg,_g,bg={exports:{}};
|
322
322
|
/**
|
323
323
|
* @license
|
324
324
|
* Lodash <https://lodash.com/>
|