(()=>{"use strict";var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};function t(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function r(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function n(e,t){var r,n,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(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=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++,n=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],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}Object.create;function i(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function s(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function a(e){return this instanceof a?(this.v=e,this):new a(e)}function c(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),o=[];return n={},s("next"),s("throw"),s("return"),n[Symbol.asyncIterator]=function(){return this},n;function s(e){i[e]&&(n[e]=function(t){return new Promise((function(r,n){o.push([e,t,r,n])>1||c(e,t)}))})}function c(e,t){try{(r=i[e](t)).value instanceof a?Promise.resolve(r.value.v).then(u,l):d(o[0][2],r)}catch(e){d(o[0][3],e)}var r}function u(e){c("next",e)}function l(e){c("throw",e)}function d(e,t){e(t),o.shift(),o.length&&c(o[0][0],o[0][1])}}function u(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=i(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,i,(t=e[r](t)).done,t.value)}))}}}Object.create;function l(e){return"function"==typeof e}function d(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var h=d((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n  "):"",this.name="UnsubscriptionError",this.errors=t}}));function p(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var f=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,r,n,a;if(!this.closed){this.closed=!0;var c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var u=i(c),d=u.next();!d.done;d=u.next()){d.value.remove(this)}}catch(t){e={error:t}}finally{try{d&&!d.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}else c.remove(this);var p=this.initialTeardown;if(l(p))try{p()}catch(e){a=e instanceof h?e.errors:[e]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var v=i(f),g=v.next();!g.done;g=v.next()){var b=g.value;try{m(b)}catch(e){a=null!=a?a:[],e instanceof h?a=s(s([],o(a)),o(e.errors)):a.push(e)}}}catch(e){r={error:e}}finally{try{g&&!g.done&&(n=v.return)&&n.call(v)}finally{if(r)throw r.error}}}if(a)throw new h(a)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)m(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&p(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&p(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),v=f.EMPTY;function g(e){return e instanceof f||e&&"closed"in e&&l(e.remove)&&l(e.add)&&l(e.unsubscribe)}function m(e){l(e)?e():e.unsubscribe()}var b={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},y={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=y.delegate;return(null==i?void 0:i.setTimeout)?i.setTimeout.apply(i,s([e,t],o(r))):setTimeout.apply(void 0,s([e,t],o(r)))},clearTimeout:function(e){var t=y.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function w(e){y.setTimeout((function(){var t=b.onUnhandledError;if(!t)throw e;t(e)}))}function A(){}var S=x("C",void 0,void 0);function x(e,t,r){return{kind:e,value:t,error:r}}var E=null;function T(e){if(b.useDeprecatedSynchronousErrorHandling){var t=!E;if(t&&(E={errorThrown:!1,error:null}),e(),t){var r=E,n=r.errorThrown,i=r.error;if(E=null,n)throw i}}else e()}var I=function(e){function r(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,g(t)&&t.add(r)):r.destination=_,r}return t(r,e),r.create=function(e,t,r){return new V(e,t,r)},r.prototype.next=function(e){this.isStopped?D(function(e){return x("N",e,void 0)}(e),this):this._next(e)},r.prototype.error=function(e){this.isStopped?D(x("E",void 0,e),this):(this.isStopped=!0,this._error(e))},r.prototype.complete=function(){this.isStopped?D(S,this):(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(e){this.destination.next(e)},r.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(f),k=Function.prototype.bind;function C(e,t){return k.call(e,t)}var P=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){M(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){M(e)}else M(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){M(e)}},e}(),V=function(e){function r(t,r,n){var i,o,s=e.call(this)||this;l(t)||!t?i={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:s&&b.useDeprecatedNextContext?((o=Object.create(t)).unsubscribe=function(){return s.unsubscribe()},i={next:t.next&&C(t.next,o),error:t.error&&C(t.error,o),complete:t.complete&&C(t.complete,o)}):i=t;return s.destination=new P(i),s}return t(r,e),r}(I);function M(e){var t;b.useDeprecatedSynchronousErrorHandling?(t=e,b.useDeprecatedSynchronousErrorHandling&&E&&(E.errorThrown=!0,E.error=t)):w(e)}function D(e,t){var r=b.onStoppedNotification;r&&y.setTimeout((function(){return r(e,t)}))}var _={closed:!0,next:A,error:function(e){throw e},complete:A},O="function"==typeof Symbol&&Symbol.observable||"@@observable";function L(e){return e}function z(e){return 0===e.length?L:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var N=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,i=this,o=(n=e)&&n instanceof I||function(e){return e&&l(e.next)&&l(e.error)&&l(e.complete)}(n)&&g(n)?e:new V(e,t,r);return T((function(){var e=i,t=e.operator,r=e.source;o.add(t?t.call(o,r):r?i._subscribe(o):i._trySubscribe(o))})),o},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=B(t))((function(t,n){var i=new V({next:function(t){try{e(t)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t});r.subscribe(i)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[O]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return z(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=B(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function B(e){var t;return null!==(t=null!=e?e:b.Promise)&&void 0!==t?t:Promise}var R=d((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),U=function(e){function r(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return t(r,e),r.prototype.lift=function(e){var t=new H(this,this);return t.operator=e,t},r.prototype._throwIfClosed=function(){if(this.closed)throw new R},r.prototype.next=function(e){var t=this;T((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=i(t.currentObservers),s=o.next();!s.done;s=o.next()){s.value.next(e)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},r.prototype.error=function(e){var t=this;T((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},r.prototype.complete=function(){var e=this;T((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},r.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},r.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,i=r.isStopped,o=r.observers;return n||i?v:(this.currentObservers=null,o.push(e),new f((function(){t.currentObservers=null,p(o,e)})))},r.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,i=t.isStopped;r?e.error(n):i&&e.complete()},r.prototype.asObservable=function(){var e=new N;return e.source=this,e},r.create=function(e,t){return new H(e,t)},r}(N),H=function(e){function r(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return t(r,e),r.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},r.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},r.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},r.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:v},r}(U);function j(e){return e&&l(e.schedule)}function F(e){return e[e.length-1]}function W(e){return j(F(e))?e.pop():void 0}var q=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function Q(e){return l(null==e?void 0:e.then)}function X(e){return l(e[O])}function G(e){return Symbol.asyncIterator&&l(null==e?void 0:e[Symbol.asyncIterator])}function $(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var Y="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function J(e){return l(null==e?void 0:e[Y])}function K(e){return c(this,arguments,(function(){var t,r,i;return n(this,(function(n){switch(n.label){case 0:t=e.getReader(),n.label=1;case 1:n.trys.push([1,,9,10]),n.label=2;case 2:return[4,a(t.read())];case 3:return r=n.sent(),i=r.value,r.done?[4,a(void 0)]:[3,5];case 4:return[2,n.sent()];case 5:return[4,a(i)];case 6:return[4,n.sent()];case 7:return n.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}function Z(e){return l(null==e?void 0:e.getReader)}function ee(e){if(e instanceof N)return e;if(null!=e){if(X(e))return o=e,new N((function(e){var t=o[O]();if(l(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(q(e))return n=e,new N((function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()}));if(Q(e))return r=e,new N((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,w)}));if(G(e))return te(e);if(J(e))return t=e,new N((function(e){var r,n;try{for(var o=i(t),s=o.next();!s.done;s=o.next()){var a=s.value;if(e.next(a),e.closed)return}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()}));if(Z(e))return te(K(e))}var t,r,n,o;throw $(e)}function te(e){return new N((function(t){(function(e,t){var i,o,s,a;return r(this,void 0,void 0,(function(){var r,c;return n(this,(function(n){switch(n.label){case 0:n.trys.push([0,5,6,11]),i=u(e),n.label=1;case 1:return[4,i.next()];case 2:if((o=n.sent()).done)return[3,4];if(r=o.value,t.next(r),t.closed)return[2];n.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=n.sent(),s={error:c},[3,11];case 6:return n.trys.push([6,,9,10]),o&&!o.done&&(a=i.return)?[4,a.call(i)]:[3,8];case 7:n.sent(),n.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function re(e,t,r,n,i){void 0===n&&(n=0),void 0===i&&(i=!1);var o=t.schedule((function(){r(),i?e.add(this.schedule(null,n)):this.unsubscribe()}),n);if(e.add(o),!i)return o}function ne(e){return function(t){if(function(e){return l(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function ie(e,t,r,n,i){return new oe(e,t,r,n,i)}var oe=function(e){function r(t,r,n,i,o,s){var a=e.call(this,t)||this;return a.onFinalize=o,a.shouldUnsubscribe=s,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return t(r,e),r.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},r}(I);function se(e,t){return void 0===t&&(t=0),ne((function(r,n){r.subscribe(ie(n,(function(r){return re(n,e,(function(){return n.next(r)}),t)}),(function(){return re(n,e,(function(){return n.complete()}),t)}),(function(r){return re(n,e,(function(){return n.error(r)}),t)})))}))}function ae(e,t){return void 0===t&&(t=0),ne((function(r,n){n.add(e.schedule((function(){return r.subscribe(n)}),t))}))}function ce(e,t){if(!e)throw new Error("Iterable cannot be null");return new N((function(r){re(r,t,(function(){var n=e[Symbol.asyncIterator]();re(r,t,(function(){n.next().then((function(e){e.done?r.complete():r.next(e.value)}))}),0,!0)}))}))}function ue(e,t){if(null!=e){if(X(e))return function(e,t){return ee(e).pipe(ae(t),se(t))}(e,t);if(q(e))return function(e,t){return new N((function(r){var n=0;return t.schedule((function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())}))}))}(e,t);if(Q(e))return function(e,t){return ee(e).pipe(ae(t),se(t))}(e,t);if(G(e))return ce(e,t);if(J(e))return function(e,t){return new N((function(r){var n;return re(r,t,(function(){n=e[Y](),re(r,t,(function(){var e,t,i;try{t=(e=n.next()).value,i=e.done}catch(e){return void r.error(e)}i?r.complete():r.next(t)}),0,!0)})),function(){return l(null==n?void 0:n.return)&&n.return()}}))}(e,t);if(Z(e))return function(e,t){return ce(K(e),t)}(e,t)}throw $(e)}function le(e,t){return t?ue(e,t):ee(e)}function de(e,t,r){var n=l(e)||t||r?{next:e,error:t,complete:r}:e;return n?ne((function(e,t){var r;null===(r=n.subscribe)||void 0===r||r.call(n);var i=!0;e.subscribe(ie(t,(function(e){var r;null===(r=n.next)||void 0===r||r.call(n,e),t.next(e)}),(function(){var e;i=!1,null===(e=n.complete)||void 0===e||e.call(n),t.complete()}),(function(e){var r;i=!1,null===(r=n.error)||void 0===r||r.call(n,e),t.error(e)}),(function(){var e,t;i&&(null===(e=n.unsubscribe)||void 0===e||e.call(n)),null===(t=n.finalize)||void 0===t||t.call(n)})))})):L}function he(e,t){return ne((function(r,n){var i=0;r.subscribe(ie(n,(function(r){n.next(e.call(t,r,i++))})))}))}function pe(e,t){return ne((function(r,n){var i=0;r.subscribe(ie(n,(function(r){return e.call(t,r,i++)&&n.next(r)})))}))}function fe(e,t,r){return void 0===r&&(r=1/0),l(t)?fe((function(r,n){return he((function(e,i){return t(r,e,n,i)}))(ee(e(r,n)))}),r):("number"==typeof t&&(r=t),ne((function(t,n){return function(e,t,r,n,i,o,s,a){var c=[],u=0,l=0,d=!1,h=function(){!d||c.length||u||t.complete()},p=function(e){return u<n?f(e):c.push(e)},f=function(e){o&&t.next(e),u++;var a=!1;ee(r(e,l++)).subscribe(ie(t,(function(e){null==i||i(e),o?p(e):t.next(e)}),(function(){a=!0}),void 0,(function(){if(a)try{u--;for(var e=function(){var e=c.shift();s?re(t,s,(function(){return f(e)})):f(e)};c.length&&u<n;)e();h()}catch(e){t.error(e)}})))};return e.subscribe(ie(t,p,(function(){d=!0,h()}))),function(){null==a||a()}}(t,n,e,r)})))}function ve(e,t=!0){return new Promise(((r,n)=>{var i=new XMLHttpRequest;i.withCredentials=t,i.onreadystatechange=function(){if(4==this.readyState&&200==this.status)try{let e=this.responseXML;e||(e=(new DOMParser).parseFromString(this.responseText,"application/xml")),r(e)}catch(e){n(e)}else 4==this.readyState&&2!=Math.floor(this.status/100)&&n()},i.addEventListener("error",n),i.addEventListener("abort",n),i.open("GET",e),i.send()}))}function ge(e,t=!0){return new Promise(((r,n)=>{const i=new Image;i.src=e,i.addEventListener("load",(()=>r())),t||i.addEventListener("error",(e=>n(e)))}))}function me(e,t,r){if(!r.length||!e||!t)return null;const n={width:e,height:t},i=r.reduce(((e,t)=>{const r=function(e,t){try{const r=Number(t.getAttribute("width")),n=Number(t.getAttribute("height"));return Math.sqrt(Math.pow(e.width-r,2)+Math.pow(e.height-n,2))}catch(e){return console.error("Error calculating element distance",e),999999}}(n,t);if(!e||r<e.distance)return{distance:r,element:t}}),null);return i&&i.element?i.element:null}function be(e,...t){if(1===t.length)return e.getElementsByTagName(t[0]);const r=t.shift(),n=e.getElementsByTagName(r);return n.length<1?n:be(n.item(0),...t)}class ye{constructor(e,t){this.name=e,this.level=t}setLevel(e){this.level=e}debug(...e){"debug"===this.level&&console.log(...[this.name].concat(...e))}info(...e){"info"!==this.level&&"debug"!==this.level||console.log(...[this.name].concat(...e))}warn(...e){"error"!==this.level&&console.log(...[this.name].concat(...e))}error(...e){console.log(...[this.name].concat(...e))}}function we(e){const t={customParams:{},lookupParams:{}};if(t.accountId=e.get(Me.AccountID),e.has(Me.MeasurementID)&&(t.measurementId=e.get(Me.MeasurementID)),e.has(Me.TagID)&&(t.tagId=e.get(Me.TagID)),e.has(Me.EventID)&&(t.eventId=e.get(Me.EventID)),e.has(Me.MediaType)&&(t.mediaType=e.get(Me.MediaType)),e.has(Me.Domain)&&(t.domain=e.get(Me.Domain)),e.has(Me.App)&&(t.app=e.get(Me.App)),e.has(Me.Cost)&&(t.cost=e.get(Me.Cost)),e.has(Me.Revenue)&&(t.revenue=e.get(Me.Revenue)),e.has(Me.Height)&&(t.height=e.get(Me.Height)),e.has(Me.Height)&&(t.width=e.get(Me.Height)),e.has(Me.Size)){t.size=e.get(Me.Size).toLowerCase();const[r,n]=t.size.split("x");t.width=+r,t.height=+n}e.has(Me.Endpoint)&&(t.endpoint=e.get(Me.Endpoint)),e.has(Me.ImageURL)&&(t.imageUrl=e.get(Me.ImageURL)),e.has(Me.CustomModel)&&(t.customModel=e.get(Me.CustomModel)),e.has(Me.QuerySelector)&&(t.querySelector=e.get(Me.QuerySelector)),e.has(Me.IntersectionMode)&&(t.intersectionMode=e.get(Me.IntersectionMode));for(const[r,n]of e)r.startsWith(Me.CustomParamsPrefix)&&(t.customParams[r.replace(Me.CustomParamsPrefix,"")]=n);for(const[r,n]of e)r.startsWith(Me.LookupParamsPrefix)&&(t.lookupParams[r.replace(Me.LookupParamsPrefix,"")]=n);if(e.has(Me.Duration)){const r=parseInt(e.get(Me.Duration));isNaN(r)||(t.duration=r)}return t}function Ae(e,t){return function(e,t,r){return e<t?t:e>r?r:isNaN(e)?t:isFinite(e)?e:r}(e.height*e.width/(t.height*t.width),0,1)}var Se=function(e){function r(t,r){return e.call(this)||this}return t(r,e),r.prototype.schedule=function(e,t){return void 0===t&&(t=0),this},r}(f),xe={setInterval:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=xe.delegate;return(null==i?void 0:i.setInterval)?i.setInterval.apply(i,s([e,t],o(r))):setInterval.apply(void 0,s([e,t],o(r)))},clearInterval:function(e){var t=xe.delegate;return((null==t?void 0:t.clearInterval)||clearInterval)(e)},delegate:void 0},Ee=function(e){function r(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n.pending=!1,n}return t(r,e),r.prototype.schedule=function(e,t){var r;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,i=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(i,n,t)),this.pending=!0,this.delay=t,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(i,this.id,t),this},r.prototype.requestAsyncId=function(e,t,r){return void 0===r&&(r=0),xe.setInterval(e.flush.bind(e,this),r)},r.prototype.recycleAsyncId=function(e,t,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return t;null!=t&&xe.clearInterval(t)},r.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(e,t);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},r.prototype._execute=function(e,t){var r,n=!1;try{this.work(e)}catch(e){n=!0,r=e||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},r.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,p(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},r}(Se),Te={now:function(){return(Te.delegate||Date).now()},delegate:void 0},Ie=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=Te.now,e}(),ke=new(function(e){function r(t,r){void 0===r&&(r=Ie.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return t(r,e),r.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},r}(Ie))(Ee),Ce=ke;function Pe(e,t,r){void 0===e&&(e=0),void 0===r&&(r=Ce);var n=-1;return null!=t&&(j(t)?r=t:n=t),new N((function(t){var i,o=(i=e)instanceof Date&&!isNaN(i)?+e-r.now():e;o<0&&(o=0);var s=0;return r.schedule((function(){t.closed||(t.next(s++),0<=n?this.schedule(void 0,n):t.complete())}),o)}))}var Ve=new N((function(e){return e.complete()}));var Me,De,_e;!function(e){e.AccountID="aid",e.MeasurementID="mid",e.TagID="tid",e.EventID="evid",e.MediaType="mt",e.Domain="d",e.App="a",e.Cost="c",e.Revenue="r",e.Height="h",e.Width="w",e.Size="size",e.Endpoint="endpoint",e.ImageURL="imageUrl",e.CustomModel="customModel",e.QuerySelector="querySelector",e.IntersectionMode="intersectionMode",e.CustomParamsPrefix="cp_",e.LookupParamsPrefix="lp_",e.Duration="duration"}(Me||(Me={})),function(e){e.Start="start",e.End="end"}(De||(De={})),function(e){e.Element="element",e.Viewport="viewport"}(_e||(_e={}));class Oe{constructor(e={}){this.config=e,this.eventId="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})),this.wallTime=new Date,this.histogramBucketSize=.1,this.intersectionObserverThresholds=new Array(11).fill(0).map(((e,t)=>t*this.histogramBucketSize)),this.viewabilityHistogramSum=this.intersectionObserverThresholds.map((e=>({percentageViewable:e,duration:0}))),this.viewabilityHistogramMax=this.intersectionObserverThresholds.map((e=>({percentageViewable:e,duration:0,maxDuration:0}))),this.traceStartTime=Date.now(),this.trace=[],this.percentageViewable=0,this.lastCheckedTime=new Date,this.updateInterval=50,this.onDestroy=new U,this.sequence=0,this.videoState={audioEnabled:!1},this.destroyed=!1,e.eventId&&(this.eventId=e.eventId),this.init(),this.callMeasurementEndpoint(De.Start)}init(){var e,t,r,n;this.determineMode(),this.createObserver(),this.callImageUrl(),(t=this.updateInterval,void 0===t&&(t=0),void 0===r&&(r=ke),t<0&&(t=0),Pe(t,t,r)).pipe((e=this.onDestroy,ne((function(t,r){ee(e).subscribe(ie(r,(function(){return r.complete()}),A)),!r.closed&&t.subscribe(r)})))).subscribe((()=>this.updateState())),Pe(3e5).pipe((n=1,n<=0?function(){return Ve}:ne((function(e,t){var r=0;e.subscribe(ie(t,(function(e){++r<=n&&(t.next(e),n<=r&&t.complete())})))})))).subscribe((()=>this.onDestroy.next())),this.onDestroy.subscribe((()=>{this.destroy()})),document.addEventListener("beforeunload",(()=>{this.onDestroy.next()}),{capture:!0}),document.addEventListener("unload",(()=>{this.onDestroy.next()}),{capture:!0}),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.onDestroy.next()}),{capture:!0}),window.addEventListener("pagehide",(()=>{this.onDestroy.next()}),{capture:!0})}determineMode(){this.config.mode||(window.IntersectionObserver?this.config.mode="IntersectionObserver":this.config.mode="Geometric")}callImageUrl(){if(!this.config.imageUrl)return;ge(decodeURI(this.config.imageUrl).replace("{EVENT_ID}",this.eventId))}updateState(){const e=new Date,t=e.getTime()-this.lastCheckedTime.getTime();this.incrementViewabilityHistogramSum(this.percentageViewable,t),this.incrementViewabilityHistogramMax(this.percentageViewable,t),this.updateVideoState(),this.updateTrace(),this.lastCheckedTime=e}updateTrace(){this.percentageViewable!=this.traceLastPercentageViewable&&this.traceLastPercentageViewable&&this.trace.push({pv:+(.1*Math.ceil(this.percentageViewable/.1)).toFixed(2),ts:50*Math.floor((Date.now()-this.traceStartTime)/50)}),this.traceLastPercentageViewable=this.percentageViewable}updateFinalTrace(){this.trace.push({pv:+(.1*Math.floor(this.percentageViewable/.1)).toFixed(2),ts:50*Math.floor((Date.now()-this.traceStartTime)/50)})}incrementViewabilityHistogramSum(e,t){this.viewabilityHistogramSum=this.viewabilityHistogramSum.map(((r,n)=>(e>=r.percentageViewable&&e<r.percentageViewable+this.histogramBucketSize&&(r.duration+=t),r)))}incrementViewabilityHistogramMax(e,t){this.viewabilityHistogramMax=this.viewabilityHistogramMax.map(((r,n)=>(e>=r.percentageViewable&&e<r.percentageViewable+this.histogramBucketSize?(r.duration+=t,r.duration>r.maxDuration&&(r.maxDuration=r.duration)):e<r.percentageViewable&&(r.duration=0),r)))}getElement(){if(this.config.el)return this.config.el;if(this.config.elementId)return document.getElementById(this.config.elementId);var e=Array.from(window.document.getElementsByTagName("script")).filter((e=>-1!==e.src.indexOf("attn")));let t=e[e.length-1].parentNode;if("HEAD"===t.tagName&&(t=t.parentNode),this.config.querySelector){const e=t.querySelector(this.config.querySelector);if(e)return e;const r=document.querySelector(this.config.querySelector);if(r)return r}return t}createObserver(){const e=this.getElement();if(!e)throw new Error("could not determine element to measure");if("Geometric"===this.config.mode)this.createGeometricObserver(e);else this.createIntersectionObserver(e)}getIntersectionMode(){switch(this.config.intersectionMode){case _e.Element:case _e.Viewport:}return _e.Element}createIntersectionObserver(e){try{this.intersectionObserver=new window.IntersectionObserver((e=>{if(1!==e.length)return;const t=e[0];switch(this.getIntersectionMode()){case _e.Element:this.percentageViewable=t.intersectionRatio;break;case _e.Viewport:this.percentageViewable=Ae(t.intersectionRect,t.rootBounds)}}),{threshold:this.intersectionObserverThresholds}).observe(e)}catch(t){this.createGeometricObserver(e)}}createGeometricObserver(e){throw new Error("GeometricObserver not implemented")}getScroll(){const e={x:0,y:0};return this.isIframe()||"number"!=typeof top.pageYOffset?document.body&&(document.body.scrollLeft||document.body.scrollTop)?(e.y=document.body.scrollTop,e.x=document.body.scrollLeft):document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)&&(e.y=document.documentElement.scrollTop,e.x=document.documentElement.scrollLeft):(e.y=top.pageYOffset,e.x=top.pageXOffset),e}isIframe(){try{return self!==top}catch(e){return!0}}getViewport(){const e={x:0,y:0};return this.isIframe()||void 0===top.innerWidth?void 0!==document.documentElement&&void 0!==document.documentElement.clientWidth&&0!==document.documentElement.clientWidth?(e.x=document.documentElement.clientWidth,e.y=document.documentElement.clientHeight):(e.x=document.getElementsByTagName("body")[0].clientWidth,e.y=document.getElementsByTagName("body")[0].clientHeight):(e.x=top.innerWidth,e.y=top.innerHeight),e}callMeasurementEndpoint(e){const t={};t.mid=this.config.measurementId,t.mt=this.getMediaType(),t.d=this.getDomain(),this.config.app&&(t.a=this.config.app),t.c=this.config.cost||0,t.r=this.config.revenue||0,t.evid=this.eventId,t.vmet=this.config.mode,t.seq=this.sequence,t.sev=e,t.sst=this.wallTime.toISOString(),t.h=this.config.height||this.getElement().getBoundingClientRect().height,t.w=this.config.width||this.getElement().getBoundingClientRect().width,t.sh=window.screen.height,t.sw=window.screen.width,t.sah=window.screen.availHeight,t.saw=window.screen.availWidth,t.vsum=this.viewabilityHistogramSum.map((e=>e.duration)).join(","),t.vmax=this.viewabilityHistogramMax.map((e=>e.maxDuration)).join(","),t.trk="IntersectionObserver"===this.config.mode||!function(){try{return self!==top}catch(e){return!0}}(),this.config.customModel&&(t.cm=this.config.customModel),this.config.tagId&&(t.tid=this.config.tagId),this.config.size&&(t.size=this.config.size),this.config.customParams&&Object.keys(this.config.customParams).forEach((e=>{t[`cp_${e}`]=this.config.customParams[e]})),this.config.lookupParams&&Object.keys(this.config.lookupParams).forEach((e=>{t[`lp_${e}`]=this.config.lookupParams[e]})),this.addVideoStateAsCustomParams(t),3===this.getMediaType()&&(t.duration=this.config.duration),t.vts=this.trace.map((e=>[e.pv,e.ts])).reduce(((e,t)=>e.concat(t)),[]).slice(0,100).join(",");const r=`${this.getEndpoint()}/measure/${this.config.accountId}?${function(e){var t="",r=0;for(var n in e)"function"!=typeof e[n]&&(0===r?(t+=n+"="+e[n],r++):(t+="&"+n+"="+e[n],r++));return t}(t)}`;return this.sequence++,function(e){try{return fetch(e,{keepalive:!0,mode:"no-cors"})?Promise.resolve():Promise.reject(new Error("beacon not queued"))}catch(e){return Promise.reject(e)}}(r).catch((e=>console.error(`error making request:${e.message}`))).then((()=>console.log("measurement sent")))}getDomain(){if(this.config.domain)return this.config.domain;const e=window.location;if(e.ancestorOrigins&&0===e.ancestorOrigins.length)return window.location.host;try{return new URL(e.ancestorOrigins[e.ancestorOrigins.length-1].toString()).host}catch(e){}return null}getEndpoint(){return this.config.endpoint?this.config.endpoint:"https://measure.lamp.avct.cloud"}getMediaType(){switch(this.config.mediaType){case"displayBanner":default:return 1;case"displayNative":return 2;case"video":return 3;case"audio":return 4}}updateVideoState(){if(!this.config.videoEl)return;const{videoEl:e}=this.config;!e.muted&&e.volume>0&&(this.videoState.audioEnabled=!0)}addVideoStateAsCustomParams(e){if(this.config.videoEl)return e.vp_ae=this.videoState.audioEnabled,e}destroy(){this.destroyed||(this.destroyed=!0,this.updateState(),this.updateFinalTrace(),this.percentageViewable=0,this.intersectionObserver&&this.intersectionObserver.disconnect(),this.callMeasurementEndpoint(De.End).then((()=>this.onDestroy.complete())))}}var Le={leading:!0,trailing:!1};function ze(e,t,r){void 0===t&&(t=ke),void 0===r&&(r=Le);var n=Pe(e,t);return function(e,t){return void 0===t&&(t=Le),ne((function(r,n){var i=t.leading,o=t.trailing,s=!1,a=null,c=null,u=!1,l=function(){null==c||c.unsubscribe(),c=null,o&&(p(),u&&n.complete())},d=function(){c=null,u&&n.complete()},h=function(t){return c=ee(e(t)).subscribe(ie(n,l,d))},p=function(){if(s){s=!1;var e=a;a=null,n.next(e),!u&&h(e)}};r.subscribe(ie(n,(function(e){s=!0,a=e,(!c||c.closed)&&(i?p():h(e))}),(function(){u=!0,(!(o&&s&&c)||c.closed)&&n.complete()})))}))}((function(){return n}),r)}const Ne={AdLoaded:"AdLoaded",AdStarted:"AdStarted",AdStopped:"AdStopped",AdSkipped:"AdSkipped",AdSkippableStateChange:"AdSkippableStateChange",AdSizeChange:"AdSizeChange",AdLinearChange:"AdLinearChange",AdDurationChange:"AdDurationChange",AdExpandedChange:"AdExpandedChange",AdRemainingTimeChange:"AdRemainingTimeChange",AdVolumeChange:"AdVolumeChange",AdImpression:"AdImpression",AdVideoStart:"AdVideoStart",AdVideoFirstQuartile:"AdVideoFirstQuartile",AdVideoMidpoint:"AdVideoMidpoint",AdVideoThirdQuartile:"AdVideoThirdQuartile",AdVideoComplete:"AdVideoComplete",AdClickThru:"AdClickThru",AdInteraction:"AdInteraction",AdUserAcceptInvitation:"AdUserAcceptInvitation",AdUserMinimize:"AdUserMinimize",AdUserClose:"AdUserClose",AdPaused:"AdPaused",AdPlaying:"AdPlaying",AdLog:"AdLog",AdError:"AdError"},Be={[Ne.AdStarted]:"start",[Ne.AdVideoFirstQuartile]:"firstQuartile",[Ne.AdVideoMidpoint]:"midpoint",[Ne.AdVideoThirdQuartile]:"thirdQuartile",[Ne.AdVideoComplete]:"complete",[Ne.AdPaused]:"pause",[Ne.AdUserAcceptInvitation]:"acceptInvitation",[Ne.AdUserClose]:"close"};class Re{constructor(e){if(this.vastXML=e,this.checkPoints=new Set,this.subscriptions=new Map,this.adRemainingTimeChange=new U,this.events=new U,this.adLinear=!0,this.adExpanded=!1,this.adSkippableState=!0,1!==this.vastXML.getElementsByTagName("Ad").length)throw new Error("Only a single Ad element is currently supported");this.adRemainingTimeChange.pipe(ze(500)).subscribe(this.events)}getAdLinear(){return this.adLinear}getAdWidth(){return this.adWidth}getAdHeight(){return this.adHeight}getAdExpanded(){return this.adExpanded}getAdSkippableState(){return this.adSkippableState}getAdRemainingTime(){return this.adRemainingTime}getAdDuration(){return this.adDuration}getAdVolume(){return this.adVolume}setAdVolume(e){this.adVolume=e,this.videoSlot.volume=e}getAdCompanions(){return this.adCompanions}getAdIcons(){return this.adIcons}handshakeVersion(e){return e}send(e,t){this.checkPoints.add(e),arguments?this.events.next({type:e,args:t}):this.events.next({type:e})}initAd(e,t,r="normal",n,i,o){if(this.initParams={width:e,height:t,viewMode:r,desiredBitrate:n,creativeData:i,environmentVars:o},this.adDuration=Array.from(be(this.vastXML,"Ad","InLine","Linear","Duration")).map((e=>+e.textContent.split(":").pop())).shift(),this.send(Ne.AdDurationChange),this.adMediaFiles=Array.from(be(this.vastXML,"Ad","InLine","Linear","MediaFiles","MediaFile")),o.videoSlot.src=this.adMediaFiles.filter((e=>{const t=e.getAttribute("type");return o.videoSlot.canPlayType(t)})).map((e=>e.textContent)).shift(),!o.videoSlot.src)throw new Error("no supported media files");this.setupVideoEventListeners(o.videoSlot,o.slot),this.videoSlot=o.videoSlot,o.videoSlot.load()}setupVideoEventListeners(e,t){e.addEventListener("canplay",(()=>{this.adDuration=e.duration,this.adRemainingTime=e.duration,this.send(Ne.AdLoaded),this.send(Ne.AdDurationChange)})),e.addEventListener("playing",(()=>{this.checkPoints.has(Ne.AdStarted)||this.send(Ne.AdStarted),this.checkPoints.has(Ne.AdVideoStart)?this.send(Ne.AdPlaying):this.send(Ne.AdVideoStart),this.checkPoints.has(Ne.AdImpression)||this.send(Ne.AdImpression)})),e.addEventListener("timeupdate",(()=>{const t=e.currentTime;this.adRemainingTime=this.adDuration-t,this.adRemainingTimeChange.next({type:Ne.AdRemainingTimeChange}),t>=this.adDuration/4&&!this.checkPoints.has(Ne.AdVideoFirstQuartile)&&this.send(Ne.AdVideoFirstQuartile),t>=this.adDuration/2&&!this.checkPoints.has(Ne.AdVideoMidpoint)&&this.send(Ne.AdVideoMidpoint),t>=this.adDuration/(4/3)&&!this.checkPoints.has(Ne.AdVideoThirdQuartile)&&this.send(Ne.AdVideoThirdQuartile)})),e.addEventListener("ended",(()=>{this.send(Ne.AdVideoComplete)})),t.addEventListener("mouseover",(()=>{this.checkPoints.has(Ne.AdVideoStart)&&this.send(Ne.AdInteraction)})),t.addEventListener("click",(()=>{const e=Array.from(this.vastXML.getElementsByTagName("ClickThrough")).map((e=>e.textContent)).shift();this.send(Ne.AdClickThru,[e,"",!0])})),e.addEventListener("pause",(()=>{this.getAdRemainingTime()>0&&!this.checkPoints.has(Ne.AdSkipped)&&this.send(Ne.AdPaused)}))}startAd(){try{this.videoSlot.play()}catch(e){console.error(e)}}stopAd(){this.videoSlot.pause(),this.videoSlot.currentTime=0,this.send(Ne.AdStopped)}pauseAd(){this.videoSlot.pause()}resumeAd(){this.videoSlot.play()}skipAd(){this.getAdSkippableState()&&(this.videoSlot.pause(),this.send(Ne.AdSkipped))}resizeAd(e,t,r){const n=me(e,t,this.adMediaFiles);this.videoSlot.src=n.textContent,this.videoSlot.load(),this.send(Ne.AdSizeChange)}expandAd(){}collapseAd(){}subscribe(e,t,r){const n=this.events.pipe(pe((e=>e.type===t))).subscribe((t=>{e.call(r||this,...t.args||[])}));this.subscriptions.set(e,n)}unsubscribe(e){this.subscriptions.has(e)&&this.subscriptions.get(e).unsubscribe()}}class Ue{constructor(){this.events=new U,this.subscriptions=new Map,this.wrappers=[],this.logger=new ye("AttnVPAIDAd","info"),this.scriptSrc=Array.from(document.getElementsByTagName("script")).map((e=>e.src)).find((e=>-1!==e.indexOf("vpaid")&&-1!==e.indexOf("vastUrl")))}handshakeVersion(e){return this.creative.handshakeVersion(e)}initAd(e,t,r,n,i,o){this.initParams={width:e,height:t,viewMode:r,desiredBitrate:n,creativeData:i,environmentVars:o},o.slot&&(this.slot=null==o?void 0:o.slot),o.videoSlot&&(this.videoSlot=null==o?void 0:o.videoSlot);const s=new URLSearchParams(this.scriptSrc.substring(this.scriptSrc.indexOf("?")+1,this.scriptSrc.length));this.config=we(s),this.logger.setLevel(s.get("logLevel")||"info"),this.logger.debug("found script src",this.scriptSrc),this.logger.debug("parsed query params",s.toString()),this.xmlSrc=s.get("vastUrl"),this.logger.debug("loading vast url",this.xmlSrc),this.setupViewabilityTracking(),this.resolveAndProcessVAST(this.xmlSrc,!0)}resolveAndProcessVAST(e,t=!0){ve(e,t).then((r=>{if(r.getElementsByTagName("Wrapper").length>0){this.logger.debug("found vast wrapper at location:",e),this.wrappers.push(r);const n=r.getElementsByTagName("VASTAdTagURI");return this.resolveAndProcessVAST(n[0].textContent,t)}return this.logger.debug("found vast inline at location:",e),this.processVASTXML(r)})).catch((()=>{if(t)return this.resolveAndProcessVAST(e,!1);this.logger.error("error fetching vast document")}))}processVASTXML(e){const t=Array.from(e.getElementsByTagName("MediaFile"));if(!t||!t.length)throw new Error("no media files found");const r=Array.from(e.getElementsByTagName("AdParameters")).map((e=>e.textContent)).shift();r&&(this.initParams.creativeData.AdParameters=r);const n=Array.from(e.getElementsByTagName("CompanionAds")).shift();this.adCompanions=n?(new XMLSerializer).serializeToString(n):null,this.clickThrough=Array.from(e.getElementsByTagName("ClickThrough")).map((e=>e.textContent)).shift();let i=Array.from(e.getElementsByTagName("ClickTracking")),o=Array.from(e.getElementsByTagName("Impression")),s=Array.from(e.getElementsByTagName("Tracking"));var a,c;this.wrappers.length&&(i.push(...Array.from(this.wrappers.reduce(((e,t)=>e.concat(Array.from(be(t,"Ad","Wrapper","Creatives","Creative","Linear","VideoClicks","ClickTracking")))),[]))),o.push(...Array.from(this.wrappers.reduce(((e,t)=>e.concat(Array.from(be(t,"Ad","Wrapper","Impression")))),[]))),s.push(...Array.from(this.wrappers.reduce(((e,t)=>e.concat(Array.from(be(t,"Ad","Wrapper","Creatives","Creative","Linear","TrackingEvents","Tracking")))),[])))),this.logger.debug("processed vast doc",e),this.logger.debug("found impression trackers",o),this.logger.debug("found click through",this.clickThrough),this.logger.debug("found click trackers",i),this.logger.debug("found event trackers",s),this.logger.debug("found event trackers",s),this.events.pipe(de((e=>{e.type===Ne.AdClickThru&&(this.logger.debug("calling click trackers",i),i.forEach((e=>this.getImage(e.textContent)))),e.type===Ne.AdImpression&&(this.logger.debug("calling impression trackers",o),o.forEach((e=>this.getImage(e.textContent))))})),he((e=>Be[e.type])),pe(Boolean),(a=e=>function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=W(e);return le(e,r)}(...s.filter((t=>t.getAttribute("event")===e)).map((e=>e.textContent))),l(c)?fe(a,c,1):fe(a,1))).subscribe((e=>this.getImage(e)));const u=this.findVpaidWrapper(t);u?(this.logger.debug("vast contains VPAID ad, creating vpaid proxy to",u.textContent),function(e,t=50,r=100){let n=0;return new Promise(((i,o)=>{const s=document.createElement("iframe");s.id="adloaderframe",s.frameBorder="0",s.style.top="0",s.style.left="0",s.style.border="none",s.style.overflow="hidden",s.style.padding="0",s.style.height="0px",s.style.width="0px",document.body.appendChild(s),s.contentWindow.document.write("<html>","<body>",'<script src="'+e+'"><\/script>',"</body>","</html>");const a=()=>{var e=s.contentWindow.getVPAIDAd;e&&"function"==typeof e?i(e()):n<t&&(n++,setTimeout((()=>a()),r))};a()}))}(u.textContent).then((e=>{this.logger.debug("loaded vpaid ad creative",e),this.creative=e,this.isProxy=!0,this.initializeCreative()}))):(this.creative=new Re(e),this.isProxy=!1,this.initializeCreative())}getImage(e){return this.logger.debug("making request to:",e),ge(e)}findVpaidWrapper(e){return e.find((e=>"VPAID"===e.getAttribute("apiFramework")))}initializeCreative(){this.subscribeCreative(),this.creative.initAd(this.initParams.width,this.initParams.height,this.initParams.viewMode,this.initParams.desiredBitrate,this.initParams.creativeData,this.initParams.environmentVars)}setupViewabilityTracking(){this.subscribe((()=>{this.logger.debug("setting up viewability tracking"),this.viewabilityTracker=new Oe(Object.assign(Object.assign({},this.config),{el:this.slot,videoEl:this.videoSlot}))}),Ne.AdVideoStart,this),this.events.pipe(de((e=>{this.logger.debug(e)})),pe((e=>{switch(e.type){case Ne.AdStopped:case Ne.AdVideoComplete:return!0;default:return!1}}))).subscribe((e=>{this.viewabilityTracker&&(this.logger.debug("tearing down viewability tracking"),this.viewabilityTracker.destroy())}))}startAd(){return this.creative.startAd()}stopAd(){return this.creative.stopAd()}setAdVolume(e){return this.creative.setAdVolume(e)}resizeAd(e,t,r){return this.creative.resizeAd(e,t,r)}pauseAd(){return this.creative.pauseAd()}resumeAd(){return this.creative.resumeAd()}expandAd(){return this.creative.expandAd()}collapseAd(){return this.creative.collapseAd()}skipAd(){return this.creative.skipAd()}getAdLinear(){return this.creative.getAdLinear()}getAdWidth(){return this.creative.getAdWidth()}getAdHeight(){return this.creative.getAdHeight()}getAdExpanded(){return this.creative.getAdExpanded()}getAdSkippableState(){return this.creative.getAdSkippableState()}getAdRemainingTime(){return this.creative.getAdRemainingTime()}getAdDuration(){return this.creative.getAdDuration()}getAdVolume(){return this.creative.getAdVolume()}getAdCompanions(){return this.creative.getAdCompanions()||this.adCompanions}getAdIcons(){return this.creative.getAdIcons()}subscribeCreative(){Object.keys(Ne).forEach((e=>{this.creative.subscribe((function(){this.events.next({type:Ne[e],args:arguments})}),Ne[e],this)}))}subscribe(e,t,r){this.logger.debug(`subscription added for ${t}`);const n=this.events.pipe(pe((e=>e.type===t))).subscribe((n=>{if(this.logger.debug(`calling subscription callback for ${t}:`,n.args),n.type===Ne.AdClickThru){const t=(n.args||[])[0],i=(n.args||[])[2];void 0===t&&!0===i?(n.args[0]=this.clickThrough,e.call(r||this,...n.args)):e.call(r||this,...n.args||[])}else e.call(r||this,...n.args||[])}));this.subscriptions.set(e,n)}unsubscribe(e){this.subscriptions.has(e)&&this.subscriptions.get(e).unsubscribe()}}const He="attn",je="trackers";window[He]={measure:e=>{const t=new Oe(e);return window[He][je][t.eventId]=t,t},trackers:window[He]?window[He][je]:{},getVPAIDAd:()=>new Ue};const Fe=Array.from(document.getElementsByTagName("script")).map((e=>e.src)).filter((e=>-1!==e.indexOf("attn"))).pop();if(Fe){const e=we(new URLSearchParams(Fe.substring(Fe.indexOf("?")+1,Fe.length))),t=new Oe(e);window[He][je][t.eventId]=t}})();
//# sourceMappingURL=attn.js.map