@netacea/f5 5.8.14 → 5.8.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -331,6 +331,7 @@ interface InjectResponse<T = any> extends MitigateResponse<T> {
331
331
  * Response value, using Response generic
332
332
  */
333
333
  response?: T | undefined;
334
+ signatureStatus?: string;
334
335
  }
335
336
  type NetaceaMitigationResponse<T> = MitigateResponse<T> | InjectResponse<T> | undefined;
336
337
  interface NetaceaWorker<RequestArgs, Response> {
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var e,t;function r(e){var t="function"==typeof Map?new Map:void 0;return r=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(a())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&s(i,r.prototype),i}(e,arguments,i(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)},r(e)}function n(e,t,r){return t=i(t),function(e,t){if(t&&("object"==u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,a()?Reflect.construct(t,r||[],i(e).constructor):t.apply(e,r))}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(a=function(){return!!e})()}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function o(){o=function(e,t){return new r(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function r(e,n,a){var i=RegExp(e,n);return t.set(i,a||t.get(e)),s(i,r.prototype)}function n(e,r){var n=t.get(r);return Object.keys(n).reduce((function(t,r){var a=n[r];if("number"==typeof a)t[r]=e[a];else{for(var i=0;void 0===e[a[i]]&&i+1<a.length;)i++;t[r]=e[a[i]]}return t}),Object.create(null))}return c(r,RegExp),r.prototype.exec=function(t){var r=e.exec.call(this,t);if(r){r.groups=n(r,this);var a=r.indices;a&&(a.groups=n(a,this))}return r},r.prototype[Symbol.replace]=function(r,a){if("string"==typeof a){var i=t.get(this);return e[Symbol.replace].call(this,r,a.replace(/\$<([^>]+)(>|$)/g,(function(e,t,r){if(""===r)return e;var n=i[t];return Array.isArray(n)?"$"+n.join("$"):"number"==typeof n?"$"+n:""})))}if("function"==typeof a){var o=this;return e[Symbol.replace].call(this,r,(function(){var e=arguments;return"object"!=u(e[e.length-1])&&(e=[].slice.call(e)).push(n(e,o)),a.apply(this,e)}))}return e[Symbol.replace].call(this,r,a)},o.apply(this,arguments)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function l(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",a=r.toStringTag||"@@toStringTag";function i(r,n,a,i){var s=n&&n.prototype instanceof c?n:c,u=Object.create(s.prototype);return h(u,"_invoke",function(r,n,a){var i,c,s,u=0,l=a||[],h=!1,d={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,r){return i=t,c=0,s=e,d.n=r,o}};function f(r,n){for(c=r,s=n,t=0;!h&&u&&!a&&t<l.length;t++){var a,i=l[t],f=d.p,p=i[2];r>3?(a=p===n)&&(s=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=f&&((a=r<2&&f<i[1])?(c=0,d.v=n,d.n=i[1]):f<p&&(a=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,d.n=p,c=0))}if(a||r>1)return o;throw h=!0,n}return function(a,l,p){if(u>1)throw TypeError("Generator is already running");for(h&&1===l&&f(l,p),c=l,s=p;(t=c<2?e:s)||!h;){i||(c?c<3?(c>1&&(d.n=-1),f(c,s)):d.n=s:d.v=s);try{if(u=2,i){if(c||(a="next"),t=i[a]){if(!(t=t.call(i,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(s=TypeError("The iterator does not provide a '"+a+"' method"),c=1);i=e}else if((t=(h=d.n<0)?s:r.call(n,d))!==o)break}catch(t){i=e,c=1,s=t}finally{u=1}}return{value:t,done:h}}}(r,a,i),!0),u}var o={};function c(){}function s(){}function u(){}t=Object.getPrototypeOf;var d=[][n]?t(t([][n]())):(h(t={},n,(function(){return this})),t),f=u.prototype=c.prototype=Object.create(d);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,h(e,a,"GeneratorFunction")),e.prototype=Object.create(f),e}return s.prototype=u,h(f,"constructor",u),h(u,"constructor",s),s.displayName="GeneratorFunction",h(u,a,"GeneratorFunction"),h(f),h(f,a,"Generator"),h(f,n,(function(){return this})),h(f,"toString",(function(){return"[object Generator]"})),(l=function(){return{w:i,m:p}})()}function h(e,t,r,n){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}h=function(e,t,r,n){function i(t,r){h(e,t,(function(e){return this._invoke(t,r,e)}))}t?a?a(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},h(e,t,r,n)}function d(e){return function(e){if(Array.isArray(e))return A(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||O(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t,r,n,a,i,o){try{var c=e[i](o),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,a)}function p(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){f(i,n,a,o,c,"next",e)}function c(e){f(i,n,a,o,c,"throw",e)}o(void 0)}))}}function v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,b(n.key),n)}}function g(e,t,r){return t&&y(e.prototype,t),r&&y(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function k(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){C(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function C(e,t,r){return(t=b(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(e){var t=function(e,t){if("object"!=u(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==u(t)?t:t+""}function S(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=O(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){c=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(c)throw i}}}}function I(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i,o,c=[],s=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);s=!0);}catch(e){u=!0,a=e}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw a}}return c}}(e,t)||O(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){if(e){if("string"==typeof e)return A(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?A(e,t):void 0}}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var w=require("crypto"),N=require("buffer"),E=require("https"),_=require("querystring"),P=require("aws4");function T(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var R,M,K,x=T(w),H=T(E),j=T(_);!function(e){e.ORIGIN="ORIGIN",e.HTTP="HTTP",e.KINESIS="KINESIS",e.NATIVE="NATIVE"}(R||(R={})),function(e){e.MITIGATE="MITIGATE",e.INJECT="INJECT",e.INGEST="INGEST"}(M||(M={})),function(e){e.CAPTCHA_GET="captcha_get",e.CAPTCHA_POST="captcha_post",e.EXPIRED_SESSION="expired_session",e.FORCED_REVALIDATION="forced_revalidation",e.INVALID_SESSION="invalid_session",e.IP_CHANGE="ip_change",e.NO_SESSION="no_session"}(K||(K={}));var V=3e3;var L="_/@#/",F={none:"",block:"block",captcha:"captcha",allow:"allow",captchaPass:"captchapass"},D={0:F.none,1:F.block,2:F.none,3:F.block,4:F.none,5:F.block},B={1:F.captcha,2:F.captchaPass,3:F.captcha,4:F.allow,5:F.captcha,6:F.allow,7:F.captcha,a:F.captcha,b:F.captchaPass,c:F.captcha,d:F.allow,e:F.captcha},q=Object.freeze({__proto__:null,COOKIEDELIMITER:L,bestMitigationCaptchaMap:B,bestMitigationMap:D,captchaMap:{0:"",1:"captcha_serve",2:"captcha_pass",3:"captcha_fail",4:"captcha_cookiepass",5:"captcha_cookiefail",6:"checkpoint_signal",7:"checkpoint_post",a:"checkpoint_serve",b:"checkpoint_pass",c:"checkpoint_fail",d:"checkpoint_cookiepass",e:"checkpoint_cookiefail"},captchaStatusCodes:{"":0,captchaServe:1,captchaPass:2,captchaFail:3,captchaCookiePass:4,captchaCookieFail:5,checkpointSignal:6,checkpointPost:7,checkpointServe:"a",checkpointPass:"b",checkpointFail:"c",checkpointCookiePass:"d",checkpointCookieFail:"e"},matchMap:{0:"",1:"ua_",2:"ip_",3:"visitor_",4:"datacenter_",5:"customer_session_",6:"organisation_",7:"asn_",8:"country_",9:"combination_",b:"headerFP_",c:"vendorFamily_",d:"vendorName_",e:"vendor_",f:"vendorCrawlerClassification_"},mitigateMap:{0:"",1:"blocked",2:"allow",3:"hardblocked",4:"flagged",5:"monetised"},mitigationTypes:F,netaceaCookieV3KeyMap:{clientIP:"cip",userId:"uid",gracePeriod:"grp",cookieId:"cid",match:"mat",mitigate:"mit",captcha:"cap",issueTimestamp:"ist",issueReason:"isr"},netaceaCookieV3OptionalKeyMap:{checkAllPostRequests:"fCAPR"},netaceaHeaders:{match:"x-netacea-match",mitigate:"x-netacea-mitigate",captcha:"x-netacea-captcha",mitata:"x-netacea-mitata-value",mitataExpiry:"x-netacea-mitata-expiry",mitataCaptcha:"x-netacea-mitatacaptcha-value",mitataCaptchaExpiry:"x-netacea-mitatacaptcha-expiry",eventId:"x-netacea-event-id"},netaceaSettingsMap:{checkAllPostRequests:"checkAllPostRequests"}}),U="ignored",z="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),G=/^(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/((\d|[a-z])(\d)(\d|[a-z]))$/i;function X(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:z,r=w.randomBytes(e-1),n=Array.from(r).map((function(e){return t[e%t.length]})).join("");return"c".concat(n)}function J(e,t,r,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"000";void 0===t&&(t=X());var i=[r,t,W(e+"|"+String(r),n),a].join(L),o=W(i,n);return"".concat(o).concat(L).concat(i)}function W(e,t){var r=w.createHmac("sha256",t);return r.update(e),N.Buffer.from(r.digest("hex")).toString("base64")}function $(e,t,r){var n={mitata:void 0,requiresReissue:!1,isExpired:!1,shouldExpire:!1,isSameIP:!1,isPrimaryHashValid:!1,captcha:"0",match:"0",mitigate:"0"};if("string"!=typeof e||""===e)return n;var a=function(e){if(void 0!==e){var t=e.match(G);if(null!=t){var r=I(t,9);return{signature:r[1],expiry:r[2],userId:r[3],ipHash:r[4],mitigationType:r[5],match:r[6],mitigate:r[7],captcha:r[8]}}}}(e);if(void 0!==a){var i=[a.expiry,a.userId,a.ipHash,a.mitigationType].join(L),o=Math.floor(Date.now()/1e3),c=parseInt(a.expiry)<o,s=["1","3","5","a","c","e"].includes(a.captcha),u="3"===a.mitigate,l=s||u,h=W(t+"|"+a.expiry,r),d=a.ipHash===h;return{mitata:a,requiresReissue:c||!d,isExpired:c,shouldExpire:l,isSameIP:d,isPrimaryHashValid:a.signature===W(i,r),match:a.match,mitigate:a.mitigate,captcha:a.captcha,userId:a.userId}}return n}function Q(e,t){var r=e.split(";").map((function(e){return e.trim()})).filter((function(e){return e.toLowerCase().startsWith(t.toLowerCase())}))[0];return void 0!==r&&r.length>0?null==r?void 0:r.replace("".concat(t,"="),""):void 0}function Y(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"string"!=typeof e&&(e=e.join("; ")),""===e?"":Z(e.split(";"),t).join("; ")}function Z(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])return Z(e.reverse()).reverse();var t,r=new Set,n=[],a=S(e);try{for(a.s();!(t=a.n()).done;){var i=t.value;if(""!==(i=i.trimStart()).trim()){var o=i.split("=")[0].toUpperCase();r.has(o)||(r.add(o),n.push(i))}}}catch(e){a.e(e)}finally{a.f()}return n}function ee(e){var t,r,n=Y([null!==(t=e.otherAttributes)&&void 0!==t?t:"","Max-Age=".concat(null!==(r=e.maxAgeAttribute)&&void 0!==r?r:86400),"Path=/"].join("; "));return"".concat(e.cookieName,"=").concat(e.cookieValue,"; ").concat(n)}var te={cookie:{attributes:Object.freeze({__proto__:null,configureCookiesDomain:function(e,t){var r=e=Y(null!=e?e:"",!0),n=t=Y(null!=t?t:"",!0);if(void 0!==e&&void 0!==t){var a=Q(e,"Domain"),i=Q(t,"Domain");void 0!==a&&void 0!==i?n=t.replace(i,a):void 0!==a&&void 0===i?n=t+(""!==t?"; Domain=".concat(a):"Domain=".concat(a)):void 0===a&&void 0!==i&&(r=e+(""!==e?"; Domain=".concat(i):"Domain=".concat(i)))}else if(void 0!==e&&void 0===t){var o=Q(e,"Domain");void 0!==o&&(n="Domain=".concat(o))}else if(void 0===e&&void 0!==t){var c=Q(t,"Domain");void 0!==c&&(r="Domain=".concat(c))}return{cookieAttributes:""!==r?r:void 0,captchaCookieAttributes:""!==n?n:void 0}},extractAndRemoveCookieAttr:function(e,t){var r=Q(e,t);return void 0!==r?{extractedAttribute:r,cookieAttributes:e.replace(/ /g,"").replace("".concat(t,"=").concat(r),"").split(";").filter((function(e){return e.length>0})).join("; ")}:{extractedAttribute:void 0,cookieAttributes:e}},extractCookieAttr:Q,removeDuplicateAttrs:Y}),netaceaSession:Object.freeze({__proto__:null,createNetaceaCaptchaSetCookieString:function(e){var t;return ee(k(k({},e),{},{cookieName:null!==(t=e.cookieName)&&void 0!==t?t:"_mitatacaptcha"}))},createNetaceaSetCookieString:function(e){var t;return ee(k(k({},e),{},{cookieName:null!==(t=e.cookieName)&&void 0!==t?t:"_mitata"}))},createSetCookieString:ee})}},re=function(){function e(t,r){v(this,e),this.crypto=t,this.TextEncoder=r}return g(e,[{key:"hashString",value:(r=p(l().m((function e(t,r){var n,a,i,o,c,s,u=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:return a=(n=u.length>2&&void 0!==u[2]&&u[2])?d(r).sort():d(r),i=(new this.TextEncoder).encode(a.join(",")),e.n=1,this.crypto.subtle.digest(t,i);case 1:return o=e.v,c=Array.from(new Uint8Array(o)),s=c.map((function(e){return e.toString(16).padStart(2,"0")})).join("").substring(0,12),e.a(2,"h"+(n?"s":"")+"_".concat(r.length,"_").concat(s))}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"hashHeaders",value:(t=p(l().m((function t(r){var n,a,i,o=arguments;return l().w((function(t){for(;;)switch(t.n){case 0:if(n=o.length>1&&void 0!==o[1]&&o[1],0!==(a=e.filterHeaderNames(r)).length){t.n=1;break}return t.a(2,"");case 1:return t.p=1,t.n=2,this.hashString("SHA-256",a,n);case 2:return t.a(2,t.v);case 3:return t.p=3,i=t.v,console.error(i),t.a(2,"")}}),t,this,[[1,3]])}))),function(e){return t.apply(this,arguments)})}],[{key:"filterHeaderNames",value:function(e){return e.filter((function(e){var t=e.toLowerCase();return!["","cookie","referer"].includes(t)&&null===t.match(/^(x-netacea-|cloudfront-)/i)}))}}]);var t,r}();function ne(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ae(e){var t=(e+"===".slice(0,(4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/");return Buffer.from(t,"base64")}var ie="eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0";function oe(e){return 5===e.split(".").length&&e.includes("..")}function ce(e,t){var r=w.randomBytes(12),n=w.createCipheriv("aes-256-gcm",t,r),a=Buffer.from(ie,"ascii");n.setAAD(a);var i=n.update(e,"utf8");i=Buffer.concat([i,n.final()]);var o=n.getAuthTag();return[ie,"",ne(r),ne(i),ne(o)].join(".")}function se(e,t){var r=e.split(".");if(5!==r.length)throw new Error("JWE should have 5 parts, got ".concat(r.length));var n=I(r,5),a=n[0],i=n[1],o=n[2],c=n[3],s=n[4];if(a!==ie)throw new Error("Incorrect JWE header");if(""!==i)throw new Error("Expected empty encrypted key for direct encryption");var u=ae(o),l=ae(c),h=ae(s);if(12!==u.length)throw new Error("IV must be ".concat(12," bytes, got ").concat(u.length));if(16!==h.length)throw new Error("Auth tag must be ".concat(16," bytes, got ").concat(h.length));var d=w.createDecipheriv("aes-256-gcm",t,u),f=Buffer.from(a,"ascii");d.setAAD(f),d.setAuthTag(h);var p=d.update(l);return(p=Buffer.concat([p,d.final()])).toString("utf8")}var ue,le,he,de="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},fe={},pe={};Object.defineProperty(pe,"__esModule",{value:!0}),pe.MitigateCode=pe.MatchCode=pe.CaptchaCode=void 0,function(e){e.NONE="0",e.SERVE="1",e.PASS="2",e.FAIL="3",e.COOKIE_PASS="4",e.COOKIE_FAIL="5",e.CHECKPOINT_SIGNAL="6",e.CHECKPOINT_POST="7",e.CHECKPOINT_SERVE="a",e.CHECKPOINT_PASS="b",e.CHECKPOINT_FAIL="c",e.CHECKPOINT_COOKIE_PASS="d",e.CHECKPOINT_COOKIE_FAIL="e"}(ue||(pe.CaptchaCode=ue={})),function(e){e.NONE="0",e.USER_AGENT="1",e.IP="2",e.VISITOR="3",e.DATACENTER="4",e.CUSTOMER_SESSION="5",e.ORGANISATION="6",e.ASN="7",e.COUNTRY="8",e.COMBINATION="9",e.HEADER_FINGERPRINT="b",e.VENDOR_FAMILY="c",e.VENDOR_NAME="d",e.VENDOR="e",e.VENDOR_CRAWLER_CLASSIFICATION="f"}(le||(pe.MatchCode=le={})),function(e){e.NONE="0",e.BLOCK="1",e.ALLOW="2",e.HARDBLOCK="3",e.FLAG="4",e.MONETISE="5"}(he||(pe.MitigateCode=he={}));var ve,ye={};Object.defineProperty(ye,"__esModule",{value:!0}),ye.NetaceaCookieV3IssueReason=void 0,function(e){e.CAPTCHA_GET="captcha_get",e.CAPTCHA_POST="captcha_post",e.EXPIRED_SESSION="expired_session",e.FORCED_REVALIDATION="forced_revalidation",e.INVALID_SESSION="invalid_session",e.IP_CHANGE="ip_change",e.NO_SESSION="no_session",e.UNKNOWN="unknown"}(ve||(ye.NetaceaCookieV3IssueReason=ve={}));var ge={},me={},ke={};Object.defineProperty(ke,"__esModule",{value:!0}),ke.netaceaCookieV3OptionalKeyMap=ke.netaceaCookieV3KeyMap=ke.COOKIEDELIMITER=void 0,ke.COOKIEDELIMITER="_/@#/",ke.netaceaCookieV3KeyMap={clientIP:"cip",userId:"uid",gracePeriod:"grp",cookieId:"cid",match:"mat",mitigate:"mit",captcha:"cap",issueTimestamp:"ist",issueReason:"isr"},ke.netaceaCookieV3OptionalKeyMap={checkAllPostRequests:"fCAPR"},Object.defineProperty(me,"__esModule",{value:!0}),me.defaultInvalidResponse=me.matchNetaceaCookieV3=me.checkNetaceaCookieV3=me.objectIsNetaceaCookieV3=me.cookieIsNetaceaV3Format=me.createNetaceaCookieV3=void 0;var Ce=ye,be=ke;function Se(e){if(void 0!==e&&""!==e){var t,r=e.split("&"),n={clientIP:"",userId:"",cookieId:"",gracePeriod:0,match:"0",mitigate:"0",captcha:"0",issueTimestamp:0,issueReason:"",checkAllPostRequests:void 0},a=S(r);try{var i=function(){var e,r=I(t.value.split("="),2),a=r[0],i=r[1],o=decodeURIComponent(i),c=Object.keys(be.netaceaCookieV3KeyMap).find((function(e){return be.netaceaCookieV3KeyMap[e]===a}));void 0===c&&(c=Object.keys(be.netaceaCookieV3OptionalKeyMap).find((function(e){return be.netaceaCookieV3OptionalKeyMap[e]===a}))),void 0!==(e=void 0!==c&&["match","mitigate","captcha"].includes(c)?""===o?void 0:o:""===o?void 0:Number(o))&&"string"!=typeof e&&isNaN(e)&&(e=o),n[c]=e};for(a.s();!(t=a.n()).done;)i()}catch(e){a.e(e)}finally{a.f()}return n}}function Ie(){return{mitata:void 0,requiresReissue:!1,isExpired:!1,shouldExpire:!1,isSameIP:!1,isPrimaryHashValid:!1,captcha:"0",match:"0",mitigate:"0",issueReason:Ce.NetaceaCookieV3IssueReason.NO_SESSION}}me.createNetaceaCookieV3=function(e){return Object.entries(e).filter((function(e){var t=I(e,2);t[0];return void 0!==t[1]})).map((function(e){var t=I(e,2),r=t[0],n=t[1];return r in be.netaceaCookieV3OptionalKeyMap?"".concat(be.netaceaCookieV3OptionalKeyMap[r],"=").concat(encodeURIComponent(n)):"".concat(be.netaceaCookieV3KeyMap[r],"=").concat(encodeURIComponent(n))})).join("&")},me.cookieIsNetaceaV3Format=function(e){if(void 0===e||""===e)return!1;var t=e.split("&").map((function(e){return e.split("=")[0]})).filter((function(e){return!Object.values(be.netaceaCookieV3OptionalKeyMap).includes(e)}));return 0!==t.length&&t.every((function(e){return Object.values(be.netaceaCookieV3KeyMap).includes(e)}))},me.objectIsNetaceaCookieV3=function(e){if("object"!==u(e)||null===e)return!1;for(var t=0,r=Object.keys(be.netaceaCookieV3KeyMap);t<r.length;t++){var n=r[t];if(!(n in e))return!1;if(void 0===e[n])return!1}return!0},me.checkNetaceaCookieV3=function(e,t){if(void 0===e||""===e)return Ie();var r;try{r=Se(e)}catch(e){return Ie()}if(void 0!==r){var n=Math.floor(Date.now()/1e3),a=r.issueTimestamp+r.gracePeriod<n,i=t===r.clientIP,o=["1","3","5","a","c","e"].includes(r.captcha),c="3"===r.mitigate;return{mitata:r,requiresReissue:a||!i,isExpired:a,shouldExpire:o||c,isSameIP:i,isPrimaryHashValid:!0,match:r.match,mitigate:r.mitigate,captcha:r.captcha,issueReason:r.issueReason}}return Ie()},me.matchNetaceaCookieV3=Se,me.defaultInvalidResponse=Ie;var Oe={};Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.AbstractCookieFactory=void 0;var Ae=ye,we=me,Ne=ke,Ee="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),_e=/^(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/((\d|[a-z])(\d)(\d|[a-z]))$/i,Pe=function(){return g((function e(t){v(this,e),this.config=t}),[{key:"isEncrypted",value:function(e){return 5===e.split(".").length}},{key:"createCookieValue",value:(n=p(l().m((function e(t){var r,n,a,i,o;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0===this.config.cookieEncryptionKey){e.n=2;break}return a=(0,we.createNetaceaCookieV3)({clientIP:t.clientIP,userId:null!==(r=t.userId)&&void 0!==r?r:this.generateUserId(),match:t.match,mitigate:t.mitigate,captcha:t.captcha,gracePeriod:t.gracePeriod,cookieId:t.cookieId,issueTimestamp:Math.floor(Date.now()/1e3),issueReason:null!==(n=t.issueReason)&&void 0!==n?n:Ae.NetaceaCookieV3IssueReason.NO_SESSION,checkAllPostRequests:t.checkAllPostRequests}),e.n=1,this.encrypt(a);case 1:case 4:return e.a(2,e.v);case 2:if(void 0!==this.config.secretKey){e.n=3;break}throw new Error("Cannot build cookie without secret key.");case 3:return i=[t.match,t.mitigate,t.captcha].join(""),o=Math.floor(Date.now()/1e3)+t.gracePeriod,e.n=4,this.buildMitataCookie(t.clientIP,t.userId,o,this.config.secretKey,i)}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"retrieveCookieInfo",value:(r=p(l().m((function e(t,r){var n,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==t&&""!==t){e.n=1;break}return e.a(2,(0,we.defaultInvalidResponse)());case 1:if(a=t,!this.isEncrypted(t)){e.n=3;break}return e.n=2,this.decrypt(t);case 2:a=e.v;case 3:if(!(0,we.cookieIsNetaceaV3Format)(a)){e.n=4;break}return e.a(2,(0,we.checkNetaceaCookieV3)(a,r));case 4:return e.n=5,this.checkMitataCookie(a,r,null!==(n=this.config.secretKey)&&void 0!==n?n:"");case 5:return e.a(2,e.v)}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"buildMitataCookie",value:(t=p(l().m((function e(t,r,n,a,i){var o,c,s,u;return l().w((function(e){for(;;)switch(e.n){case 0:return o=null!=r?r:this.generateUserId(),e.n=1,this.hash("".concat(t,"|").concat(String(n)),a);case 1:return c=e.v,s=[n,o,c,i].join(Ne.COOKIEDELIMITER),e.n=2,this.hash(s,a);case 2:return u=e.v,e.a(2,"".concat(u).concat(Ne.COOKIEDELIMITER).concat(s))}}),e,this)}))),function(e,r,n,a,i){return t.apply(this,arguments)})},{key:"checkMitataCookie",value:(e=p(l().m((function e(t,r,n){var a,i,o,c,s,u,h,d,f,p,v;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==(a=Te(t))){e.n=1;break}return e.a(2,(0,we.defaultInvalidResponse)());case 1:return i=Math.floor(Date.now()/1e3),o=parseInt(a.expiry)<i,c=["1","3","5"].includes(a.captcha),s="3"===a.mitigate,u=c||s,e.n=2,this.hash("".concat(r,"|").concat(a.expiry),n);case 2:return h=e.v,d=h===a.ipHash,f=[a.expiry,a.userId,a.ipHash,a.mitigationType].join(Ne.COOKIEDELIMITER),e.n=3,this.hash(f,n);case 3:return p=e.v,v=p===a.signature,e.a(2,{mitata:a,requiresReissue:o||!d,isExpired:o,shouldExpire:u,isSameIP:d,isPrimaryHashValid:v,match:a.match,mitigate:a.mitigate,captcha:a.captcha,issueReason:Ae.NetaceaCookieV3IssueReason.NO_SESSION})}}),e,this)}))),function(t,r,n){return e.apply(this,arguments)})},{key:"generateUserId",value:function(){var e=new Uint16Array((arguments.length>0&&void 0!==arguments[0]?arguments[0]:16)-1);this.getRandomValues(e);var t=Array.from(e).map((function(e){return Ee[e%Ee.length]})).join("");return"c".concat(t)}}]);var e,t,r,n}();function Te(e){var t=e.match(_e);if(null!==t){var r=I(t,9);return{signature:r[1],expiry:r[2],userId:r[3],ipHash:r[4],mitigationType:r[5],match:r[6],mitigate:r[7],captcha:r[8]}}}Oe.AbstractCookieFactory=Pe,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NetaceaCookieV3IssueReason=e.COOKIEDELIMITER=e.netaceaCookieV3OptionalKeyMap=e.netaceaCookieV3KeyMap=e.AbstractCookieFactory=e.defaultInvalidResponse=e.objectIsNetaceaCookieV3=e.cookieIsNetaceaV3Format=e.matchNetaceaCookieV3=e.checkNetaceaCookieV3=e.createNetaceaCookieV3=void 0;var t=me;Object.defineProperty(e,"createNetaceaCookieV3",{enumerable:!0,get:function(){return t.createNetaceaCookieV3}}),Object.defineProperty(e,"checkNetaceaCookieV3",{enumerable:!0,get:function(){return t.checkNetaceaCookieV3}}),Object.defineProperty(e,"matchNetaceaCookieV3",{enumerable:!0,get:function(){return t.matchNetaceaCookieV3}}),Object.defineProperty(e,"cookieIsNetaceaV3Format",{enumerable:!0,get:function(){return t.cookieIsNetaceaV3Format}}),Object.defineProperty(e,"objectIsNetaceaCookieV3",{enumerable:!0,get:function(){return t.objectIsNetaceaCookieV3}}),Object.defineProperty(e,"defaultInvalidResponse",{enumerable:!0,get:function(){return t.defaultInvalidResponse}});var r=Oe;Object.defineProperty(e,"AbstractCookieFactory",{enumerable:!0,get:function(){return r.AbstractCookieFactory}});var n=ke;Object.defineProperty(e,"netaceaCookieV3KeyMap",{enumerable:!0,get:function(){return n.netaceaCookieV3KeyMap}}),Object.defineProperty(e,"netaceaCookieV3OptionalKeyMap",{enumerable:!0,get:function(){return n.netaceaCookieV3OptionalKeyMap}}),Object.defineProperty(e,"COOKIEDELIMITER",{enumerable:!0,get:function(){return n.COOKIEDELIMITER}});var a=ye;Object.defineProperty(e,"NetaceaCookieV3IssueReason",{enumerable:!0,get:function(){return a.NetaceaCookieV3IssueReason}})}(ge);var Re={};Object.defineProperty(Re,"__esModule",{value:!0}),Re.validateRedirectLocation=void 0,Re.validateRedirectLocation=function(e){if(""!==(e=null!=e?e:""))try{return new URL(e).toString()}catch(t){if(/^https?:\/\//i.test(e))return;return e.startsWith("/")?e:"/".concat(e)}};var Me={},Ke={};function xe(e,t){for(var r=0,n=Object.keys(e);r<n.length;r++){var a,i=n[r];if("cookie"===i||"Cookie"===i){var o=null!==(a=e[i])&&void 0!==a?a:"",c=je("string"==typeof o?o:o.join("; "),t);if(void 0!==c)return c}}}function He(e,t){for(var r=[],n=0,a=Object.keys(e);n<a.length;n++){var i,o=a[n];if("cookie"===o||"Cookie"===o){var c=null!==(i=e[o])&&void 0!==i?i:"",s="string"==typeof c?c:c.join("; ");r.push.apply(r,d(Ve(s,t)))}}return r}function je(e,t){var r=t+"=";return e.split(";").map((function(e){return e.trimStart()})).find((function(e){return e.startsWith(r)}))}function Ve(e,t){var r=t+"=";return e.split(";").map((function(e){return e.trimStart()})).filter((function(e){return e.startsWith(r)}))}Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.findAllInCookieString=Ke.findFirstInCookieString=Ke.findAllInHeaders=Ke.findFirstInHeaders=Ke.findOnlyValueInHeaders=Ke.findAllValuesInHeaders=Ke.findFirstValueInHeaders=void 0,Ke.findFirstValueInHeaders=function(e,t){var r=xe(e,t);if(void 0!==r)return r.slice(t.length+1)},Ke.findAllValuesInHeaders=function(e,t){return He(e,t).map((function(e){return e.slice(t.length+1)}))},Ke.findOnlyValueInHeaders=function(e,t){var r,n=He(e,t);if(n.length>1)throw new Error("Found more than one cookie with name ".concat(t));return null===(r=n[0])||void 0===r?void 0:r.slice(t.length+1)},Ke.findFirstInHeaders=xe,Ke.findAllInHeaders=He,Ke.findFirstInCookieString=je,Ke.findAllInCookieString=Ve;var Le={};function Fe(e){return"set-cookie"===e||"Set-Cookie"===e}function De(e,t){var r=t+"=";return e.startsWith(r)}function Be(e,t){if(!De(e,t))throw new Error("Cookie '".concat(t,"' not found in '").concat(e,"'"));return e.slice(t.length+1).split(";")[0]}function qe(e,t){var r,n=null!==(r=e[t])&&void 0!==r?r:[];return"string"==typeof n?[n]:n}function Ue(e,t){for(var r=0,n=Object.keys(e);r<n.length;r++){var a=n[r];if(Fe(a)){var i=ze(qe(e,a),t);if(void 0!==i)return i}}}function ze(e,t){return e.map((function(e){return e.trimStart()})).find((function(e){return De(e,t)}))}function Ge(e,t){for(var r=[],n=0,a=Object.keys(e);n<a.length;n++){var i=a[n];if(Fe(i)){var o=qe(e,i);r.push.apply(r,d(Xe(o,t)))}}return r}function Xe(e,t){return e.map((function(e){return e.trimStart()})).filter((function(e){return De(e,t)}))}Object.defineProperty(Le,"__esModule",{value:!0}),Le.findAllInSetCookieStrings=Le.findAllInHeaders=Le.findValueInSetCookieStrings=Le.findFirstInSetCookieStrings=Le.findFirstInHeaders=Le.findOnlyValueInHeaders=Le.findFirstValueInHeaders=Le.parseValueFromString=void 0,Le.parseValueFromString=Be,Le.findFirstValueInHeaders=function(e,t){var r=Ue(e,t);return void 0!==r?Be(r,t):void 0},Le.findOnlyValueInHeaders=function(e,t){var r=Ge(e,t);if(r.length>1)throw new Error("Found more than one set-cookie with name ".concat(t));return void 0!==r[0]?Be(r[0],t):void 0},Le.findFirstInHeaders=Ue,Le.findFirstInSetCookieStrings=ze,Le.findValueInSetCookieStrings=function(e,t){var r=ze(e,t);if(void 0!==r)return Be(r,t)},Le.findAllInHeaders=Ge,Le.findAllInSetCookieStrings=Xe;var Je=de&&de.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),We=de&&de.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),$e=de&&de.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&Je(t,e,r);return We(t,e),t};Object.defineProperty(Me,"__esModule",{value:!0}),Me.setCookie=Me.cookie=void 0,Me.cookie=$e(Ke),Me.setCookie=$e(Le);var Qe={},Ye={},Ze={};Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.KINESIS_URL=Ze.API_VERSION=Ze.REGION=Ze.PAYLOAD_TYPE=Ze.STATE=void 0,Ze.STATE={ACTIVE:"ACTIVE",UPDATING:"UPDATING",CREATING:"CREATING",DELETING:"DELETING"},Ze.PAYLOAD_TYPE="string",Ze.REGION="eu-west-1",Ze.API_VERSION="2013-12-02",Ze.KINESIS_URL="https://kinesis.eu-west-1.amazonaws.com";var et={};function tt(){return(tt=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,new Promise((function(e){setTimeout(e,t)}));case 1:return e.a(2)}}),e)})))).apply(this,arguments)}Object.defineProperty(et,"__esModule",{value:!0}),et.headersToRecord=et.increaseBatchSize=et.handleFailedLogs=et.batchArrayForKinesis=et.sleep=void 0,et.sleep=function(e){return tt.apply(this,arguments)},et.batchArrayForKinesis=function(e,t,r){for(var n=[],a=0;a<e.length;a+=t){var i=e.slice(a,a+t);n.push({Data:r.from(JSON.stringify(i)).toString("base64"),PartitionKey:Date.now().toString()})}return n},et.handleFailedLogs=function(e,t,r){var n=2*r,a=[].concat(d(e),d(t)),i=a.length-n;return i>0&&(console.error("Netacea Error :: failed to send ".concat(i," log(s) to Kinesis ingest.")),a.splice(0,i)),a},et.increaseBatchSize=function(e,t){return e!==t?Math.min(t,2*e):e},et.headersToRecord=function(e){var t={};return e.forEach((function(e,r){t[r]=e})),t},Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.WebStandardKinesis=void 0;var rt=Ze,nt=et,at=function(){return g((function e(t){var r=t.deps,n=t.kinesisIngestArgs;if(v(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.deps=r,void 0===n.kinesisAccessKey)throw new Error("kinesisAccessKey is required for kinesis ingest");if(void 0===n.kinesisSecretKey)throw new Error("kinesisSecretKey is required for kinesis ingest");this.kinesisStreamName=n.kinesisStreamName,this.kinesisAccessKey=n.kinesisAccessKey,this.kinesisSecretKey=n.kinesisSecretKey,this.maxAwaitTimePerIngestCallMs=n.maxAwaitTimePerIngestCallMs,void 0!==n.maxLogAgeSeconds&&n.maxLogAgeSeconds<this.maxLogAgeSeconds&&n.maxLogAgeSeconds>0&&(this.maxLogAgeSeconds=n.maxLogAgeSeconds),void 0!==n.logBatchSize&&(this.maxLogBatchSize=n.logBatchSize),this.logBatchSize=!0===n.rampUpBatchSize?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(r=p(l().m((function e(){var t,r,n;return l().w((function(e){for(;;)switch(e.n){case 0:if(0!==this.logCache.length){e.n=1;break}return e.a(2);case 1:return t=d(this.logCache),this.logCache=[],e.p=2,r=new this.deps.AwsClient({accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey}),e.n=3,this.signRequest(r,{streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},t,this.logBatchSize);case 3:return n=e.v,e.n=4,this.deps.makeRequest({headers:(0,nt.headersToRecord)(n.headers),host:rt.KINESIS_URL,method:"POST",path:"/",body:n.body});case 4:this.logBatchSize=(0,nt.increaseBatchSize)(this.logBatchSize,this.maxLogBatchSize),e.n=6;break;case 5:e.p=5,e.v,this.logCache=(0,nt.handleFailedLogs)(this.logCache,t,this.maxLogBatchSize);case 6:return e.a(2)}}),e,this,[[2,5]])}))),function(){return r.apply(this,arguments)})},{key:"ingest",value:(t=p(l().m((function e(t){var r,n,a=this;return l().w((function(e){for(;;)switch(e.n){case 0:if(this.logCache.push(t),!(this.logCache.length>=this.logBatchSize)){e.n=2;break}return(r=[]).push(this.putToKinesis()),void 0!==this.maxAwaitTimePerIngestCallMs&&r.push((0,nt.sleep)(this.maxAwaitTimePerIngestCallMs)),e.n=1,Promise.race(r);case 1:e.n=3;break;case 2:if(this.intervalSet){e.n=3;break}if(this.intervalSet=!0,n=(0,nt.sleep)(1e3*this.maxLogAgeSeconds).then(p(l().m((function e(){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,a.putToKinesis();case 1:a.intervalSet=!1;case 2:return e.a(2)}}),e)})))).catch((function(){})),void 0!==this.maxAwaitTimePerIngestCallMs){e.n=3;break}return e.n=3,n;case 3:return e.a(2)}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"signRequest",value:(e=p(l().m((function e(t,r,n,a){var i,o;return l().w((function(e){for(;;)switch(e.n){case 0:return i={Records:(0,nt.batchArrayForKinesis)(n,a,this.deps.Buffer),PartitionKey:Date.now().toString(),StreamName:r.streamName},e.n=1,t.sign(rt.KINESIS_URL,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"}});case 1:return o=e.v,e.a(2,o)}}),e,this)}))),function(t,r,n,a){return e.apply(this,arguments)})}]);var e,t,r}();Ye.WebStandardKinesis=at;var it={};Object.defineProperty(it,"__esModule",{value:!0}),it.Kinesis=void 0;var ot=Ze,ct=et,st=function(){return g((function e(t){var r=t.deps,n=t.kinesisIngestArgs;v(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.deps=r,this.kinesisStreamName=n.kinesisStreamName,this.kinesisAccessKey=n.kinesisAccessKey,this.kinesisSecretKey=n.kinesisSecretKey,this.maxAwaitTimePerIngestCallMs=n.maxAwaitTimePerIngestCallMs,void 0!==n.maxLogAgeSeconds&&n.maxLogAgeSeconds<this.maxLogAgeSeconds&&n.maxLogAgeSeconds>0&&(this.maxLogAgeSeconds=n.maxLogAgeSeconds),void 0!==n.logBatchSize&&(this.maxLogBatchSize=n.logBatchSize),this.logBatchSize=!0===n.rampUpBatchSize?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(t=p(l().m((function e(){var t,r,n,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(0!==this.logCache.length){e.n=1;break}return e.a(2);case 1:if(t=d(this.logCache),this.logCache=[],e.p=2,"POST"===(a=this.signRequest({streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},t,this.logBatchSize)).method){e.n=3;break}throw new Error("Unexpected method. Expected POST but got ".concat(a.method));case 3:return e.n=4,this.deps.makeRequest({headers:null!==(r=a.headers)&&void 0!==r?r:{},host:"https://".concat(a.hostname),method:a.method,path:null!==(n=a.path)&&void 0!==n?n:"/",body:a.body});case 4:this.logBatchSize=(0,ct.increaseBatchSize)(this.logBatchSize,this.maxLogBatchSize),e.n=6;break;case 5:e.p=5,e.v,this.logCache=(0,ct.handleFailedLogs)(this.logCache,t,this.maxLogBatchSize);case 6:return e.a(2)}}),e,this,[[2,5]])}))),function(){return t.apply(this,arguments)})},{key:"ingest",value:(e=p(l().m((function e(t){var r,n,a=this;return l().w((function(e){for(;;)switch(e.n){case 0:if(this.logCache.push(t),!(this.logCache.length>=this.logBatchSize)){e.n=2;break}return(r=[]).push(this.putToKinesis()),void 0!==this.maxAwaitTimePerIngestCallMs&&r.push((0,ct.sleep)(this.maxAwaitTimePerIngestCallMs)),e.n=1,Promise.race(r);case 1:e.n=3;break;case 2:if(this.intervalSet){e.n=3;break}if(this.intervalSet=!0,n=(0,ct.sleep)(1e3*this.maxLogAgeSeconds).then(p(l().m((function e(){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,a.putToKinesis();case 1:a.intervalSet=!1;case 2:return e.a(2)}}),e)})))).catch((function(){})),void 0!==this.maxAwaitTimePerIngestCallMs){e.n=3;break}return e.n=3,n;case 3:return e.a(2)}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"signRequest",value:function(e,t,r){var n=e.accessKeyId,a=e.secretAccessKey,i={Records:(0,ct.batchArrayForKinesis)(t,r,this.deps.Buffer),PartitionKey:Date.now().toString(),StreamName:e.streamName};return this.deps.aws4.sign({service:"kinesis",body:JSON.stringify(i),headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"},region:ot.REGION},{accessKeyId:n,secretAccessKey:a})}}]);var e,t}();it.Kinesis=st,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Kinesis=e.WebStandardKinesis=void 0;var t=Ye;Object.defineProperty(e,"WebStandardKinesis",{enumerable:!0,get:function(){return t.WebStandardKinesis}});var r=it;Object.defineProperty(e,"Kinesis",{enumerable:!0,get:function(){return r.Kinesis}})}(Qe);var ut={};function lt(e,t){var r=null;if("number"==typeof e&&Number.isFinite(e))r=e;else if("string"==typeof e&&""!==e.trim()){var n=Number(e);Number.isFinite(n)&&(r=n)}if(null===r){if("number"!=typeof t.defaultValue)return t.defaultValue;r=t.defaultValue}return void 0!==t.minValue&&(r=Math.max(t.minValue,r)),void 0!==t.maxValue&&(r=Math.min(t.maxValue,r)),r}Object.defineProperty(ut,"__esModule",{value:!0}),ut.parseUrl=ut.parseHttpHeaderName=ut.stringOrDefault=ut.parseIntOrDefault=ut.parseNumberOrDefault=void 0,ut.parseNumberOrDefault=lt,ut.parseIntOrDefault=function(e,t){var r=lt(e,t);return"number"==typeof r?Math.floor(r):r},ut.stringOrDefault=function(e,t){return"string"==typeof e&&""!==e?e:"number"==typeof e?e.toString():t},ut.parseHttpHeaderName=function(e){if("string"==typeof e){return/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/.test(e)?e:void 0}},ut.parseUrl=function(e){var t=/^[a-z][a-z\d+.-]*:\/\/([^/?#]+)([^?#]*)?(?:[?#].*)?$/i.exec(e);if(null!==t){var r=I(t,3),n=r[1],a=r[2];return{host:n.slice(n.lastIndexOf("@")+1),path:void 0===a||""===a?"/":a}}};var ht={};Object.defineProperty(ht,"__esModule",{value:!0}),ht.searchParamsFromRecord=void 0,ht.searchParamsFromRecord=function(e){for(var t=new URLSearchParams,r=0,n=Object.entries(e);r<n.length;r++){var a=I(n[r],2),i=a[0],o=a[1];t.append(i,o)}return t};var dt={},ft={};Object.defineProperty(ft,"__esModule",{value:!0}),ft.JweFactory=void 0;var pt=function(){return g((function e(t){v(this,e),this.jose=t}),[{key:"encrypt",value:(t=p(l().m((function e(t,r){var n,a,i,o,c=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:return n=c.length>2&&void 0!==c[2]?c[2]:"A128CBC-HS256",a=this.jose.base64url.decode(r),i=(new TextEncoder).encode(t),e.n=1,new this.jose.CompactEncrypt(i).setProtectedHeader({alg:"dir",enc:n}).encrypt(a);case 1:return o=e.v,e.a(2,o)}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"decrypt",value:(e=p(l().m((function e(t,r){var n,a,i;return l().w((function(e){for(;;)switch(e.n){case 0:return n=this.jose.base64url.decode(r),e.n=1,this.jose.compactDecrypt(t,n,{keyManagementAlgorithms:["dir"],contentEncryptionAlgorithms:["A256GCM","A128CBC-HS256"]});case 1:return a=e.v,i=a.plaintext,e.a(2,(new TextDecoder).decode(i))}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}],[{key:"isJweEncrypted",value:function(e){return 5===e.split(".").length&&e.includes("..")}}]);var e,t}();ft.JweFactory=pt;var vt=de&&de.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),yt=de&&de.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),gt=de&&de.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&vt(t,e,r);return yt(t,e),t};Object.defineProperty(dt,"__esModule",{value:!0}),dt.jwe=void 0,dt.jwe=gt(ft);var mt={};Object.defineProperty(mt,"__esModule",{value:!0}),mt.truncateLongFields=mt.parseGraphQl=mt.parseGraphQlRequestBody=mt.getGraphQLParserConfig=void 0;var kt=ut;function Ct(e,t){var r,n,a=e.parserRegex;return null!==(r=null===(n=t.match(a))||void 0===n?void 0:n.groups)&&void 0!==r?r:{}}function bt(e,t){for(var r,n,a=e.maxValueLength,i=0,o=Object.keys(t);i<o.length;i++){var c=o[i],s=t[c];t[c]=(n=a,(r=s).length<=n?r:r.slice(0,n)+"…")}return t}mt.getGraphQLParserConfig=function(e){var t,r={includePaths:[],maxParsableBytes:(0,kt.parseIntOrDefault)(null==e?void 0:e.maxParsableBytes,{defaultValue:1e6,minValue:1e3}),maxValueLength:(0,kt.parseIntOrDefault)(null==e?void 0:e.maxValueLength,{defaultValue:256,minValue:8}),parserRegex:o(/^\s*(query|mutation|subscription)\s+([_A-Za-z][_0-9A-Za-z]+)?/,{OpType:1,OpName:2}),useStrictAcceptHeaderCheck:null===(t=null==e?void 0:e.useStrictAcceptHeaderCheck)||void 0===t||t};if(Array.isArray(null==e?void 0:e.includePaths)){var n,a=S(e.includePaths);try{for(a.s();!(n=a.n()).done;){var i=n.value;"string"==typeof i&&r.includePaths.push(i)}}catch(e){a.e(e)}finally{a.f()}}try{if((null==e?void 0:e.parserRegex)instanceof RegExp)r.parserRegex=null==e?void 0:e.parserRegex;else if("object"===u(null==e?void 0:e.parserRegex)){var c=null==e?void 0:e.parserRegex,s=c.regex,l=c.flags;"string"==typeof s&&(r.parserRegex=new RegExp(s,l))}}catch(e){}return r},mt.parseGraphQlRequestBody=function(e,t){var r,n;if(""===t)throw new Error("Netacea Error: Empty GraphQL body received");var a=JSON.parse(t);if("object"!==u(a))throw new Error("Netacea Error: Invalid GraphQL JSON");var i=k({},Ct(e,null!==(r=null==a?void 0:a.query)&&void 0!==r?r:"")),o=(null!==(n=null==a?void 0:a.operationName)&&void 0!==n?n:"").trim();return""!==o&&(i.OpName=o),bt(e,i)},mt.parseGraphQl=Ct,mt.truncateLongFields=bt;var St={},It={};Object.defineProperty(It,"__esModule",{value:!0}),It.findBestMitigation=It.isCaptchaMitigation=void 0;var Ot=pe;function At(e){return"[".concat(e,"]")}var wt=(C(C(C(C(C(C(C(C(C(C(e={},Ot.MatchCode.NONE,""),Ot.MatchCode.USER_AGENT,"ua_"),Ot.MatchCode.IP,"ip_"),Ot.MatchCode.VISITOR,"visitor_"),Ot.MatchCode.DATACENTER,"datacenter_"),Ot.MatchCode.CUSTOMER_SESSION,"customer_session_"),Ot.MatchCode.ORGANISATION,"organisation_"),Ot.MatchCode.ASN,"asn_"),Ot.MatchCode.COUNTRY,"country_"),Ot.MatchCode.COMBINATION,"combination_"),C(C(C(C(C(e,Ot.MatchCode.HEADER_FINGERPRINT,"headerFP_"),Ot.MatchCode.VENDOR_FAMILY,"vendorFamily_"),Ot.MatchCode.VENDOR_NAME,"vendorName_"),Ot.MatchCode.VENDOR,"vendor_"),Ot.MatchCode.VENDOR_CRAWLER_CLASSIFICATION,"vendorCrawlerClassification_")),Nt=C(C(C(C(C(C({},Ot.MitigateCode.NONE,""),Ot.MitigateCode.BLOCK,"blocked"),Ot.MitigateCode.ALLOW,"allow"),Ot.MitigateCode.HARDBLOCK,"hardblocked"),Ot.MitigateCode.FLAG,"flagged"),Ot.MitigateCode.MONETISE,"monetised"),Et=(C(C(C(C(C(C(C(C(C(C(t={},Ot.CaptchaCode.NONE,""),Ot.CaptchaCode.SERVE,"captcha_serve"),Ot.CaptchaCode.PASS,"captcha_pass"),Ot.CaptchaCode.FAIL,"captcha_fail"),Ot.CaptchaCode.COOKIE_PASS,"captcha_cookiepass"),Ot.CaptchaCode.COOKIE_FAIL,"captcha_cookiefail"),Ot.CaptchaCode.CHECKPOINT_SIGNAL,"checkpoint_signal"),Ot.CaptchaCode.CHECKPOINT_POST,"checkpoint_post"),Ot.CaptchaCode.CHECKPOINT_SERVE,"checkpoint_serve"),Ot.CaptchaCode.CHECKPOINT_PASS,"checkpoint_pass"),C(C(C(t,Ot.CaptchaCode.CHECKPOINT_FAIL,"checkpoint_fail"),Ot.CaptchaCode.CHECKPOINT_COOKIE_PASS,"checkpoint_cookiepass"),Ot.CaptchaCode.CHECKPOINT_COOKIE_FAIL,"checkpoint_cookiefail"));It.isCaptchaMitigation=function(e){return[Ot.CaptchaCode.SERVE,Ot.CaptchaCode.FAIL,Ot.CaptchaCode.COOKIE_FAIL,Ot.CaptchaCode.CHECKPOINT_POST,Ot.CaptchaCode.CHECKPOINT_SERVE,Ot.CaptchaCode.CHECKPOINT_FAIL,Ot.CaptchaCode.CHECKPOINT_COOKIE_FAIL].includes(e.captcha)},It.findBestMitigation=function(e,t,r,n){var a,i,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];r=function(e,t){var r;return t?e:null!==(r=C(C(C(C({},Ot.CaptchaCode.PASS,Ot.CaptchaCode.COOKIE_PASS),Ot.CaptchaCode.FAIL,Ot.CaptchaCode.COOKIE_FAIL),Ot.CaptchaCode.CHECKPOINT_PASS,Ot.CaptchaCode.CHECKPOINT_COOKIE_PASS),Ot.CaptchaCode.CHECKPOINT_FAIL,Ot.CaptchaCode.CHECKPOINT_COOKIE_FAIL)[e])&&void 0!==r?r:e}(r,n),o&&(r=Ot.CaptchaCode.CHECKPOINT_SIGNAL);var c,s=null!==(a=wt[e])&&void 0!==a?a:At(e)+"_";return s+=null!==(i=Nt[t])&&void 0!==i?i:At(t),r!==Ot.CaptchaCode.NONE&&(s+=","+(null!==(c=Et[r])&&void 0!==c?c:At(r))),{sessionStatus:s,codes:{match:e,mitigate:t,captcha:r}}},function(e){var t=de&&de.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=de&&de.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(It,e)}(St);var _t={},Pt={};Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.ResponseView=Pt.AbstractResponseView=void 0;var Tt=function(){return g((function e(t){v(this,e),this.cacheStatus=t}),[{key:"contentType",get:function(){var e;return null===(e=this.readHeader("content-type"))||void 0===e?void 0:e[0]}},{key:"contentLength",get:function(){var e;return null===(e=this.readHeader("content-length"))||void 0===e?void 0:e[0]}},{key:"location",get:function(){var e;return null===(e=this.readHeader("location"))||void 0===e?void 0:e[0]}},{key:"setCookie",get:function(){return this.readHeader("set-cookie")}}])}();Pt.AbstractResponseView=Tt;var Rt=function(){function e(t,r){var a;return v(this,e),(a=n(this,e,[r])).response=t,a}return c(e,Tt),g(e,[{key:"status",get:function(){return this.response.status}},{key:"getBody",value:(t=p(l().m((function e(){var t,r,n,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==this._body){e.n=5;break}return e.n=1,this.response.clone().text();case 1:if(n=t=e.v,!(r=null!==n)){e.n=2;break}r=void 0!==t;case 2:if(!r){e.n=3;break}a=t,e.n=4;break;case 3:a="";case 4:this._body=a;case 5:return e.a(2,this._body)}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"readHeader",value:function(e){var t;if("set-cookie"===(e=e.toLowerCase()))return this.response.headers.getSetCookie();var r=null!==(t=this.response.headers.get(e))&&void 0!==t?t:void 0;return void 0!==r?[r]:[]}},{key:"readHeaders",value:function(){var e={};return this.response.headers.forEach((function(t,r){e[r]=[t]})),e["set-cookie"]=this.response.headers.getSetCookie(),e}}]);var t}();Pt.ResponseView=Rt,Object.defineProperty(_t,"__esModule",{value:!0}),_t.HttpClient=_t.AbstractHttpClient=void 0;var Mt=Pt,Kt=function(){return g((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};v(this,e),this.cache=t.cache}),[{key:"request",value:(n=p(l().m((function e(t,r){var n,a,i;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0===(a=null===(n=this.cache)||void 0===n?void 0:n.get(t,r))){e.n=1;break}return e.a(2,this.createCachedResponseView(a));case 1:return e.n=2,this.fetch(t,r);case 2:return i=e.v,e.n=3,this.populateCache(t,r,i);case 3:return e.a(2,i)}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"populateCache",value:(r=p(l().m((function e(t,r,n){return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==this.cache){e.n=1;break}return e.a(2);case 1:return e.n=2,this.cache.set(t,r,n).catch((function(){}));case 2:return e.a(2)}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"get",value:(t=p(l().m((function e(t,r){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.request(t,k(k({},r),{},{method:"GET"}));case 1:return e.a(2,e.v)}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"post",value:(e=p(l().m((function e(t,r,n){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.request(t,k(k({},n),{},{method:"POST",body:r}));case 1:return e.a(2,e.v)}}),e,this)}))),function(t,r,n){return e.apply(this,arguments)})}]);var e,t,r,n}();_t.AbstractHttpClient=Kt;var xt=function(){function e(t){var r;return v(this,e),(r=n(this,e,[t])).fetchFn=t.fetch,r}return c(e,Kt),g(e,[{key:"fetch",value:(t=p(l().m((function e(t,r){var n;return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,Ht(this.fetchFn(t,r),null==r?void 0:r.timeoutMs);case 1:return n=e.v,e.a(2,new Mt.ResponseView(n,"MISS"))}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"createCachedResponseView",value:function(e){var t=new Response(e.body,e);return new Mt.ResponseView(t,"HIT")}}]);var t}();function Ht(e,t){return jt.apply(this,arguments)}function jt(){return(jt=p(l().m((function e(t,r){var n,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==r){e.n=2;break}return e.n=1,t;case 1:case 4:return e.a(2,e.v);case 2:return a=new Promise((function(e,t){n=setTimeout((function(){t(new Error("HTTP request timed out after ".concat(r,"ms")))}),r)})),e.p=3,e.n=4,Promise.race([t,a]);case 5:return e.p=5,void 0!==n&&clearTimeout(n),e.f(5);case 6:return e.a(2)}}),e,null,[[3,,5,6]])})))).apply(this,arguments)}_t.HttpClient=xt;var Vt={},Lt={};Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.LruCache=void 0;var Ft=function(){return g((function e(t){if(v(this,e),this.capacity=t,this.entries=new Map,!Number.isInteger(t)||t<=0)throw new RangeError("LruCache capacity must be a positive integer")}),[{key:"size",get:function(){return this.entries.size}},{key:"get",value:function(e){if(this.entries.has(e)){var t=this.entries.get(e);return this.entries.delete(e),this.entries.set(e,t),t}}},{key:"set",value:function(e,t){if(this.entries.delete(e),this.entries.set(e,t),this.entries.size>this.capacity){var r=Array.from(this.entries.keys());r.length>0&&this.entries.delete(r[0])}}},{key:"find",value:function(e){var t,r=S(this.entries);try{for(r.s();!(t=r.n()).done;){var n=I(t.value,2),a=n[0];if(e(n[1],a))return this.get(a)}}catch(e){r.e(e)}finally{r.f()}}},{key:"delete",value:function(e){return this.entries.delete(e)}},{key:"clear",value:function(){this.entries.clear()}}])}();Lt.LruCache=Ft,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.HttpCache=void 0;var Dt=Lt,Bt=ut,qt=1048576;function Ut(e){var t={};if(void 0===e)return t;for(var r=0,n=Object.entries(e);r<n.length;r++){var a=I(n[r],2),i=a[0],o=a[1];t[i.toLowerCase()]=o}return t}function zt(e){if(void 0===e||""===e.trim())return{};var t,r={},n=S(e.split(","));try{for(n.s();!(t=n.n()).done;){var a=t.value.trim();if(""!==a){var i=a.indexOf("=");if(-1!==i)r[a.slice(0,i).trim().toLowerCase()]=a.slice(i+1).trim().replace(/^"(.+)"$/,"$1");else r[a.toLowerCase()]=!0}}}catch(e){n.e(e)}finally{n.f()}return r}function Gt(e){var t=(0,Bt.parseNumberOrDefault)(e,{defaultValue:void 0});return"number"==typeof t&&t>=0?t:void 0}function Xt(e){if(void 0!==e){var t=Date.parse(e);return Number.isNaN(t)?void 0:t}}function Jt(e,t){return{method:(r=null==t?void 0:t.method,(null!=r?r:"GET").toUpperCase()),url:e,headers:Ut(null==t?void 0:t.headers)};var r}function Wt(e){for(var t={},r=0,n=Object.entries(e.readHeaders());r<n.length;r++){var a=I(n[r],2),i=a[0],o=a[1];o.length>0&&(t[i.toLowerCase()]=o.join(", "))}return t}function $t(e){return void 0===e.vary?[]:e.vary.split(",").map((function(e){return e.trim().toLowerCase()})).filter((function(e){return""!==e}))}function Qt(e){return"GET"!==e.method?"method=".concat(e.method):void 0!==e.headers.authorization?"authorization header present":void 0!==e.headers.range?"range header present":void 0!==e.headers["if-match"]?"if-match header present":void 0!==e.headers["if-none-match"]?"if-none-match header present":void 0!==e.headers["if-modified-since"]?"if-modified-since header present":void 0!==e.headers["if-unmodified-since"]?"if-unmodified-since header present":void 0!==e.headers["if-range"]?"if-range header present":void 0!==zt(e.headers["cache-control"])["no-store"]?"request cache-control=no-store":void 0}function Yt(e,t){return!t.vary.includes("*")&&t.vary.every((function(r){var n,a;return(null!==(n=e.headers[r])&&void 0!==n?n:"")===(null!==(a=t.varyRequestHeaders[r])&&void 0!==a?a:"")}))}function Zt(e){var t,r=Gt(e.cacheControl["s-maxage"]);if(void 0!==r)return r;var n=Gt(e.cacheControl["max-age"]);if(void 0!==n)return n;var a=Xt(e.headers.expires);return void 0===a?0:Math.max(0,Math.floor((a-(null!==(t=e.dateHeaderMs)&&void 0!==t?t:e.storedAt))/1e3))}function er(e){return JSON.stringify([e.url,e.vary.map((function(t){var r;return[t,null!==(r=e.varyRequestHeaders[t])&&void 0!==r?r:""]}))])}var tr=function(){return g((function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};v(this,e),this.entries=new Dt.LruCache(10),this.defaultCacheControl=r.defaultCacheControl,this.now=null!==(t=r.now)&&void 0!==t?t:function(){return Date.now()}}),[{key:"get",value:function(e,t){var r=Jt(e,t);if("GET"!==r.method)return{body:"Not Found",headers:{},status:404,storedAt:this.now(),url:r.url,vary:[],varyRequestHeaders:{},cacheControl:{},ageSeconds:0};if(void 0===Qt(r)){var n=zt(r.headers["cache-control"]);if(void 0===n["no-cache"]){var a=this.entries.find((function(e){return e.url===r.url&&Yt(r,e)}));if(void 0!==a&&void 0===a.cacheControl["no-cache"]){var i=Gt(n["max-age"]),o=void 0===i?Zt(a):Math.min(Zt(a),i),c=function(e,t){return Math.max(0,Math.floor((t-e.storedAt)/1e3))+e.ageSeconds}(a,this.now());if(!(c>=o))return k(k({},a),{},{headers:k(k({},a.headers),{},{age:String(c)})})}}}}},{key:"set",value:(e=p(l().m((function e(t,r,n){var a,i,o,c,s,u,h,d,f,p,v,y,g,m,k;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0===Qt(o=Jt(t,r))){e.n=1;break}return e.a(2);case 1:if(c=this.entries.find((function(e){return e.url===o.url&&Yt(o,e)})),s=Wt(n),u=null!==(a=s["cache-control"])&&void 0!==a?a:this.defaultCacheControl,h=zt(u),!(200!==n.status||void 0!==h["no-store"]||void 0!==h.private||n.setCookie.length>0)){e.n=2;break}return this.removeEntry(c),e.a(2);case 2:if(!(d=$t(s)).includes("*")){e.n=3;break}return this.removeEntry(c),e.a(2);case 3:if(f=Number(s["content-length"]),!(Number.isFinite(f)&&f>qt)){e.n=4;break}return this.removeEntry(c),e.a(2);case 4:return e.n=5,n.getBody();case 5:if(p=e.v,!((new TextEncoder).encode(p).byteLength>qt)){e.n=6;break}return this.removeEntry(c),e.a(2);case 6:v=this.now(),y=Number(null!==(i=s.age)&&void 0!==i?i:"0"),g=Xt(s.date),m=void 0===g?0:Math.max(0,Math.floor((v-g)/1e3)),k={body:p,headers:s,status:n.status,storedAt:v,url:o.url,vary:d,varyRequestHeaders:Object.fromEntries(d.map((function(e){var t;return[e,null!==(t=o.headers[e])&&void 0!==t?t:""]}))),cacheControl:h,dateHeaderMs:g,ageSeconds:Math.max(Number.isFinite(y)&&y>=0?y:0,m)},void 0!==c&&this.entries.delete(er(c)),this.entries.set(er(k),k);case 7:return e.a(2)}}),e,this)}))),function(t,r,n){return e.apply(this,arguments)})},{key:"removeEntry",value:function(e){void 0!==e&&this.entries.delete(er(e))}}]);var e}();Vt.HttpCache=tr;var rr={},nr={};Object.defineProperty(nr,"__esModule",{value:!0}),nr.createComputedSignatureInputs=nr.createComputedSignatureInput=void 0;var ar=/^[a-z*][a-z0-9_.*-]{0,63}$/,ir=/^"(?:[^"\\]|\\.)*"$/,or=/^[^;"\s]+$/,cr=/^"[^"\\]+"(?:;[a-z*][a-z0-9_.*-]*(?:=(?:"(?:[^"\\]|\\.)*"|[^; ]+))?)*$/;function sr(e,t){var r=hr(t);if(void 0!==r){var n=[].concat(d(r.componentIdentifiers.map((function(t){var r=function(e,t){var r,n=null===(r=/^"([^"\\]+)"/.exec(t))||void 0===r?void 0:r[1];if(void 0===n)return;var a,i=ur(t,"name");switch(n){case"@authority":a=e.url.host;break;case"@method":a=e.method;break;case"@path":a=e.url.path;break;case"@query":a=e.url.query;break;case"@query-param":a="string"==typeof i?function(e,t){var r=new URLSearchParams(e.slice(1)).getAll(t);return r.map(lr).join(", ")}(e.url.query,i):void 0;break;case"@request-target":a="".concat(e.method.toLowerCase()," ").concat(e.url.path).concat(e.url.query);break;case"@scheme":a=e.url.scheme;break;case"@target-uri":a=e.url.toString();break;default:a=function(e,t,r){var n=e.readHeader(t),a=0===n.length?void 0:n.map((function(e){return e.trim()})).join(", ");return void 0!==a&&r?function(e){var t,r="",n=!1,a=!1,i=!1,o=!1,c=S(e.trim());try{for(c.s();!(t=c.n()).done;){var s=t.value;a?(r+=s,a=!1):n&&"\\"===s?(r+=s,a=!0):'"'===s?(r+=s,n=!n):n?r+=s:/\s/.test(s)?o||(i=!0):"="===s||";"===s?(r=r.trimEnd()+s,i=!1,o=!0):","===s?(r=r.trimEnd()+", ",i=!1,o=!1):(i&&""!==r&&!r.endsWith(" ")&&(r+=" "),r+=s,i=!1,o=!1)}}catch(e){c.e(e)}finally{c.f()}return r.trimEnd()}(a):a}(e,n,!0===ur(t,"sf"))}return a}(e,t);return void 0===r?void 0:"".concat(t,": ").concat(r)}))),['"@signature-params": '.concat(r.parameters)]);if(!n.some((function(e){return void 0===e})))return n.join("\n")}}function ur(e,t){var r=e.indexOf('"',1),n=e.slice(r+1);if(n.startsWith(";")){var a,i=S(fr(n.slice(1),";"));try{for(i.s();!(a=i.n()).done;){var o=a.value,c=o.indexOf("=");if((-1===c?o:o.slice(0,c))===t){if(-1===c)return!0;var s=o.slice(c+1);return ir.test(s)?s.slice(1,-1).replace(/\\(.)/g,"$1"):s}}}catch(e){i.e(e)}finally{i.f()}}}function lr(e){return encodeURIComponent(e).replace(/[!'()*]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function hr(e){var t=e.indexOf("=");if(-1!==t){var r=e.slice(0,t);if(ar.test(r)){var n=e.slice(t+1),a=dr(n,")",1);if(n.startsWith("(")&&-1!==a&&function(e){if(""===e)return!0;return e.startsWith(";")&&fr(e.slice(1),";").every((function(e){var t=e.indexOf("=");if(-1===t)return!1;var r=e.slice(0,t),n=e.slice(t+1);return ar.test(r)&&function(e){return ir.test(e)||or.test(e)}(n)}))}(n.slice(a+1))){var i=n.slice(1,a),o=""===i?[]:fr(i," ");return o.every((function(e){return cr.test(e)}))?{label:r,componentIdentifiers:o,parameters:n}:void 0}}}}function dr(e,t){for(var r=!1,n=!1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;a<e.length;a++){var i=e[a];if(n)n=!1;else if(r&&"\\"===i)n=!0;else if('"'===i)r=!r;else if(!r&&i===t)return a}return-1}function fr(e,t){for(var r=[],n=0,a=dr(e,t);-1!==a;)r.push(e.slice(n,a)),a=dr(e,t,n=a+1);return r.push(e.slice(n)),r}nr.createComputedSignatureInput=sr,nr.createComputedSignatureInputs=function(e,t){var r,n={},a=S(fr(t,","));try{for(a.s();!(r=a.n()).done;){var i=r.value.trim(),o=hr(i),c=sr(e,i);if(void 0===o||void 0===c)return;n[o.label]=c}}catch(e){a.e(e)}finally{a.f()}return n},Object.defineProperty(rr,"__esModule",{value:!0}),rr.AbstractRequestView=void 0;var pr=ut,vr=nr,yr=function(){return g((function e(t){v(this,e),this._httpMsgSignature=void 0,this._buffer=t}),[{key:"contentLength",get:function(){var e;return(0,pr.parseIntOrDefault)(null===(e=this.readHeader("content-length"))||void 0===e?void 0:e[0],{defaultValue:0,minValue:0,maxValue:Number.MAX_SAFE_INTEGER})}},{key:"userAgent",get:function(){var e,t;return null!==(e=null===(t=this.readHeader("user-agent"))||void 0===t?void 0:t[0])&&void 0!==e?e:""}},{key:"contentType",get:function(){var e;return null===(e=this.readHeader("content-type"))||void 0===e?void 0:e[0]}},{key:"xForwardedFor",get:function(){var e;return null===(e=this.readHeader("x-forwarded-for"))||void 0===e?void 0:e[0]}},{key:"referer",get:function(){var e;return null===(e=this.readHeader("referer"))||void 0===e?void 0:e[0]}},{key:"accept",get:function(){var e;return null===(e=this.readHeader("accept"))||void 0===e?void 0:e[0]}},{key:"host",get:function(){var e;return null===(e=this.readHeader("host"))||void 0===e?void 0:e[0]}},{key:"getHttpMsgSignature",value:(e=p(l().m((function e(){var t,r,n,a,i,o,c,s,u;return l().w((function(e){for(;;)switch(e.n){case 0:if(t=this.readJoinedHeader("Signature-Input"),r=this.readJoinedHeader("Signature"),n=void 0===t?void 0:this.createBase64SignatureInput(t),void 0!==this._httpMsgSignature){e.n=4;break}if(a=r,void 0!==r){e.n=1;break}i=void 0,e.n=3;break;case 1:return e.n=2,this.sha256Hash(r);case 2:i=e.v.toLowerCase().slice(0,12);case 3:o=i,c=t,s=this.readJoinedHeader("Signature-Agent"),u=n,this._httpMsgSignature={signature:a,signatureSha256:o,signatureInput:c,signatureAgent:s,computedInput:u};case 4:return e.a(2,this._httpMsgSignature)}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"readJoinedHeader",value:function(e){var t=this.readHeader(e).join(",");return""!==t?t:void 0}},{key:"toBase64",value:function(e){if(void 0!==e)return this._buffer.from(e).toString("base64")}},{key:"createBase64SignatureInput",value:function(e){var t=this,r=(0,vr.createComputedSignatureInputs)(this,e);if(void 0!==r)return Object.entries(r).map((function(e){var r=I(e,2),n=r[0],a=r[1];return"".concat(n,"=:").concat(t.toBase64(a),":")})).join(", ")}}]);var e}();rr.AbstractRequestView=yr;var gr={};Object.defineProperty(gr,"__esModule",{value:!0}),gr.RequestUrl=void 0;var mr=function(){function e(t,r,n,a){v(this,e),this.scheme=t,this.host=r,this.path=n,this.query=a}return g(e,[{key:"toString",value:function(){var e=""===this.scheme?"":"".concat(this.scheme,"://");return"".concat(e).concat(this.host).concat(this.path).concat(this.query)}}],[{key:"fromString",value:function(t){var r,n,a,i=/^(?:([a-z][a-z0-9+.-]*):\/\/)?([^/?#]+)(\/[^?#]*)?(\?[^#]*)?(?:#.*)?$/i.exec(t);if(null===i)throw new TypeError("Invalid request URL: ".concat(t));return new e(null!==(r=i[1])&&void 0!==r?r:"",i[2],null!==(n=i[3])&&void 0!==n?n:"/",null!==(a=i[4])&&void 0!==a?a:"")}}])}();gr.RequestUrl=mr;var kr={};Object.defineProperty(kr,"__esModule",{value:!0}),kr.ProtectorApiResponseView=void 0;var Cr=ut,br=function(){return g((function e(t){v(this,e),this.responseView=t}),[{key:"status",get:function(){return this.responseView.status}},{key:"getBody",value:(t=p(l().m((function e(){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.responseView.getBody();case 1:return e.a(2,e.v)}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"readHeader",value:function(e){return this.responseView.readHeader(e)}},{key:"redirectHost",get:function(){var e;return null===(e=this.readHeader("x-netacea-redirect-host"))||void 0===e?void 0:e[0]}},{key:"redirectLocation",get:function(){var e;return null===(e=this.readHeader("x-netacea-redirect-location"))||void 0===e?void 0:e[0]}},{key:"redirectStatus",get:function(){var e;return null===(e=this.readHeader("x-netacea-redirect-status"))||void 0===e?void 0:e[0]}},{key:"redirectStatusCode",get:function(){var e,t=null===(e=this.readHeader("x-netacea-redirect-status"))||void 0===e?void 0:e[0];if(void 0!==t){var r=(0,Cr.parseIntOrDefault)(t,{defaultValue:0,minValue:0,maxValue:Number.MAX_SAFE_INTEGER});return r>=300&&r<400?r:void 0}}},{key:"eventId",get:function(){var e;return null===(e=this.readHeader("x-netacea-event-id"))||void 0===e?void 0:e[0]}},{key:"signatureStatus",get:function(){var e;return null===(e=this.readHeader("x-netacea-signature-status"))||void 0===e?void 0:e[0]}},{key:"netaceaSettings",get:function(){var e,t=null===(e=this.readHeader("x-netacea-settings"))||void 0===e?void 0:e[0];if(void 0===t)return{checkAllPostRequests:!1};try{var r=new URLSearchParams(t).get("checkAllPostRequests");return null===r?{checkAllPostRequests:!1}:{checkAllPostRequests:"1"===r}}catch(e){return{checkAllPostRequests:!1}}}},{key:"sessionCookieMaxAge",get:function(){var e;return(0,Cr.parseIntOrDefault)(null===(e=this.readHeader("x-netacea-mitata-expiry"))||void 0===e?void 0:e[0],{defaultValue:86400,minValue:0,maxValue:Number.MAX_SAFE_INTEGER})}},{key:"captchaCookieMaxAge",get:function(){var e,t=null===(e=this.readHeader("x-netacea-mitatacaptcha-expiry"))||void 0===e?void 0:e[0];return(0,Cr.parseIntOrDefault)(t,{defaultValue:86400,minValue:0,maxValue:Number.MAX_SAFE_INTEGER})}},{key:"getProtectorCodes",value:function(e){var t,r,n,a,i,o,c,s,u;return{match:null!==(t=null!==(r=null===(n=this.readHeader("x-netacea-match"))||void 0===n?void 0:n[0])&&void 0!==r?r:null==e?void 0:e.match)&&void 0!==t?t:"0",mitigate:null!==(a=null!==(i=null===(o=this.readHeader("x-netacea-mitigate"))||void 0===o?void 0:o[0])&&void 0!==i?i:null==e?void 0:e.mitigate)&&void 0!==a?a:"0",captcha:null!==(c=null!==(s=null===(u=this.readHeader("x-netacea-captcha"))||void 0===u?void 0:u[0])&&void 0!==s?s:null==e?void 0:e.captcha)&&void 0!==c?c:"0"}}},{key:"getMonetisationRedirectLocation",value:function(e,t){var r=this.redirectLocation;if(void 0!==r)return r;var n=this.redirectHost;if(void 0!==n){var a=new URL("https://".concat(n));return a.pathname=e,a.search=t,a.toString()}}},{key:"getMonetisationRedirect",value:function(e,t){var r,n=this.getMonetisationRedirectLocation(e,t);if(void 0!==n)return{location:n,statusCode:null!==(r=this.redirectStatusCode)&&void 0!==r?r:303}}},{key:"getCaptchaJson",value:(e=p(l().m((function e(t,r){var n,a,i;return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.getBody();case 1:if(n=e.v,void 0===(a=this.eventId)&&"string"==typeof n&&(i=JSON.parse(n),a=Ir(i)),void 0!==a){e.n=2;break}throw new Error("Could not resolve Tracking ID for captcha event.");case 2:return e.a(2,Sr(t,r,a))}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}]);var e,t}();function Sr(e,t,r){var n="".concat(e,"?trackingId=").concat(r),a=void 0!==t?"https://".concat(t).concat(n):void 0;return JSON.stringify({captchaRelativeURL:n,captchaAbsoluteURL:a})}function Ir(e){if(null==e||"object"!==u(e))throw new Error("Response body is not a valid object!");var t=e.trackingId;if("string"!=typeof t||0===t.length)throw new Error("Response body does not contain a valid trackingId!");return t}kr.ProtectorApiResponseView=br;var Or={};Object.defineProperty(Or,"__esModule",{value:!0}),Or.acceptHeaderToNetaceaContentType=Or.APIError=Or.ProtectorApiClient=void 0;var Ar=kr,wr=function(){return g((function e(t,r){v(this,e),this.httpClient=t.httpClient,this.timeoutMs=t.timeoutMs;var n=/^https:\/\/([^/?#]+)/i.exec(r.protectorApiUrl);if(null===n)throw new Error("Protector API URL must use HTTPS");this.protectorApiHost=n[1],this.apiKey=r.apiKey}),[{key:"getDecisionResponse",value:(r=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.getResponse("/",t);case 1:return e.a(2,e.v)}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getChallengePage",value:(t=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.getResponse("/captcha",t);case 1:return e.a(2,e.v)}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"getResponse",value:(e=p(l().m((function e(t,r){var n,a,i,o,c,s,u,h,d;return l().w((function(e){for(;;)switch(e.n){case 0:return n=[],a=new Pr,i={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r.clientIp},void 0===r.userId||r.isNewUser||(i["X-Netacea-UserId"]=r.userId),o=r.captchaSiteKey,c=r.captchaSecretKey,void 0!==o&&void 0!==c&&(i["X-Netacea-Captcha-Site-Key"]=o,i["X-Netacea-Captcha-Secret-Key"]=c),void 0!==r.customerSessionId&&(i["X-Netacea-Customer-Session-ID"]=r.customerSessionId),void 0!==r.accept&&(i.Accept=r.accept,s=_r(r.accept),i["X-Netacea-Captcha-Content-Type"]=s),void 0!==r.headerFingerprint&&a.setQuery("headerFP",r.headerFingerprint),void 0===r.checkAllPostRequests&&a.setQuery("getSettings","checkAllPostRequests"),void 0!==r.challengeAssetsPath&&a.setQuery("challengeAssetsPath",r.challengeAssetsPath),void 0!==r.trackingId&&a.setQuery("trackingId",r.trackingId),void 0!==r.base64UserAgent?(i["X-Netacea-User-Agent"]=r.base64UserAgent,n.push("User-Agent")):void 0!==r.userAgent&&(i["User-Agent"]=r.userAgent),void 0!==r.requestId&&(i["X-Netacea-Request-Id"]=r.requestId,n.push("Request-Id")),void 0!==r.captchaCookie&&((u=r.captchaCookie).startsWith("_mitatacaptcha=")||(u="_mitatacaptcha="+u),i.Cookie=u),void 0!==r.httpMsgSignature&&Nr(i,n,r.httpMsgSignature),n.length>0&&a.setQuery("netaceaHeaders",n.join(",")),h=this.protectorApiHost,e.n=1,this.httpClient.get("https://".concat(h).concat(t)+a.buildQueryString(),{headers:i,timeoutMs:this.timeoutMs});case 1:if(200===(d=e.v).status){e.n=2;break}throw Er.fromResponse(d);case 2:return e.a(2,new Ar.ProtectorApiResponseView(d))}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}]);var e,t,r}();function Nr(e,t,r){void 0!==r.signature&&(e.Signature=r.signature),void 0!==r.signatureInput&&(e["Signature-Input"]=r.signatureInput),void 0!==r.signatureAgent&&(e["Signature-Agent"]=r.signatureAgent),void 0!==r.computedInput&&(e["X-Netacea-Computed-Signature-Input"]=r.computedInput,t.push("Computed-Signature-Input"))}Or.ProtectorApiClient=wr;var Er=function(){function e(t,r){var a;return v(this,e),(a=n(this,e,[t])).response=r,a}return c(e,r(Error)),g(e,null,[{key:"fromResponse",value:function(t){var r="Unknown error";switch(t.status){case 403:r="Invalid credentials";break;case 500:r="Server error";break;case 502:r="Bad Gateway";break;case 503:r="Service Unavailable";break;case 400:r="Invalid request"}return new e(r,t)}}])}();function _r(e){var t,r=null!==(t=null==e?void 0:e.toLowerCase())&&void 0!==t?t:"text/html",n=(null==r?void 0:r.includes("text/html"))||(null==r?void 0:r.includes("application/html"));return(null==r?void 0:r.includes("application/json"))&&!n?"application/json":"text/html"}Or.APIError=Er,Or.acceptHeaderToNetaceaContentType=_r;var Pr=function(){return g((function e(){v(this,e),this.queries={}}),[{key:"setQuery",value:function(e,t){return this.queries[e]=encodeURIComponent(t),this}},{key:"removeQuery",value:function(e){var t=this.queries,r=(t[e],function(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}(t,[e].map(b)));return this.queries=r,this}},{key:"buildQueryString",value:function(){var e=Object.entries(this.queries).map((function(e){var t=I(e,2),r=t[0],n=t[1];return"".concat(r,"=").concat(n)})).join("&");return e.length>0?"?".concat(e):""}}])}();!function(e){var t=de&&de.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=de&&de.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=de&&de.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&t(n,e,a);return r(n,e),n},a=de&&de.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.mitigation=e.graphql=e.webcrypto=e.url=e.parsing=e.ingest=e.headers=e.configValidation=e.cookie=e.NetaceaCookieV3IssueReason=e.MitigateCode=e.MatchCode=e.CaptchaCode=void 0;var i=pe;Object.defineProperty(e,"CaptchaCode",{enumerable:!0,get:function(){return i.CaptchaCode}}),Object.defineProperty(e,"MatchCode",{enumerable:!0,get:function(){return i.MatchCode}}),Object.defineProperty(e,"MitigateCode",{enumerable:!0,get:function(){return i.MitigateCode}});var o=ye;Object.defineProperty(e,"NetaceaCookieV3IssueReason",{enumerable:!0,get:function(){return o.NetaceaCookieV3IssueReason}}),e.cookie=n(ge),e.configValidation=n(Re),e.headers=n(Me),e.ingest=n(Qe),e.parsing=n(ut),e.url=n(ht),e.webcrypto=n(dt),e.graphql=n(mt),e.mitigation=n(St),a(_t,e),a(Vt,e),a(Lt,e),a(rr,e),a(gr,e),a(Pt,e),a(kr,e),a(Or,e)}(fe);var Tr=function(){function e(t,r){var a;return v(this,e),C(a=n(this,e,[void 0===r?k(k({},t),{},{cookieEncryptionKey:void 0}):t]),"encryptionKeyBuffer",void 0),a.encryptionKeyBuffer=r,a}return c(e,fe.cookie.AbstractCookieFactory),g(e,[{key:"encrypt",value:(a=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==this.encryptionKeyBuffer){e.n=1;break}throw new Error("F5CookieFactory.encrypt called without a configured encryption key");case 1:return e.a(2,ce(t,this.encryptionKeyBuffer))}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"decrypt",value:(r=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==this.encryptionKeyBuffer){e.n=1;break}throw new Error("F5CookieFactory.decrypt called without a configured encryption key");case 1:return e.a(2,se(t,this.encryptionKeyBuffer))}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"hash",value:(t=p(l().m((function e(t,r){var n;return l().w((function(e){for(;;)if(0===e.n)return(n=w.createHmac("sha256",r)).update(t),e.a(2,N.Buffer.from(n.digest("hex")).toString("base64"))}),e)}))),function(e,r){return t.apply(this,arguments)})},{key:"getRandomValues",value:function(e){for(var t=w.randomBytes(2*e.length),r=0;r<e.length;r++)e[r]=t[2*r]|t[2*r+1]<<8;return e}},{key:"isEncrypted",value:function(e){return oe(e)}}]);var t,r,a}(),Rr={},Mr={},Kr={},xr={};Object.defineProperty(xr,"__esModule",{value:!0}),xr.API_VERSION=xr.REGION=xr.PAYLOAD_TYPE=xr.STATE=void 0,xr.STATE={ACTIVE:"ACTIVE",UPDATING:"UPDATING",CREATING:"CREATING",DELETING:"DELETING"},xr.PAYLOAD_TYPE="string",xr.REGION="eu-west-1",xr.API_VERSION="2013-12-02",Object.defineProperty(Kr,"__esModule",{value:!0}),Kr.signRequest=void 0;var Hr=P,jr=xr;function Vr(e,t){for(var r=[],n=0;n<e.length;n+=t){var a=e.slice(n,n+t);r.push({Data:Buffer.from(JSON.stringify(a)).toString("base64"),PartitionKey:Date.now().toString()})}return r}Kr.signRequest=function(e,t,r){var n=e.accessKeyId,a=e.secretAccessKey,i={Records:Vr(t,r),PartitionKey:Date.now().toString(),StreamName:e.streamName};return Hr.sign({service:"kinesis",body:JSON.stringify(i),headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"},region:jr.REGION},{accessKeyId:n,secretAccessKey:a})},Object.defineProperty(Mr,"__esModule",{value:!0});var Lr=Kr;function Fr(e){return Dr.apply(this,arguments)}function Dr(){return(Dr=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,new Promise((function(e){setTimeout(e,t)}));case 1:return e.a(2)}}),e)})))).apply(this,arguments)}var Br=function(){return g((function e(t){var r=t.kinesisStreamName,n=t.kinesisAccessKey,a=t.kinesisSecretKey,i=t.maxLogAgeSeconds,o=t.logBatchSize,c=t.rampUpBatchSize,s=t.maxAwaitTimePerIngestCallMs;v(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.kinesisStreamName=r,this.kinesisAccessKey=n,this.kinesisSecretKey=a,this.maxAwaitTimePerIngestCallMs=s,void 0!==i&&i<this.maxLogAgeSeconds&&i>0&&(this.maxLogAgeSeconds=i),void 0!==o&&(this.maxLogBatchSize=o),this.logBatchSize=!0===c?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(t=p(l().m((function e(t){var r,n,a,i;return l().w((function(e){for(;;)switch(e.n){case 0:if(0!==this.logCache.length){e.n=1;break}return e.a(2);case 1:return r=d(this.logCache),this.logCache=[],e.p=2,n=(0,Lr.signRequest)({streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},r,this.logBatchSize),e.n=3,t({headers:n.headers,host:"https://".concat(n.hostname),method:n.method,path:n.path,body:n.body});case 3:this.logBatchSize!==this.maxLogBatchSize&&(this.logBatchSize=Math.min(this.maxLogBatchSize,2*this.logBatchSize)),e.n=5;break;case 4:e.p=4,i=e.v,(a=this.logCache).push.apply(a,d(r)),console.error(i);case 5:return e.a(2)}}),e,this,[[2,4]])}))),function(e){return t.apply(this,arguments)})},{key:"ingest",value:(e=p(l().m((function e(t,r){var n,a,i=this;return l().w((function(e){for(;;)switch(e.n){case 0:if(this.logCache.push(t),!(this.logCache.length>=this.logBatchSize)){e.n=2;break}return(n=[]).push(this.putToKinesis(r)),void 0!==this.maxAwaitTimePerIngestCallMs&&n.push(Fr(this.maxAwaitTimePerIngestCallMs)),e.n=1,Promise.race(n);case 1:e.n=3;break;case 2:if(this.intervalSet){e.n=3;break}if(this.intervalSet=!0,a=Fr(1e3*this.maxLogAgeSeconds).then(p(l().m((function e(){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,i.putToKinesis(r);case 1:i.intervalSet=!1;case 2:return e.a(2)}}),e)})))).catch((function(){})),void 0!==this.maxAwaitTimePerIngestCallMs){e.n=3;break}return e.n=3,a;case 3:return e.a(2)}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}]);var e,t}();Mr.default=Br,Object.defineProperty(Rr,"__esModule",{value:!0});var qr,Ur=Mr,zr=Rr.default=Ur.default,Gr={subtle:{digest:(qr=p(l().m((function e(t,r){var n,a,i,o,c;return l().w((function(e){for(;;)if(0===e.n)return a=null!==(n={"SHA-256":"sha256","SHA-1":"sha1","SHA-384":"sha384","SHA-512":"sha512"}[t])&&void 0!==n?n:t.toLowerCase().replace("-",""),i=r instanceof ArrayBuffer?Buffer.from(r):Buffer.from(r.buffer,r.byteOffset,r.byteLength),o=new Uint8Array(i),c=x.createHash(a).update(o).digest(),e.a(2,c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength))}),e)}))),function(e,t){return qr.apply(this,arguments)})}},Xr=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Jr=/^\/[a-zA-Z0-9/]*$/;function Wr(e,t,r){return void 0!==r&&""!==r&&(function(e){var t=e,r=t.indexOf("//");if(-1!==r){var n=(t=t.substring(r+2)).indexOf("/");if(-1===n)return"/";t=t.substring(n)}var a=t.indexOf("?");return-1!==a&&(t=t.substring(0,a)),t}(e)===r&&"get"===t.toLowerCase())}function $r(e){var t=function(e,t){var r=e.indexOf("?");if(-1!==r)for(var n=e.substring(r+1).split("&"),a=0;a<n.length;a++){var i=n[a].split("=");if(i[0]===t)return void 0!==i[1]?decodeURIComponent(i[1]):void 0}}(e,"trackingId");return void 0!==t&&Xr.test(t)?t:null}function Qr(e){if(void 0===e)return"text/html";var t=e.toLowerCase(),r=t.includes("text/html")||t.includes("application/html"),n=t.includes("application/json");return!r&&n?"application/json":"text/html"}function Yr(e,t,r){if(void 0===e||""===e)return"";var n;try{n=JSON.parse(e)}catch(e){return""}if(!function(e){if(null==e)return!1;var t=e;return void 0!==t.captchaSiteKey&&void 0!==t.trackingId&&void 0!==t.captchaURL}(n))return"";var a=r+"?trackingId="+n.trackingId,i="https://"+t+a;return JSON.stringify({captchaRelativeURL:a,captchaAbsoluteURL:i})}var Zr=te.cookie.attributes.configureCookiesDomain,en=te.cookie.netaceaSession,tn=en.createNetaceaSetCookieString,rn=en.createNetaceaCaptchaSetCookieString,nn=function(){return g((function e(t){var r,n,a=t.apiKey,i=t.secretKey,o=t.timeout,c=void 0===o?3e3:o,s=t.mitigationServiceUrl,u=void 0===s?"https://mitigations.netacea.net":s,l=t.ingestServiceUrl,h=void 0===l?"https://ingest.netacea.net":l,d=t.mitigationType,f=void 0===d?M.INGEST:d,p=t.captchaSiteKey,y=t.captchaSecretKey,g=t.ingestType,m=void 0===g?R.HTTP:g,b=t.kinesis,S=t.mitataCookieExpirySeconds,I=t.netaceaCookieExpirySeconds,O=t.netaceaCookieName,A=t.netaceaCaptchaCookieName,w=t.netaceaCookieAttributes,N=t.netaceaCaptchaCookieAttributes;if(v(this,e),C(this,"mitataCookieExpirySeconds",void 0),C(this,"apiKey",void 0),C(this,"secretKey",void 0),C(this,"mitigationServiceUrl",void 0),C(this,"ingestServiceUrl",void 0),C(this,"timeout",void 0),C(this,"captchaSiteKey",void 0),C(this,"captchaSecretKey",void 0),C(this,"ingestType",void 0),C(this,"kinesis",void 0),C(this,"mitigationType",void 0),C(this,"encryptedCookies",[]),C(this,"netaceaCookieName",void 0),C(this,"netaceaCaptchaCookieName",void 0),C(this,"netaceaCookieAttributes",void 0),C(this,"netaceaCaptchaCookieAttributes",void 0),C(this,"cookieFactory",void 0),null==a)throw new Error("apiKey is a required parameter");this.apiKey=a,this.secretKey=i,this.mitigationServiceUrl=u,this.ingestServiceUrl=h,this.mitigationType=f,this.ingestType=null!=m?m:R.HTTP,this.ingestType===R.KINESIS&&(void 0===b?console.warn("NETACEA WARN: no kinesis args provided, when ingestType is ".concat(this.ingestType)):this.kinesis=new zr(k(k({},b),{},{apiKey:this.apiKey}))),void 0===p&&void 0===y||(this.captchaSiteKey=p,this.captchaSecretKey=y),this.timeout=function(e){return e<=0?V:e}(c),this.netaceaCookieName=cn(O,"_mitata"),this.netaceaCaptchaCookieName=cn(A,"_mitatacaptcha"),this.encryptedCookies=[this.netaceaCookieName,this.netaceaCaptchaCookieName],this.mitataCookieExpirySeconds=function(e,t){return void 0===t?e===M.INGEST?3600:60:t}(f,null!=I?I:S);var E=Zr(null!=w?w:"",null!=N?N:"");this.netaceaCookieAttributes=null!==(r=E.cookieAttributes)&&void 0!==r?r:"",this.netaceaCaptchaCookieAttributes=null!==(n=E.captchaCookieAttributes)&&void 0!==n?n:""}),[{key:"runMitigation",value:(b=p(l().m((function e(t){var r,n,a,i,o;return l().w((function(e){for(;;)switch(e.n){case 0:e.p=0,i=this.mitigationType,e.n=i===M.MITIGATE?1:i===M.INJECT?3:i===M.INGEST?5:7;break;case 1:return e.n=2,this.mitigate(t);case 2:case 4:case 6:return e.a(2,e.v);case 3:return e.n=4,this.inject(t);case 5:return e.n=6,this.processIngest(t);case 7:throw new Error("Netacea Error: Mitigation type ".concat(this.mitigationType," not recognised"));case 8:e.n=10;break;case 9:return e.p=9,o=e.v,console.error("Netacea FAILOPEN Error:",o),r=t,n=this.isUrlCaptchaPost(r.url,r.method),a=this.mitigationType===M.MITIGATE,e.a(2,{injectHeaders:{"x-netacea-captcha":"0","x-netacea-match":"0","x-netacea-mitigate":"0"},sessionStatus:a&&n?"error_open":""});case 10:return e.a(2)}}),e,this,[[0,9]])}))),function(e){return b.apply(this,arguments)})},{key:"readCookie",value:(m=p(l().m((function e(t,r){var n,a,i,o,c,s,u;return l().w((function(e){for(;;)switch(e.n){case 0:if(null!=r){e.n=1;break}return e.a(2,void 0);case 1:if("string"!=typeof r){e.n=3;break}return e.n=2,this.readCookie(t,r.split(";"));case 2:return e.a(2,e.v);case 3:n="".concat(t,"="),a=S(r),e.p=4,a.s();case 5:if((i=a.n()).done){e.n=11;break}if(o=i.value,!(c=o.split(";")[0].trimStart()).startsWith(n)){e.n=10;break}if(s=c.slice(n.length),!this.encryptedCookies.includes(t)){e.n=9;break}return e.p=6,e.n=7,this.decryptCookieValue(s);case 7:return e.a(2,e.v);case 8:return e.p=8,e.v,e.a(2,void 0);case 9:return e.a(2,s);case 10:e.n=5;break;case 11:e.n=13;break;case 12:e.p=12,u=e.v,a.e(u);case 13:return e.p=13,a.f(),e.f(13);case 14:return e.a(2,void 0)}}),e,this,[[6,8],[4,12,13,14]])}))),function(e,t){return m.apply(this,arguments)})},{key:"callIngest",value:(y=p(l().m((function e(t){var r,n,a,i;return l().w((function(e){for(;;)switch(e.n){case 0:if(r=this.constructWebLog(t),this.ingestType!==R.KINESIS){e.n=5;break}if(void 0!==this.kinesis){e.n=1;break}return console.error("Netacea Error: Unable to log as Kinesis has not been defined."),e.a(2);case 1:return e.p=1,e.n=2,this.kinesis.ingest(k(k({},r),{},{apiKey:this.apiKey}),this.makeRequest.bind(this));case 2:e.n=4;break;case 3:e.p=3,i=e.v,console.error("NETACEA Error: ",i.message);case 4:e.n=7;break;case 5:return n={"X-Netacea-API-Key":this.apiKey,"content-type":"application/json"},e.n=6,this.makeIngestApiCall(n,r);case 6:if(200===(a=e.v).status){e.n=7;break}throw this.APIError(a);case 7:return e.a(2)}}),e,this,[[1,3]])}))),function(e){return y.apply(this,arguments)})},{key:"makeIngestApiCall",value:(f=p(l().m((function e(t,r){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.makeRequest({host:this.ingestServiceUrl,method:"POST",path:"/",headers:t,body:JSON.stringify(r),timeout:this.timeout});case 1:return e.a(2,e.v)}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"constructV1WebLog",value:function(e){var t=e.ip,r=e.userAgent,n=e.status,a=e.method,i=e.path,o=e.protocol,c=e.referer,s=e.bytesSent,u=e.requestTime,l=e.mitataCookie,h=e.sessionStatus,d=e.integrationType,f=e.integrationVersion,p=e.headerFingerprint,v=e.requestHost,y=(new Date).toUTCString();return{Request:"".concat(a," ").concat(i," ").concat(o),TimeLocal:y,RealIp:t,UserAgent:r,Status:n,RequestTime:null==u?void 0:u.toString(),BytesSent:null==s?void 0:s.toString(),Referer:""===c?"-":c,NetaceaUserIdCookie:null!=l?l:"",NetaceaMitigationApplied:null!=h?h:"",IntegrationType:null!=d?d:"",IntegrationVersion:null!=f?f:"",HeaderHash:null!=p?p:"",RequestHost:v}}},{key:"constructWebLog",value:function(e){return e.bytesSent=""===e.bytesSent?"0":e.bytesSent,this.constructV1WebLog(e)}},{key:"check",value:(d=p(l().m((function e(t,r,n,a,i,o,c){var s,u,h,d,f,p,v,y,g,m,C,b,S,I,O;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0===this.cookieFactory){e.n=2;break}return e.n=1,this.cookieFactory.retrieveCookieInfo(t,r);case 1:I=e.v,e.n=3;break;case 2:I=$(t,r,null!==(s=this.secretKey)&&void 0!==s?s:"");case 3:if((m=I).isPrimaryHashValid&&!m.requiresReissue){e.n=6;break}return C=void 0!==m.mitata?m.mitata.userId:void 0,b=on(m),e.n=4,this.makeMitigateAPICall(C,r,n,a,i,o,b);case 4:return S=e.v,u=S.status,h=S.match,d=S.mitigate,f=S.captcha,p=S.body,e.n=5,this.createMitata(r,C,h,d,f,S.mitataMaxAge,void 0,b);case 5:O=e.v,v=[O],y=S.eventId,"5"===d&&void 0!==c&&(g=this.computeMonetisationRedirect(c,S.redirectHost,S.redirectLocation,S.redirectStatus)),e.n=7;break;case 6:u=-1,h=m.match,d=m.mitigate,f=m.captcha,p=void 0,v=[];case 7:return e.a(2,k(k({},this.composeResult(p,v,u,h,d,f,!1,y)),{},{redirect:g}))}}),e,this)}))),function(e,t,r,n,a,i,o){return d.apply(this,arguments)})},{key:"computeMonetisationRedirect",value:function(e,t,r,n){var a=void 0!==n?parseInt(n,10):NaN,i=!isNaN(a)&&a>=300&&a<400?a:303;if(void 0!==r)return{location:r,statusCode:i};if(void 0!==t){var o=e.replace(/^https?:\/\/[^/]+/,"");return{location:"https://".concat(t).concat(""!==o?o:"/"),statusCode:i}}}},{key:"createMitata",value:(h=p(l().m((function e(t,r,n,a,i){var o,c,s,u,h,d,f,p,v,y,g=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:if(o=g.length>5&&void 0!==g[5]?g[5]:86400,c=g.length>6&&void 0!==g[6]?g[6]:void 0,s=g.length>7&&void 0!==g[7]?g[7]:K.NO_SESSION,u=["1","3","5"].includes(i),h="3"===a,d="5"===a,f=u||h||d?-60:this.mitataCookieExpirySeconds,void 0===this.cookieFactory){e.n=2;break}return e.n=1,this.cookieFactory.createCookieValue({clientIP:t,userId:r,match:n,mitigate:a,captcha:i,gracePeriod:f,cookieId:X(),issueReason:s});case 1:p=e.v,e.n=4;break;case 2:if(void 0!==this.secretKey){e.n=3;break}throw new Error("Cannot build cookie without secret key.");case 3:v=null!=c?c:Math.floor(Date.now()/1e3)+f,y=[n,a,i].join(""),p=J(t,r,v,this.secretKey,y);case 4:return e.a(2,tn({cookieName:this.netaceaCookieName,cookieValue:p,maxAgeAttribute:String(o),otherAttributes:this.netaceaCookieAttributes}))}}),e,this)}))),function(e,t,r,n,a){return h.apply(this,arguments)})},{key:"processCaptcha",value:(u=p(l().m((function e(t,r,n,a,i){var o,c,s,u,h,d,f,p,v,y,g,m,k;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0===this.cookieFactory){e.n=2;break}return e.n=1,this.cookieFactory.retrieveCookieInfo(t,r);case 1:k=e.v,e.n=3;break;case 2:k=$(t,r,null!==(o=this.secretKey)&&void 0!==o?o:"");case 3:return u=on(s=k),h=null===(c=s.mitata)||void 0===c?void 0:c.userId,e.n=4,this.makeCaptchaAPICall(h,r,n,a,i,u);case 4:return d=e.v,f=d.status,p=d.match,v=d.mitigate,y=d.captcha,g=d.body,m=d.setCookie,e.a(2,this.composeResult(g,m,f,p,v,y,!0))}}),e,this)}))),function(e,t,r,n,a){return u.apply(this,arguments)})},{key:"getMitataCaptchaFromHeaders",value:(s=p(l().m((function e(t){var r,n,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(!Object.prototype.hasOwnProperty.call(t,q.netaceaHeaders.mitataCaptcha)){e.n=3;break}if(r=t[q.netaceaHeaders.mitataCaptcha],Array.isArray(r)&&(r=r[0]),null!=r&&""!==r){e.n=1;break}return e.a(2,void 0);case 1:return n=parseInt(t[q.netaceaHeaders.mitataCaptchaExpiry]),e.n=2,this.encryptCookieValue(r);case 2:return a=e.v,e.a(2,rn({cookieName:this.netaceaCaptchaCookieName,cookieValue:a,maxAgeAttribute:String(isNaN(n)?86400:n),otherAttributes:this.netaceaCaptchaCookieAttributes}));case 3:return e.a(2,void 0)}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"makeCaptchaAPICall",value:(c=p(l().m((function e(t,r,n,a,i){var o,c,s,u,h=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:return o=h.length>5&&void 0!==h[5]?h[5]:K.NO_SESSION,c={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":n,"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},void 0!==t&&(c["X-Netacea-UserId"]=t),void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(c["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,c["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),s={},"string"==typeof i&&""!==i&&(s.headerFP=i),e.n=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/AtaVerifyCaptcha",headers:c,method:"POST",body:a,timeout:this.timeout,params:s});case 1:return u=e.v,e.n=2,this.getApiCallResponseFromResponse(u,t,r,o);case 2:return e.a(2,e.v)}}),e,this)}))),function(e,t,r,n,a){return c.apply(this,arguments)})},{key:"getApiCallResponseFromResponse",value:(o=p(l().m((function e(t,r,n){var a,i,o,c,s,u,h,d,f,p,v,y,g,m,k,C,b,S,I,O,A,w,N=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:if(p=N.length>3&&void 0!==N[3]?N[3]:K.NO_SESSION,200===t.status){e.n=1;break}throw this.APIError(t);case 1:return v=null!==(a=null===(i=t.headers[q.netaceaHeaders.match])||void 0===i?void 0:i.toString())&&void 0!==a?a:"0",y=null!==(o=null===(c=t.headers[q.netaceaHeaders.mitigate])||void 0===c?void 0:c.toString())&&void 0!==o?o:"0",g=null!==(s=null===(u=t.headers[q.netaceaHeaders.captcha])||void 0===u?void 0:u.toString())&&void 0!==s?s:"0",m=parseInt(t.headers[q.netaceaHeaders.mitataExpiry]),isNaN(m)&&(m=86400),e.n=2,this.createMitata(n,r,v,y,g,86400,void 0,p);case 2:return k=e.v,e.n=3,this.getMitataCaptchaFromHeaders(t.headers);case 3:return C=e.v,b=[k,C].filter((function(e){return void 0!==e})),S=t.body,I=t.headers[q.netaceaHeaders.eventId],O=null===(h=t.headers["x-netacea-redirect-host"])||void 0===h?void 0:h.toString(),A=null===(d=t.headers["x-netacea-redirect-location"])||void 0===d?void 0:d.toString(),w=null===(f=t.headers["x-netacea-redirect-status"])||void 0===f?void 0:f.toString(),e.a(2,{status:t.status,match:v,mitigate:y,captcha:g,setCookie:b,body:S,eventId:I,mitataMaxAge:m,redirectHost:O,redirectLocation:A,redirectStatus:w})}}),e,this)}))),function(e,t,r){return o.apply(this,arguments)})},{key:"buildCookieHeader",value:function(e){var t="",r="";for(var n in e){var a=e[n];void 0!==a&&(t="".concat(t).concat(r).concat(n,"=").concat(a),r="; ")}return t}},{key:"makeMitigateAPICall",value:(i=p(l().m((function e(t,r,n,a,i,o){var c,s,u,h,d=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:return c=d.length>6&&void 0!==d[6]?d[6]:K.NO_SESSION,s={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":n,cookie:this.buildCookieHeader({_mitatacaptcha:a})},void 0!==t&&(s["X-Netacea-UserId"]=t),void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(s["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,s["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),void 0!==o&&(s["X-Netacea-Captcha-Content-Type"]=o),u={},"string"==typeof i&&""!==i&&(u.headerFP=i),e.n=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/",headers:s,method:"GET",timeout:this.timeout,params:u});case 1:return h=e.v,e.n=2,this.getApiCallResponseFromResponse(h,t,r,c);case 2:return e.a(2,e.v)}}),e,this)}))),function(e,t,r,n,a,o){return i.apply(this,arguments)})},{key:"composeResult",value:function(e,t,r,n,a,i,o,c){var s=this.findBestMitigation(n,a,i,o),u={body:e,apiCallStatus:r,setCookie:t,sessionStatus:s.sessionStatus,mitigation:s.mitigation,mitigated:[q.mitigationTypes.block,q.mitigationTypes.captcha,q.mitigationTypes.captchaPass].includes(s.mitigation)};if(this.mitigationType===M.INJECT){var l={"x-netacea-match":s.parts.match.toString(),"x-netacea-mitigate":s.parts.mitigate.toString(),"x-netacea-captcha":s.parts.captcha.toString()};void 0!==c&&(l["x-netacea-event-id"]=c),u.injectHeaders=l}return u}},{key:"findBestMitigation",value:function(e,t,r,n){var a,i,o=function(e){return"[".concat(e,"]")};n||("2"===r?r="4":"3"===r&&(r="5"));var c=null!==(a=q.matchMap[e])&&void 0!==a?a:o(e)+"_";c+=null!==(i=q.mitigateMap[t])&&void 0!==i?i:o(t);var s=q.bestMitigationMap[t];if("0"!==r){var u;c+=","+(null!==(u=q.captchaMap[r])&&void 0!==u?u:o(r));var l=q.bestMitigationCaptchaMap[r];void 0!==l&&(s=l)}return this.mitigationType===M.INJECT&&(s=q.mitigationTypes.none),{sessionStatus:c,mitigation:s,parts:{match:e,mitigate:t,captcha:r}}}},{key:"APIError",value:function(e){var t="Unknown error";switch(e.status){case 403:t="Invalid credentials";break;case 500:t="Server error";break;case 502:t="Bad Gateway";break;case 503:t="Service Unavailable";break;case 400:t="Invalid request"}return new Error("Error reaching Netacea API (".concat(t,"), status: ").concat(e.status))}},{key:"isUrlCaptchaPost",value:function(e,t){if("post"!==t.toLowerCase())return!1;if(e.includes("/AtaVerifyCaptcha"))return!0;var r=this.netaceaCaptchaPath;return!(void 0===r||!e.includes(r))}},{key:"processMitigateRequest",value:(a=p(l().m((function e(t,r,n){var a,i,o,c,s,u,h;return l().w((function(e){for(;;)switch(e.n){case 0:if(!this.isUrlCaptchaPost(t.url,t.method)){e.n=2;break}return i=this,o=t.mitata,c=t.clientIp,s=t.userAgent,e.n=1,t.getBodyFn();case 1:u=e.v,h=r,a=i.processCaptcha.call(i,o,c,s,u,h),e.n=3;break;case 2:a=this.check(t.mitata,t.clientIp,t.userAgent,t.mitataCaptcha,r,n,t.url);case 3:return e.n=4,a;case 4:return e.a(2,e.v)}}),e,this)}))),function(e,t,r){return a.apply(this,arguments)})},{key:"setIngestOnlyMitataCookie",value:(n=p(l().m((function e(t){var r,n,a=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:return r=a.length>1&&void 0!==a[1]?a[1]:K.NO_SESSION,e.n=1,this.createMitata(U,t,"0","0","0",86400,void 0,r);case 1:return n=e.v,e.a(2,{sessionStatus:"",setCookie:[n]})}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"processIngest",value:(r=p(l().m((function e(t){var r,n,a,i,o,c;return l().w((function(e){for(;;)switch(e.n){case 0:return n=this.getCookieHeader(t),e.n=1,this.readCookie(this.netaceaCookieName,n);case 1:if(a=e.v,void 0===this.cookieFactory){e.n=3;break}return e.n=2,this.cookieFactory.retrieveCookieInfo(a,U);case 2:c=e.v,e.n=4;break;case 3:c=$(a,U,null!==(r=this.secretKey)&&void 0!==r?r:"");case 4:if((i=c).isPrimaryHashValid){e.n=6;break}return e.n=5,this.setIngestOnlyMitataCookie(void 0,on(i));case 5:return e.a(2,e.v);case 6:if(!i.requiresReissue){e.n=8;break}return o=void 0!==i.mitata?i.mitata.userId:void 0,e.n=7,this.setIngestOnlyMitataCookie(o,on(i));case 7:return e.a(2,e.v);case 8:return e.a(2,{sessionStatus:"",setCookie:[]})}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"encryptCookieValue",value:(t=p(l().m((function e(t){return l().w((function(e){for(;;)if(0===e.n)return e.a(2,t)}),e)}))),function(e){return t.apply(this,arguments)})},{key:"decryptCookieValue",value:(e=p(l().m((function e(t){return l().w((function(e){for(;;)if(0===e.n)return e.a(2,t)}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,r,n,a,i,o,c,s,u,h,d,f,y,m,b}(),an=function(){function e(t){var r,a,i,o,c,s;v(this,e),C(s=n(this,e,[t]),"httpsAgent",void 0),C(s,"mitataCookieName",void 0),C(s,"mitataCaptchaCookieName",void 0),C(s,"hashGenerator",void 0),C(s,"debugMode",void 0),C(s,"encryptionEnabled",!1),C(s,"encryptionKeyBuffer",void 0),C(s,"mitigationHeaders",["cookie","user-agent","accept","host"]),C(s,"netaceaCaptchaPath",void 0),C(s,"hostHeaderName",void 0),C(s,"enableCaptchaContentNegotiation",void 0),s.httpsAgent=new H.Agent({timeout:s.timeout,keepAlive:!0,maxSockets:null!==(r=t.maxSockets)&&void 0!==r?r:25}),s.mitataCookieName=null!==(a=t.netaceaCookieName)&&void 0!==a?a:"_mitata",s.mitataCaptchaCookieName=null!==(i=t.netaceaCaptchaCookieName)&&void 0!==i?i:"_mitatacaptcha";var u=function(){return g((function e(){v(this,e)}),[{key:"encode",value:function(e){return new Uint8Array(Buffer.from(e,"utf8"))}}])}();if(s.hashGenerator=new re(Gr,u),s.debugMode=null!==(o=t.debugMode)&&void 0!==o&&o,s.netaceaCaptchaPath=function(e){if(null!=e&&""!==e)return"/"!==e[0]&&(e="/"+e),Jr.test(e)?e:void 0}(t.netaceaCaptchaPath),s.hostHeaderName=null===(c=t.hostHeaderName)||void 0===c||null===(c=c.toLowerCase())||void 0===c?void 0:c.trim(),void 0===s.hostHeaderName||s.mitigationHeaders.includes(s.hostHeaderName)||s.mitigationHeaders.push(s.hostHeaderName),s.enableCaptchaContentNegotiation=!0===t.enableCaptchaContentNegotiation,void 0!==t.cookieEncryptionKey){var l=function(e){if(null==e||""===e)return{valid:!1,error:"key is empty"};if(!/^[A-Za-z0-9_-]+$/.test(e))return{valid:!1,error:"key contains invalid base64url characters"};var t;try{t=ae(e)}catch(e){return{valid:!1,error:"key is not valid base64url"}}return 32!==t.length?{valid:!1,error:"key must be ".concat(32," bytes (256 bits), got ").concat(t.length," bytes")}:{valid:!0,keyBuffer:t}}(t.cookieEncryptionKey);l.valid&&void 0!==l.keyBuffer?(s.encryptionKeyBuffer=l.keyBuffer,s.encryptionEnabled=!0):console.warn("NETACEA WARN: Invalid cookieEncryptionKey - ".concat(l.error,". Cookies will not be encrypted."))}return s.cookieFactory=new Tr({cookieEncryptionKey:t.cookieEncryptionKey,secretKey:t.secretKey,expirySeconds:s.mitataCookieExpirySeconds},s.encryptionEnabled&&void 0!==s.encryptionKeyBuffer?s.encryptionKeyBuffer:void 0),s}return c(e,nn),g(e,[{key:"computeHeaderFingerprint",value:(f=p(l().m((function e(t){var r;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==t&&""!==t){e.n=1;break}return e.a(2,"");case 1:return r=t.split(","),e.n=2,this.hashGenerator.hashHeaders(r);case 2:return e.a(2,e.v)}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"handleGetCaptchaRequest",value:(d=p(l().m((function e(t,r,n,a,i,o,c){var s,u,h,d,f,p;return l().w((function(e){for(;;)switch(e.n){case 0:return s=$r(o),u=this.enableCaptchaContentNegotiation?Qr(i):"text/html",h={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":t,"user-agent":r,cookie:void 0!==n?"_mitatacaptcha="+n:"","X-Netacea-Captcha-Content-Type":u},void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(h["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,h["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),d={netaceaHeaders:"request-id"},"string"==typeof a&&""!==a&&(d.headerFP=a),null!==s&&(d.trackingId=s),e.n=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/captcha",headers:h,method:"GET",timeout:this.timeout,params:d});case 1:if(200===(f=e.v).status){e.n=2;break}throw this.APIError(f);case 2:return p=f.body,"application/json"===u&&void 0!==this.netaceaCaptchaPath&&void 0!==p&&(p=Yr(p,null!=c?c:"",this.netaceaCaptchaPath)),e.a(2,{body:p,apiCallStatus:f.status,setCookie:[],sessionStatus:",captcha_serve",mitigation:"captcha",mitigated:!0})}}),e,this)}))),function(e,t,r,n,a,i,o){return d.apply(this,arguments)})},{key:"encryptCookieValue",value:(h=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:if(this.encryptionEnabled&&void 0!==this.encryptionKeyBuffer){e.n=1;break}return e.a(2,t);case 1:return e.a(2,ce(t,this.encryptionKeyBuffer))}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"decryptCookieValue",value:(u=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:if(this.encryptionEnabled&&void 0!==this.encryptionKeyBuffer){e.n=1;break}return e.a(2,t);case 1:if(oe(t)){e.n=2;break}throw new Error("Cookie is not JWE encrypted");case 2:return e.a(2,se(t,this.encryptionKeyBuffer))}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"getInjectHeaders",value:function(e){if(this.mitigationType===M.INJECT){var t=e;if(void 0!==t.injectHeaders){var r={},n=t.injectHeaders;return r["x-netacea-match"]=n["x-netacea-match"],r["x-netacea-mitigate"]=n["x-netacea-mitigate"],r["x-netacea-captcha"]=n["x-netacea-captcha"],void 0!==n["x-netacea-event-id"]&&(r["x-netacea-event-id"]=n["x-netacea-event-id"]),this.encodeHeadersAsKeyValueList(r)}}return[]}},{key:"registerPolicyHandler",value:function(e){var t=this;e.addMethod("getMitigationHeaderPolicy",(function(e,r){var n=t.mitigationHeaders.join(",");console.info('level=info component=f5 handler=getMitigationHeaderPolicy policy="'.concat(n,'"')),r.reply(n)}))}},{key:"encodeHeadersAsKeyValueList",value:function(e){for(var t=[],r=0,n=Object.entries(e);r<n.length;r++){var a=I(n[r],2),i=a[0],o=a[1];if(Array.isArray(o)){var c,s=S(o);try{for(s.s();!(c=s.n()).done;){var u=c.value;t.push(i,Buffer.from(u).toString("base64"))}}catch(e){s.e(e)}finally{s.f()}}else t.push(i,Buffer.from(o).toString("base64"))}return t}},{key:"registerMitigateHandler",value:function(e){var t=this;e.addMethod("handleRequest",function(){var e=p(l().m((function e(r,n){var a,i,o,c,s,u,h,d,f,p,v,y,g,m,k,C,b,S,O,A,w,N,E,_,P,T,R,M,K,x,H,j,V;return l().w((function(e){for(;;)switch(e.n){case 0:return o=r.params(),c=I(o,3),s=c[0],u=c[1],h=c[2],d=t.getArrayValueOrDefault(o,3,void 0),f=t.getArrayValueOrDefault(o,4,void 0),p=t.getArrayValueOrDefault(o,5,void 0),v=t.parseHeaderValues(p),y=null!==(a=v.cookie)&&void 0!==a?a:null,g=null!==(i=v["user-agent"])&&void 0!==i?i:"",m=v.accept,e.p=1,e.n=2,t.computeHeaderFingerprint(f);case 2:return b=e.v,t.debugMode&&console.info('level=debug component=f5 handler=handleRequest event=header_fingerprint method="'.concat(u,'" ')+'path="'.concat(h,'" headers="').concat(null!=f?f:"",'" header_count=').concat(null!==(S=null==f?void 0:f.split(",").length)&&void 0!==S?S:0," ")+'fingerprint="'.concat(b,'"')),e.n=3,t.getMitataCookies(y);case 3:return O=e.v,A=I(O,2),w=A[0],N=A[1],t.debugMode&&console.info('level=debug component=f5 handler=handleRequest event=mitigation_request headerFP="'.concat(b,'"')),e.n=4,t.runMitigation({ip:s,method:u,url:h,mitataCaptchaCookie:N,mitataCookie:w,userAgent:g,body:d,headerFingerprint:b,acceptHeader:m,hostHeader:t.resolveHostHeader(v)});case 4:if(E=e.v,_="",(Wr(h,u,t.netaceaCaptchaPath)||void 0!==t.netaceaCaptchaPath&&"captcha"===(null==E||null===(k=E.response)||void 0===k?void 0:k.mitigation))&&(_=t.enableCaptchaContentNegotiation&&"application/json"===Qr(m)?"application/json":"text/html; charset=UTF-8"),"error_open"!==(null==E?void 0:E.sessionStatus)){e.n=5;break}return n.reply(["",500,"error_open",!0,"",b,[],[],500]),e.a(2);case 5:if(void 0!==E){e.n=6;break}return n.reply(["",0,"",!1,"",b,[],[],0]),e.a(2);case 6:P="",T=0,R=!1,M=0,K=t.getValueOrDefault(w,""),void 0!==E.setCookie&&E.setCookie.length>0&&void 0!==(x=E.setCookie.find((function(e){return e.includes("".concat(t.netaceaCookieName,"="))})))&&(K=x.split(";")[0].replace("".concat(t.netaceaCookieName,"="),"")),void 0!==E.response&&(T=t.getValueOrDefault(E.response.apiCallStatus,0),P=t.getValueOrDefault(E.response.body,"Forbidden"),R=t.getValueOrDefault(E.response.mitigated,R),M=t.getValueOrDefault(E.response.status,403)),H={},void 0!==E.setCookie&&E.setCookie.length>0&&(H["Set-Cookie"]=E.setCookie),""!==_&&(H["Content-Type"]=_),void 0!==(j=null===(C=E.response)||void 0===C?void 0:C.redirect)&&(H.Location=j.location),n.reply([P,T,t.getValueOrDefault(E.sessionStatus,""),R,t.getValueOrDefault(K,""),b,t.getInjectHeaders(E),t.encodeHeadersAsKeyValueList(H),M]),e.n=8;break;case 7:e.p=7,V=e.v,console.error("Could not reach Netacea mitigation API: ",V.message),n.reply(["",0,"",!1,"","",[],[],0]);case 8:return e.a(2)}}),e,null,[[1,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"resolveHostHeader",value:function(e){var t=void 0!==this.hostHeaderName?e[this.hostHeaderName]:void 0;return void 0!==t&&""!==t?t:e.host}},{key:"parseHeaderValues",value:function(e){var t={};if(void 0===e||""===e)return t;for(var r=e.split(","),n=0;n<this.mitigationHeaders.length&&n<r.length;n++)t[this.mitigationHeaders[n].toLowerCase()]=Buffer.from(r[n],"base64").toString("utf8");return t}},{key:"getValueOrDefault",value:function(e,t){return null!=e?e:t}},{key:"getArrayValueOrDefault",value:function(e,t,r){var n;return null!==(n=e[t])&&void 0!==n?n:r}},{key:"getMitataCookies",value:(s=p(l().m((function e(t){var r,n,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(r=null==t?void 0:t.split("; "),n=this.getCookie(this.mitataCookieName,r),a=this.getCookie(this.mitataCaptchaCookieName,r),void 0===n){e.n=4;break}return e.p=1,e.n=2,this.decryptCookieValue(n);case 2:n=e.v,e.n=4;break;case 3:e.p=3,e.v,n=void 0;case 4:if(void 0===a){e.n=8;break}return e.p=5,e.n=6,this.decryptCookieValue(a);case 6:a=e.v,e.n=8;break;case 7:e.p=7,e.v,a=void 0;case 8:return e.a(2,[n,a])}}),e,this,[[5,7],[1,3]])}))),function(e){return s.apply(this,arguments)})},{key:"getCookie",value:function(e,t){var r;return null==t||null===(r=t.find((function(t){return t.includes("".concat(e,"="))})))||void 0===r?void 0:r.replace("".concat(e,"="),"")}},{key:"registerIngestHandler",value:function(e){var t=this;e.addMethod("ingest",function(){var e=p(l().m((function e(r,n){var a,i,o,c,s,u,h,d,f,p,v,y,g,m,k,C,b,S;return l().w((function(e){for(;;)switch(e.n){case 0:if(c=r.params(),s=t.getArrayValueOrDefault(c,0,""),u=t.getArrayValueOrDefault(c,1,""),h=t.getArrayValueOrDefault(c,2,"-1"),d=t.getArrayValueOrDefault(c,3,""),f=t.getArrayValueOrDefault(c,4,""),p=t.getArrayValueOrDefault(c,5,""),v=t.getArrayValueOrDefault(c,6,""),y=t.getArrayValueOrDefault(c,7,"0"),g=t.getArrayValueOrDefault(c,8,"0"),o=t.getArrayValueOrDefault(c,9,""),m=t.getArrayValueOrDefault(c,10,""),k=t.getArrayValueOrDefault(c,11,""),C=t.getArrayValueOrDefault(c,12,void 0),b=t.parseHeaderValues(C),S=t.resolveHostHeader(b),t.debugMode&&console.info('level=debug component=f5 handler=ingest event=ingest_request ingestType="'.concat(t.ingestType,'" ')+'headerFingerprint="'.concat(k,'"')),void 0===o){e.n=4;break}return e.p=1,e.n=2,t.decryptCookieValue(o);case 2:o=e.v,e.n=4;break;case 3:e.p=3,e.v,o=void 0;case 4:t.ingest({ip:s,userAgent:null!==(a=b["user-agent"])&&void 0!==a?a:u,status:h,method:d,path:f,protocol:p,referer:null!==(i=b.referer)&&void 0!==i?i:v,bytesSent:y,requestTime:g,mitataCookie:o,sessionStatus:m,headerFingerprint:k,requestHost:S}).catch((function(e){console.error("Could not reach Netacea ingest API: "+e.message)})),n.reply("done");case 5:return e.a(2)}}),e,null,[[1,3]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"makeRequest",value:(o=p(l().m((function e(t){var r=this;return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,new Promise((function(e,n){t.host=t.host.replace("https://","");var a=t.path;if(void 0!==t.params){var i=t.params instanceof URLSearchParams?t.params.toString():j.stringify(t.params);""!==i&&(a+=(a.includes("?")?"&":"?")+i)}for(var o=H.request({agent:r.httpsAgent,host:t.host,path:a,headers:t.headers,method:t.method,body:t.body},(function(t){var r="";t.on("data",(function(e){r+=e})),t.on("end",(function(){var n;e({headers:t.headers,status:null!==(n=t.statusCode)&&void 0!==n?n:0,body:""===r?void 0:r})}))})),c=0,s=["error","abort","timeout"];c<s.length;c++){var u=s[c];o.on(u,(function(e){n(e),o.destroyed||o.destroy()}))}"post"===t.method.toLowerCase()&&o.write(t.body),o.end()}));case 1:return e.a(2,e.v)}}),e)}))),function(e){return o.apply(this,arguments)})},{key:"mitigate",value:(i=p(l().m((function e(t){var r,n,a,i,o,c;return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.getMitigationResponse(t);case 1:return r=e.v,n={sessionStatus:r.sessionStatus,setCookie:r.setCookie},r.mitigated&&(n.response={body:null!==(a=r.body)&&void 0!==a?a:"Forbidden",status:null!==(i=null===(o=r.redirect)||void 0===o?void 0:o.statusCode)&&void 0!==i?i:r.sessionStatus.includes("monetised")?402:403,apiCallStatus:null!==(c=r.apiCallStatus)&&void 0!==c?c:-1,mitigation:r.mitigation,mitigated:r.mitigated,redirect:r.redirect}),e.a(2,n)}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"inject",value:(a=p(l().m((function e(t){var r;return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.getMitigationResponse(t);case 1:return r=e.v,e.a(2,{injectHeaders:r.injectHeaders,sessionStatus:r.sessionStatus,setCookie:r.setCookie})}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getMitigationResponse",value:(r=p(l().m((function e(t){var r,n,a,i,o,c,s,u,h,d,f,v;return l().w((function(e){for(;;)switch(e.n){case 0:if(r=t.ip,n=t.userAgent,a=t.url,i=t.method,o=t.mitataCookie,c=t.mitataCaptchaCookie,s=t.body,u=t.headerFingerprint,h=t.acceptHeader,d=t.hostHeader,!Wr(a,i,this.netaceaCaptchaPath)){e.n=2;break}return e.n=1,this.handleGetCaptchaRequest(r,n,c,null!=u?u:"",h,a,d);case 1:return e.a(2,e.v);case 2:return f=this.enableCaptchaContentNegotiation&&void 0!==this.netaceaCaptchaPath?Qr(h):void 0,e.n=3,this.processMitigateRequest({clientIp:r,getBodyFn:function(){var e=p(l().m((function e(){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,Promise.resolve(s);case 1:return e.a(2,e.v)}}),e)})));return function(){return e.apply(this,arguments)}}(),method:i,mitata:o,mitataCaptcha:c,url:a,userAgent:n},u,f);case 3:return v=e.v,"application/json"===f&&void 0!==this.netaceaCaptchaPath&&void 0!==v.body&&"captcha"===v.mitigation&&(v.body=Yr(v.body,null!=d?d:"",this.netaceaCaptchaPath)),e.a(2,v)}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"ingest",value:(t=p(l().m((function e(t){var r,n,a,i,o,c,s,u,h,d,f,p,v;return l().w((function(e){for(;;)switch(e.n){case 0:return r=t.ip,n=t.userAgent,a=t.status,i=t.method,o=t.path,c=t.protocol,s=t.referer,u=t.bytesSent,h=t.requestTime,d=t.mitataCookie,f=t.sessionStatus,p=t.headerFingerprint,v=t.requestHost,e.n=1,this.callIngest({ip:r,userAgent:n,status:a,method:i,bytesSent:u,path:o,protocol:c,referer:s,requestTime:h,mitataCookie:d,sessionStatus:f,headerFingerprint:p,requestHost:v,integrationType:"@netacea/f5".replace("@netacea/",""),integrationVersion:"5.8.14"});case 1:return e.a(2)}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"getCookieHeader",value:function(e){if(void 0!==e.mitataCookie)return"".concat(this.mitataCookieName,"=").concat(e.mitataCookie)}}]);var t,r,a,i,o,s,u,h,d,f}();function on(e){return e.isPrimaryHashValid?e.isSameIP?e.isExpired?K.EXPIRED_SESSION:K.NO_SESSION:K.IP_CHANGE:K.NO_SESSION}function cn(e,t){return"string"==typeof e&&""!==e?e:"number"==typeof e?e.toString():t}module.exports=an;
1
+ "use strict";var e,t;function r(e){var t="function"==typeof Map?new Map:void 0;return r=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(a())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&s(i,r.prototype),i}(e,arguments,i(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)},r(e)}function n(e,t,r){return t=i(t),function(e,t){if(t&&("object"==u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,a()?Reflect.construct(t,r||[],i(e).constructor):t.apply(e,r))}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(a=function(){return!!e})()}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function o(){o=function(e,t){return new r(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function r(e,n,a){var i=RegExp(e,n);return t.set(i,a||t.get(e)),s(i,r.prototype)}function n(e,r){var n=t.get(r);return Object.keys(n).reduce((function(t,r){var a=n[r];if("number"==typeof a)t[r]=e[a];else{for(var i=0;void 0===e[a[i]]&&i+1<a.length;)i++;t[r]=e[a[i]]}return t}),Object.create(null))}return c(r,RegExp),r.prototype.exec=function(t){var r=e.exec.call(this,t);if(r){r.groups=n(r,this);var a=r.indices;a&&(a.groups=n(a,this))}return r},r.prototype[Symbol.replace]=function(r,a){if("string"==typeof a){var i=t.get(this);return e[Symbol.replace].call(this,r,a.replace(/\$<([^>]+)(>|$)/g,(function(e,t,r){if(""===r)return e;var n=i[t];return Array.isArray(n)?"$"+n.join("$"):"number"==typeof n?"$"+n:""})))}if("function"==typeof a){var o=this;return e[Symbol.replace].call(this,r,(function(){var e=arguments;return"object"!=u(e[e.length-1])&&(e=[].slice.call(e)).push(n(e,o)),a.apply(this,e)}))}return e[Symbol.replace].call(this,r,a)},o.apply(this,arguments)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function l(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",a=r.toStringTag||"@@toStringTag";function i(r,n,a,i){var s=n&&n.prototype instanceof c?n:c,u=Object.create(s.prototype);return h(u,"_invoke",function(r,n,a){var i,c,s,u=0,l=a||[],h=!1,d={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,r){return i=t,c=0,s=e,d.n=r,o}};function f(r,n){for(c=r,s=n,t=0;!h&&u&&!a&&t<l.length;t++){var a,i=l[t],f=d.p,p=i[2];r>3?(a=p===n)&&(s=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=f&&((a=r<2&&f<i[1])?(c=0,d.v=n,d.n=i[1]):f<p&&(a=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,d.n=p,c=0))}if(a||r>1)return o;throw h=!0,n}return function(a,l,p){if(u>1)throw TypeError("Generator is already running");for(h&&1===l&&f(l,p),c=l,s=p;(t=c<2?e:s)||!h;){i||(c?c<3?(c>1&&(d.n=-1),f(c,s)):d.n=s:d.v=s);try{if(u=2,i){if(c||(a="next"),t=i[a]){if(!(t=t.call(i,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(s=TypeError("The iterator does not provide a '"+a+"' method"),c=1);i=e}else if((t=(h=d.n<0)?s:r.call(n,d))!==o)break}catch(t){i=e,c=1,s=t}finally{u=1}}return{value:t,done:h}}}(r,a,i),!0),u}var o={};function c(){}function s(){}function u(){}t=Object.getPrototypeOf;var d=[][n]?t(t([][n]())):(h(t={},n,(function(){return this})),t),f=u.prototype=c.prototype=Object.create(d);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,h(e,a,"GeneratorFunction")),e.prototype=Object.create(f),e}return s.prototype=u,h(f,"constructor",u),h(u,"constructor",s),s.displayName="GeneratorFunction",h(u,a,"GeneratorFunction"),h(f),h(f,a,"Generator"),h(f,n,(function(){return this})),h(f,"toString",(function(){return"[object Generator]"})),(l=function(){return{w:i,m:p}})()}function h(e,t,r,n){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}h=function(e,t,r,n){function i(t,r){h(e,t,(function(e){return this._invoke(t,r,e)}))}t?a?a(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},h(e,t,r,n)}function d(e){return function(e){if(Array.isArray(e))return A(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||O(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t,r,n,a,i,o){try{var c=e[i](o),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,a)}function p(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){f(i,n,a,o,c,"next",e)}function c(e){f(i,n,a,o,c,"throw",e)}o(void 0)}))}}function v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,b(n.key),n)}}function g(e,t,r){return t&&y(e.prototype,t),r&&y(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function k(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){C(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function C(e,t,r){return(t=b(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(e){var t=function(e,t){if("object"!=u(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==u(t)?t:t+""}function S(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=O(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){c=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(c)throw i}}}}function I(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i,o,c=[],s=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);s=!0);}catch(e){u=!0,a=e}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw a}}return c}}(e,t)||O(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){if(e){if("string"==typeof e)return A(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?A(e,t):void 0}}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var w=require("crypto"),N=require("buffer"),E=require("buffer/"),_=require("https"),P=require("querystring"),T=require("aws4");function R(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var M,K,x,H=R(w),j=R(_),V=R(P);!function(e){e.ORIGIN="ORIGIN",e.HTTP="HTTP",e.KINESIS="KINESIS",e.NATIVE="NATIVE"}(M||(M={})),function(e){e.MITIGATE="MITIGATE",e.INJECT="INJECT",e.INGEST="INGEST"}(K||(K={})),function(e){e.CAPTCHA_GET="captcha_get",e.CAPTCHA_POST="captcha_post",e.EXPIRED_SESSION="expired_session",e.FORCED_REVALIDATION="forced_revalidation",e.INVALID_SESSION="invalid_session",e.IP_CHANGE="ip_change",e.NO_SESSION="no_session"}(x||(x={}));var L=3e3;var F="_/@#/",D={none:"",block:"block",captcha:"captcha",allow:"allow",captchaPass:"captchapass"},B={0:D.none,1:D.block,2:D.none,3:D.block,4:D.none,5:D.block},q={1:D.captcha,2:D.captchaPass,3:D.captcha,4:D.allow,5:D.captcha,6:D.allow,7:D.captcha,a:D.captcha,b:D.captchaPass,c:D.captcha,d:D.allow,e:D.captcha},U=Object.freeze({__proto__:null,COOKIEDELIMITER:F,bestMitigationCaptchaMap:q,bestMitigationMap:B,captchaMap:{0:"",1:"captcha_serve",2:"captcha_pass",3:"captcha_fail",4:"captcha_cookiepass",5:"captcha_cookiefail",6:"checkpoint_signal",7:"checkpoint_post",a:"checkpoint_serve",b:"checkpoint_pass",c:"checkpoint_fail",d:"checkpoint_cookiepass",e:"checkpoint_cookiefail"},captchaStatusCodes:{"":0,captchaServe:1,captchaPass:2,captchaFail:3,captchaCookiePass:4,captchaCookieFail:5,checkpointSignal:6,checkpointPost:7,checkpointServe:"a",checkpointPass:"b",checkpointFail:"c",checkpointCookiePass:"d",checkpointCookieFail:"e"},matchMap:{0:"",1:"ua_",2:"ip_",3:"visitor_",4:"datacenter_",5:"customer_session_",6:"organisation_",7:"asn_",8:"country_",9:"combination_",b:"headerFP_",c:"vendorFamily_",d:"vendorName_",e:"vendor_",f:"vendorCrawlerClassification_"},mitigateMap:{0:"",1:"blocked",2:"allow",3:"hardblocked",4:"flagged",5:"monetised"},mitigationTypes:D,netaceaCookieV3KeyMap:{clientIP:"cip",userId:"uid",gracePeriod:"grp",cookieId:"cid",match:"mat",mitigate:"mit",captcha:"cap",issueTimestamp:"ist",issueReason:"isr"},netaceaCookieV3OptionalKeyMap:{checkAllPostRequests:"fCAPR"},netaceaHeaders:{match:"x-netacea-match",mitigate:"x-netacea-mitigate",captcha:"x-netacea-captcha",mitata:"x-netacea-mitata-value",mitataExpiry:"x-netacea-mitata-expiry",mitataCaptcha:"x-netacea-mitatacaptcha-value",mitataCaptchaExpiry:"x-netacea-mitatacaptcha-expiry",eventId:"x-netacea-event-id"},netaceaSettingsMap:{checkAllPostRequests:"checkAllPostRequests"}}),z="ignored",G="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),X=/^(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/((\d|[a-z])(\d)(\d|[a-z]))$/i;function J(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:G,r=w.randomBytes(e-1),n=Array.from(r).map((function(e){return t[e%t.length]})).join("");return"c".concat(n)}function W(e,t,r,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"000";void 0===t&&(t=J());var i=[r,t,$(e+"|"+String(r),n),a].join(F),o=$(i,n);return"".concat(o).concat(F).concat(i)}function $(e,t){var r=w.createHmac("sha256",t);return r.update(e),N.Buffer.from(r.digest("hex")).toString("base64")}function Q(e,t,r){var n={mitata:void 0,requiresReissue:!1,isExpired:!1,shouldExpire:!1,isSameIP:!1,isPrimaryHashValid:!1,captcha:"0",match:"0",mitigate:"0"};if("string"!=typeof e||""===e)return n;var a=function(e){if(void 0!==e){var t=e.match(X);if(null!=t){var r=I(t,9);return{signature:r[1],expiry:r[2],userId:r[3],ipHash:r[4],mitigationType:r[5],match:r[6],mitigate:r[7],captcha:r[8]}}}}(e);if(void 0!==a){var i=[a.expiry,a.userId,a.ipHash,a.mitigationType].join(F),o=Math.floor(Date.now()/1e3),c=parseInt(a.expiry)<o,s=["1","3","5","a","c","e"].includes(a.captcha),u="3"===a.mitigate,l=s||u,h=$(t+"|"+a.expiry,r),d=a.ipHash===h;return{mitata:a,requiresReissue:c||!d,isExpired:c,shouldExpire:l,isSameIP:d,isPrimaryHashValid:a.signature===$(i,r),match:a.match,mitigate:a.mitigate,captcha:a.captcha,userId:a.userId}}return n}function Y(e,t){var r=e.split(";").map((function(e){return e.trim()})).filter((function(e){return e.toLowerCase().startsWith(t.toLowerCase())}))[0];return void 0!==r&&r.length>0?null==r?void 0:r.replace("".concat(t,"="),""):void 0}function Z(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"string"!=typeof e&&(e=e.join("; ")),""===e?"":ee(e.split(";"),t).join("; ")}function ee(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])return ee(e.reverse()).reverse();var t,r=new Set,n=[],a=S(e);try{for(a.s();!(t=a.n()).done;){var i=t.value;if(""!==(i=i.trimStart()).trim()){var o=i.split("=")[0].toUpperCase();r.has(o)||(r.add(o),n.push(i))}}}catch(e){a.e(e)}finally{a.f()}return n}function te(e){var t,r,n=Z([null!==(t=e.otherAttributes)&&void 0!==t?t:"","Max-Age=".concat(null!==(r=e.maxAgeAttribute)&&void 0!==r?r:86400),"Path=/"].join("; "));return"".concat(e.cookieName,"=").concat(e.cookieValue,"; ").concat(n)}var re={cookie:{attributes:Object.freeze({__proto__:null,configureCookiesDomain:function(e,t){var r=e=Z(null!=e?e:"",!0),n=t=Z(null!=t?t:"",!0);if(void 0!==e&&void 0!==t){var a=Y(e,"Domain"),i=Y(t,"Domain");void 0!==a&&void 0!==i?n=t.replace(i,a):void 0!==a&&void 0===i?n=t+(""!==t?"; Domain=".concat(a):"Domain=".concat(a)):void 0===a&&void 0!==i&&(r=e+(""!==e?"; Domain=".concat(i):"Domain=".concat(i)))}else if(void 0!==e&&void 0===t){var o=Y(e,"Domain");void 0!==o&&(n="Domain=".concat(o))}else if(void 0===e&&void 0!==t){var c=Y(t,"Domain");void 0!==c&&(r="Domain=".concat(c))}return{cookieAttributes:""!==r?r:void 0,captchaCookieAttributes:""!==n?n:void 0}},extractAndRemoveCookieAttr:function(e,t){var r=Y(e,t);return void 0!==r?{extractedAttribute:r,cookieAttributes:e.replace(/ /g,"").replace("".concat(t,"=").concat(r),"").split(";").filter((function(e){return e.length>0})).join("; ")}:{extractedAttribute:void 0,cookieAttributes:e}},extractCookieAttr:Y,removeDuplicateAttrs:Z}),netaceaSession:Object.freeze({__proto__:null,createNetaceaCaptchaSetCookieString:function(e){var t;return te(k(k({},e),{},{cookieName:null!==(t=e.cookieName)&&void 0!==t?t:"_mitatacaptcha"}))},createNetaceaSetCookieString:function(e){var t;return te(k(k({},e),{},{cookieName:null!==(t=e.cookieName)&&void 0!==t?t:"_mitata"}))},createSetCookieString:te})}},ne=function(){function e(t,r){v(this,e),this.crypto=t,this.TextEncoder=r}return g(e,[{key:"hashString",value:(r=p(l().m((function e(t,r){var n,a,i,o,c,s,u=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:return a=(n=u.length>2&&void 0!==u[2]&&u[2])?d(r).sort():d(r),i=(new this.TextEncoder).encode(a.join(",")),e.n=1,this.crypto.subtle.digest(t,i);case 1:return o=e.v,c=Array.from(new Uint8Array(o)),s=c.map((function(e){return e.toString(16).padStart(2,"0")})).join("").substring(0,12),e.a(2,"h"+(n?"s":"")+"_".concat(r.length,"_").concat(s))}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"hashHeaders",value:(t=p(l().m((function t(r){var n,a,i,o=arguments;return l().w((function(t){for(;;)switch(t.n){case 0:if(n=o.length>1&&void 0!==o[1]&&o[1],0!==(a=e.filterHeaderNames(r)).length){t.n=1;break}return t.a(2,"");case 1:return t.p=1,t.n=2,this.hashString("SHA-256",a,n);case 2:return t.a(2,t.v);case 3:return t.p=3,i=t.v,console.error(i),t.a(2,"")}}),t,this,[[1,3]])}))),function(e){return t.apply(this,arguments)})}],[{key:"filterHeaderNames",value:function(e){return e.filter((function(e){var t=e.toLowerCase();return!["","cookie","referer"].includes(t)&&null===t.match(/^(x-netacea-|cloudfront-)/i)}))}}]);var t,r}();function ae(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ie(e){var t=(e+"===".slice(0,(4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/");return Buffer.from(t,"base64")}var oe="eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0";function ce(e){return 5===e.split(".").length&&e.includes("..")}function se(e,t){var r=w.randomBytes(12),n=w.createCipheriv("aes-256-gcm",t,r),a=Buffer.from(oe,"ascii");n.setAAD(a);var i=n.update(e,"utf8");i=Buffer.concat([i,n.final()]);var o=n.getAuthTag();return[oe,"",ae(r),ae(i),ae(o)].join(".")}function ue(e,t){var r=e.split(".");if(5!==r.length)throw new Error("JWE should have 5 parts, got ".concat(r.length));var n=I(r,5),a=n[0],i=n[1],o=n[2],c=n[3],s=n[4];if(a!==oe)throw new Error("Incorrect JWE header");if(""!==i)throw new Error("Expected empty encrypted key for direct encryption");var u=ie(o),l=ie(c),h=ie(s);if(12!==u.length)throw new Error("IV must be ".concat(12," bytes, got ").concat(u.length));if(16!==h.length)throw new Error("Auth tag must be ".concat(16," bytes, got ").concat(h.length));var d=w.createDecipheriv("aes-256-gcm",t,u),f=Buffer.from(a,"ascii");d.setAAD(f),d.setAuthTag(h);var p=d.update(l);return(p=Buffer.concat([p,d.final()])).toString("utf8")}var le,he,de,fe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},pe={},ve={};Object.defineProperty(ve,"__esModule",{value:!0}),ve.MitigateCode=ve.MatchCode=ve.CaptchaCode=void 0,function(e){e.NONE="0",e.SERVE="1",e.PASS="2",e.FAIL="3",e.COOKIE_PASS="4",e.COOKIE_FAIL="5",e.CHECKPOINT_SIGNAL="6",e.CHECKPOINT_POST="7",e.CHECKPOINT_SERVE="a",e.CHECKPOINT_PASS="b",e.CHECKPOINT_FAIL="c",e.CHECKPOINT_COOKIE_PASS="d",e.CHECKPOINT_COOKIE_FAIL="e"}(le||(ve.CaptchaCode=le={})),function(e){e.NONE="0",e.USER_AGENT="1",e.IP="2",e.VISITOR="3",e.DATACENTER="4",e.CUSTOMER_SESSION="5",e.ORGANISATION="6",e.ASN="7",e.COUNTRY="8",e.COMBINATION="9",e.HEADER_FINGERPRINT="b",e.VENDOR_FAMILY="c",e.VENDOR_NAME="d",e.VENDOR="e",e.VENDOR_CRAWLER_CLASSIFICATION="f"}(he||(ve.MatchCode=he={})),function(e){e.NONE="0",e.BLOCK="1",e.ALLOW="2",e.HARDBLOCK="3",e.FLAG="4",e.MONETISE="5"}(de||(ve.MitigateCode=de={}));var ye,ge={};Object.defineProperty(ge,"__esModule",{value:!0}),ge.NetaceaCookieV3IssueReason=void 0,function(e){e.CAPTCHA_GET="captcha_get",e.CAPTCHA_POST="captcha_post",e.EXPIRED_SESSION="expired_session",e.FORCED_REVALIDATION="forced_revalidation",e.INVALID_SESSION="invalid_session",e.IP_CHANGE="ip_change",e.NO_SESSION="no_session",e.UNKNOWN="unknown"}(ye||(ge.NetaceaCookieV3IssueReason=ye={}));var me={},ke={},Ce={};Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.netaceaCookieV3OptionalKeyMap=Ce.netaceaCookieV3KeyMap=Ce.COOKIEDELIMITER=void 0,Ce.COOKIEDELIMITER="_/@#/",Ce.netaceaCookieV3KeyMap={clientIP:"cip",userId:"uid",gracePeriod:"grp",cookieId:"cid",match:"mat",mitigate:"mit",captcha:"cap",issueTimestamp:"ist",issueReason:"isr"},Ce.netaceaCookieV3OptionalKeyMap={checkAllPostRequests:"fCAPR"},Object.defineProperty(ke,"__esModule",{value:!0}),ke.defaultInvalidResponse=ke.matchNetaceaCookieV3=ke.checkNetaceaCookieV3=ke.objectIsNetaceaCookieV3=ke.cookieIsNetaceaV3Format=ke.createNetaceaCookieV3=void 0;var be=ge,Se=Ce;function Ie(e){if(void 0!==e&&""!==e){var t,r=e.split("&"),n={clientIP:"",userId:"",cookieId:"",gracePeriod:0,match:"0",mitigate:"0",captcha:"0",issueTimestamp:0,issueReason:"",checkAllPostRequests:void 0},a=S(r);try{var i=function(){var e,r=I(t.value.split("="),2),a=r[0],i=r[1],o=decodeURIComponent(i),c=Object.keys(Se.netaceaCookieV3KeyMap).find((function(e){return Se.netaceaCookieV3KeyMap[e]===a}));void 0===c&&(c=Object.keys(Se.netaceaCookieV3OptionalKeyMap).find((function(e){return Se.netaceaCookieV3OptionalKeyMap[e]===a}))),void 0!==(e=void 0!==c&&["match","mitigate","captcha"].includes(c)?""===o?void 0:o:""===o?void 0:Number(o))&&"string"!=typeof e&&isNaN(e)&&(e=o),n[c]=e};for(a.s();!(t=a.n()).done;)i()}catch(e){a.e(e)}finally{a.f()}return n}}function Oe(){return{mitata:void 0,requiresReissue:!1,isExpired:!1,shouldExpire:!1,isSameIP:!1,isPrimaryHashValid:!1,captcha:"0",match:"0",mitigate:"0",issueReason:be.NetaceaCookieV3IssueReason.NO_SESSION}}ke.createNetaceaCookieV3=function(e){return Object.entries(e).filter((function(e){var t=I(e,2);t[0];return void 0!==t[1]})).map((function(e){var t=I(e,2),r=t[0],n=t[1];return r in Se.netaceaCookieV3OptionalKeyMap?"".concat(Se.netaceaCookieV3OptionalKeyMap[r],"=").concat(encodeURIComponent(n)):"".concat(Se.netaceaCookieV3KeyMap[r],"=").concat(encodeURIComponent(n))})).join("&")},ke.cookieIsNetaceaV3Format=function(e){if(void 0===e||""===e)return!1;var t=e.split("&").map((function(e){return e.split("=")[0]})).filter((function(e){return!Object.values(Se.netaceaCookieV3OptionalKeyMap).includes(e)}));return 0!==t.length&&t.every((function(e){return Object.values(Se.netaceaCookieV3KeyMap).includes(e)}))},ke.objectIsNetaceaCookieV3=function(e){if("object"!==u(e)||null===e)return!1;for(var t=0,r=Object.keys(Se.netaceaCookieV3KeyMap);t<r.length;t++){var n=r[t];if(!(n in e))return!1;if(void 0===e[n])return!1}return!0},ke.checkNetaceaCookieV3=function(e,t){if(void 0===e||""===e)return Oe();var r;try{r=Ie(e)}catch(e){return Oe()}if(void 0!==r){var n=Math.floor(Date.now()/1e3),a=r.issueTimestamp+r.gracePeriod<n,i=t===r.clientIP,o=["1","3","5","a","c","e"].includes(r.captcha),c="3"===r.mitigate;return{mitata:r,requiresReissue:a||!i,isExpired:a,shouldExpire:o||c,isSameIP:i,isPrimaryHashValid:!0,match:r.match,mitigate:r.mitigate,captcha:r.captcha,issueReason:r.issueReason}}return Oe()},ke.matchNetaceaCookieV3=Ie,ke.defaultInvalidResponse=Oe;var Ae={};Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.AbstractCookieFactory=void 0;var we=ge,Ne=ke,Ee=Ce,_e="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),Pe=/^(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/((\d|[a-z])(\d)(\d|[a-z]))$/i,Te=function(){return g((function e(t){v(this,e),this.config=t}),[{key:"isEncrypted",value:function(e){return 5===e.split(".").length}},{key:"createCookieValue",value:(n=p(l().m((function e(t){var r,n,a,i,o;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0===this.config.cookieEncryptionKey){e.n=2;break}return a=(0,Ne.createNetaceaCookieV3)({clientIP:t.clientIP,userId:null!==(r=t.userId)&&void 0!==r?r:this.generateUserId(),match:t.match,mitigate:t.mitigate,captcha:t.captcha,gracePeriod:t.gracePeriod,cookieId:t.cookieId,issueTimestamp:Math.floor(Date.now()/1e3),issueReason:null!==(n=t.issueReason)&&void 0!==n?n:we.NetaceaCookieV3IssueReason.NO_SESSION,checkAllPostRequests:t.checkAllPostRequests}),e.n=1,this.encrypt(a);case 1:case 4:return e.a(2,e.v);case 2:if(void 0!==this.config.secretKey){e.n=3;break}throw new Error("Cannot build cookie without secret key.");case 3:return i=[t.match,t.mitigate,t.captcha].join(""),o=Math.floor(Date.now()/1e3)+t.gracePeriod,e.n=4,this.buildMitataCookie(t.clientIP,t.userId,o,this.config.secretKey,i)}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"retrieveCookieInfo",value:(r=p(l().m((function e(t,r){var n,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==t&&""!==t){e.n=1;break}return e.a(2,(0,Ne.defaultInvalidResponse)());case 1:if(a=t,!this.isEncrypted(t)){e.n=3;break}return e.n=2,this.decrypt(t);case 2:a=e.v;case 3:if(!(0,Ne.cookieIsNetaceaV3Format)(a)){e.n=4;break}return e.a(2,(0,Ne.checkNetaceaCookieV3)(a,r));case 4:return e.n=5,this.checkMitataCookie(a,r,null!==(n=this.config.secretKey)&&void 0!==n?n:"");case 5:return e.a(2,e.v)}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"buildMitataCookie",value:(t=p(l().m((function e(t,r,n,a,i){var o,c,s,u;return l().w((function(e){for(;;)switch(e.n){case 0:return o=null!=r?r:this.generateUserId(),e.n=1,this.hash("".concat(t,"|").concat(String(n)),a);case 1:return c=e.v,s=[n,o,c,i].join(Ee.COOKIEDELIMITER),e.n=2,this.hash(s,a);case 2:return u=e.v,e.a(2,"".concat(u).concat(Ee.COOKIEDELIMITER).concat(s))}}),e,this)}))),function(e,r,n,a,i){return t.apply(this,arguments)})},{key:"checkMitataCookie",value:(e=p(l().m((function e(t,r,n){var a,i,o,c,s,u,h,d,f,p,v;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==(a=Re(t))){e.n=1;break}return e.a(2,(0,Ne.defaultInvalidResponse)());case 1:return i=Math.floor(Date.now()/1e3),o=parseInt(a.expiry)<i,c=["1","3","5"].includes(a.captcha),s="3"===a.mitigate,u=c||s,e.n=2,this.hash("".concat(r,"|").concat(a.expiry),n);case 2:return h=e.v,d=h===a.ipHash,f=[a.expiry,a.userId,a.ipHash,a.mitigationType].join(Ee.COOKIEDELIMITER),e.n=3,this.hash(f,n);case 3:return p=e.v,v=p===a.signature,e.a(2,{mitata:a,requiresReissue:o||!d,isExpired:o,shouldExpire:u,isSameIP:d,isPrimaryHashValid:v,match:a.match,mitigate:a.mitigate,captcha:a.captcha,issueReason:we.NetaceaCookieV3IssueReason.NO_SESSION})}}),e,this)}))),function(t,r,n){return e.apply(this,arguments)})},{key:"generateUserId",value:function(){var e=new Uint16Array((arguments.length>0&&void 0!==arguments[0]?arguments[0]:16)-1);this.getRandomValues(e);var t=Array.from(e).map((function(e){return _e[e%_e.length]})).join("");return"c".concat(t)}}]);var e,t,r,n}();function Re(e){var t=e.match(Pe);if(null!==t){var r=I(t,9);return{signature:r[1],expiry:r[2],userId:r[3],ipHash:r[4],mitigationType:r[5],match:r[6],mitigate:r[7],captcha:r[8]}}}Ae.AbstractCookieFactory=Te,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NetaceaCookieV3IssueReason=e.COOKIEDELIMITER=e.netaceaCookieV3OptionalKeyMap=e.netaceaCookieV3KeyMap=e.AbstractCookieFactory=e.defaultInvalidResponse=e.objectIsNetaceaCookieV3=e.cookieIsNetaceaV3Format=e.matchNetaceaCookieV3=e.checkNetaceaCookieV3=e.createNetaceaCookieV3=void 0;var t=ke;Object.defineProperty(e,"createNetaceaCookieV3",{enumerable:!0,get:function(){return t.createNetaceaCookieV3}}),Object.defineProperty(e,"checkNetaceaCookieV3",{enumerable:!0,get:function(){return t.checkNetaceaCookieV3}}),Object.defineProperty(e,"matchNetaceaCookieV3",{enumerable:!0,get:function(){return t.matchNetaceaCookieV3}}),Object.defineProperty(e,"cookieIsNetaceaV3Format",{enumerable:!0,get:function(){return t.cookieIsNetaceaV3Format}}),Object.defineProperty(e,"objectIsNetaceaCookieV3",{enumerable:!0,get:function(){return t.objectIsNetaceaCookieV3}}),Object.defineProperty(e,"defaultInvalidResponse",{enumerable:!0,get:function(){return t.defaultInvalidResponse}});var r=Ae;Object.defineProperty(e,"AbstractCookieFactory",{enumerable:!0,get:function(){return r.AbstractCookieFactory}});var n=Ce;Object.defineProperty(e,"netaceaCookieV3KeyMap",{enumerable:!0,get:function(){return n.netaceaCookieV3KeyMap}}),Object.defineProperty(e,"netaceaCookieV3OptionalKeyMap",{enumerable:!0,get:function(){return n.netaceaCookieV3OptionalKeyMap}}),Object.defineProperty(e,"COOKIEDELIMITER",{enumerable:!0,get:function(){return n.COOKIEDELIMITER}});var a=ge;Object.defineProperty(e,"NetaceaCookieV3IssueReason",{enumerable:!0,get:function(){return a.NetaceaCookieV3IssueReason}})}(me);var Me={};Object.defineProperty(Me,"__esModule",{value:!0}),Me.validateRedirectLocation=void 0,Me.validateRedirectLocation=function(e){if(""!==(e=null!=e?e:""))try{return new URL(e).toString()}catch(t){if(/^https?:\/\//i.test(e))return;return e.startsWith("/")?e:"/".concat(e)}};var Ke={},xe={};function He(e,t){for(var r=0,n=Object.keys(e);r<n.length;r++){var a,i=n[r];if("cookie"===i||"Cookie"===i){var o=null!==(a=e[i])&&void 0!==a?a:"",c=Ve("string"==typeof o?o:o.join("; "),t);if(void 0!==c)return c}}}function je(e,t){for(var r=[],n=0,a=Object.keys(e);n<a.length;n++){var i,o=a[n];if("cookie"===o||"Cookie"===o){var c=null!==(i=e[o])&&void 0!==i?i:"",s="string"==typeof c?c:c.join("; ");r.push.apply(r,d(Le(s,t)))}}return r}function Ve(e,t){var r=t+"=";return e.split(";").map((function(e){return e.trimStart()})).find((function(e){return e.startsWith(r)}))}function Le(e,t){var r=t+"=";return e.split(";").map((function(e){return e.trimStart()})).filter((function(e){return e.startsWith(r)}))}Object.defineProperty(xe,"__esModule",{value:!0}),xe.findAllInCookieString=xe.findFirstInCookieString=xe.findAllInHeaders=xe.findFirstInHeaders=xe.findOnlyValueInHeaders=xe.findAllValuesInHeaders=xe.findFirstValueInHeaders=void 0,xe.findFirstValueInHeaders=function(e,t){var r=He(e,t);if(void 0!==r)return r.slice(t.length+1)},xe.findAllValuesInHeaders=function(e,t){return je(e,t).map((function(e){return e.slice(t.length+1)}))},xe.findOnlyValueInHeaders=function(e,t){var r,n=je(e,t);if(n.length>1)throw new Error("Found more than one cookie with name ".concat(t));return null===(r=n[0])||void 0===r?void 0:r.slice(t.length+1)},xe.findFirstInHeaders=He,xe.findAllInHeaders=je,xe.findFirstInCookieString=Ve,xe.findAllInCookieString=Le;var Fe={};function De(e){return"set-cookie"===e||"Set-Cookie"===e}function Be(e,t){var r=t+"=";return e.startsWith(r)}function qe(e,t){if(!Be(e,t))throw new Error("Cookie '".concat(t,"' not found in '").concat(e,"'"));return e.slice(t.length+1).split(";")[0]}function Ue(e,t){var r,n=null!==(r=e[t])&&void 0!==r?r:[];return"string"==typeof n?[n]:n}function ze(e,t){for(var r=0,n=Object.keys(e);r<n.length;r++){var a=n[r];if(De(a)){var i=Ge(Ue(e,a),t);if(void 0!==i)return i}}}function Ge(e,t){return e.map((function(e){return e.trimStart()})).find((function(e){return Be(e,t)}))}function Xe(e,t){for(var r=[],n=0,a=Object.keys(e);n<a.length;n++){var i=a[n];if(De(i)){var o=Ue(e,i);r.push.apply(r,d(Je(o,t)))}}return r}function Je(e,t){return e.map((function(e){return e.trimStart()})).filter((function(e){return Be(e,t)}))}Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.findAllInSetCookieStrings=Fe.findAllInHeaders=Fe.findValueInSetCookieStrings=Fe.findFirstInSetCookieStrings=Fe.findFirstInHeaders=Fe.findOnlyValueInHeaders=Fe.findFirstValueInHeaders=Fe.parseValueFromString=void 0,Fe.parseValueFromString=qe,Fe.findFirstValueInHeaders=function(e,t){var r=ze(e,t);return void 0!==r?qe(r,t):void 0},Fe.findOnlyValueInHeaders=function(e,t){var r=Xe(e,t);if(r.length>1)throw new Error("Found more than one set-cookie with name ".concat(t));return void 0!==r[0]?qe(r[0],t):void 0},Fe.findFirstInHeaders=ze,Fe.findFirstInSetCookieStrings=Ge,Fe.findValueInSetCookieStrings=function(e,t){var r=Ge(e,t);if(void 0!==r)return qe(r,t)},Fe.findAllInHeaders=Xe,Fe.findAllInSetCookieStrings=Je;var We=fe&&fe.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),$e=fe&&fe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Qe=fe&&fe.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&We(t,e,r);return $e(t,e),t};Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.setCookie=Ke.cookie=void 0,Ke.cookie=Qe(xe),Ke.setCookie=Qe(Fe);var Ye={},Ze={},et={};Object.defineProperty(et,"__esModule",{value:!0}),et.KINESIS_URL=et.API_VERSION=et.REGION=et.PAYLOAD_TYPE=et.STATE=void 0,et.STATE={ACTIVE:"ACTIVE",UPDATING:"UPDATING",CREATING:"CREATING",DELETING:"DELETING"},et.PAYLOAD_TYPE="string",et.REGION="eu-west-1",et.API_VERSION="2013-12-02",et.KINESIS_URL="https://kinesis.eu-west-1.amazonaws.com";var tt={};function rt(){return(rt=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,new Promise((function(e){setTimeout(e,t)}));case 1:return e.a(2)}}),e)})))).apply(this,arguments)}Object.defineProperty(tt,"__esModule",{value:!0}),tt.headersToRecord=tt.increaseBatchSize=tt.handleFailedLogs=tt.batchArrayForKinesis=tt.sleep=void 0,tt.sleep=function(e){return rt.apply(this,arguments)},tt.batchArrayForKinesis=function(e,t,r){for(var n=[],a=0;a<e.length;a+=t){var i=e.slice(a,a+t);n.push({Data:r.from(JSON.stringify(i)).toString("base64"),PartitionKey:Date.now().toString()})}return n},tt.handleFailedLogs=function(e,t,r){var n=2*r,a=[].concat(d(e),d(t)),i=a.length-n;return i>0&&(console.error("Netacea Error :: failed to send ".concat(i," log(s) to Kinesis ingest.")),a.splice(0,i)),a},tt.increaseBatchSize=function(e,t){return e!==t?Math.min(t,2*e):e},tt.headersToRecord=function(e){var t={};return e.forEach((function(e,r){t[r]=e})),t},Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.WebStandardKinesis=void 0;var nt=et,at=tt,it=function(){return g((function e(t){var r=t.deps,n=t.kinesisIngestArgs;if(v(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.deps=r,void 0===n.kinesisAccessKey)throw new Error("kinesisAccessKey is required for kinesis ingest");if(void 0===n.kinesisSecretKey)throw new Error("kinesisSecretKey is required for kinesis ingest");this.kinesisStreamName=n.kinesisStreamName,this.kinesisAccessKey=n.kinesisAccessKey,this.kinesisSecretKey=n.kinesisSecretKey,this.maxAwaitTimePerIngestCallMs=n.maxAwaitTimePerIngestCallMs,void 0!==n.maxLogAgeSeconds&&n.maxLogAgeSeconds<this.maxLogAgeSeconds&&n.maxLogAgeSeconds>0&&(this.maxLogAgeSeconds=n.maxLogAgeSeconds),void 0!==n.logBatchSize&&(this.maxLogBatchSize=n.logBatchSize),this.logBatchSize=!0===n.rampUpBatchSize?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(r=p(l().m((function e(){var t,r,n;return l().w((function(e){for(;;)switch(e.n){case 0:if(0!==this.logCache.length){e.n=1;break}return e.a(2);case 1:return t=d(this.logCache),this.logCache=[],e.p=2,r=new this.deps.AwsClient({accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey}),e.n=3,this.signRequest(r,{streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},t,this.logBatchSize);case 3:return n=e.v,e.n=4,this.deps.makeRequest({headers:(0,at.headersToRecord)(n.headers),host:nt.KINESIS_URL,method:"POST",path:"/",body:n.body});case 4:this.logBatchSize=(0,at.increaseBatchSize)(this.logBatchSize,this.maxLogBatchSize),e.n=6;break;case 5:e.p=5,e.v,this.logCache=(0,at.handleFailedLogs)(this.logCache,t,this.maxLogBatchSize);case 6:return e.a(2)}}),e,this,[[2,5]])}))),function(){return r.apply(this,arguments)})},{key:"ingest",value:(t=p(l().m((function e(t){var r,n,a=this;return l().w((function(e){for(;;)switch(e.n){case 0:if(this.logCache.push(t),!(this.logCache.length>=this.logBatchSize)){e.n=2;break}return(r=[]).push(this.putToKinesis()),void 0!==this.maxAwaitTimePerIngestCallMs&&r.push((0,at.sleep)(this.maxAwaitTimePerIngestCallMs)),e.n=1,Promise.race(r);case 1:e.n=3;break;case 2:if(this.intervalSet){e.n=3;break}if(this.intervalSet=!0,n=(0,at.sleep)(1e3*this.maxLogAgeSeconds).then(p(l().m((function e(){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,a.putToKinesis();case 1:a.intervalSet=!1;case 2:return e.a(2)}}),e)})))).catch((function(){})),void 0!==this.maxAwaitTimePerIngestCallMs){e.n=3;break}return e.n=3,n;case 3:return e.a(2)}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"signRequest",value:(e=p(l().m((function e(t,r,n,a){var i,o;return l().w((function(e){for(;;)switch(e.n){case 0:return i={Records:(0,at.batchArrayForKinesis)(n,a,this.deps.Buffer),PartitionKey:Date.now().toString(),StreamName:r.streamName},e.n=1,t.sign(nt.KINESIS_URL,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"}});case 1:return o=e.v,e.a(2,o)}}),e,this)}))),function(t,r,n,a){return e.apply(this,arguments)})}]);var e,t,r}();Ze.WebStandardKinesis=it;var ot={};Object.defineProperty(ot,"__esModule",{value:!0}),ot.Kinesis=void 0;var ct=et,st=tt,ut=function(){return g((function e(t){var r=t.deps,n=t.kinesisIngestArgs;v(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.deps=r,this.kinesisStreamName=n.kinesisStreamName,this.kinesisAccessKey=n.kinesisAccessKey,this.kinesisSecretKey=n.kinesisSecretKey,this.maxAwaitTimePerIngestCallMs=n.maxAwaitTimePerIngestCallMs,void 0!==n.maxLogAgeSeconds&&n.maxLogAgeSeconds<this.maxLogAgeSeconds&&n.maxLogAgeSeconds>0&&(this.maxLogAgeSeconds=n.maxLogAgeSeconds),void 0!==n.logBatchSize&&(this.maxLogBatchSize=n.logBatchSize),this.logBatchSize=!0===n.rampUpBatchSize?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(t=p(l().m((function e(){var t,r,n,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(0!==this.logCache.length){e.n=1;break}return e.a(2);case 1:if(t=d(this.logCache),this.logCache=[],e.p=2,"POST"===(a=this.signRequest({streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},t,this.logBatchSize)).method){e.n=3;break}throw new Error("Unexpected method. Expected POST but got ".concat(a.method));case 3:return e.n=4,this.deps.makeRequest({headers:null!==(r=a.headers)&&void 0!==r?r:{},host:"https://".concat(a.hostname),method:a.method,path:null!==(n=a.path)&&void 0!==n?n:"/",body:a.body});case 4:this.logBatchSize=(0,st.increaseBatchSize)(this.logBatchSize,this.maxLogBatchSize),e.n=6;break;case 5:e.p=5,e.v,this.logCache=(0,st.handleFailedLogs)(this.logCache,t,this.maxLogBatchSize);case 6:return e.a(2)}}),e,this,[[2,5]])}))),function(){return t.apply(this,arguments)})},{key:"ingest",value:(e=p(l().m((function e(t){var r,n,a=this;return l().w((function(e){for(;;)switch(e.n){case 0:if(this.logCache.push(t),!(this.logCache.length>=this.logBatchSize)){e.n=2;break}return(r=[]).push(this.putToKinesis()),void 0!==this.maxAwaitTimePerIngestCallMs&&r.push((0,st.sleep)(this.maxAwaitTimePerIngestCallMs)),e.n=1,Promise.race(r);case 1:e.n=3;break;case 2:if(this.intervalSet){e.n=3;break}if(this.intervalSet=!0,n=(0,st.sleep)(1e3*this.maxLogAgeSeconds).then(p(l().m((function e(){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,a.putToKinesis();case 1:a.intervalSet=!1;case 2:return e.a(2)}}),e)})))).catch((function(){})),void 0!==this.maxAwaitTimePerIngestCallMs){e.n=3;break}return e.n=3,n;case 3:return e.a(2)}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"signRequest",value:function(e,t,r){var n=e.accessKeyId,a=e.secretAccessKey,i={Records:(0,st.batchArrayForKinesis)(t,r,this.deps.Buffer),PartitionKey:Date.now().toString(),StreamName:e.streamName};return this.deps.aws4.sign({service:"kinesis",body:JSON.stringify(i),headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"},region:ct.REGION},{accessKeyId:n,secretAccessKey:a})}}]);var e,t}();ot.Kinesis=ut,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Kinesis=e.WebStandardKinesis=void 0;var t=Ze;Object.defineProperty(e,"WebStandardKinesis",{enumerable:!0,get:function(){return t.WebStandardKinesis}});var r=ot;Object.defineProperty(e,"Kinesis",{enumerable:!0,get:function(){return r.Kinesis}})}(Ye);var lt={};function ht(e,t){var r=null;if("number"==typeof e&&Number.isFinite(e))r=e;else if("string"==typeof e&&""!==e.trim()){var n=Number(e);Number.isFinite(n)&&(r=n)}if(null===r){if("number"!=typeof t.defaultValue)return t.defaultValue;r=t.defaultValue}return void 0!==t.minValue&&(r=Math.max(t.minValue,r)),void 0!==t.maxValue&&(r=Math.min(t.maxValue,r)),r}Object.defineProperty(lt,"__esModule",{value:!0}),lt.parseUrl=lt.parseHttpHeaderName=lt.stringOrDefault=lt.parseIntOrDefault=lt.parseNumberOrDefault=void 0,lt.parseNumberOrDefault=ht,lt.parseIntOrDefault=function(e,t){var r=ht(e,t);return"number"==typeof r?Math.floor(r):r},lt.stringOrDefault=function(e,t){return"string"==typeof e&&""!==e?e:"number"==typeof e?e.toString():t},lt.parseHttpHeaderName=function(e){if("string"==typeof e){return/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/.test(e)?e:void 0}},lt.parseUrl=function(e){var t=/^[a-z][a-z\d+.-]*:\/\/([^/?#]+)([^?#]*)?(?:[?#].*)?$/i.exec(e);if(null!==t){var r=I(t,3),n=r[1],a=r[2];return{host:n.slice(n.lastIndexOf("@")+1),path:void 0===a||""===a?"/":a}}};var dt={};Object.defineProperty(dt,"__esModule",{value:!0}),dt.searchParamsFromRecord=void 0,dt.searchParamsFromRecord=function(e){for(var t=new URLSearchParams,r=0,n=Object.entries(e);r<n.length;r++){var a=I(n[r],2),i=a[0],o=a[1];t.append(i,o)}return t};var ft={},pt={};Object.defineProperty(pt,"__esModule",{value:!0}),pt.JweFactory=void 0;var vt=function(){return g((function e(t){v(this,e),this.jose=t}),[{key:"encrypt",value:(t=p(l().m((function e(t,r){var n,a,i,o,c=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:return n=c.length>2&&void 0!==c[2]?c[2]:"A128CBC-HS256",a=this.jose.base64url.decode(r),i=(new TextEncoder).encode(t),e.n=1,new this.jose.CompactEncrypt(i).setProtectedHeader({alg:"dir",enc:n}).encrypt(a);case 1:return o=e.v,e.a(2,o)}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"decrypt",value:(e=p(l().m((function e(t,r){var n,a,i;return l().w((function(e){for(;;)switch(e.n){case 0:return n=this.jose.base64url.decode(r),e.n=1,this.jose.compactDecrypt(t,n,{keyManagementAlgorithms:["dir"],contentEncryptionAlgorithms:["A256GCM","A128CBC-HS256"]});case 1:return a=e.v,i=a.plaintext,e.a(2,(new TextDecoder).decode(i))}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}],[{key:"isJweEncrypted",value:function(e){return 5===e.split(".").length&&e.includes("..")}}]);var e,t}();pt.JweFactory=vt;var yt=fe&&fe.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),gt=fe&&fe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),mt=fe&&fe.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&yt(t,e,r);return gt(t,e),t};Object.defineProperty(ft,"__esModule",{value:!0}),ft.jwe=void 0,ft.jwe=mt(pt);var kt={};Object.defineProperty(kt,"__esModule",{value:!0}),kt.truncateLongFields=kt.parseGraphQl=kt.parseGraphQlRequestBody=kt.getGraphQLParserConfig=void 0;var Ct=lt;function bt(e,t){var r,n,a=e.parserRegex;return null!==(r=null===(n=t.match(a))||void 0===n?void 0:n.groups)&&void 0!==r?r:{}}function St(e,t){for(var r,n,a=e.maxValueLength,i=0,o=Object.keys(t);i<o.length;i++){var c=o[i],s=t[c];t[c]=(n=a,(r=s).length<=n?r:r.slice(0,n)+"…")}return t}kt.getGraphQLParserConfig=function(e){var t,r={includePaths:[],maxParsableBytes:(0,Ct.parseIntOrDefault)(null==e?void 0:e.maxParsableBytes,{defaultValue:1e6,minValue:1e3}),maxValueLength:(0,Ct.parseIntOrDefault)(null==e?void 0:e.maxValueLength,{defaultValue:256,minValue:8}),parserRegex:o(/^\s*(query|mutation|subscription)\s+([_A-Za-z][_0-9A-Za-z]+)?/,{OpType:1,OpName:2}),useStrictAcceptHeaderCheck:null===(t=null==e?void 0:e.useStrictAcceptHeaderCheck)||void 0===t||t};if(Array.isArray(null==e?void 0:e.includePaths)){var n,a=S(e.includePaths);try{for(a.s();!(n=a.n()).done;){var i=n.value;"string"==typeof i&&r.includePaths.push(i)}}catch(e){a.e(e)}finally{a.f()}}try{if((null==e?void 0:e.parserRegex)instanceof RegExp)r.parserRegex=null==e?void 0:e.parserRegex;else if("object"===u(null==e?void 0:e.parserRegex)){var c=null==e?void 0:e.parserRegex,s=c.regex,l=c.flags;"string"==typeof s&&(r.parserRegex=new RegExp(s,l))}}catch(e){}return r},kt.parseGraphQlRequestBody=function(e,t){var r,n;if(""===t)throw new Error("Netacea Error: Empty GraphQL body received");var a=JSON.parse(t);if("object"!==u(a))throw new Error("Netacea Error: Invalid GraphQL JSON");var i=k({},bt(e,null!==(r=null==a?void 0:a.query)&&void 0!==r?r:"")),o=(null!==(n=null==a?void 0:a.operationName)&&void 0!==n?n:"").trim();return""!==o&&(i.OpName=o),St(e,i)},kt.parseGraphQl=bt,kt.truncateLongFields=St;var It={},Ot={},At={};Object.defineProperty(At,"__esModule",{value:!0}),At.createComputedSignatureInputs=At.createComputedSignatureInput=void 0;var wt=/^[a-z*][a-z0-9_.*-]{0,63}$/,Nt=/^"(?:[^"\\]|\\.)*"$/,Et=/^[^;"\s]+$/,_t=/^"[^"\\]+"(?:;[a-z*][a-z0-9_.*-]*(?:=(?:"(?:[^"\\]|\\.)*"|[^; ]+))?)*$/;function Pt(e,t){var r=Mt(t);if(void 0!==r){var n=[].concat(d(r.componentIdentifiers.map((function(t){var r=function(e,t){var r,n=null===(r=/^"([^"\\]+)"/.exec(t))||void 0===r?void 0:r[1];if(void 0===n)return;var a,i=Tt(t,"name");switch(n){case"@authority":a=e.url.host;break;case"@method":a=e.method;break;case"@path":a=e.url.path;break;case"@query":a=e.url.query;break;case"@query-param":a="string"==typeof i?function(e,t){var r=new URLSearchParams(e.slice(1)).getAll(t);return r.map(Rt).join(", ")}(e.url.query,i):void 0;break;case"@request-target":a="".concat(e.method.toLowerCase()," ").concat(e.url.path).concat(e.url.query);break;case"@scheme":a=e.url.scheme;break;case"@target-uri":a=e.url.toString();break;default:a=function(e,t,r){var n=e.readHeader(t),a=0===n.length?void 0:n.map((function(e){return e.trim()})).join(", ");return void 0!==a&&r?function(e){var t,r="",n=!1,a=!1,i=!1,o=!1,c=S(e.trim());try{for(c.s();!(t=c.n()).done;){var s=t.value;a?(r+=s,a=!1):n&&"\\"===s?(r+=s,a=!0):'"'===s?(r+=s,n=!n):n?r+=s:/\s/.test(s)?o||(i=!0):"="===s||";"===s?(r=r.trimEnd()+s,i=!1,o=!0):","===s?(r=r.trimEnd()+", ",i=!1,o=!1):(i&&""!==r&&!r.endsWith(" ")&&(r+=" "),r+=s,i=!1,o=!1)}}catch(e){c.e(e)}finally{c.f()}return r.trimEnd()}(a):a}(e,n,!0===Tt(t,"sf"))}return a}(e,t);return void 0===r?void 0:"".concat(t,": ").concat(r)}))),['"@signature-params": '.concat(r.parameters)]);if(!n.some((function(e){return void 0===e})))return n.join("\n")}}function Tt(e,t){var r=e.indexOf('"',1),n=e.slice(r+1);if(n.startsWith(";")){var a,i=S(xt(n.slice(1),";"));try{for(i.s();!(a=i.n()).done;){var o=a.value,c=o.indexOf("=");if((-1===c?o:o.slice(0,c))===t){if(-1===c)return!0;var s=o.slice(c+1);return Nt.test(s)?s.slice(1,-1).replace(/\\(.)/g,"$1"):s}}}catch(e){i.e(e)}finally{i.f()}}}function Rt(e){return encodeURIComponent(e).replace(/[!'()*]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function Mt(e){var t=e.indexOf("=");if(-1!==t){var r=e.slice(0,t);if(wt.test(r)){var n=e.slice(t+1),a=Kt(n,")",1);if(n.startsWith("(")&&-1!==a&&function(e){if(""===e)return!0;return e.startsWith(";")&&xt(e.slice(1),";").every((function(e){var t=e.indexOf("=");if(-1===t)return!1;var r=e.slice(0,t),n=e.slice(t+1);return wt.test(r)&&function(e){return Nt.test(e)||Et.test(e)}(n)}))}(n.slice(a+1))){var i=n.slice(1,a),o=""===i?[]:xt(i," ");return o.every((function(e){return _t.test(e)}))?{label:r,componentIdentifiers:o,parameters:n}:void 0}}}}function Kt(e,t){for(var r=!1,n=!1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;a<e.length;a++){var i=e[a];if(n)n=!1;else if(r&&"\\"===i)n=!0;else if('"'===i)r=!r;else if(!r&&i===t)return a}return-1}function xt(e,t){for(var r=[],n=0,a=Kt(e,t);-1!==a;)r.push(e.slice(n,a)),a=Kt(e,t,n=a+1);return r.push(e.slice(n)),r}At.createComputedSignatureInput=Pt,At.createComputedSignatureInputs=function(e,t){var r,n={},a=S(xt(t,","));try{for(a.s();!(r=a.n()).done;){var i=r.value.trim(),o=Mt(i),c=Pt(e,i);if(void 0===o||void 0===c)return;n[o.label]=c}}catch(e){a.e(e)}finally{a.f()}return n},Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.AbstractRequestView=void 0;var Ht=lt,jt=At,Vt=function(){return g((function e(t){v(this,e),this._httpMsgSignature=void 0,this._buffer=t}),[{key:"contentLength",get:function(){var e;return(0,Ht.parseIntOrDefault)(null===(e=this.readHeader("content-length"))||void 0===e?void 0:e[0],{defaultValue:0,minValue:0,maxValue:Number.MAX_SAFE_INTEGER})}},{key:"userAgent",get:function(){var e,t;return null!==(e=null===(t=this.readHeader("user-agent"))||void 0===t?void 0:t[0])&&void 0!==e?e:""}},{key:"contentType",get:function(){var e;return null===(e=this.readHeader("content-type"))||void 0===e?void 0:e[0]}},{key:"xForwardedFor",get:function(){var e;return null===(e=this.readHeader("x-forwarded-for"))||void 0===e?void 0:e[0]}},{key:"referer",get:function(){var e;return null===(e=this.readHeader("referer"))||void 0===e?void 0:e[0]}},{key:"accept",get:function(){var e;return null===(e=this.readHeader("accept"))||void 0===e?void 0:e[0]}},{key:"host",get:function(){var e;return null===(e=this.readHeader("host"))||void 0===e?void 0:e[0]}},{key:"getHttpMsgSignature",value:(e=p(l().m((function e(){var t,r,n,a,i,o,c,s,u;return l().w((function(e){for(;;)switch(e.n){case 0:if(t=this.readJoinedHeader("Signature-Input"),r=this.readJoinedHeader("Signature"),n=void 0===t?void 0:this.createBase64SignatureInput(t),void 0!==this._httpMsgSignature){e.n=4;break}if(a=r,void 0!==r){e.n=1;break}i=void 0,e.n=3;break;case 1:return e.n=2,this.sha256Hash(r);case 2:i=e.v.toLowerCase().slice(0,12);case 3:o=i,c=t,s=this.readJoinedHeader("Signature-Agent"),u=n,this._httpMsgSignature={signature:a,signatureSha256:o,signatureInput:c,signatureAgent:s,computedInput:u};case 4:return e.a(2,this._httpMsgSignature)}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"readJoinedHeader",value:function(e){var t=this.readHeader(e).join(",");return""!==t?t:void 0}},{key:"toBase64",value:function(e){if(void 0!==e)return this._buffer.from(e).toString("base64")}},{key:"createBase64SignatureInput",value:function(e){var t=this,r=(0,jt.createComputedSignatureInputs)(this,e);if(void 0!==r)return Object.entries(r).map((function(e){var r=I(e,2),n=r[0],a=r[1];return"".concat(n,"=:").concat(t.toBase64(a),":")})).join(", ")}}]);var e}();Ot.AbstractRequestView=Vt;var Lt={};Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.RequestUrl=void 0;var Ft=function(){function e(t,r,n,a){v(this,e),this.scheme=t,this.host=r,this.path=n,this.query=a}return g(e,[{key:"toString",value:function(){var e=""===this.scheme?"":"".concat(this.scheme,"://");return"".concat(e).concat(this.host).concat(this.path).concat(this.query)}}],[{key:"fromString",value:function(t){var r,n,a,i=/^(?:([a-z][a-z0-9+.-]*):\/\/)?([^/?#]+)(\/[^?#]*)?(\?[^#]*)?(?:#.*)?$/i.exec(t);if(null===i)throw new TypeError("Invalid request URL: ".concat(t));return new e(null!==(r=i[1])&&void 0!==r?r:"",i[2],null!==(n=i[3])&&void 0!==n?n:"/",null!==(a=i[4])&&void 0!==a?a:"")}}])}();Lt.RequestUrl=Ft,Object.defineProperty(It,"__esModule",{value:!0}),It.RequestView=void 0;var Dt=E,Bt=Ot,qt=Lt,Ut=function(){function e(t,r){var a;return v(this,e),(a=n(this,e,[Dt.Buffer])).request=t,a.sha256Digest=r,a}return c(e,Bt.AbstractRequestView),g(e,[{key:"method",get:function(){return this.request.method}},{key:"url",get:function(){return qt.RequestUrl.fromString(this.request.url)}},{key:"getBody",value:(r=p(l().m((function e(){var t,r,n,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==this._body){e.n=5;break}return e.n=1,this.request.clone().text();case 1:if(n=t=e.v,!(r=null!==n)){e.n=2;break}r=void 0!==t;case 2:if(!r){e.n=3;break}a=t,e.n=4;break;case 3:a="";case 4:this._body=a;case 5:return e.a(2,this._body)}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"readHeader",value:function(e){var t,r=null!==(t=this.request.headers.get(e))&&void 0!==t?t:void 0;return void 0!==r?[r]:[]}},{key:"sha256Hash",value:(t=p(l().m((function e(t){var r,n;return l().w((function(e){for(;;)switch(e.n){case 0:return r=(new TextEncoder).encode(t),e.n=1,this.sha256Digest.digest("SHA-256",r);case 1:return n=e.v,e.a(2,Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""))}}),e,this)}))),function(e){return t.apply(this,arguments)})}]);var t,r}();It.RequestView=Ut;var zt={},Gt={};Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.findBestMitigation=Gt.isCaptchaMitigation=void 0;var Xt=ve;function Jt(e){return"[".concat(e,"]")}var Wt=(C(C(C(C(C(C(C(C(C(C(e={},Xt.MatchCode.NONE,""),Xt.MatchCode.USER_AGENT,"ua_"),Xt.MatchCode.IP,"ip_"),Xt.MatchCode.VISITOR,"visitor_"),Xt.MatchCode.DATACENTER,"datacenter_"),Xt.MatchCode.CUSTOMER_SESSION,"customer_session_"),Xt.MatchCode.ORGANISATION,"organisation_"),Xt.MatchCode.ASN,"asn_"),Xt.MatchCode.COUNTRY,"country_"),Xt.MatchCode.COMBINATION,"combination_"),C(C(C(C(C(e,Xt.MatchCode.HEADER_FINGERPRINT,"headerFP_"),Xt.MatchCode.VENDOR_FAMILY,"vendorFamily_"),Xt.MatchCode.VENDOR_NAME,"vendorName_"),Xt.MatchCode.VENDOR,"vendor_"),Xt.MatchCode.VENDOR_CRAWLER_CLASSIFICATION,"vendorCrawlerClassification_")),$t=C(C(C(C(C(C({},Xt.MitigateCode.NONE,""),Xt.MitigateCode.BLOCK,"blocked"),Xt.MitigateCode.ALLOW,"allow"),Xt.MitigateCode.HARDBLOCK,"hardblocked"),Xt.MitigateCode.FLAG,"flagged"),Xt.MitigateCode.MONETISE,"monetised"),Qt=(C(C(C(C(C(C(C(C(C(C(t={},Xt.CaptchaCode.NONE,""),Xt.CaptchaCode.SERVE,"captcha_serve"),Xt.CaptchaCode.PASS,"captcha_pass"),Xt.CaptchaCode.FAIL,"captcha_fail"),Xt.CaptchaCode.COOKIE_PASS,"captcha_cookiepass"),Xt.CaptchaCode.COOKIE_FAIL,"captcha_cookiefail"),Xt.CaptchaCode.CHECKPOINT_SIGNAL,"checkpoint_signal"),Xt.CaptchaCode.CHECKPOINT_POST,"checkpoint_post"),Xt.CaptchaCode.CHECKPOINT_SERVE,"checkpoint_serve"),Xt.CaptchaCode.CHECKPOINT_PASS,"checkpoint_pass"),C(C(C(t,Xt.CaptchaCode.CHECKPOINT_FAIL,"checkpoint_fail"),Xt.CaptchaCode.CHECKPOINT_COOKIE_PASS,"checkpoint_cookiepass"),Xt.CaptchaCode.CHECKPOINT_COOKIE_FAIL,"checkpoint_cookiefail"));Gt.isCaptchaMitigation=function(e){return[Xt.CaptchaCode.SERVE,Xt.CaptchaCode.FAIL,Xt.CaptchaCode.COOKIE_FAIL,Xt.CaptchaCode.CHECKPOINT_POST,Xt.CaptchaCode.CHECKPOINT_SERVE,Xt.CaptchaCode.CHECKPOINT_FAIL,Xt.CaptchaCode.CHECKPOINT_COOKIE_FAIL].includes(e.captcha)},Gt.findBestMitigation=function(e,t,r,n){var a,i,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];r=function(e,t){var r;return t?e:null!==(r=C(C(C(C({},Xt.CaptchaCode.PASS,Xt.CaptchaCode.COOKIE_PASS),Xt.CaptchaCode.FAIL,Xt.CaptchaCode.COOKIE_FAIL),Xt.CaptchaCode.CHECKPOINT_PASS,Xt.CaptchaCode.CHECKPOINT_COOKIE_PASS),Xt.CaptchaCode.CHECKPOINT_FAIL,Xt.CaptchaCode.CHECKPOINT_COOKIE_FAIL)[e])&&void 0!==r?r:e}(r,n),o&&(r=Xt.CaptchaCode.CHECKPOINT_SIGNAL);var c,s=null!==(a=Wt[e])&&void 0!==a?a:Jt(e)+"_";return s+=null!==(i=$t[t])&&void 0!==i?i:Jt(t),r!==Xt.CaptchaCode.NONE&&(s+=","+(null!==(c=Qt[r])&&void 0!==c?c:Jt(r))),{sessionStatus:s,codes:{match:e,mitigate:t,captcha:r}}},function(e){var t=fe&&fe.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=fe&&fe.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(Gt,e)}(zt);var Yt={},Zt={};Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.ResponseView=Zt.AbstractResponseView=void 0;var er=function(){return g((function e(t){v(this,e),this.cacheStatus=t}),[{key:"contentType",get:function(){var e;return null===(e=this.readHeader("content-type"))||void 0===e?void 0:e[0]}},{key:"contentLength",get:function(){var e;return null===(e=this.readHeader("content-length"))||void 0===e?void 0:e[0]}},{key:"location",get:function(){var e;return null===(e=this.readHeader("location"))||void 0===e?void 0:e[0]}},{key:"setCookie",get:function(){return this.readHeader("set-cookie")}}])}();Zt.AbstractResponseView=er;var tr=function(){function e(t,r){var a;return v(this,e),(a=n(this,e,[r])).response=t,a}return c(e,er),g(e,[{key:"status",get:function(){return this.response.status}},{key:"getBody",value:(t=p(l().m((function e(){var t,r,n,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==this._body){e.n=5;break}return e.n=1,this.response.clone().text();case 1:if(n=t=e.v,!(r=null!==n)){e.n=2;break}r=void 0!==t;case 2:if(!r){e.n=3;break}a=t,e.n=4;break;case 3:a="";case 4:this._body=a;case 5:return e.a(2,this._body)}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"readHeader",value:function(e){var t;if("set-cookie"===(e=e.toLowerCase()))return this.response.headers.getSetCookie();var r=null!==(t=this.response.headers.get(e))&&void 0!==t?t:void 0;return void 0!==r?[r]:[]}},{key:"readHeaders",value:function(){var e={};return this.response.headers.forEach((function(t,r){e[r]=[t]})),e["set-cookie"]=this.response.headers.getSetCookie(),e}}]);var t}();Zt.ResponseView=tr,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.HttpClient=Yt.AbstractHttpClient=void 0;var rr=Zt,nr=function(){return g((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};v(this,e),this.cache=t.cache}),[{key:"request",value:(n=p(l().m((function e(t,r){var n,a,i;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0===(a=null===(n=this.cache)||void 0===n?void 0:n.get(t,r))){e.n=1;break}return e.a(2,this.createCachedResponseView(a));case 1:return e.n=2,this.fetch(t,r);case 2:return i=e.v,e.n=3,this.populateCache(t,r,i);case 3:return e.a(2,i)}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"populateCache",value:(r=p(l().m((function e(t,r,n){return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==this.cache){e.n=1;break}return e.a(2);case 1:return e.n=2,this.cache.set(t,r,n).catch((function(){}));case 2:return e.a(2)}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"get",value:(t=p(l().m((function e(t,r){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.request(t,k(k({},r),{},{method:"GET"}));case 1:return e.a(2,e.v)}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"post",value:(e=p(l().m((function e(t,r,n){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.request(t,k(k({},n),{},{method:"POST",body:r}));case 1:return e.a(2,e.v)}}),e,this)}))),function(t,r,n){return e.apply(this,arguments)})}]);var e,t,r,n}();Yt.AbstractHttpClient=nr;var ar=function(){function e(t){var r;return v(this,e),(r=n(this,e,[t])).fetchFn=t.fetch,r}return c(e,nr),g(e,[{key:"fetch",value:(t=p(l().m((function e(t,r){var n,a;return l().w((function(e){for(;;)switch(e.n){case 0:return n=new AbortController,e.n=1,ir(this.fetchFn(t,k(k({},r),{},{signal:n.signal})),null==r?void 0:r.timeoutMs,(function(){n.abort()}));case 1:return a=e.v,e.a(2,new rr.ResponseView(a,"MISS"))}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"createCachedResponseView",value:function(e){var t=new Response(e.body,e);return new rr.ResponseView(t,"HIT")}}]);var t}();function ir(e,t,r){return or.apply(this,arguments)}function or(){return(or=p(l().m((function e(t,r,n){var a,i;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==r){e.n=2;break}return e.n=1,t;case 1:case 4:return e.a(2,e.v);case 2:return i=new Promise((function(e,t){a=setTimeout((function(){n(),t(new Error("HTTP request timed out after ".concat(r,"ms")))}),r)})),e.p=3,e.n=4,Promise.race([t,i]);case 5:return e.p=5,void 0!==a&&clearTimeout(a),Promise.resolve(t).catch((function(){})),e.f(5);case 6:return e.a(2)}}),e,null,[[3,,5,6]])})))).apply(this,arguments)}Yt.HttpClient=ar;var cr={},sr={};Object.defineProperty(sr,"__esModule",{value:!0}),sr.LruCache=void 0;var ur=function(){return g((function e(t){if(v(this,e),this.capacity=t,this.entries=new Map,!Number.isInteger(t)||t<=0)throw new RangeError("LruCache capacity must be a positive integer")}),[{key:"size",get:function(){return this.entries.size}},{key:"get",value:function(e){if(this.entries.has(e)){var t=this.entries.get(e);return this.entries.delete(e),this.entries.set(e,t),t}}},{key:"set",value:function(e,t){if(this.entries.delete(e),this.entries.set(e,t),this.entries.size>this.capacity){var r=Array.from(this.entries.keys());r.length>0&&this.entries.delete(r[0])}}},{key:"find",value:function(e){var t,r=S(this.entries);try{for(r.s();!(t=r.n()).done;){var n=I(t.value,2),a=n[0];if(e(n[1],a))return this.get(a)}}catch(e){r.e(e)}finally{r.f()}}},{key:"delete",value:function(e){return this.entries.delete(e)}},{key:"clear",value:function(){this.entries.clear()}}])}();sr.LruCache=ur,Object.defineProperty(cr,"__esModule",{value:!0}),cr.HttpCache=void 0;var lr=sr,hr=lt,dr=1048576;function fr(e){var t={};if(void 0===e)return t;for(var r=0,n=Object.entries(e);r<n.length;r++){var a=I(n[r],2),i=a[0],o=a[1];t[i.toLowerCase()]=o}return t}function pr(e){if(void 0===e||""===e.trim())return{};var t,r={},n=S(e.split(","));try{for(n.s();!(t=n.n()).done;){var a=t.value.trim();if(""!==a){var i=a.indexOf("=");if(-1!==i)r[a.slice(0,i).trim().toLowerCase()]=a.slice(i+1).trim().replace(/^"(.+)"$/,"$1");else r[a.toLowerCase()]=!0}}}catch(e){n.e(e)}finally{n.f()}return r}function vr(e){var t=(0,hr.parseNumberOrDefault)(e,{defaultValue:void 0});return"number"==typeof t&&t>=0?t:void 0}function yr(e){if(void 0!==e){var t=Date.parse(e);return Number.isNaN(t)?void 0:t}}function gr(e,t){return{method:(r=null==t?void 0:t.method,(null!=r?r:"GET").toUpperCase()),url:e,headers:fr(null==t?void 0:t.headers)};var r}function mr(e){for(var t={},r=0,n=Object.entries(e.readHeaders());r<n.length;r++){var a=I(n[r],2),i=a[0],o=a[1];o.length>0&&(t[i.toLowerCase()]=o.join(", "))}return t}function kr(e){return void 0===e.vary?[]:e.vary.split(",").map((function(e){return e.trim().toLowerCase()})).filter((function(e){return""!==e}))}function Cr(e){return"GET"!==e.method?"method=".concat(e.method):void 0!==e.headers.authorization?"authorization header present":void 0!==e.headers.range?"range header present":void 0!==e.headers["if-match"]?"if-match header present":void 0!==e.headers["if-none-match"]?"if-none-match header present":void 0!==e.headers["if-modified-since"]?"if-modified-since header present":void 0!==e.headers["if-unmodified-since"]?"if-unmodified-since header present":void 0!==e.headers["if-range"]?"if-range header present":void 0!==pr(e.headers["cache-control"])["no-store"]?"request cache-control=no-store":void 0}function br(e,t){return!t.vary.includes("*")&&t.vary.every((function(r){var n,a;return(null!==(n=e.headers[r])&&void 0!==n?n:"")===(null!==(a=t.varyRequestHeaders[r])&&void 0!==a?a:"")}))}function Sr(e){var t,r=vr(e.cacheControl["s-maxage"]);if(void 0!==r)return r;var n=vr(e.cacheControl["max-age"]);if(void 0!==n)return n;var a=yr(e.headers.expires);return void 0===a?0:Math.max(0,Math.floor((a-(null!==(t=e.dateHeaderMs)&&void 0!==t?t:e.storedAt))/1e3))}function Ir(e){return JSON.stringify([e.url,e.vary.map((function(t){var r;return[t,null!==(r=e.varyRequestHeaders[t])&&void 0!==r?r:""]}))])}var Or=function(){return g((function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};v(this,e),this.entries=new lr.LruCache(10),this.defaultCacheControl=r.defaultCacheControl,this.now=null!==(t=r.now)&&void 0!==t?t:function(){return Date.now()}}),[{key:"get",value:function(e,t){var r=gr(e,t);if("GET"!==r.method)return{body:"Not Found",headers:{},status:404,storedAt:this.now(),url:r.url,vary:[],varyRequestHeaders:{},cacheControl:{},ageSeconds:0};if(void 0===Cr(r)){var n=pr(r.headers["cache-control"]);if(void 0===n["no-cache"]){var a=this.entries.find((function(e){return e.url===r.url&&br(r,e)}));if(void 0!==a&&void 0===a.cacheControl["no-cache"]){var i=vr(n["max-age"]),o=void 0===i?Sr(a):Math.min(Sr(a),i),c=function(e,t){return Math.max(0,Math.floor((t-e.storedAt)/1e3))+e.ageSeconds}(a,this.now());if(!(c>=o))return k(k({},a),{},{headers:k(k({},a.headers),{},{age:String(c)})})}}}}},{key:"set",value:(e=p(l().m((function e(t,r,n){var a,i,o,c,s,u,h,d,f,p,v,y,g,m,k;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0===Cr(o=gr(t,r))){e.n=1;break}return e.a(2);case 1:if(c=this.entries.find((function(e){return e.url===o.url&&br(o,e)})),s=mr(n),u=null!==(a=s["cache-control"])&&void 0!==a?a:this.defaultCacheControl,h=pr(u),!(200!==n.status||void 0!==h["no-store"]||void 0!==h.private||n.setCookie.length>0)){e.n=2;break}return this.removeEntry(c),e.a(2);case 2:if(!(d=kr(s)).includes("*")){e.n=3;break}return this.removeEntry(c),e.a(2);case 3:if(f=Number(s["content-length"]),!(Number.isFinite(f)&&f>dr)){e.n=4;break}return this.removeEntry(c),e.a(2);case 4:return e.n=5,n.getBody();case 5:if(p=e.v,!((new TextEncoder).encode(p).byteLength>dr)){e.n=6;break}return this.removeEntry(c),e.a(2);case 6:v=this.now(),y=Number(null!==(i=s.age)&&void 0!==i?i:"0"),g=yr(s.date),m=void 0===g?0:Math.max(0,Math.floor((v-g)/1e3)),k={body:p,headers:s,status:n.status,storedAt:v,url:o.url,vary:d,varyRequestHeaders:Object.fromEntries(d.map((function(e){var t;return[e,null!==(t=o.headers[e])&&void 0!==t?t:""]}))),cacheControl:h,dateHeaderMs:g,ageSeconds:Math.max(Number.isFinite(y)&&y>=0?y:0,m)},void 0!==c&&this.entries.delete(Ir(c)),this.entries.set(Ir(k),k);case 7:return e.a(2)}}),e,this)}))),function(t,r,n){return e.apply(this,arguments)})},{key:"removeEntry",value:function(e){void 0!==e&&this.entries.delete(Ir(e))}}]);var e}();cr.HttpCache=Or;var Ar={};Object.defineProperty(Ar,"__esModule",{value:!0}),Ar.ProtectorApiResponseView=void 0;var wr=lt,Nr=function(){return g((function e(t){v(this,e),this.responseView=t}),[{key:"status",get:function(){return this.responseView.status}},{key:"getBody",value:(t=p(l().m((function e(){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.responseView.getBody();case 1:return e.a(2,e.v)}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"readHeader",value:function(e){return this.responseView.readHeader(e)}},{key:"redirectHost",get:function(){var e;return null===(e=this.readHeader("x-netacea-redirect-host"))||void 0===e?void 0:e[0]}},{key:"redirectLocation",get:function(){var e;return null===(e=this.readHeader("x-netacea-redirect-location"))||void 0===e?void 0:e[0]}},{key:"redirectStatus",get:function(){var e;return null===(e=this.readHeader("x-netacea-redirect-status"))||void 0===e?void 0:e[0]}},{key:"redirectStatusCode",get:function(){var e,t=null===(e=this.readHeader("x-netacea-redirect-status"))||void 0===e?void 0:e[0];if(void 0!==t){var r=(0,wr.parseIntOrDefault)(t,{defaultValue:0,minValue:0,maxValue:Number.MAX_SAFE_INTEGER});return r>=300&&r<400?r:void 0}}},{key:"eventId",get:function(){var e;return null===(e=this.readHeader("x-netacea-event-id"))||void 0===e?void 0:e[0]}},{key:"signatureStatus",get:function(){var e;return null===(e=this.readHeader("x-netacea-signature-status"))||void 0===e?void 0:e[0]}},{key:"netaceaSettings",get:function(){var e,t=null===(e=this.readHeader("x-netacea-settings"))||void 0===e?void 0:e[0];if(void 0===t)return{checkAllPostRequests:!1};try{var r=new URLSearchParams(t).get("checkAllPostRequests");return null===r?{checkAllPostRequests:!1}:{checkAllPostRequests:"1"===r}}catch(e){return{checkAllPostRequests:!1}}}},{key:"sessionCookieMaxAge",get:function(){var e;return(0,wr.parseIntOrDefault)(null===(e=this.readHeader("x-netacea-mitata-expiry"))||void 0===e?void 0:e[0],{defaultValue:86400,minValue:0,maxValue:Number.MAX_SAFE_INTEGER})}},{key:"captchaCookieMaxAge",get:function(){var e,t=null===(e=this.readHeader("x-netacea-mitatacaptcha-expiry"))||void 0===e?void 0:e[0];return(0,wr.parseIntOrDefault)(t,{defaultValue:86400,minValue:0,maxValue:Number.MAX_SAFE_INTEGER})}},{key:"getProtectorCodes",value:function(e){var t,r,n,a,i,o,c,s,u;return{match:null!==(t=null!==(r=null===(n=this.readHeader("x-netacea-match"))||void 0===n?void 0:n[0])&&void 0!==r?r:null==e?void 0:e.match)&&void 0!==t?t:"0",mitigate:null!==(a=null!==(i=null===(o=this.readHeader("x-netacea-mitigate"))||void 0===o?void 0:o[0])&&void 0!==i?i:null==e?void 0:e.mitigate)&&void 0!==a?a:"0",captcha:null!==(c=null!==(s=null===(u=this.readHeader("x-netacea-captcha"))||void 0===u?void 0:u[0])&&void 0!==s?s:null==e?void 0:e.captcha)&&void 0!==c?c:"0"}}},{key:"getMonetisationRedirectLocation",value:function(e,t){var r=this.redirectLocation;if(void 0!==r)return r;var n=this.redirectHost;if(void 0!==n){var a=new URL("https://".concat(n));return a.pathname=e,a.search=t,a.toString()}}},{key:"getMonetisationRedirect",value:function(e,t){var r,n=this.getMonetisationRedirectLocation(e,t);if(void 0!==n)return{location:n,statusCode:null!==(r=this.redirectStatusCode)&&void 0!==r?r:303}}},{key:"getCaptchaJson",value:(e=p(l().m((function e(t,r){var n,a,i;return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.getBody();case 1:if(n=e.v,void 0===(a=this.eventId)&&"string"==typeof n&&(i=JSON.parse(n),a=_r(i)),void 0!==a){e.n=2;break}throw new Error("Could not resolve Tracking ID for captcha event.");case 2:return e.a(2,Er(t,r,a))}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}]);var e,t}();function Er(e,t,r){var n="".concat(e,"?trackingId=").concat(r),a=void 0!==t?"https://".concat(t).concat(n):void 0;return JSON.stringify({captchaRelativeURL:n,captchaAbsoluteURL:a})}function _r(e){if(null==e||"object"!==u(e))throw new Error("Response body is not a valid object!");var t=e.trackingId;if("string"!=typeof t||0===t.length)throw new Error("Response body does not contain a valid trackingId!");return t}Ar.ProtectorApiResponseView=Nr;var Pr={};Object.defineProperty(Pr,"__esModule",{value:!0}),Pr.acceptHeaderToNetaceaContentType=Pr.APIError=Pr.ProtectorApiClient=void 0;var Tr=Ar,Rr=function(){return g((function e(t,r){v(this,e),this.httpClient=t.httpClient,this.timeoutMs=t.timeoutMs;var n=/^https:\/\/([^/?#]+)/i.exec(r.protectorApiUrl);if(null===n)throw new Error("Protector API URL must use HTTPS");this.protectorApiHost=n[1],this.apiKey=r.apiKey}),[{key:"getDecisionResponse",value:(r=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.getResponse("/",t);case 1:return e.a(2,e.v)}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getChallengePage",value:(t=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.getResponse("/captcha",t);case 1:return e.a(2,e.v)}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"getResponse",value:(e=p(l().m((function e(t,r){var n,a,i,o,c,s,u,h,d;return l().w((function(e){for(;;)switch(e.n){case 0:return n=[],a=new Hr,i={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r.clientIp},void 0===r.userId||r.isNewUser||(i["X-Netacea-UserId"]=r.userId),o=r.captchaSiteKey,c=r.captchaSecretKey,void 0!==o&&void 0!==c&&(i["X-Netacea-Captcha-Site-Key"]=o,i["X-Netacea-Captcha-Secret-Key"]=c),void 0!==r.customerSessionId&&(i["X-Netacea-Customer-Session-ID"]=r.customerSessionId),void 0!==r.accept&&(i.Accept=r.accept,s=xr(r.accept),i["X-Netacea-Captcha-Content-Type"]=s),void 0!==r.headerFingerprint&&a.setQuery("headerFP",r.headerFingerprint),void 0===r.checkAllPostRequests&&a.setQuery("getSettings","checkAllPostRequests"),void 0!==r.challengeAssetsPath&&a.setQuery("challengeAssetsPath",r.challengeAssetsPath),void 0!==r.trackingId&&a.setQuery("trackingId",r.trackingId),void 0!==r.base64UserAgent?(i["X-Netacea-User-Agent"]=r.base64UserAgent,n.push("User-Agent")):void 0!==r.userAgent&&(i["User-Agent"]=r.userAgent),void 0!==r.requestId&&(i["X-Netacea-Request-Id"]=r.requestId,n.push("Request-Id")),void 0!==r.captchaCookie&&((u=r.captchaCookie).startsWith("_mitatacaptcha=")||(u="_mitatacaptcha="+u),i.Cookie=u),void 0!==r.httpMsgSignature&&Mr(i,n,r.httpMsgSignature),n.length>0&&a.setQuery("netaceaHeaders",n.join(",")),h=this.protectorApiHost,e.n=1,this.httpClient.get("https://".concat(h).concat(t)+a.buildQueryString(),{headers:i,timeoutMs:this.timeoutMs});case 1:if(200===(d=e.v).status){e.n=2;break}throw Kr.fromResponse(d);case 2:return e.a(2,new Tr.ProtectorApiResponseView(d))}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}]);var e,t,r}();function Mr(e,t,r){void 0!==r.signature&&(e.Signature=r.signature),void 0!==r.signatureInput&&(e["Signature-Input"]=r.signatureInput),void 0!==r.signatureAgent&&(e["Signature-Agent"]=r.signatureAgent),void 0!==r.computedInput&&(e["X-Netacea-Computed-Signature-Input"]=r.computedInput,t.push("Computed-Signature-Input"))}Pr.ProtectorApiClient=Rr;var Kr=function(){function e(t,r){var a;return v(this,e),(a=n(this,e,[t])).response=r,a}return c(e,r(Error)),g(e,null,[{key:"fromResponse",value:function(t){var r="Unknown error";switch(t.status){case 403:r="Invalid credentials";break;case 500:r="Server error";break;case 502:r="Bad Gateway";break;case 503:r="Service Unavailable";break;case 400:r="Invalid request"}return new e(r,t)}}])}();function xr(e){var t,r=null!==(t=null==e?void 0:e.toLowerCase())&&void 0!==t?t:"text/html",n=(null==r?void 0:r.includes("text/html"))||(null==r?void 0:r.includes("application/html"));return(null==r?void 0:r.includes("application/json"))&&!n?"application/json":"text/html"}Pr.APIError=Kr,Pr.acceptHeaderToNetaceaContentType=xr;var Hr=function(){return g((function e(){v(this,e),this.queries={}}),[{key:"setQuery",value:function(e,t){return this.queries[e]=encodeURIComponent(t),this}},{key:"removeQuery",value:function(e){var t=this.queries,r=(t[e],function(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}(t,[e].map(b)));return this.queries=r,this}},{key:"buildQueryString",value:function(){var e=Object.entries(this.queries).map((function(e){var t=I(e,2),r=t[0],n=t[1];return"".concat(r,"=").concat(n)})).join("&");return e.length>0?"?".concat(e):""}}])}();!function(e){var t=fe&&fe.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=fe&&fe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=fe&&fe.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&t(n,e,a);return r(n,e),n},a=fe&&fe.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.mitigation=e.graphql=e.webcrypto=e.url=e.parsing=e.ingest=e.headers=e.configValidation=e.cookie=e.NetaceaCookieV3IssueReason=e.MitigateCode=e.MatchCode=e.CaptchaCode=void 0;var i=ve;Object.defineProperty(e,"CaptchaCode",{enumerable:!0,get:function(){return i.CaptchaCode}}),Object.defineProperty(e,"MatchCode",{enumerable:!0,get:function(){return i.MatchCode}}),Object.defineProperty(e,"MitigateCode",{enumerable:!0,get:function(){return i.MitigateCode}});var o=ge;Object.defineProperty(e,"NetaceaCookieV3IssueReason",{enumerable:!0,get:function(){return o.NetaceaCookieV3IssueReason}}),e.cookie=n(me),e.configValidation=n(Me),e.headers=n(Ke),e.ingest=n(Ye),e.parsing=n(lt),e.url=n(dt),e.webcrypto=n(ft),e.graphql=n(kt),a(It,e),e.mitigation=n(zt),a(Yt,e),a(cr,e),a(sr,e),a(Ot,e),a(Lt,e),a(Zt,e),a(Ar,e),a(Pr,e)}(pe);var jr=function(){function e(t,r){var a;return v(this,e),C(a=n(this,e,[void 0===r?k(k({},t),{},{cookieEncryptionKey:void 0}):t]),"encryptionKeyBuffer",void 0),a.encryptionKeyBuffer=r,a}return c(e,pe.cookie.AbstractCookieFactory),g(e,[{key:"encrypt",value:(a=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==this.encryptionKeyBuffer){e.n=1;break}throw new Error("F5CookieFactory.encrypt called without a configured encryption key");case 1:return e.a(2,se(t,this.encryptionKeyBuffer))}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"decrypt",value:(r=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==this.encryptionKeyBuffer){e.n=1;break}throw new Error("F5CookieFactory.decrypt called without a configured encryption key");case 1:return e.a(2,ue(t,this.encryptionKeyBuffer))}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"hash",value:(t=p(l().m((function e(t,r){var n;return l().w((function(e){for(;;)if(0===e.n)return(n=w.createHmac("sha256",r)).update(t),e.a(2,N.Buffer.from(n.digest("hex")).toString("base64"))}),e)}))),function(e,r){return t.apply(this,arguments)})},{key:"getRandomValues",value:function(e){for(var t=w.randomBytes(2*e.length),r=0;r<e.length;r++)e[r]=t[2*r]|t[2*r+1]<<8;return e}},{key:"isEncrypted",value:function(e){return ce(e)}}]);var t,r,a}(),Vr={},Lr={},Fr={},Dr={};Object.defineProperty(Dr,"__esModule",{value:!0}),Dr.API_VERSION=Dr.REGION=Dr.PAYLOAD_TYPE=Dr.STATE=void 0,Dr.STATE={ACTIVE:"ACTIVE",UPDATING:"UPDATING",CREATING:"CREATING",DELETING:"DELETING"},Dr.PAYLOAD_TYPE="string",Dr.REGION="eu-west-1",Dr.API_VERSION="2013-12-02",Object.defineProperty(Fr,"__esModule",{value:!0}),Fr.signRequest=void 0;var Br=T,qr=Dr;function Ur(e,t){for(var r=[],n=0;n<e.length;n+=t){var a=e.slice(n,n+t);r.push({Data:Buffer.from(JSON.stringify(a)).toString("base64"),PartitionKey:Date.now().toString()})}return r}Fr.signRequest=function(e,t,r){var n=e.accessKeyId,a=e.secretAccessKey,i={Records:Ur(t,r),PartitionKey:Date.now().toString(),StreamName:e.streamName};return Br.sign({service:"kinesis",body:JSON.stringify(i),headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"},region:qr.REGION},{accessKeyId:n,secretAccessKey:a})},Object.defineProperty(Lr,"__esModule",{value:!0});var zr=Fr;function Gr(e){return Xr.apply(this,arguments)}function Xr(){return(Xr=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,new Promise((function(e){setTimeout(e,t)}));case 1:return e.a(2)}}),e)})))).apply(this,arguments)}var Jr=function(){return g((function e(t){var r=t.kinesisStreamName,n=t.kinesisAccessKey,a=t.kinesisSecretKey,i=t.maxLogAgeSeconds,o=t.logBatchSize,c=t.rampUpBatchSize,s=t.maxAwaitTimePerIngestCallMs;v(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.kinesisStreamName=r,this.kinesisAccessKey=n,this.kinesisSecretKey=a,this.maxAwaitTimePerIngestCallMs=s,void 0!==i&&i<this.maxLogAgeSeconds&&i>0&&(this.maxLogAgeSeconds=i),void 0!==o&&(this.maxLogBatchSize=o),this.logBatchSize=!0===c?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(t=p(l().m((function e(t){var r,n,a,i;return l().w((function(e){for(;;)switch(e.n){case 0:if(0!==this.logCache.length){e.n=1;break}return e.a(2);case 1:return r=d(this.logCache),this.logCache=[],e.p=2,n=(0,zr.signRequest)({streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},r,this.logBatchSize),e.n=3,t({headers:n.headers,host:"https://".concat(n.hostname),method:n.method,path:n.path,body:n.body});case 3:this.logBatchSize!==this.maxLogBatchSize&&(this.logBatchSize=Math.min(this.maxLogBatchSize,2*this.logBatchSize)),e.n=5;break;case 4:e.p=4,i=e.v,(a=this.logCache).push.apply(a,d(r)),console.error(i);case 5:return e.a(2)}}),e,this,[[2,4]])}))),function(e){return t.apply(this,arguments)})},{key:"ingest",value:(e=p(l().m((function e(t,r){var n,a,i=this;return l().w((function(e){for(;;)switch(e.n){case 0:if(this.logCache.push(t),!(this.logCache.length>=this.logBatchSize)){e.n=2;break}return(n=[]).push(this.putToKinesis(r)),void 0!==this.maxAwaitTimePerIngestCallMs&&n.push(Gr(this.maxAwaitTimePerIngestCallMs)),e.n=1,Promise.race(n);case 1:e.n=3;break;case 2:if(this.intervalSet){e.n=3;break}if(this.intervalSet=!0,a=Gr(1e3*this.maxLogAgeSeconds).then(p(l().m((function e(){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,i.putToKinesis(r);case 1:i.intervalSet=!1;case 2:return e.a(2)}}),e)})))).catch((function(){})),void 0!==this.maxAwaitTimePerIngestCallMs){e.n=3;break}return e.n=3,a;case 3:return e.a(2)}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}]);var e,t}();Lr.default=Jr,Object.defineProperty(Vr,"__esModule",{value:!0});var Wr,$r=Lr,Qr=Vr.default=$r.default,Yr={subtle:{digest:(Wr=p(l().m((function e(t,r){var n,a,i,o,c;return l().w((function(e){for(;;)if(0===e.n)return a=null!==(n={"SHA-256":"sha256","SHA-1":"sha1","SHA-384":"sha384","SHA-512":"sha512"}[t])&&void 0!==n?n:t.toLowerCase().replace("-",""),i=r instanceof ArrayBuffer?Buffer.from(r):Buffer.from(r.buffer,r.byteOffset,r.byteLength),o=new Uint8Array(i),c=H.createHash(a).update(o).digest(),e.a(2,c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength))}),e)}))),function(e,t){return Wr.apply(this,arguments)})}},Zr=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,en=/^\/[a-zA-Z0-9/]*$/;function tn(e,t,r){return void 0!==r&&""!==r&&(function(e){var t=e,r=t.indexOf("//");if(-1!==r){var n=(t=t.substring(r+2)).indexOf("/");if(-1===n)return"/";t=t.substring(n)}var a=t.indexOf("?");return-1!==a&&(t=t.substring(0,a)),t}(e)===r&&"get"===t.toLowerCase())}function rn(e){var t=function(e,t){var r=e.indexOf("?");if(-1!==r)for(var n=e.substring(r+1).split("&"),a=0;a<n.length;a++){var i=n[a].split("=");if(i[0]===t)return void 0!==i[1]?decodeURIComponent(i[1]):void 0}}(e,"trackingId");return void 0!==t&&Zr.test(t)?t:null}function nn(e){if(void 0===e)return"text/html";var t=e.toLowerCase(),r=t.includes("text/html")||t.includes("application/html"),n=t.includes("application/json");return!r&&n?"application/json":"text/html"}function an(e,t,r){if(void 0===e||""===e)return"";var n;try{n=JSON.parse(e)}catch(e){return""}if(!function(e){if(null==e)return!1;var t=e;return void 0!==t.captchaSiteKey&&void 0!==t.trackingId&&void 0!==t.captchaURL}(n))return"";var a=r+"?trackingId="+n.trackingId,i="https://"+t+a;return JSON.stringify({captchaRelativeURL:a,captchaAbsoluteURL:i})}var on=re.cookie.attributes.configureCookiesDomain,cn=re.cookie.netaceaSession,sn=cn.createNetaceaSetCookieString,un=cn.createNetaceaCaptchaSetCookieString,ln=function(){return g((function e(t){var r,n,a=t.apiKey,i=t.secretKey,o=t.timeout,c=void 0===o?3e3:o,s=t.mitigationServiceUrl,u=void 0===s?"https://mitigations.netacea.net":s,l=t.ingestServiceUrl,h=void 0===l?"https://ingest.netacea.net":l,d=t.mitigationType,f=void 0===d?K.INGEST:d,p=t.captchaSiteKey,y=t.captchaSecretKey,g=t.ingestType,m=void 0===g?M.HTTP:g,b=t.kinesis,S=t.mitataCookieExpirySeconds,I=t.netaceaCookieExpirySeconds,O=t.netaceaCookieName,A=t.netaceaCaptchaCookieName,w=t.netaceaCookieAttributes,N=t.netaceaCaptchaCookieAttributes;if(v(this,e),C(this,"mitataCookieExpirySeconds",void 0),C(this,"apiKey",void 0),C(this,"secretKey",void 0),C(this,"mitigationServiceUrl",void 0),C(this,"ingestServiceUrl",void 0),C(this,"timeout",void 0),C(this,"captchaSiteKey",void 0),C(this,"captchaSecretKey",void 0),C(this,"ingestType",void 0),C(this,"kinesis",void 0),C(this,"mitigationType",void 0),C(this,"encryptedCookies",[]),C(this,"netaceaCookieName",void 0),C(this,"netaceaCaptchaCookieName",void 0),C(this,"netaceaCookieAttributes",void 0),C(this,"netaceaCaptchaCookieAttributes",void 0),C(this,"cookieFactory",void 0),null==a)throw new Error("apiKey is a required parameter");this.apiKey=a,this.secretKey=i,this.mitigationServiceUrl=u,this.ingestServiceUrl=h,this.mitigationType=f,this.ingestType=null!=m?m:M.HTTP,this.ingestType===M.KINESIS&&(void 0===b?console.warn("NETACEA WARN: no kinesis args provided, when ingestType is ".concat(this.ingestType)):this.kinesis=new Qr(k(k({},b),{},{apiKey:this.apiKey}))),void 0===p&&void 0===y||(this.captchaSiteKey=p,this.captchaSecretKey=y),this.timeout=function(e){return e<=0?L:e}(c),this.netaceaCookieName=fn(O,"_mitata"),this.netaceaCaptchaCookieName=fn(A,"_mitatacaptcha"),this.encryptedCookies=[this.netaceaCookieName,this.netaceaCaptchaCookieName],this.mitataCookieExpirySeconds=function(e,t){return void 0===t?e===K.INGEST?3600:60:t}(f,null!=I?I:S);var E=on(null!=w?w:"",null!=N?N:"");this.netaceaCookieAttributes=null!==(r=E.cookieAttributes)&&void 0!==r?r:"",this.netaceaCaptchaCookieAttributes=null!==(n=E.captchaCookieAttributes)&&void 0!==n?n:""}),[{key:"runMitigation",value:(b=p(l().m((function e(t){var r,n,a,i,o;return l().w((function(e){for(;;)switch(e.n){case 0:e.p=0,i=this.mitigationType,e.n=i===K.MITIGATE?1:i===K.INJECT?3:i===K.INGEST?5:7;break;case 1:return e.n=2,this.mitigate(t);case 2:case 4:case 6:return e.a(2,e.v);case 3:return e.n=4,this.inject(t);case 5:return e.n=6,this.processIngest(t);case 7:throw new Error("Netacea Error: Mitigation type ".concat(this.mitigationType," not recognised"));case 8:e.n=10;break;case 9:return e.p=9,o=e.v,console.error("Netacea FAILOPEN Error:",o),r=t,n=this.isUrlCaptchaPost(r.url,r.method),a=this.mitigationType===K.MITIGATE,e.a(2,{injectHeaders:{"x-netacea-captcha":"0","x-netacea-match":"0","x-netacea-mitigate":"0"},sessionStatus:a&&n?"error_open":""});case 10:return e.a(2)}}),e,this,[[0,9]])}))),function(e){return b.apply(this,arguments)})},{key:"readCookie",value:(m=p(l().m((function e(t,r){var n,a,i,o,c,s,u;return l().w((function(e){for(;;)switch(e.n){case 0:if(null!=r){e.n=1;break}return e.a(2,void 0);case 1:if("string"!=typeof r){e.n=3;break}return e.n=2,this.readCookie(t,r.split(";"));case 2:return e.a(2,e.v);case 3:n="".concat(t,"="),a=S(r),e.p=4,a.s();case 5:if((i=a.n()).done){e.n=11;break}if(o=i.value,!(c=o.split(";")[0].trimStart()).startsWith(n)){e.n=10;break}if(s=c.slice(n.length),!this.encryptedCookies.includes(t)){e.n=9;break}return e.p=6,e.n=7,this.decryptCookieValue(s);case 7:return e.a(2,e.v);case 8:return e.p=8,e.v,e.a(2,void 0);case 9:return e.a(2,s);case 10:e.n=5;break;case 11:e.n=13;break;case 12:e.p=12,u=e.v,a.e(u);case 13:return e.p=13,a.f(),e.f(13);case 14:return e.a(2,void 0)}}),e,this,[[6,8],[4,12,13,14]])}))),function(e,t){return m.apply(this,arguments)})},{key:"callIngest",value:(y=p(l().m((function e(t){var r,n,a,i;return l().w((function(e){for(;;)switch(e.n){case 0:if(r=this.constructWebLog(t),this.ingestType!==M.KINESIS){e.n=5;break}if(void 0!==this.kinesis){e.n=1;break}return console.error("Netacea Error: Unable to log as Kinesis has not been defined."),e.a(2);case 1:return e.p=1,e.n=2,this.kinesis.ingest(k(k({},r),{},{apiKey:this.apiKey}),this.makeRequest.bind(this));case 2:e.n=4;break;case 3:e.p=3,i=e.v,console.error("NETACEA Error: ",i.message);case 4:e.n=7;break;case 5:return n={"X-Netacea-API-Key":this.apiKey,"content-type":"application/json"},e.n=6,this.makeIngestApiCall(n,r);case 6:if(200===(a=e.v).status){e.n=7;break}throw this.APIError(a);case 7:return e.a(2)}}),e,this,[[1,3]])}))),function(e){return y.apply(this,arguments)})},{key:"makeIngestApiCall",value:(f=p(l().m((function e(t,r){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.makeRequest({host:this.ingestServiceUrl,method:"POST",path:"/",headers:t,body:JSON.stringify(r),timeout:this.timeout});case 1:return e.a(2,e.v)}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"constructV1WebLog",value:function(e){var t=e.ip,r=e.userAgent,n=e.status,a=e.method,i=e.path,o=e.protocol,c=e.referer,s=e.bytesSent,u=e.requestTime,l=e.mitataCookie,h=e.sessionStatus,d=e.integrationType,f=e.integrationVersion,p=e.headerFingerprint,v=e.requestHost,y=(new Date).toUTCString();return{Request:"".concat(a," ").concat(i," ").concat(o),TimeLocal:y,RealIp:t,UserAgent:r,Status:n,RequestTime:null==u?void 0:u.toString(),BytesSent:null==s?void 0:s.toString(),Referer:""===c?"-":c,NetaceaUserIdCookie:null!=l?l:"",NetaceaMitigationApplied:null!=h?h:"",IntegrationType:null!=d?d:"",IntegrationVersion:null!=f?f:"",HeaderHash:null!=p?p:"",RequestHost:v}}},{key:"constructWebLog",value:function(e){return e.bytesSent=""===e.bytesSent?"0":e.bytesSent,this.constructV1WebLog(e)}},{key:"check",value:(d=p(l().m((function e(t,r,n,a,i,o,c){var s,u,h,d,f,p,v,y,g,m,C,b,S,I,O;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0===this.cookieFactory){e.n=2;break}return e.n=1,this.cookieFactory.retrieveCookieInfo(t,r);case 1:I=e.v,e.n=3;break;case 2:I=Q(t,r,null!==(s=this.secretKey)&&void 0!==s?s:"");case 3:if((m=I).isPrimaryHashValid&&!m.requiresReissue){e.n=6;break}return C=void 0!==m.mitata?m.mitata.userId:void 0,b=dn(m),e.n=4,this.makeMitigateAPICall(C,r,n,a,i,o,b);case 4:return S=e.v,u=S.status,h=S.match,d=S.mitigate,f=S.captcha,p=S.body,e.n=5,this.createMitata(r,C,h,d,f,S.mitataMaxAge,void 0,b);case 5:O=e.v,v=[O],y=S.eventId,"5"===d&&void 0!==c&&(g=this.computeMonetisationRedirect(c,S.redirectHost,S.redirectLocation,S.redirectStatus)),e.n=7;break;case 6:u=-1,h=m.match,d=m.mitigate,f=m.captcha,p=void 0,v=[];case 7:return e.a(2,k(k({},this.composeResult(p,v,u,h,d,f,!1,y)),{},{redirect:g}))}}),e,this)}))),function(e,t,r,n,a,i,o){return d.apply(this,arguments)})},{key:"computeMonetisationRedirect",value:function(e,t,r,n){var a=void 0!==n?parseInt(n,10):NaN,i=!isNaN(a)&&a>=300&&a<400?a:303;if(void 0!==r)return{location:r,statusCode:i};if(void 0!==t){var o=e.replace(/^https?:\/\/[^/]+/,"");return{location:"https://".concat(t).concat(""!==o?o:"/"),statusCode:i}}}},{key:"createMitata",value:(h=p(l().m((function e(t,r,n,a,i){var o,c,s,u,h,d,f,p,v,y,g=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:if(o=g.length>5&&void 0!==g[5]?g[5]:86400,c=g.length>6&&void 0!==g[6]?g[6]:void 0,s=g.length>7&&void 0!==g[7]?g[7]:x.NO_SESSION,u=["1","3","5"].includes(i),h="3"===a,d="5"===a,f=u||h||d?-60:this.mitataCookieExpirySeconds,void 0===this.cookieFactory){e.n=2;break}return e.n=1,this.cookieFactory.createCookieValue({clientIP:t,userId:r,match:n,mitigate:a,captcha:i,gracePeriod:f,cookieId:J(),issueReason:s});case 1:p=e.v,e.n=4;break;case 2:if(void 0!==this.secretKey){e.n=3;break}throw new Error("Cannot build cookie without secret key.");case 3:v=null!=c?c:Math.floor(Date.now()/1e3)+f,y=[n,a,i].join(""),p=W(t,r,v,this.secretKey,y);case 4:return e.a(2,sn({cookieName:this.netaceaCookieName,cookieValue:p,maxAgeAttribute:String(o),otherAttributes:this.netaceaCookieAttributes}))}}),e,this)}))),function(e,t,r,n,a){return h.apply(this,arguments)})},{key:"processCaptcha",value:(u=p(l().m((function e(t,r,n,a,i){var o,c,s,u,h,d,f,p,v,y,g,m,k;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0===this.cookieFactory){e.n=2;break}return e.n=1,this.cookieFactory.retrieveCookieInfo(t,r);case 1:k=e.v,e.n=3;break;case 2:k=Q(t,r,null!==(o=this.secretKey)&&void 0!==o?o:"");case 3:return u=dn(s=k),h=null===(c=s.mitata)||void 0===c?void 0:c.userId,e.n=4,this.makeCaptchaAPICall(h,r,n,a,i,u);case 4:return d=e.v,f=d.status,p=d.match,v=d.mitigate,y=d.captcha,g=d.body,m=d.setCookie,e.a(2,this.composeResult(g,m,f,p,v,y,!0))}}),e,this)}))),function(e,t,r,n,a){return u.apply(this,arguments)})},{key:"getMitataCaptchaFromHeaders",value:(s=p(l().m((function e(t){var r,n,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(!Object.prototype.hasOwnProperty.call(t,U.netaceaHeaders.mitataCaptcha)){e.n=3;break}if(r=t[U.netaceaHeaders.mitataCaptcha],Array.isArray(r)&&(r=r[0]),null!=r&&""!==r){e.n=1;break}return e.a(2,void 0);case 1:return n=parseInt(t[U.netaceaHeaders.mitataCaptchaExpiry]),e.n=2,this.encryptCookieValue(r);case 2:return a=e.v,e.a(2,un({cookieName:this.netaceaCaptchaCookieName,cookieValue:a,maxAgeAttribute:String(isNaN(n)?86400:n),otherAttributes:this.netaceaCaptchaCookieAttributes}));case 3:return e.a(2,void 0)}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"makeCaptchaAPICall",value:(c=p(l().m((function e(t,r,n,a,i){var o,c,s,u,h=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:return o=h.length>5&&void 0!==h[5]?h[5]:x.NO_SESSION,c={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":n,"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},void 0!==t&&(c["X-Netacea-UserId"]=t),void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(c["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,c["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),s={},"string"==typeof i&&""!==i&&(s.headerFP=i),e.n=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/AtaVerifyCaptcha",headers:c,method:"POST",body:a,timeout:this.timeout,params:s});case 1:return u=e.v,e.n=2,this.getApiCallResponseFromResponse(u,t,r,o);case 2:return e.a(2,e.v)}}),e,this)}))),function(e,t,r,n,a){return c.apply(this,arguments)})},{key:"getApiCallResponseFromResponse",value:(o=p(l().m((function e(t,r,n){var a,i,o,c,s,u,h,d,f,p,v,y,g,m,k,C,b,S,I,O,A,w,N=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:if(p=N.length>3&&void 0!==N[3]?N[3]:x.NO_SESSION,200===t.status){e.n=1;break}throw this.APIError(t);case 1:return v=null!==(a=null===(i=t.headers[U.netaceaHeaders.match])||void 0===i?void 0:i.toString())&&void 0!==a?a:"0",y=null!==(o=null===(c=t.headers[U.netaceaHeaders.mitigate])||void 0===c?void 0:c.toString())&&void 0!==o?o:"0",g=null!==(s=null===(u=t.headers[U.netaceaHeaders.captcha])||void 0===u?void 0:u.toString())&&void 0!==s?s:"0",m=parseInt(t.headers[U.netaceaHeaders.mitataExpiry]),isNaN(m)&&(m=86400),e.n=2,this.createMitata(n,r,v,y,g,86400,void 0,p);case 2:return k=e.v,e.n=3,this.getMitataCaptchaFromHeaders(t.headers);case 3:return C=e.v,b=[k,C].filter((function(e){return void 0!==e})),S=t.body,I=t.headers[U.netaceaHeaders.eventId],O=null===(h=t.headers["x-netacea-redirect-host"])||void 0===h?void 0:h.toString(),A=null===(d=t.headers["x-netacea-redirect-location"])||void 0===d?void 0:d.toString(),w=null===(f=t.headers["x-netacea-redirect-status"])||void 0===f?void 0:f.toString(),e.a(2,{status:t.status,match:v,mitigate:y,captcha:g,setCookie:b,body:S,eventId:I,mitataMaxAge:m,redirectHost:O,redirectLocation:A,redirectStatus:w})}}),e,this)}))),function(e,t,r){return o.apply(this,arguments)})},{key:"buildCookieHeader",value:function(e){var t="",r="";for(var n in e){var a=e[n];void 0!==a&&(t="".concat(t).concat(r).concat(n,"=").concat(a),r="; ")}return t}},{key:"makeMitigateAPICall",value:(i=p(l().m((function e(t,r,n,a,i,o){var c,s,u,h,d=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:return c=d.length>6&&void 0!==d[6]?d[6]:x.NO_SESSION,s={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":n,cookie:this.buildCookieHeader({_mitatacaptcha:a})},void 0!==t&&(s["X-Netacea-UserId"]=t),void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(s["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,s["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),void 0!==o&&(s["X-Netacea-Captcha-Content-Type"]=o),u={},"string"==typeof i&&""!==i&&(u.headerFP=i),e.n=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/",headers:s,method:"GET",timeout:this.timeout,params:u});case 1:return h=e.v,e.n=2,this.getApiCallResponseFromResponse(h,t,r,c);case 2:return e.a(2,e.v)}}),e,this)}))),function(e,t,r,n,a,o){return i.apply(this,arguments)})},{key:"composeResult",value:function(e,t,r,n,a,i,o,c){var s=this.findBestMitigation(n,a,i,o),u={body:e,apiCallStatus:r,setCookie:t,sessionStatus:s.sessionStatus,mitigation:s.mitigation,mitigated:[U.mitigationTypes.block,U.mitigationTypes.captcha,U.mitigationTypes.captchaPass].includes(s.mitigation)};if(this.mitigationType===K.INJECT){var l={"x-netacea-match":s.parts.match.toString(),"x-netacea-mitigate":s.parts.mitigate.toString(),"x-netacea-captcha":s.parts.captcha.toString()};void 0!==c&&(l["x-netacea-event-id"]=c),u.injectHeaders=l}return u}},{key:"findBestMitigation",value:function(e,t,r,n){var a,i,o=function(e){return"[".concat(e,"]")};n||("2"===r?r="4":"3"===r&&(r="5"));var c=null!==(a=U.matchMap[e])&&void 0!==a?a:o(e)+"_";c+=null!==(i=U.mitigateMap[t])&&void 0!==i?i:o(t);var s=U.bestMitigationMap[t];if("0"!==r){var u;c+=","+(null!==(u=U.captchaMap[r])&&void 0!==u?u:o(r));var l=U.bestMitigationCaptchaMap[r];void 0!==l&&(s=l)}return this.mitigationType===K.INJECT&&(s=U.mitigationTypes.none),{sessionStatus:c,mitigation:s,parts:{match:e,mitigate:t,captcha:r}}}},{key:"APIError",value:function(e){var t="Unknown error";switch(e.status){case 403:t="Invalid credentials";break;case 500:t="Server error";break;case 502:t="Bad Gateway";break;case 503:t="Service Unavailable";break;case 400:t="Invalid request"}return new Error("Error reaching Netacea API (".concat(t,"), status: ").concat(e.status))}},{key:"isUrlCaptchaPost",value:function(e,t){if("post"!==t.toLowerCase())return!1;if(e.includes("/AtaVerifyCaptcha"))return!0;var r=this.netaceaCaptchaPath;return!(void 0===r||!e.includes(r))}},{key:"processMitigateRequest",value:(a=p(l().m((function e(t,r,n){var a,i,o,c,s,u,h;return l().w((function(e){for(;;)switch(e.n){case 0:if(!this.isUrlCaptchaPost(t.url,t.method)){e.n=2;break}return i=this,o=t.mitata,c=t.clientIp,s=t.userAgent,e.n=1,t.getBodyFn();case 1:u=e.v,h=r,a=i.processCaptcha.call(i,o,c,s,u,h),e.n=3;break;case 2:a=this.check(t.mitata,t.clientIp,t.userAgent,t.mitataCaptcha,r,n,t.url);case 3:return e.n=4,a;case 4:return e.a(2,e.v)}}),e,this)}))),function(e,t,r){return a.apply(this,arguments)})},{key:"setIngestOnlyMitataCookie",value:(n=p(l().m((function e(t){var r,n,a=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:return r=a.length>1&&void 0!==a[1]?a[1]:x.NO_SESSION,e.n=1,this.createMitata(z,t,"0","0","0",86400,void 0,r);case 1:return n=e.v,e.a(2,{sessionStatus:"",setCookie:[n]})}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"processIngest",value:(r=p(l().m((function e(t){var r,n,a,i,o,c;return l().w((function(e){for(;;)switch(e.n){case 0:return n=this.getCookieHeader(t),e.n=1,this.readCookie(this.netaceaCookieName,n);case 1:if(a=e.v,void 0===this.cookieFactory){e.n=3;break}return e.n=2,this.cookieFactory.retrieveCookieInfo(a,z);case 2:c=e.v,e.n=4;break;case 3:c=Q(a,z,null!==(r=this.secretKey)&&void 0!==r?r:"");case 4:if((i=c).isPrimaryHashValid){e.n=6;break}return e.n=5,this.setIngestOnlyMitataCookie(void 0,dn(i));case 5:return e.a(2,e.v);case 6:if(!i.requiresReissue){e.n=8;break}return o=void 0!==i.mitata?i.mitata.userId:void 0,e.n=7,this.setIngestOnlyMitataCookie(o,dn(i));case 7:return e.a(2,e.v);case 8:return e.a(2,{sessionStatus:"",setCookie:[]})}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"encryptCookieValue",value:(t=p(l().m((function e(t){return l().w((function(e){for(;;)if(0===e.n)return e.a(2,t)}),e)}))),function(e){return t.apply(this,arguments)})},{key:"decryptCookieValue",value:(e=p(l().m((function e(t){return l().w((function(e){for(;;)if(0===e.n)return e.a(2,t)}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,r,n,a,i,o,c,s,u,h,d,f,y,m,b}(),hn=function(){function e(t){var r,a,i,o,c,s;v(this,e),C(s=n(this,e,[t]),"httpsAgent",void 0),C(s,"mitataCookieName",void 0),C(s,"mitataCaptchaCookieName",void 0),C(s,"hashGenerator",void 0),C(s,"debugMode",void 0),C(s,"encryptionEnabled",!1),C(s,"encryptionKeyBuffer",void 0),C(s,"mitigationHeaders",["cookie","user-agent","accept","host"]),C(s,"netaceaCaptchaPath",void 0),C(s,"hostHeaderName",void 0),C(s,"enableCaptchaContentNegotiation",void 0),s.httpsAgent=new j.Agent({timeout:s.timeout,keepAlive:!0,maxSockets:null!==(r=t.maxSockets)&&void 0!==r?r:25}),s.mitataCookieName=null!==(a=t.netaceaCookieName)&&void 0!==a?a:"_mitata",s.mitataCaptchaCookieName=null!==(i=t.netaceaCaptchaCookieName)&&void 0!==i?i:"_mitatacaptcha";var u=function(){return g((function e(){v(this,e)}),[{key:"encode",value:function(e){return new Uint8Array(Buffer.from(e,"utf8"))}}])}();if(s.hashGenerator=new ne(Yr,u),s.debugMode=null!==(o=t.debugMode)&&void 0!==o&&o,s.netaceaCaptchaPath=function(e){if(null!=e&&""!==e)return"/"!==e[0]&&(e="/"+e),en.test(e)?e:void 0}(t.netaceaCaptchaPath),s.hostHeaderName=null===(c=t.hostHeaderName)||void 0===c||null===(c=c.toLowerCase())||void 0===c?void 0:c.trim(),void 0===s.hostHeaderName||s.mitigationHeaders.includes(s.hostHeaderName)||s.mitigationHeaders.push(s.hostHeaderName),s.enableCaptchaContentNegotiation=!0===t.enableCaptchaContentNegotiation,void 0!==t.cookieEncryptionKey){var l=function(e){if(null==e||""===e)return{valid:!1,error:"key is empty"};if(!/^[A-Za-z0-9_-]+$/.test(e))return{valid:!1,error:"key contains invalid base64url characters"};var t;try{t=ie(e)}catch(e){return{valid:!1,error:"key is not valid base64url"}}return 32!==t.length?{valid:!1,error:"key must be ".concat(32," bytes (256 bits), got ").concat(t.length," bytes")}:{valid:!0,keyBuffer:t}}(t.cookieEncryptionKey);l.valid&&void 0!==l.keyBuffer?(s.encryptionKeyBuffer=l.keyBuffer,s.encryptionEnabled=!0):console.warn("NETACEA WARN: Invalid cookieEncryptionKey - ".concat(l.error,". Cookies will not be encrypted."))}return s.cookieFactory=new jr({cookieEncryptionKey:t.cookieEncryptionKey,secretKey:t.secretKey,expirySeconds:s.mitataCookieExpirySeconds},s.encryptionEnabled&&void 0!==s.encryptionKeyBuffer?s.encryptionKeyBuffer:void 0),s}return c(e,ln),g(e,[{key:"computeHeaderFingerprint",value:(f=p(l().m((function e(t){var r;return l().w((function(e){for(;;)switch(e.n){case 0:if(void 0!==t&&""!==t){e.n=1;break}return e.a(2,"");case 1:return r=t.split(","),e.n=2,this.hashGenerator.hashHeaders(r);case 2:return e.a(2,e.v)}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"handleGetCaptchaRequest",value:(d=p(l().m((function e(t,r,n,a,i,o,c){var s,u,h,d,f,p;return l().w((function(e){for(;;)switch(e.n){case 0:return s=rn(o),u=this.enableCaptchaContentNegotiation?nn(i):"text/html",h={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":t,"user-agent":r,cookie:void 0!==n?"_mitatacaptcha="+n:"","X-Netacea-Captcha-Content-Type":u},void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(h["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,h["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),d={netaceaHeaders:"request-id"},"string"==typeof a&&""!==a&&(d.headerFP=a),null!==s&&(d.trackingId=s),e.n=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/captcha",headers:h,method:"GET",timeout:this.timeout,params:d});case 1:if(200===(f=e.v).status){e.n=2;break}throw this.APIError(f);case 2:return p=f.body,"application/json"===u&&void 0!==this.netaceaCaptchaPath&&void 0!==p&&(p=an(p,null!=c?c:"",this.netaceaCaptchaPath)),e.a(2,{body:p,apiCallStatus:f.status,setCookie:[],sessionStatus:",captcha_serve",mitigation:"captcha",mitigated:!0})}}),e,this)}))),function(e,t,r,n,a,i,o){return d.apply(this,arguments)})},{key:"encryptCookieValue",value:(h=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:if(this.encryptionEnabled&&void 0!==this.encryptionKeyBuffer){e.n=1;break}return e.a(2,t);case 1:return e.a(2,se(t,this.encryptionKeyBuffer))}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"decryptCookieValue",value:(u=p(l().m((function e(t){return l().w((function(e){for(;;)switch(e.n){case 0:if(this.encryptionEnabled&&void 0!==this.encryptionKeyBuffer){e.n=1;break}return e.a(2,t);case 1:if(ce(t)){e.n=2;break}throw new Error("Cookie is not JWE encrypted");case 2:return e.a(2,ue(t,this.encryptionKeyBuffer))}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"getInjectHeaders",value:function(e){if(this.mitigationType===K.INJECT){var t=e;if(void 0!==t.injectHeaders){var r={},n=t.injectHeaders;return r["x-netacea-match"]=n["x-netacea-match"],r["x-netacea-mitigate"]=n["x-netacea-mitigate"],r["x-netacea-captcha"]=n["x-netacea-captcha"],void 0!==n["x-netacea-event-id"]&&(r["x-netacea-event-id"]=n["x-netacea-event-id"]),this.encodeHeadersAsKeyValueList(r)}}return[]}},{key:"registerPolicyHandler",value:function(e){var t=this;e.addMethod("getMitigationHeaderPolicy",(function(e,r){var n=t.mitigationHeaders.join(",");console.info('level=info component=f5 handler=getMitigationHeaderPolicy policy="'.concat(n,'"')),r.reply(n)}))}},{key:"encodeHeadersAsKeyValueList",value:function(e){for(var t=[],r=0,n=Object.entries(e);r<n.length;r++){var a=I(n[r],2),i=a[0],o=a[1];if(Array.isArray(o)){var c,s=S(o);try{for(s.s();!(c=s.n()).done;){var u=c.value;t.push(i,Buffer.from(u).toString("base64"))}}catch(e){s.e(e)}finally{s.f()}}else t.push(i,Buffer.from(o).toString("base64"))}return t}},{key:"registerMitigateHandler",value:function(e){var t=this;e.addMethod("handleRequest",function(){var e=p(l().m((function e(r,n){var a,i,o,c,s,u,h,d,f,p,v,y,g,m,k,C,b,S,O,A,w,N,E,_,P,T,R,M,K,x,H,j,V;return l().w((function(e){for(;;)switch(e.n){case 0:return o=r.params(),c=I(o,3),s=c[0],u=c[1],h=c[2],d=t.getArrayValueOrDefault(o,3,void 0),f=t.getArrayValueOrDefault(o,4,void 0),p=t.getArrayValueOrDefault(o,5,void 0),v=t.parseHeaderValues(p),y=null!==(a=v.cookie)&&void 0!==a?a:null,g=null!==(i=v["user-agent"])&&void 0!==i?i:"",m=v.accept,e.p=1,e.n=2,t.computeHeaderFingerprint(f);case 2:return b=e.v,t.debugMode&&console.info('level=debug component=f5 handler=handleRequest event=header_fingerprint method="'.concat(u,'" ')+'path="'.concat(h,'" headers="').concat(null!=f?f:"",'" header_count=').concat(null!==(S=null==f?void 0:f.split(",").length)&&void 0!==S?S:0," ")+'fingerprint="'.concat(b,'"')),e.n=3,t.getMitataCookies(y);case 3:return O=e.v,A=I(O,2),w=A[0],N=A[1],t.debugMode&&console.info('level=debug component=f5 handler=handleRequest event=mitigation_request headerFP="'.concat(b,'"')),e.n=4,t.runMitigation({ip:s,method:u,url:h,mitataCaptchaCookie:N,mitataCookie:w,userAgent:g,body:d,headerFingerprint:b,acceptHeader:m,hostHeader:t.resolveHostHeader(v)});case 4:if(E=e.v,_="",(tn(h,u,t.netaceaCaptchaPath)||void 0!==t.netaceaCaptchaPath&&"captcha"===(null==E||null===(k=E.response)||void 0===k?void 0:k.mitigation))&&(_=t.enableCaptchaContentNegotiation&&"application/json"===nn(m)?"application/json":"text/html; charset=UTF-8"),"error_open"!==(null==E?void 0:E.sessionStatus)){e.n=5;break}return n.reply(["",500,"error_open",!0,"",b,[],[],500]),e.a(2);case 5:if(void 0!==E){e.n=6;break}return n.reply(["",0,"",!1,"",b,[],[],0]),e.a(2);case 6:P="",T=0,R=!1,M=0,K=t.getValueOrDefault(w,""),void 0!==E.setCookie&&E.setCookie.length>0&&void 0!==(x=E.setCookie.find((function(e){return e.includes("".concat(t.netaceaCookieName,"="))})))&&(K=x.split(";")[0].replace("".concat(t.netaceaCookieName,"="),"")),void 0!==E.response&&(T=t.getValueOrDefault(E.response.apiCallStatus,0),P=t.getValueOrDefault(E.response.body,"Forbidden"),R=t.getValueOrDefault(E.response.mitigated,R),M=t.getValueOrDefault(E.response.status,403)),H={},void 0!==E.setCookie&&E.setCookie.length>0&&(H["Set-Cookie"]=E.setCookie),""!==_&&(H["Content-Type"]=_),void 0!==(j=null===(C=E.response)||void 0===C?void 0:C.redirect)&&(H.Location=j.location),n.reply([P,T,t.getValueOrDefault(E.sessionStatus,""),R,t.getValueOrDefault(K,""),b,t.getInjectHeaders(E),t.encodeHeadersAsKeyValueList(H),M]),e.n=8;break;case 7:e.p=7,V=e.v,console.error("Could not reach Netacea mitigation API: ",V.message),n.reply(["",0,"",!1,"","",[],[],0]);case 8:return e.a(2)}}),e,null,[[1,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"resolveHostHeader",value:function(e){var t=void 0!==this.hostHeaderName?e[this.hostHeaderName]:void 0;return void 0!==t&&""!==t?t:e.host}},{key:"parseHeaderValues",value:function(e){var t={};if(void 0===e||""===e)return t;for(var r=e.split(","),n=0;n<this.mitigationHeaders.length&&n<r.length;n++)t[this.mitigationHeaders[n].toLowerCase()]=Buffer.from(r[n],"base64").toString("utf8");return t}},{key:"getValueOrDefault",value:function(e,t){return null!=e?e:t}},{key:"getArrayValueOrDefault",value:function(e,t,r){var n;return null!==(n=e[t])&&void 0!==n?n:r}},{key:"getMitataCookies",value:(s=p(l().m((function e(t){var r,n,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(r=null==t?void 0:t.split("; "),n=this.getCookie(this.mitataCookieName,r),a=this.getCookie(this.mitataCaptchaCookieName,r),void 0===n){e.n=4;break}return e.p=1,e.n=2,this.decryptCookieValue(n);case 2:n=e.v,e.n=4;break;case 3:e.p=3,e.v,n=void 0;case 4:if(void 0===a){e.n=8;break}return e.p=5,e.n=6,this.decryptCookieValue(a);case 6:a=e.v,e.n=8;break;case 7:e.p=7,e.v,a=void 0;case 8:return e.a(2,[n,a])}}),e,this,[[5,7],[1,3]])}))),function(e){return s.apply(this,arguments)})},{key:"getCookie",value:function(e,t){var r;return null==t||null===(r=t.find((function(t){return t.includes("".concat(e,"="))})))||void 0===r?void 0:r.replace("".concat(e,"="),"")}},{key:"registerIngestHandler",value:function(e){var t=this;e.addMethod("ingest",function(){var e=p(l().m((function e(r,n){var a,i,o,c,s,u,h,d,f,p,v,y,g,m,k,C,b,S;return l().w((function(e){for(;;)switch(e.n){case 0:if(c=r.params(),s=t.getArrayValueOrDefault(c,0,""),u=t.getArrayValueOrDefault(c,1,""),h=t.getArrayValueOrDefault(c,2,"-1"),d=t.getArrayValueOrDefault(c,3,""),f=t.getArrayValueOrDefault(c,4,""),p=t.getArrayValueOrDefault(c,5,""),v=t.getArrayValueOrDefault(c,6,""),y=t.getArrayValueOrDefault(c,7,"0"),g=t.getArrayValueOrDefault(c,8,"0"),o=t.getArrayValueOrDefault(c,9,""),m=t.getArrayValueOrDefault(c,10,""),k=t.getArrayValueOrDefault(c,11,""),C=t.getArrayValueOrDefault(c,12,void 0),b=t.parseHeaderValues(C),S=t.resolveHostHeader(b),t.debugMode&&console.info('level=debug component=f5 handler=ingest event=ingest_request ingestType="'.concat(t.ingestType,'" ')+'headerFingerprint="'.concat(k,'"')),void 0===o){e.n=4;break}return e.p=1,e.n=2,t.decryptCookieValue(o);case 2:o=e.v,e.n=4;break;case 3:e.p=3,e.v,o=void 0;case 4:t.ingest({ip:s,userAgent:null!==(a=b["user-agent"])&&void 0!==a?a:u,status:h,method:d,path:f,protocol:p,referer:null!==(i=b.referer)&&void 0!==i?i:v,bytesSent:y,requestTime:g,mitataCookie:o,sessionStatus:m,headerFingerprint:k,requestHost:S}).catch((function(e){console.error("Could not reach Netacea ingest API: "+e.message)})),n.reply("done");case 5:return e.a(2)}}),e,null,[[1,3]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"makeRequest",value:(o=p(l().m((function e(t){var r=this;return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,new Promise((function(e,n){t.host=t.host.replace("https://","");var a=t.path;if(void 0!==t.params){var i=t.params instanceof URLSearchParams?t.params.toString():V.stringify(t.params);""!==i&&(a+=(a.includes("?")?"&":"?")+i)}for(var o=j.request({agent:r.httpsAgent,host:t.host,path:a,headers:t.headers,method:t.method,body:t.body},(function(t){var r="";t.on("data",(function(e){r+=e})),t.on("end",(function(){var n;e({headers:t.headers,status:null!==(n=t.statusCode)&&void 0!==n?n:0,body:""===r?void 0:r})}))})),c=0,s=["error","abort","timeout"];c<s.length;c++){var u=s[c];o.on(u,(function(e){n(e),o.destroyed||o.destroy()}))}"post"===t.method.toLowerCase()&&o.write(t.body),o.end()}));case 1:return e.a(2,e.v)}}),e)}))),function(e){return o.apply(this,arguments)})},{key:"mitigate",value:(i=p(l().m((function e(t){var r,n,a,i,o,c;return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.getMitigationResponse(t);case 1:return r=e.v,n={sessionStatus:r.sessionStatus,setCookie:r.setCookie},r.mitigated&&(n.response={body:null!==(a=r.body)&&void 0!==a?a:"Forbidden",status:null!==(i=null===(o=r.redirect)||void 0===o?void 0:o.statusCode)&&void 0!==i?i:r.sessionStatus.includes("monetised")?402:403,apiCallStatus:null!==(c=r.apiCallStatus)&&void 0!==c?c:-1,mitigation:r.mitigation,mitigated:r.mitigated,redirect:r.redirect}),e.a(2,n)}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"inject",value:(a=p(l().m((function e(t){var r;return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.getMitigationResponse(t);case 1:return r=e.v,e.a(2,{injectHeaders:r.injectHeaders,sessionStatus:r.sessionStatus,setCookie:r.setCookie})}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getMitigationResponse",value:(r=p(l().m((function e(t){var r,n,a,i,o,c,s,u,h,d,f,v;return l().w((function(e){for(;;)switch(e.n){case 0:if(r=t.ip,n=t.userAgent,a=t.url,i=t.method,o=t.mitataCookie,c=t.mitataCaptchaCookie,s=t.body,u=t.headerFingerprint,h=t.acceptHeader,d=t.hostHeader,!tn(a,i,this.netaceaCaptchaPath)){e.n=2;break}return e.n=1,this.handleGetCaptchaRequest(r,n,c,null!=u?u:"",h,a,d);case 1:return e.a(2,e.v);case 2:return f=this.enableCaptchaContentNegotiation&&void 0!==this.netaceaCaptchaPath?nn(h):void 0,e.n=3,this.processMitigateRequest({clientIp:r,getBodyFn:function(){var e=p(l().m((function e(){return l().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,Promise.resolve(s);case 1:return e.a(2,e.v)}}),e)})));return function(){return e.apply(this,arguments)}}(),method:i,mitata:o,mitataCaptcha:c,url:a,userAgent:n},u,f);case 3:return v=e.v,"application/json"===f&&void 0!==this.netaceaCaptchaPath&&void 0!==v.body&&"captcha"===v.mitigation&&(v.body=an(v.body,null!=d?d:"",this.netaceaCaptchaPath)),e.a(2,v)}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"ingest",value:(t=p(l().m((function e(t){var r,n,a,i,o,c,s,u,h,d,f,p,v;return l().w((function(e){for(;;)switch(e.n){case 0:return r=t.ip,n=t.userAgent,a=t.status,i=t.method,o=t.path,c=t.protocol,s=t.referer,u=t.bytesSent,h=t.requestTime,d=t.mitataCookie,f=t.sessionStatus,p=t.headerFingerprint,v=t.requestHost,e.n=1,this.callIngest({ip:r,userAgent:n,status:a,method:i,bytesSent:u,path:o,protocol:c,referer:s,requestTime:h,mitataCookie:d,sessionStatus:f,headerFingerprint:p,requestHost:v,integrationType:"@netacea/f5".replace("@netacea/",""),integrationVersion:"5.8.16"});case 1:return e.a(2)}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"getCookieHeader",value:function(e){if(void 0!==e.mitataCookie)return"".concat(this.mitataCookieName,"=").concat(e.mitataCookie)}}]);var t,r,a,i,o,s,u,h,d,f}();function dn(e){return e.isPrimaryHashValid?e.isSameIP?e.isExpired?x.EXPIRED_SESSION:x.NO_SESSION:x.IP_CHANGE:x.NO_SESSION}function fn(e,t){return"string"==typeof e&&""!==e?e:"number"==typeof e?e.toString():t}module.exports=hn;
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netacea/f5",
3
- "version": "5.8.14",
3
+ "version": "5.8.16",
4
4
  "description": "Netacea F5 CDN integration",
5
5
  "files": [
6
6
  "dist/index.js",
@@ -21,5 +21,5 @@
21
21
  "aws4": "^1.13.2",
22
22
  "f5-nodejs": "^1.0.0"
23
23
  },
24
- "gitHead": "83a07929ae5c7209c37b384ce09e8cf071ee123c"
24
+ "gitHead": "963889ec57a4d1083ff030b50238ba1ba125f686"
25
25
  }