@keploy/capture-sdk 3.1.0-rc.1 → 3.1.0-rc.2

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.
Files changed (52) hide show
  1. package/README.md +398 -58
  2. package/body-redact/package.json +6 -0
  3. package/body-worker-start/package.json +6 -0
  4. package/dist/body-jobs.d.ts +134 -0
  5. package/dist/body-redact.d.ts +23 -0
  6. package/dist/body-redact.js +1 -0
  7. package/dist/body-redact.js.map +1 -0
  8. package/dist/body-redact.mjs +1 -0
  9. package/dist/body-redact.mjs.map +1 -0
  10. package/dist/body-worker-none.d.ts +3 -0
  11. package/dist/body-worker-none.js +1 -0
  12. package/dist/body-worker-none.js.map +1 -0
  13. package/dist/body-worker-none.mjs +1 -0
  14. package/dist/body-worker-none.mjs.map +1 -0
  15. package/dist/body-worker-start.d.ts +3 -0
  16. package/dist/body-worker-start.js +1 -0
  17. package/dist/body-worker-start.js.map +1 -0
  18. package/dist/body-worker-start.mjs +1 -0
  19. package/dist/body-worker-start.mjs.map +1 -0
  20. package/dist/body-worker-unbundled.d.ts +1 -0
  21. package/dist/body-worker-unbundled.mjs +1 -0
  22. package/dist/body-worker-unbundled.mjs.map +1 -0
  23. package/dist/body-worker.d.ts +1 -0
  24. package/dist/body-worker.js +1 -0
  25. package/dist/body-worker.js.map +1 -0
  26. package/dist/errors.d.ts +38 -6
  27. package/dist/index.bundler.mjs +1 -0
  28. package/dist/index.bundler.mjs.map +1 -0
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +1 -11
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +1 -11
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/leave.d.ts +67 -0
  35. package/dist/module-of.d.ts +45 -0
  36. package/dist/network.d.ts +52 -37
  37. package/dist/privacy.d.ts +23 -2
  38. package/dist/recorder.d.ts +30 -6
  39. package/dist/request-term.d.ts +2 -0
  40. package/dist/request-term.js +1 -2
  41. package/dist/request-term.js.map +1 -1
  42. package/dist/request-term.mjs +1 -2
  43. package/dist/request-term.mjs.map +1 -1
  44. package/dist/strict-attributes.d.ts +9 -0
  45. package/dist/strict-attributes.js +1 -0
  46. package/dist/strict-attributes.js.map +1 -0
  47. package/dist/strict-attributes.mjs +1 -0
  48. package/dist/strict-attributes.mjs.map +1 -0
  49. package/dist/transport.d.ts +35 -3
  50. package/dist/types.d.ts +21 -5
  51. package/package.json +31 -4
  52. package/strict-attributes/package.json +6 -0
package/dist/index.js CHANGED
@@ -1,11 +1 @@
1
- "use strict";var js=Object.create;var Fe=Object.defineProperty;var qs=Object.getOwnPropertyDescriptor;var Hs=Object.getOwnPropertyNames;var Ks=Object.getPrototypeOf,Fs=Object.prototype.hasOwnProperty;var Vs=(e,t)=>{for(var n in t)Fe(e,n,{get:t[n],enumerable:!0})},vn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Hs(t))!Fs.call(e,s)&&s!==n&&Fe(e,s,{get:()=>t[s],enumerable:!(r=qs(t,s))||r.enumerable});return e};var En=(e,t,n)=>(n=e!=null?js(Ks(e)):{},vn(t||!e||!e.__esModule?Fe(n,"default",{value:e,enumerable:!0}):n,e)),Xs=e=>vn(Fe({},"__esModule",{value:!0}),e);var jc={};Vs(jc,{CaptureDeclined:()=>Ae,CaptureError:()=>q,CaptureIdentityBuilder:()=>De,DomRecorderRefusal:()=>J,IngestRejection:()=>ke,KeployCapture:()=>bn,KeployCaptureRecorder:()=>Ne,NetworkInterceptor:()=>xe,PrivacyConflict:()=>Ie,PrivacyEngine:()=>Re,PrivacyRouteRefusal:()=>Y,SDK_ERRORS:()=>pt,SDK_WARNINGS:()=>ps,SESSION_ID_MAX_LENGTH:()=>us,SESSION_ID_PATTERN:()=>rn,SESSION_ID_RULE:()=>qe,SessionIdRefusal:()=>Z,Transport:()=>Ce,codeForStatus:()=>ht,currentOrigin:()=>mn,defaultPrivacyConfig:()=>nn,describeValue:()=>j,isValidSessionId:()=>lt,mintSessionNonce:()=>yn,parseServerError:()=>gt});module.exports=Xs(jc);var Gs=/%[0-7][\da-f]|%(?:c[2-9a-f]|d[\da-f])%[89ab][\da-f]|%e0%[ab][\da-f]%[89ab][\da-f]|%e[1-9a-ce-f](?:%[89ab][\da-f]){2}|%ed%[89][\da-f]%[89ab][\da-f]|%f0%[9ab][\da-f](?:%[89ab][\da-f]){2}|%f[1-3](?:%[89ab][\da-f]){3}|%f4%8[\da-f](?:%[89ab][\da-f]){2}/gi;function T(e){return e.includes("%")?e.replace(Gs,t=>decodeURIComponent(t)):e}var Zs=new Set(["password","passwd","pwd","secret","token","accesstoken","refreshtoken","idtoken","authorization","auth","apikey","clientsecret","privatekey","session","sessionid","cookie","ssn","socialsecuritynumber","creditcard","cardnumber","cvv","cvc","pin","passphrase","pass1","pass2","currentpass","rpkey","codeverifier","rawkey","apikeyauth","setcookie","proxyauthorization","samlresponse","confirmkey","tokenhash","clerkticket","nonce","hmac","loginhash","magiclink","phpsessid","oauthverifier","sig","sid","sessid","csrf","xsrf","bearer","authentication","credentials","pass","tokenid","authkey","secretkey","accesskey","clientkey","signingkey","sessionkey","subscriptionkey","functionskey","factorcode","jwtassertion","samlassertion","clientassertion","secretaccesskey","accesskeysecret"]),Js=new Set(["invitecode","invitationcode","authcode","authorizationcode","verificationcode","verifycode","confirmationcode","confirmcode","resetcode","mfacode","smscode","otpcode","totpcode","twofactorcode","2facode","logincode","passcode","oobcode","linkcode"]),Ys=new Set(["cardexpiry","cardexpiration","cardexpirydate","cardexpirationdate","cardexp","cardexpdate","cardexpmonth","cardexpyear","ccexp","ccexpiry","ccexpiration","ccexpdate","ccexpmonth","ccexpyear","creditcardexpiry","creditcardexpiration","expmonth","expyear","expirymonth","expiryyear","expirationmonth","expirationyear"]),Qs=/(?:password(?:\d|confirm|confirmation|new|old|repeat|again|verify|retype)?|passwd|secret|token|apikey|privatekey|passphrase|signature|sessionid|jwt|otp|credential|curl)$/,ei=new Set(["pagetoken","nextpagetoken","prevpagetoken","previouspagetoken","pagingtoken","paginationtoken","nexttoken","prevtoken","previoustoken","continuationtoken","nextcontinuationtoken","cursortoken","synctoken","nextsynctoken","startingtoken","starttoken","skiptoken","deltatoken","resumptiontoken","scrolltoken","aftertoken","beforetoken"]),ti=new Set(["auth","session","cookie","pin","sig"]);function P(e,t){return T(e).split(t==="key"?/[[\]]+/:/[[\].]+/).map(n=>n.toLowerCase().replace(/[-_$+\s]/g,"")).filter(n=>n!=="")}function wn(e,t){return ei.has(e)||t==="page"&&ti.has(e)?!1:Zs.has(e)||Js.has(e)||Ys.has(e)||Qs.test(e)}function H(e,t){return Ze(P(e,t),t)}function Ze(e,t){return e.some(n=>wn(n,t))||e.length>1&&wn(e.join(""),t)}var kn=/(&|;(?=[^;&=#]+=|end$))/;function ni(e){let t=[],n=e.split(kn);for(let r=0;r<n.length;r+=2){let s=n[r].indexOf("=");s>0&&t.push(n[r].slice(0,s))}return t}function re(e){let t=e.replace(/\+/g," ");if(!/%/.test(t))return t;if(/%(?![0-9A-Fa-f]{2})/.test(t))return e;try{return decodeURIComponent(t)}catch{return e}}var ri=1,si=/^(?:[a-z][a-z0-9+.-]*:\/\/|\/)[^?#]*[?#]./i,An=/[&;?#][^&;=?#]+=/;function ii(e,t,n){return/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?Tn(e,t,n+1):e.startsWith("/")?Xe(e,t,n+1):An.test(e)?/[?#]/.test(e)?Xe(e,t,n+1):ge(e,t,n+1):null}function Xe(e,t,n){let r=e.indexOf("#"),s=r===-1?e:e.slice(0,r),i=s.indexOf("?"),a=i===-1?s:s.slice(0,i),o=i===-1?null:s.slice(i+1),c=r===-1?null:e.slice(r+1),l=Pe(a,t)+(o===null?"":`?${ge(o,t,n,a)}`)+(c===null?"":`#${xn(c,t,n,a)}`);return l===e?e:l}function In(e,t=!1){if(t){let i=e.search(/\s/);return i===-1?e.length:i}let n=0,r=0,s=0;for(let i=0;i<e.length;i++){let a=e[i];if(/[\s,;"'<>\\`]/.test(a))return i;if(a==="(")n++;else if(a==="[")r++;else if(a==="{")s++;else{if(a===")"&&n--===0)return i;if(a==="]"&&r--===0)return i;if(a==="}"&&s--===0)return i}}return e.length}function Ge(e,t){let n=e;for(let r=0;r<4;r++){let s=T(n);if(s===n)break;n=s}for(let r of n.matchAll(/(?:^|[?&;#])([^?&;#=/\s]+)=/g))if(H(r[1],t))return!0;return!1}function ge(e,t,n=0,r=""){let s=e.split(t.whole?/(&)/:kn),i=s.filter((o,c)=>c%2===0),a={path:r,pairs:i,depth:n};return i.map(o=>{let c=o.indexOf("=");if(c===-1)return t.bare?.(o)===!0?"[REDACTED]":o;let l=o.slice(0,c),d=o.slice(c+1);if(d==="")return o;let u=re(d),p=()=>`${l}=[REDACTED]`,h=t.before?.(l,d,a)??null;if(h!==null)return`${l}=${h}`;if(t.strict||(t.whole?ni(o):[l]).some(b=>H(b,t.kind))||t.value?.(l,d,u)===!0){if(t.spaced!==!0)return p();let b=In(d,t.form),v=d.slice(b);return`${l}=${b===0&&!t.form?"":"[REDACTED]"}${t.tail?.(v)??v}`}if(n>=ri&&(si.test(u)||An.test(u)))return t.kind==="page"||Ge(u,t.kind)?p():o;let m=ii(u,t,n);return m!==null&&m!==u?t.whole?p():t.raw!==!0?`${l}=${encodeURIComponent(m)}`:d===u?`${l}=${m}`:encodeURIComponent(u)===d?`${l}=${encodeURIComponent(m)}`:p():T(u)!==u&&Ge(u,t.kind)?p():o}).map((o,c)=>(c===0?"":s[2*c-1])+o).join("")}function Pe(e,t){let n=e.split("/"),r=n.map(s=>s.split(";")[0]);return n.map((s,i)=>{if(t.segment?.(s)===!0)return"[REDACTED]";let a=s.indexOf(";"),o=r[i],c=t.head?.(e,o,i,r)===!0?"[REDACTED]":o;return a===-1?c:c+s.slice(a).replace(/;([^;=]+)=([^;]*)/g,(l,d,u)=>{let p=t.spaced===!0?In(u,t.form):u.length;return p>0&&H(d,t.kind)?`;${d}=[REDACTED]${u.slice(p)}`:l})}).join("/")}function xn(e,t,n,r=""){let s=e.indexOf("?");if(s!==-1){let o=e.slice(0,s);return`${Pe(o,t)}?${ge(e.slice(s+1),t,n,`${r}/${o}`)}`}let i=e.indexOf("=");if(i!==-1&&!e.slice(0,i).includes("/"))return ge(e,t,n,r);let a=i===-1?null:/^([^&;]*)([&;])/.exec(e);return a!==null?`${Pe(a[1],t)}${a[2]}${ge(e.slice(a[0].length),t,n,`${r}/${a[1]}`)}`:Pe(e,t)}function Tn(e,t,n){if(t.whole||t.raw===!0||!oi.test(e))return Sn(e,t,n);let r;try{r=new URL(e)}catch{return Sn(e,t,n)}let s=r.search.slice(1),i=r.hash.slice(1),a=Pe(r.pathname,t),o=r.search?ge(s,t,n,r.pathname):"",c=r.hash?xn(i,t,n,r.pathname):"";return a===r.pathname&&o===s&&c===i&&r.username===""&&r.password===""?e:`${r.protocol}//${r.host}`+a+(r.search?`?${o}`:"")+(r.hash?`#${c}`:"")}var oi=/^(?:https?:|[a-z][a-z0-9+.-]*:[/\\]{2})/i;function Sn(e,t,n){let r=/^([a-z][a-z0-9+.-]*:)([/\\]*)([^/\\?#]*)/i.exec(e),[s,i,a,o]=r,c=a===""?-1:o.lastIndexOf("@"),l=i+a+o.slice(c+1)+Xe(e.slice(s.length),t,n);return l===e?e:l}function Q(e,t){let n=e.length-e.trimStart().length,r=e.length-e.trimEnd().length,s=e.slice(n,e.length-r),i;return/^(?:javascript|vbscript|data|blob):/i.test(s)?e:(/^[a-z][a-z0-9+.-]*:/i.test(s)?i=Tn(s,t,0):i=Xe(s,t,0),i===s?e:e.slice(0,n)+i+e.slice(e.length-r))}var Ve=/[a-z][a-z0-9+.-]{0,31}:[/\\]{2}|(?<attr>\bcontent\s*=\s*(?:["']\s*)?\d[\d.]*\s*[;,]\s*url\s*=\s*["']?|\b(?:href|src|action|formaction|poster|cite|data|background|longdesc|content|data-src|data-href|xlink:href)\s*=\s*["']?|(?<![\w:.-])[\w:.-]{1,40}\s*=\s*["'](?=\.{0,2}\/|[?#]|[a-z][a-z0-9+.-]{0,31}:\/|[a-z][a-z0-9-]{0,30}[+.][a-z0-9+.-]{0,30}:|localhost:\d{1,5}[/?#]|(?:mailto|tel|sms|urn|data|javascript|vbscript|blob|about|xmpp|sip|sips|magnet|intent|bitcoin|geo|market|news):)|\burl\(\s*["']?)(?=[^\s"'<>])/gi,ai=/[\s"'<>\\^`{|}]/,ci=".,;:!?",Rn=/[a-z][a-z0-9+.-]{0,31}:\/\//iy;function li(e,t,n){let r=0,s=0;for(let i=t;i<n;i++){let a=e[i];a==="("?r++:a===")"?r--:a==="["?s++:a==="]"&&s--}for(;n>t;){let i=e[n-1];if(i===")"){if(r>=0)break;r++}else if(i==="]"){if(s>=0)break;s++}else if(!ci.includes(i))break;n--}return n}function ui(e,t,n,r){let s=t,i=0,a=0;for(;s<e.length;s++){let o=e[s];if(ai.test(o)||r&&o===","&&(Rn.lastIndex=s+1,Rn.test(e)))break;if(n){if(o==="(")i++;else if(o==="[")a++;else if(o===")"||o==="]"){if((o===")"?i:a)===0)break;o===")"?i--:a--}}}return li(e,t,s)}var St=/url\(\s*["']?/iy;function di(e,t=!1){let n=[];Ve.lastIndex=0;for(let r=Ve.exec(e);r!==null;r=Ve.exec(e)){let s=r.index+(r.groups?.attr?.length??0);St.lastIndex=s;let i=r.groups?.attr!==void 0&&St.test(e);i&&(s=St.lastIndex);let a=r.groups?.attr??"",o=ui(e,s,!/["']$/.test(a)||/^url\(/i.test(a)||i,t);e[o]==="{"&&o>s&&e[o-1]==="$"&&o--,o>s&&n.push([s,o]),Ve.lastIndex=Math.max(o,r.index+r[0].length,s+1)}return n}function Cn(e,t){let n=[];for(let[r,s]of di(e,t.list===!0)){let i=e.slice(r,s),a=Q(i,t);a!==i&&n.push([r,s,a])}return n}function Rt(e){return{kind:"param",strict:e,whole:!0}}var Mn="[REDACTED]",fi=new Set(["expiry","expirydate","expiration","expirationdate","expdate","exp"]),pi=new Set(["cardnumber","creditcard","creditcardnumber","ccnumber","cardnum","pan","cvv","cvc"]),hi="[UNPARSEABLE_BODY_NOT_REDACTED]",gi=[/^\[Blob: \d+ bytes, truncated\]$/,/^\[Blob: \d+ bytes\]$/,/^\[Binary: \d+ bytes\]$/,/^\[Response body too large: \d+ bytes\]$/,/^\[ReadableStream\]$/,/^\[Unreadable body\]$/,/^\[(?:arraybuffer|blob|document|json|text|) response\]$/];function yi(e){return gi.some(t=>t.test(e))}function se(e){return P(e,"key").join("")}var mi=/^[A-Za-z]+(?:[-_][A-Za-z]+)*$/,bi=/^[A-Za-z][a-z]+(?:[A-Z][a-z]+)+$/;function Tt(e){return mi.test(e)?e.length<=16||bi.test(e)||/^[A-Za-z][a-z]+(?:[-_][A-Za-z][a-z]+)+$/.test(e):!1}var vi=new Set(["authorization_code","urn:ietf:params:oauth:grant-type:device_code"]),Bn=new Set(["code","devicecode"]),$n=new Set([...Bn,"state"]),Ei=new Set(["redirecturi","clientid","verificationuri"]);function zn(e){let t=!1,n=!1,r=!1,s=!1;for(let[i,a]of e){if(i==="granttype"&&vi.has(a.trim().toLowerCase())||i==="codeverifier")return!0;Bn.has(i)&&(t=!0,a.length>=10&&(r=!0)),Ei.has(i)&&(n=!0),i==="state"&&wi(a)&&(s=!0)}return t&&(n||s&&r)}function wi(e){return e.length>=16&&/^[A-Za-z0-9_\-.~+/=]+$/.test(e)&&/[A-Za-z]/.test(e)&&(/\d/.test(e)||/[a-z]/.test(e)&&/[A-Z]/.test(e))&&!Tt(e)&&!Si(e)}function Si(e){return/^(?:[A-Z]+|[A-Z]?[a-z]+)\d*(?:[-_](?:(?:[A-Z]+|[A-Z]?[a-z]+)\d*|\d+))+$/.test(e)&&/(?:^|[-_])[A-Za-z]+(?:[-_]|$)/.test(e)}var Ri=new Set(["passcode"]);function ki(e){return e.kind==="object"||e.kind==="array"}function ie(e){return H(e,"key")}function Ai(e){return P(e,"key").some(t=>Ri.has(t)||t.endsWith("otp"))}var Ii=new Set(["credentials","authentication","pass"]);function xi(e){return P(e,"key").some(t=>Ii.has(t))}var _n=/[a-zA-Z0-9.-]{1,253}\.[a-zA-Z]{2,63}/y;function Ti(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===46||e===95||e===37||e===43||e===45}function Ci(e,t){let n=0,r=e.indexOf("@");for(;r!==-1;){let s=Math.max(n,r-64),i=r;for(;i>s&&Ti(e.charCodeAt(i-1));)i--;if(i<r){_n.lastIndex=r+1;let a=_n.exec(e);if(a){n=r+1+a[0].length,t.push([i,n]),r=e.indexOf("@",n);continue}}r=e.indexOf("@",r+1)}}var Wn=/(?<![A-Za-z0-9])(?:kep_[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{36,}|github_pat_[A-Za-z0-9_]{22,}|glpat-[A-Za-z0-9_-]{20,}|xox[abprse]-[A-Za-z0-9-]{10,}|[sr]k_(?:live|test)_[A-Za-z0-9]{16,}|sk-(?:proj|ant)-[A-Za-z0-9_-]{20,}|npm_[A-Za-z0-9]{36,}|whsec_[A-Za-z0-9+/=]{24,}|(?:AKIA|ASIA)[0-9A-Z]{16,}|AIza[0-9A-Za-z_-]{35,})/g,_i=/\b\d{3}-\d{2}-\d{4}\b/g,Ni=/(?:\+\d{1,3}[ .-]?)?(?:\(\d{3}\)[ .-]?|\b\d{3}[ .-])\d{3}[ .-]\d{4}\b/g,jn=/(?<![A-Za-z0-9_-])eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g,Di=/(?<![\d.])(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)(?![\d.])/g;function Pi(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let s=e.charCodeAt(r)-48;if(s<0||s>9)return!1;n&&(s*=2,s>9&&(s-=9)),t+=s,n=!n}return t%10===0}function qn(e){if(e.length<13||e.length>19)return!1;let t=e[0]==="4"&&(e.length===13||e.length===16||e.length===19),n=/^(5[1-5]|2[2-7])/.test(e)&&e.length===16,r=/^3[47]/.test(e)&&e.length===15,s=/^6(?:011|5)/.test(e)&&e.length===16,i=/^(?:35|3[068])/.test(e)&&e.length>=14&&e.length<=19;return t||n||r||s||i?Pi(e):!1}function Oi(e,t){for(let n of e.matchAll(/\b(?:\d[ -]?){12,18}\d\b/g))qn(n[0].replace(/[^0-9]/g,""))&&t.push([n.index,n.index+n[0].length])}function ee(e,t,n){for(let r of e.matchAll(t))r[0]!==""&&n.push([r.index,r.index+r[0].length])}function me(e,t,n){ee(e,jn,n),ee(e,Wn,n),Ci(e,n),ee(e,_i,n),ee(e,Ni,n),ee(e,Di,n),Oi(e,n);for(let r of t)ee(e,r,n)}function te(e,t){if(t.length===0)return e;t.sort((o,c)=>o[0]-c[0]||c[1]-o[1]);let n="",r=0,[s,i,a]=t[0];for(let o=1;o<=t.length;o++){let c=t[o];if(c!==void 0&&c[0]<i){c[1]>i&&(i=c[1]),a=void 0;continue}n+=e.slice(r,s)+(a??Mn),r=i,c!==void 0&&([s,i,a]=c)}return n+e.slice(r)}function ve(e,t=[]){if(!e)return e;let n=[];return me(e,t,n),te(e,n)}function Ui(e,t){if(!e)return e;let n=[];return Ee(e,n,"string"),me(e,t,n),te(e,n)}function Ct(e){return e&&te(e,_t(e))}var Li=/eyJ|kep_|gh[pousr]_|github_pat_|glpat-|xox[abprse]-|[sr]k_(?:live|test)_|sk-(?:proj|ant)-|npm_|whsec_|AKIA|ASIA|AIza/;function _t(e){let t=[];return Li.test(e)&&(ee(e,jn,t),ee(e,Wn,t)),t}var Mi=64,Bi={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
- `,r:"\r",t:" "};function $i(e,t){let n=0,r=()=>{for(;n<e.length;){let o=e.charCodeAt(n);if(o!==32&&o!==9&&o!==10&&o!==13)break;n++}},s=()=>{n++;let o="",c=n;for(;e[n]!=='"';){if(e[n]!=="\\"){n++;continue}o+=e.slice(c,n);let l=e[n+1];l==="u"?(o+=String.fromCharCode(parseInt(e.slice(n+2,n+6),16)),n+=6):(o+=Bi[l],n+=2),c=n}return o+=e.slice(c,n),n++,o},i=()=>{let o=0;do{let c=e[n];if(c==='"'){for(n++;e[n]!=='"';)n+=e[n]==="\\"?2:1;n++}else if(c==="{"||c==="[")o++,n++;else if(c==="}"||c==="]")o--,n++;else{if(o===0&&(c===","||c===":"))break;n++}}while(o>0||n<e.length&&!/[\s,\]}]/.test(e[n]))},a=o=>{r();let c=n;if(o>Mi)return i(),{kind:"deep",start:c,end:n};let l=e[n];if(l==="{"){n++;let d=[];if(r(),e[n]==="}")n++;else for(;;){r();let u=s();if(r(),n++,d.push({key:u,value:a(o+1)}),r(),e[n++]==="}")break}return{kind:"object",start:c,end:n,entries:d}}if(l==="["){n++;let d=[];if(r(),e[n]==="]")n++;else for(;d.push(a(o+1)),r(),e[n++]!=="]";);return{kind:"array",start:c,end:n,items:d}}if(l==='"'){let d=s();return{kind:"string",start:c,end:n,value:d}}for(;n<e.length&&!/[\s,\]}]/.test(e[n]);)n++;return{kind:"scalar",start:c,end:n}};return a(t)}var ye=JSON.stringify(Mn),et={kind:"param",strict:!1,whole:!1,raw:!0},Hn={...et,spaced:!0,tail:e=>be(e,Wi)},zi={...et,spaced:!0,form:!0},Wi={...et,spaced:!0,list:!0},ji=/^(?=[^={}<>"'\\^`|]*(?:=|$))(?:(?:[a-z][a-z0-9+.-]*:\/|[a-z][a-z0-9-]*[+.][a-z0-9+.-]*:|localhost:\d{1,5}[/?#]|(?:mailto|tel|sms|urn|data|javascript|vbscript|blob|about|xmpp|sip|sips|magnet|intent|bitcoin|geo|market|news):|\.{0,2}\/)[^\s?#]*[?#]|(?:[\w.~%-][\w.~%/-]*)?[?#][^\s=&#]+=|\.{0,2}\/[^\s?#;=]*;)/i,qi=/^\S*/,Hi=/^[^\r\n]*/gm;function be(e,t=et){let n=e.replace(Hi,a=>ji.test(qi.exec(a)[0])?Q(a,t):a),r=Cn(n,t);if(r.length===0)return Nn(n,t);let s="",i=0;for(let[a,o,c]of r)s+=n.slice(i,a)+c,i=o;return Nn(s+n.slice(i),t)}var Ki=/[a-z][a-z0-9+.-]{0,31}:(?:\\\/|\\u002[fF]){2}(?:[^\s"'<>\\^`{|}()[\]/]|\/(?![dgimsuvy]*(?![\w$]))|\\\/|\\u002[fF])*/gi;function Nn(e,t){return/:(?:\\\/|\\u002[fF])/.test(e)?e.replace(Ki,n=>{let r="",s=[];for(let l=0;l<n.length;){s.push(l);let d=Fi.exec(n.slice(l,l+6));r+=d===null?n[l]:"/",l+=d===null?1:d[0].length}s.push(n.length);let i=Q(r,t);if(i===r)return n;let a=0;for(;a<i.length&&i[a]===r[a];)a++;let o=0;for(;o<i.length-a&&o<r.length-a&&i[i.length-1-o]===r[r.length-1-o];)o++;let c=/\\\/|\\u002[fF]/.exec(n)[0];return n.slice(0,s[a])+i.slice(a,i.length-o).replace(/\//g,c)+n.slice(s[r.length-o])}):e}var Fi=/^(?:\\\/|\\u002[fF])/;function Nt(e){let t=be(e,Hn),n=[];return Ee(t,n,"header"),te(t,n)}function Vi(e){if(!/[%+]/.test(e))return!1;let t=Oe(e);if(t===e)return!1;if(T(t)!==t&&Ge(t,"param"))return!0;let n=be(t);if(n===t)return!1;let r=[];return Ee(t,r),te(t,r)!==n}function Xi(e){if(!/^-?\d/.test(e))return null;let t=Number(e);return Number.isInteger(t)?String(t):null}function At(e,t){return t.kind==="scalar"?/^(?:true|false)$/.test(e.slice(t.start,t.end)):t.kind==="array"&&t.items.every(n=>At(e,n))}function It(e,t,n,r,s,i){let a=u=>{i.push([t.start,t.end,u])};if(t.kind==="deep")return a(ye);if(t.kind==="scalar"&&e.startsWith("null",t.start)||At(e,t))return;let o=n!==null&&Ai(n);if(n!==null&&ie(n)&&!(o&&ki(t))&&!(t.kind!=="string"&&xi(n)))return a(ye);if(t.kind==="scalar"){let u=e.slice(t.start,t.end),p=/^\d+$/.test(u)?u:Xi(u);p!==null&&qn(p)&&a(ye);return}if(t.kind==="string"){let u=Ye(t.value,r,s)??Ui(be(t.value),s);u!==t.value&&a(JSON.stringify(u));return}if(t.kind==="array"){for(let u of t.items)It(e,u,n,r+1,s,i);return}let c=t.entries.some(({key:u,value:p})=>Zi.has(u.toLowerCase())&&p.kind==="string"&&ie(p.value)),l=t.entries.some(({key:u})=>pi.has(se(u))),d=zn(t.entries.map(({key:u,value:p})=>[se(u),p.kind==="string"?p.value:""]));for(let{key:u,value:p}of t.entries)At(e,p)||(l&&fi.has(se(u))?i.push([p.start,p.end,ye]):(d&&$n.has(se(u))||o&&se(u)==="code")&&!(p.kind==="scalar"&&e.startsWith("null",p.start))?i.push([p.start,p.end,ye]):c&&Ji.has(u.toLowerCase())?i.push([p.start,p.end,ye]):It(e,p,ie(u)?u:null,r+1,s,i))}function Gi(e,t){if(t.length===0)return e;t.sort((s,i)=>s[0]-i[0]);let n="",r=0;for(let[s,i,a]of t)n+=e.slice(r,s)+a,r=i;return n+e.slice(r)}function Kn(e,t,n){let r=[];return It(e,$i(e,t),null,t,n,r),Gi(e,r)}var Zi=new Set(["key","name","header"]),Ji=new Set(["value","values","expected","actual"]);function Ye(e,t,n){if(!/^\s*[[{]/.test(e))return null;try{JSON.parse(e)}catch{return null}return Kn(e,t+1,n)}function Dt(e,t,n=[]){if(e==null||e==="")return e??null;if(yi(e))return e;if((t??"").toLowerCase().includes("json")||/^\s*[[{]/.test(e)){try{JSON.parse(e)}catch{return hi}return Kn(e,0,n)}let s=e.endsWith(N),i=s?e.slice(0,-N.length):e,a=be(i,zi),o=oo(s?a+N:a,t??""),c=o||a===i?a:be(i,Hn),l=s?c+N:c,d=uo(l,t??"",n);if(d!==null)return d;if(Pt.test(t??"")&&!o)return fo;let u=ao(l,n,o,/(?:java|ecma)script/i.test(t??""));return u!==null?u:ve(l,n)}var N="...[truncated]",Yi=/^[A-Za-z0-9_.~!*'()%+[\]-]*$/;function Oe(e){if(!/[%+]/.test(e))return e;let t=Fn(e.length);return xt(e,0,e.length,t),t.parts.join("")}function Dn(e,t){if(t+2>e.length)return-1;let n=parseInt(e[t],16),r=parseInt(e[t+1],16);return Number.isNaN(n)||Number.isNaN(r)?-1:n*16+r}function Fn(e){return{parts:[],start:new Int32Array(e),end:new Int32Array(e),length:0}}function Qe(e,t,n,r){e.parts.push(t);for(let s=0;s<t.length;s++)e.start[e.length]=n,e.end[e.length]=r,e.length++}function kt(e,t,n,r){if(!(t>=n)){r.parts.push(e.slice(t,n));for(let s=t;s<n;s++)r.start[r.length]=s,r.end[r.length]=s+1,r.length++}}function xt(e,t,n,r){let s={parts:r.parts.length,length:r.length},i=t,a=t;for(;a<n;){let o=e.charCodeAt(a);if(o!==43&&o!==37){a++;continue}if(kt(e,i,a,r),o===43){Qe(r," ",a,a+1),i=++a;continue}let c=a+3<=n?Dn(e,a+1):-1,l=-1,d=128,u=191;c>=0&&c<128?l=0:c>=194&&c<=223?l=1:c>=224&&c<=239?(l=2,c===224&&(d=160),c===237&&(u=159)):c>=240&&c<=244&&(l=3,c===240&&(d=144),c===244&&(u=143));let p=l<=0?c:c&63>>l;for(let m=1;m<=l&&p>=0;m++){let b=a+3*m,v=b+3<=n&&e[b]==="%"?Dn(e,b+1):-1;p=v<(m===1?d:128)||v>(m===1?u:191)?-1:p<<6|v&63}if(l<0||p<0){r.parts.length=s.parts,r.length=s.length,kt(e,t,n,r);return}let h=a+3*(l+1);Qe(r,String.fromCodePoint(p),a,h),i=a=h}kt(e,i,n,r)}var Qi=/(^|[?&;\n>#]|(?<!\b(?:var|let|const)|[(){}])[ \t\r\f\v])([\w%-]*(?:\[[\w%-]*\][\w%-]*)*)=/g,eo=/(^|[?&;\n]|(?<=[\w/%~-])(?<!\*\/|(?:^|[^\w$/%~.-])(?:static|accessor))#)([\w%-]*(?:\[[\w%-]*\][\w%-]*)*)=/g,to=/(^|[?&]|(?<=[\w/%~-])(?<!\*\/|(?:^|[^\w$/%~.-])(?:static|accessor))#)([\w%-]*(?:\[[\w%-]*\][\w%-]*)*)=/g,no=/(^|[?&;,\s]|(?<=[\w/%~-])#)([\w%-]*(?:\[[\w%-]*\][\w%-]*)*)=/g,Pn=/(?:[^\s&"'`<>\\,;(){}[\]$]|\$(?!\{))+/y,On=/[^&]+/y;function Ee(e,t,n="text"){let r=n==="code"?eo:n==="string"?to:n==="header"?no:Qi,s=n!=="text"||!/<script/i.test(e)?[]:ro(e),i=0;r.lastIndex=0;for(let a=r.exec(e);a!==null;a=r.exec(e)){if(!H(a[2],"param"))continue;if(s.length>0&&(/^[ \t\r\f\v>]$/.test(a[1])||a[1]==="#"&&(!/[\w/%~-]/.test(e[a.index-1]??"")||e.startsWith("*/",a.index-2)||/(?:^|[^\w$/%~.-])(?:static|accessor)$/.test(e.slice(Math.max(0,a.index-9),a.index))))){for(;i<s.length&&s[i][1]<=a.index;)i++;if(i<s.length&&s[i][0]<=a.index)continue}let o=a.index+a[0].length;Pn.lastIndex=o;let c=Pn.exec(e);if(c===null)continue;n==="string"&&(On.lastIndex=o,c=On.exec(e)??c);let l=o+c[0].length;t.push([o,l]),r.lastIndex=l}}function ro(e){let t=[],n=/<script\b/gi,r=/<\/script\s*>/gi;for(let s=n.exec(e);s!==null;s=n.exec(e)){let i=e.indexOf(">",s.index);if(i===-1)break;r.lastIndex=i+1;let a=r.exec(e),o=a===null?e.length:a.index;t.push([i+1,o]),n.lastIndex=o}return t}var so=/[?;\n]|%(?:3[FfBb]|26|0[Aa])/;function Vn(e){let t=e.indexOf("="),n=(t===-1?e:e.slice(0,t)).trim();return Yi.test(n)&&(t===-1||!/\s/.test(e.slice(t+1)))}function Un(e,t,n,r){let s=!1;for(let a=t;a<n&&!s;a++){let o=e.charCodeAt(a);s=o===63||o===59||o===38||o===10}if(!s)return;let i=[];Ee(e.slice(t,n),i);for(let[a,o]of i)r.push([t+a,t+o])}var io=/^\s*(?:application\/x-www-form-urlencoded|multipart\/form-data)\s*(?:;|$)/i;function oo(e,t){if(Pt.test(t))return po(e);if(io.test(t))return!0;let n=e.endsWith(N),s=(n?e.slice(0,-N.length):e).split("&"),i=s.length-1;return s.some(a=>a.includes("="))&&s.every((a,o)=>n&&o===i||Vn(a))}function ao(e,t,n,r=!1){let s=e.endsWith(N),i=s?e.slice(0,-N.length):e,a=i.split("&");if(!n){let y=[];return Ee(i,y,r?"code":"text"),y.length===0?null:(me(i,t,y),te(i,y)+(s?N:""))}let o=[];me(i,t,o);let c=/[%+]/.test(i),l=Fn(c?i.length:0),d=so.test(i),u=[],p=zn(a.flatMap(y=>{let g=y.indexOf("=");return g===-1?[]:[[se(Oe(y.slice(0,g))),Oe(y.slice(g+1))]]})),h=[],m,b=0;for(let y of a){let g=y.indexOf("="),f=g===-1?b+y.length:b+g,E=b+y.length,R=l.length;c&&xt(i,b,f,l),g!==-1&&c&&(Qe(l,"=",f,f+1),xt(i,f+1,E,l)),g!==-1&&(H(y.slice(0,g),"param")||p&&$n.has(se(Oe(y.slice(0,g)))))?o.push([f+1,E]):g!==-1&&Vi(i.slice(f+1,E))?o.push([f+1,E]):g!==-1&&(m=go(i,f+1,E,t))!==null?m.length===3?h.push(m):o.push(m):d&&(Un(i,b,E,o),c&&u.push(R,l.length)),b+=y.length,b<i.length&&(c&&Qe(l,"&",b,b+1),b++)}if(c){let y=[],g=l.parts.join("");me(g,t,y);for(let f=0;f<u.length;f+=2)Un(g,u[f],u[f+1],y);for(let[f,E]of y)o.push([l.start[f],l.end[E-1]])}let v=o.filter(([y,g])=>!ho(h,y,g));return te(i,[...v,...h])+(s?N:"")}var Pt=/^\s*multipart\/form-data\s*(?:;|$)/i,co=/;\s*boundary\s*=\s*(?:"([^"\r\n]{1,200})"|([^\s;"]{1,200}))/i,lo=/^content-disposition\s*:[^\n]*?;\s*name\s*=\s*(?:"([^"\r\n]*)"|([^\s;]+))/im,Ln=/^content-disposition\s*:[^\n]*?;\s*filename\*?\s*=/im;function uo(e,t,n){if(!Pt.test(t))return null;let r=e.endsWith(N),s=r?e.slice(0,-N.length):e,i=co.exec(t),a=i!==null?i[1]??i[2]:/^--([^\r\n]{1,200})\r?\n/.exec(s)?.[1]??null;if(a===null)return null;let o="--"+a,c=s.startsWith(o)?0:s.indexOf(`
3
- `+o);if(c===-1)return null;c>0&&(c+=1);let l=[];for(Je(s,0,c,n,l);;){let d=c+o.length;if(s.startsWith("--",d)&&s.indexOf(`
4
- `+o,d)===-1){Je(s,d+2,s.length,n,l);break}let u=s.indexOf(`
5
- `,d);if(u===-1)break;let p=u+1,h=-1;for(;p<s.length;){let R=s.indexOf(`
6
- `,p);if(R===-1)break;if(R===p||R===p+1&&s[p]==="\r"){h=R+1;break}p=R+1}let m=h===-1?s.length:h;if(Je(s,u+1,m,n,l),h===-1)break;let b=s.indexOf(`
7
- `+o,h),v=b===-1?s.length:b;b!==-1&&v>h&&s[v-1]==="\r"&&v--;let y=s.slice(u+1,m),g=lo.exec(y),f=g===null?"":g[1]??g[2],E=Ln.test(y)||H(f,"param")?null:Ye(s.slice(h,v),0,n);if(Ln.test(y)||H(f,"param")?l.push([h,v]):E!==null&&E!==s.slice(h,v)?l.push([h,v,E]):Je(s,h,v,n,l),b===-1)break;c=b+1}return te(s,l)+(r?N:"")}var fo="[Unreadable body]";function po(e){return e.split("&").every(Vn)}function ho(e,t,n){let r=0,s=e.length-1;for(;r<=s;){let i=r+s>>1,[a,o]=e[i];if(t<a)s=i-1;else if(t>=o)r=i+1;else return n<=o}return!1}function go(e,t,n,r){let s=e.slice(t,n);if(!/^(?:%7B|%5B|[[{])/i.test(s))return null;if(/[%+]/.test(s)){let a=Oe(s),o=Ye(a,0,r);return o===null||o===a?null:[t,n]}let i=Ye(s,0,r);return i===null||i===s?null:[t,n,i]}function Je(e,t,n,r,s){if(t>=n)return;let i=e.slice(t,n),a=[];me(i,r,a),Ee(i,a);for(let[o,c]of a)s.push([t+o,t+c])}function yo(e,t=!1){return Q(e,t?bo:mo)}var mo=Rt(!1),bo=Rt(!0),zt={scanned:0},vo=47,gr=38,yr=59,mr=63,br=35,Xn=61;function Gn(e){return e===vo||e===gr||e===yr||e===mr||e===br}function vr(e,t){let n=e.length,r=0;for(;r<=n;){let s=r,i=0;for(;s<n&&(i=e.charCodeAt(s))!==Xn&&!Gn(i);)s++;zt.scanned+=s-r+1;let a;s<n&&i===Xn?a=s>r?t(r,s):s+1:a=s;let o=a;for(;a<n&&!Gn(e.charCodeAt(a));)a++;if(zt.scanned+=a-o+1,a>=n)return;r=a+1}}function Er(e,t,n){let r=t;for(;r<e.length;r++){let s=e.charCodeAt(r);if(s===gr||s===yr||s===br||!n&&s===mr)break}return zt.scanned+=r-t+1,r}function wr(e){let t=[];return vr(e,(n,r)=>{let s=Er(e,r+1,!0);return t.push([e.slice(n,r),e.slice(r+1,s)]),s}),t}var Eo=256;function Ot(e,t,n=!1){let r="",s=0;return vr(e,(i,a)=>{let o=P(e.slice(i,a),"page"),c=a+1;if(!Ze(o,"page")&&!(n&&Ft(o,e.slice(c,c+Eo))))return c;let l=Er(e,c,t);return r+=e.slice(s,c)+"[REDACTED]",s=l,l}),r+e.slice(s)}function Zn(e,t){let n=e.indexOf("?");return n===-1?Ot(e,!1):`${Ot(e.slice(0,n),!1)}?${Ot(e.slice(n+1),!0,t)}`}var Ht=/^!?\//,wo=8;function K(e){return e.length<wo?!1:Number(/[a-z]/.test(e))+Number(/[A-Z]/.test(e))+Number(/\d/.test(e))>=2&&!/^[A-Z][a-z]+$/.test(e)&&!/^[A-Za-z][a-z]*(?:[-_](?:[A-Za-z][a-z]*|\d+))+$/.test(e)&&!/^[A-Za-z][a-z]{2,}(?:[A-Z][a-z]{2,})+$/.test(e)}function F(e,t=!0){return(t?/^(?:\/|[a-z][a-z\d+.-]*:\/\/)/i:/^[a-z][a-z\d+.-]*:\/\//i).test(T(e))}function X(e){return T(e).replace(/([a-z\d])([A-Z])/g,"$1 $2").split(/[\s\-_.]+/).filter(t=>t!=="").map(t=>t.toLowerCase())}var So=new Set(["reset","resets","verify","unlock","activate","invite","forgot","forgotten","recover","recovery"]),Ro=new Set(["passwordreset","passwordresets","resetpassword","verifyemail","emailverification","magiclink","magiclogin","emaillogin","loginlink","lostpassword","setpassword","createpassword"]),ko=new Set(["setpassword","createpassword","resetpassword","passwordreset","forgotpassword","forgottenpassword","lostpassword","verifyemail","emailverification"]),Ao=new Set(["sent","done","success","complete","new","error","expired","failed","invalid"]),Jn=new Set(["confirm","confirmation","confirmations","invites","invitation","invitations","verification","verifications","activation","activations","password","passwords","signup","login"]),Io=new Set(["email","account","registration","registrations","signup"]),xo=new Set(["accept","link","new","old","sign","up","email","account","registration","admin","change","php","asp","aspx","htm","html","jsp","cgi"]),Yn=e=>e.some(t=>Io.has(t))||e.join("").includes("signup");function Wt(e,t){let n=X(e),r=n.join("");if(Ro.has(r))return 2;Jn.has(r)&&(n=[r]);let s=0;for(let i of n)if(So.has(i))s=2;else if(Jn.has(i))s||=1;else if(!xo.has(i))return 0;return s===1&&(n.includes("accept")||n.includes("confirm")&&(Yn(n)||Yn(X(t))))?2:s}function Sr(e){return/^(?:\d+|[\da-f]{24}|[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12})$/i.test(e)||/^(?:[0-7][\dA-HJKMNP-TV-Z]{25}|c[a-z\d]{24})$/.test(e)}function To(e){if(e.length%4===1||!/^[\w-]+$/.test(e))return!1;try{return/^[\x20-\x7e]+$/.test(atob(e.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((e.length+3)%4)))}catch{return!1}}function Co(e){return e.length<=4||Rr(e)}function Rr(e){return X(e).every(t=>t.startsWith("confirm")||t==="accept"||t==="edit")}function kr(e,t){let n=e[t]??"";return ko.has(X(e[t-1]??"").join(""))&&!Rr(n)&&!Ao.has(n.toLowerCase())&&!/\.[A-Za-z][A-Za-z\d]{0,4}$/.test(n)&&!(Sr(n)&&(e[t+1]??"")!=="")}var Ar=new Set(["cb","auth","sso","signin","authorize","authorized","redirect"]);function _o(e){return X(e).some(t=>t.startsWith("invit"))}function Kt(e,t){return/^(?:rp|resetpass)$/.test(t)||e.some(n=>n.some(r=>Wt(r,"")!==0))}function Ir(e){return e.find(([t])=>P(t,"page").includes("action"))?.[1]??""}function Ft(e,t){return e.some(n=>/^(?:key|t|hash|code)$/.test(n))&&!F(t,!1)}function No(e){let t=X(e);return t.length>0&&t.every(n=>n==="accept"||n==="join")}var Vt="a route is `/`-separated segments from the path's start, each a literal, `*` (any one segment) or `:name` (the value it names), with no `?` or `#`; a secret route names at least one `:name`, a keep route has at least one literal";function xr(e,t=!1){if(typeof e!="string"||!/^\/[^?#]*$/.test(e))return null;let n=e.split("/").filter(s=>s!==""),r=s=>/^:\w+$/.test(s);return n.every(s=>s==="*"||r(s)||!/[:*]/.test(s))&&n.some(s=>t?s!=="*"&&!r(s):r(s))?n:null}var we={secret:[],keep:[]},Qn=new Set,Tr=0;function Cr(){return Tr}function _r(e,t){for(let[n,r]of[[we.secret,e],[we.keep,t]])for(let s of r){let i=`${n===we.keep}${s.join("/")}`;Qn.has(i)||(Qn.add(i),n.push(s),Tr++,oe=["",[],!1,null])}}function Nr(e,t){return e==="*"||e[0]===":"||T(t).toLowerCase()===T(e).toLowerCase()}function er(e,t){let n=[];return e.every((r,s)=>{let i=t[s];return i===void 0?!1:(r[0]===":"&&n.push([i,t[s-1]??"",s]),Nr(r,i))})?n:null}function Do(e,t){return we.keep.some(n=>t<n.length&&n[t]!=="*"&&n[t][0]!==":"&&n.slice(0,t+1).every((r,s)=>Nr(r,e[s])))}function Dr(e){let t=!1,n=new Set;for(let s of we.keep){let i=er(s,e);if(i!==null){i.length===0&&(t||=s.length===e.length&&!s.includes("*"));for(let[a]of i)n.add(a)}}let r=[];for(let s of we.secret)for(let[i,a,o]of er(s,e)??[])!Do(e,o)&&Po(i)&&r.push([i,a]);return{secret:r,kept:n,own:t}}function Po(e){let t=e;for(let n=0;n<=Oo;n++){let r=T(t);if(r===t)return/[\p{L}\p{N}]/u.test(t);t=r}return!1}var Oo=16;function Xt(e){let t=e.indexOf("#"),n=[e.slice(0,t===-1?e.length:t).replace(/^[a-z][a-z\d+.-]*:\/\/[^/?#]*/i,"")],r=t===-1?"":e.slice(t+1);return Ht.test(r)&&n.push(r.replace(/^!/,"")),n.map(s=>s.split(/[?#]/)[0].split("/").map(i=>i.split(";")[0]))}var Uo=32,Lo=65536;function Ue(e,t,n){let r=e.get(t);r===void 0&&e.set(t,r=new Set),r.add(Mo(n))}function Mo(e){return _(T(e))}function Pr(e,t,n,r,s,i){let a=Xt(e);for(let m of a){let b=m.length,{secret:v,kept:y,own:g}=Dr(m.filter(f=>f!==""));for(let[f,E]of v)n.add(f),Ue(r,f,E),t===0&&Ue(s,f,E);for(let f=0;f<b;f++){let E=Wt(m[f],m[f-1]??"");if(E===0)continue;let R=_o(m[f]),w=m[f+1];kr(m,f+1)&&!y.has(w)&&!g&&(n.add(w),K(T(w))||(r.has(w)||i.add(w),Ue(r,w,m[f])));let S="",k="",A=f+1;for(;A<b;A++){let I=m[A],x=m[A+1]??"";if(Sr(I)||(E===2||x.length>=16&&K(x))&&To(I)){k=I;continue}if(I.length>=(E===2?16:20)&&K(I)){S=I;break}if(R&&K(I)){k=I;continue}let C=Wt(I,m[A-1]);if(C>E){E=C,k="";continue}if(k!==""&&No(I)){S=k;break}if(!Co(I))break}S===""&&E===2&&A===b&&(S=k),S!==""&&!y.has(S)&&!g&&n.add(S),f=S===""?A-1:A}}let o=wr(e).map(([m,b])=>[P(m,"page"),b]),c=m=>o.find(([b])=>b.includes(m))?.[1]??"",l=Kt(a,c("action")),d=c("organization")!=="",u=c("code"),p=c("state"),h=!F(u)&&(u.length>=10&&K(p)&&!/^[A-Za-z][a-z]+(?:[A-Z][a-z]+)+$/.test(p)&&!F(p)||u.length>=20&&K(u)&&a.some(m=>m.some(b=>/callback|oauth/i.test(b)||[...X(b),X(b).join("")].some(v=>Ar.has(v)))));for(let[m,b]of o){let v=h&&(m.includes("code")||m.includes("state"));if((v||Ze(m,"page")||l&&Ft(m,b)||d&&m.includes("invitation")||m.includes("ticket")&&/^(?:ST|PT|TGT)-/.test(b))&&!F(b,v)){n.add(b);continue}let y=T(b);t<2&&(/[?#=]/.test(y)||F(y))&&Pr(y,t+1,n,r,s,i)}}function Or(e){try{return new URL(e).origin}catch{return""}}var Bo=6;function Be(e){return Ur(e)[0]}var oe=["",[],!1,null];function Ur(e){if(oe[0]===e)return[oe[1],oe[2],oe[3]];let t=new Set,n=new Map,r=new Map,s=new Set,i=e.indexOf("#"),a=i===-1?e:e.slice(0,i),o=i===-1?"":e.slice(i+1),c=Ht.test(o),l=a.length+(c?o.length:0)>Lo;if(!l)Pr(e,0,t,n,r,s);else for(let v of Xt(e))for(let[y,g]of Dr(v.filter(f=>f!=="")).secret)t.add(y),Ue(n,y,g),Ue(r,y,g);let d=l,u=Or(e),p=new Set,h=[],m=0,b=(v,y)=>y!==null&&r.get(v)?.has(y)===!0?!0:m<Uo?(m++,!0):(d=!0,!1);for(let v of[...r.keys(),...[...t].filter(y=>!r.has(y))]){let y=n.get(v),g=y===void 0?void 0:[...y].filter(f=>b(v,f));if(g?.length===0||g===void 0&&!b(v,null))break;if(g!==void 0){let f=T(v),E=f.length>=Bo&&!s.has(v),R=[];for(let w=v,S=0;S<jo;S++)R.push(w=encodeURIComponent(w));for(let w of new Set([v,f,...R,encodeURIComponent(f),f.replace(/[\u0080-\uffff]/g,S=>`\\u${S.charCodeAt(0).toString(16).padStart(4,"0")}`)])){if(w==="")continue;let S=!u.includes(w),k=S&&K(w)&&!F(w,!1);if(E&&k&&h.push({kind:0,value:w}),E&&S)h.push({kind:1,value:w});else for(let A of g)h.push({kind:2,value:w,before:A})}continue}p.add(v);for(let f=v.lastIndexOf("/"),E=0;f>0&&E<4;f=v.lastIndexOf("/",f-1),E++)p.add(v.slice(0,f));p.add(encodeURIComponent(v));for(let f of[v,v.replace(/\+/g," ")])try{let E=decodeURIComponent(f);p.add(E),p.add(encodeURIComponent(E));for(let R=E.lastIndexOf("/"),w=0;R>0&&w<4;R=E.lastIndexOf("/",R-1),w++)p.add(E.slice(0,R))}catch{}}for(let v of p)K(v)&&!F(v,!1)&&!u.includes(v)&&h.push({kind:0,value:v});return h.sort((v,y)=>y.value.length-v.value.length),oe=[e,h,d,Qt(h)],[h,d,oe[3]]}function _(e){if(!/[A-Z]/.test(e))return e;if(L.lowered+=e.length,!/[^\0-\x7f]/.test(e))return e.toLowerCase();let t=new Uint16Array(Math.min(e.length,Ut)),n="";for(let r=0;r<e.length;r+=Ut){let s=Math.min(Ut,e.length-r);for(let i=0;i<s;i++){let a=e.charCodeAt(r+i);t[i]=a>=65&&a<=90?a+32:a}n+=String.fromCharCode(...t.subarray(0,s))}return n}var Ut=8192;function nt(e,t){let n=new Int32Array(t.length);for(let s=1,i=0;s<t.length;s++){for(;i>0&&t.charCodeAt(s)!==t.charCodeAt(i);)i=n[i-1];t.charCodeAt(s)===t.charCodeAt(i)&&i++,n[s]=i}let r=[];for(let s=0,i=0;s<e.length;s++){for(;i>0&&e.charCodeAt(s)!==t.charCodeAt(i);)i=n[i-1];e.charCodeAt(s)===t.charCodeAt(i)&&i++,i===t.length&&(r.push(s-i+1),i=n[i-1])}return r}var M=1/0,V=0;function $o(e){let t=M;M=1/0;try{return e()}finally{M=t}}function ae(e){if(V+e>M)throw new Se(V+e,M)}function Me(e,t,n="[redacted]"){if(e.includes(t))return!0;if(!/[[\]]/.test(t))return!1;let r=t.split(n),s=r[0],i=s.lastIndexOf("[");i>=0&&n.startsWith(s.slice(i))&&(r[0]=s.slice(0,i));let a=r[r.length-1],o=a.indexOf("]");return o>=0&&n.endsWith(a.slice(0,o+1))&&(r[r.length-1]=a.slice(o+1)),r.every(c=>e.includes(c))}function zo(e,t){let n=o=>o.length>G;if(e.plain.some(o=>n(o)&&Me(t,o,"[REDACTED]"))||e.plain.some(o=>t.includes(o)))return!1;let r=[...e.bounded,...e.words.map(({value:o})=>o)],s=r.filter(n),i=r.filter(o=>/[^a-z0-9]/.test(o));if(s.length===0&&i.length===0)return!0;let a=_(t);return!s.some(o=>Me(a,o))&&!i.some(o=>a.includes(o))}var G=10;function Lr(e,t){let n=s=>s.length>G&&/[[\]]/.test(s);if(e.plain.some(s=>n(s)&&Me(t,s,"[REDACTED]")))return!0;let r=_(t);return[...e.bounded,...e.words.map(({value:s})=>s)].some(s=>n(s)&&Me(r,s))}function tr(e,t,n,r,s=!1){let i=[],a=0,o=G-n.length;for(let d of nt(t,n))d<a||!r(d,d+n.length)||(i.push(d),a=d+n.length,s&&ae(e.length+i.length*o));if(i.length===0)return[e,()=>t];let c=(d,u)=>{let p=[],h=0;for(let m of i)p.push(d.slice(h,m)),h=m+n.length;return p.push(d.slice(h)),p.join(u)},l;return[c(e,"[REDACTED]"),()=>l??=c(t,"[redacted]")]}var nr=/[A-Za-z0-9]/,Wo=/(?:%(?:25)*[\da-f]{2}|(?:\\|%(?:25)*5c)(?:[nrtbf]|u[\da-f]{4}))$/i;function Mr(e,t,n){return(t===0||!nr.test(e[t-1])||Wo.test(e.slice(Math.max(0,t-16),t)))&&(n===e.length||!nr.test(e[n]))}var Gt=[["%25252f",3],["%252f",2],["%2f",1],["\\/",0],["/",0]],jo=Math.max(...Gt.map(([,e])=>e)),Br=/[/\\?#\s"<>`{}|^[\]]/,$r=/[!$&'()*+,;=:@]/,qo=64;function Zt(e,t,n){return Gt.find(([r,s])=>s<=n&&t>=r.length&&e.startsWith(r,t-r.length))}function Ho(e,t,n){if(e[t]===";")return!0;for(let r=1;r<=n;r++)if(e.startsWith(`%${"25".repeat(r-1)}3b`,t))return!0;return!1}function Ko(e,t){return t===0||Br.test(e[t-1])||$r.test(e[t-1])||/(?::|%(?:25)*3a)$/.test(e.slice(Math.max(0,t-9),t))}var L={pieces:0,strings:0,scanned:0,lowered:0};function Fo(e,t,n){let r=t;for(;;){let s=Zt(e,r,n);if(s===void 0)return r;r-=s[0].length,L.scanned++}}function zr(e,t,n,r){if(n!==e.length&&/[a-z0-9_~-]/.test(e[n]))return!1;let s=Zt(e,t,3);if(s===void 0)return!1;let[i,a]=s,o=Fo(e,t-i.length,a);return o!==t-i.length&&Ko(e,o)?!1:r.befores.has("")?!0:r.longest===0?!1:Vo(e,o,a,r)}function Vo(e,t,n,r){let s=t;for(;s>0&&!Br.test(e[s-1])&&Zt(e,s,n)===void 0;)s--;L.scanned+=t-s;let i=t,a="",o=!1;for(let c=t;c>=s;c--){if(c<t&&Ho(e,c,n)&&(i=c,a="",o=!1),o||c!==s&&!$r.test(e[c-1]))continue;let l=e.slice(c,i);for(let d=0;d<=n;d++)l=T(l);if(L.pieces++,a=_(l)+a,i=c,a.length>r.longest)o=!0;else if(r.lengths.has(a.length)&&r.befores.has(a))return!0}return!1}function st(e,t){if(!Jt(e,t))return e;if(/^[ \t\n\r]*[{[]/.test(e)){let n=Wr(e,t);if(n!==null)return n}return $e(e,t)}function Xo(e,t){return Jt(e,t)?Wr(e,t)??$e(e,t):e}function Jt(e,t){return rr(e,t)?!0:e.includes("\\")&&rr(Yt(e),t)}function rr(e,t){if(t.plain.some(r=>e.includes(r)))return!0;if(t.bounded.length===0&&t.words.length===0)return!1;let n=_(e);return t.bounded.some(r=>n.includes(r))||t.words.some(({value:r})=>n.includes(r))}function Go(e,t){let n=_(e),r=e.includes("\\")?_(Yt(e)):n,s=i=>n.includes(_(i))||n.includes(_(Zo(i)))||r.includes(_(i));return{...t,plain:t.plain.filter(s),bounded:t.bounded.filter(s),words:t.words.filter(({value:i})=>s(i))}}function Yt(e){return e.replace(/\\+u([0-9a-fA-F]{4})/g,(t,n)=>String.fromCharCode(parseInt(n,16))).replace(/\\+\//g,"/")}function Zo(e){return JSON.stringify(e).slice(1,-1).replace(/[\u0080-\uffff]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`)}var sr=/"(?:[^"\\]|\\[\s\S])*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|[{}]/g,tt=/[ \t\n\r]*:/y;function Wr(e,t){try{JSON.parse(e)}catch{return null}let n=Go(e,t),r=[],s=[];for(let d of e.matchAll(sr)){let u=d[0];u==="{"?(s.push(r.length),r.push(new Set)):u==="}"?s.pop():u[0]==='"'&&s.length>0&&(tt.lastIndex=d.index+u.length,tt.test(e)&&r[s[s.length-1]].add(JSON.parse(u)))}let i=V,a="",o=0,c=0,l=[];for(let d of e.matchAll(sr)){let u=d[0];if(u==="{"){l.push(new Set(r[c++]));continue}if(u==="}"){l.pop();continue}let p=u;if(u[0]==='"'){let h=JSON.parse(u);V=i+a.length+(d.index-o);let m;try{m=st(h,n)}finally{V=i}tt.lastIndex=d.index+u.length;let b=tt.test(e)?l[l.length-1]:void 0;if(b!==void 0&&m!==h){let v=m;for(let y=2;b.has(m);y++)m=`${v}#${y}`;b.add(m)}m!==h&&(p=JSON.stringify(m))}else $o(()=>$e(u,n))!==u&&(p='"[REDACTED]"');p!==u&&(a+=e.slice(o,d.index)+p,o=d.index+u.length,ae(a.length))}return a+e.slice(o)}function jr(e){let t="",n=[],r=0;for(let s of e.matchAll(/\\+u([0-9a-fA-F]{4})|\\+\//g))t+=e.slice(r,s.index),n.push(t.length,s.index+s[0].length),t+=s[1]===void 0?"/":String.fromCharCode(parseInt(s[1],16)),r=s.index+s[0].length;return{text:t+e.slice(r),escapes:n}}function ir(e,t){let n=0,r=e.length/2;for(;n<r;){let i=n+r>>1;e[i*2]<t?n=i+1:r=i}if(n===0)return t;let s=(n-1)*2;return e[s+1]+(t-e[s]-1)}function or(e,t,n=!1){let r=[],s=[],i=(o,c,l)=>{let d=new Int32Array(o.length),u=0,p=c>G,h=-1,m=-1;for(let b of o)!n&&l(b)?d[u++]=b:p&&(b<m||(h>=0&&s.push(h,m),h=b),m=b+c);h>=0&&s.push(h,m),u>0&&r.push({at:d.subarray(0,u),length:c})};for(let o of t.plain)i(nt(e,o),o.length,()=>!0);let a=_(e);for(let o of t.bounded)i(nt(a,o),o.length,c=>Mr(e,c,c+o.length));for(let o of t.words)i(nt(a,o.value),o.value.length,c=>zr(a,c,c+o.value.length,o));return{lists:r,slack:Jo(s)}}function Jo(e){if(e.length===0)return 0;let t=Array.from({length:e.length/2},(a,o)=>o).sort((a,o)=>e[2*a]-e[2*o]),n=0,r=e[2*t[0]],s=e[2*t[0]+1],i=()=>{s-r>G&&(n+=s-r-G)};for(let a of t){let o=e[2*a],c=e[2*a+1];o<s?c>s&&(s=c):(i(),r=o,s=c)}return i(),n}function Yo(e,t){let n=M!==1/0&&V+G*e.length>M,{text:r,escapes:s}=e.includes("\\")?jr(e):{text:e,escapes:[]},i=or(r,t),{lists:a}=i;if(a.length===0)return e;let o=n&&!Lr(t,e),c=i.slack+(o&&s.length>0?or(e,t,!0).slack:0),l=new Int32Array(a.length),d=g=>a[g].at[l[g]],u=[],p=(g,f)=>{let E=u[g];u[g]=u[f],u[f]=E},h=g=>{for(;;){let f=2*g+1,E=g;if(f<u.length&&d(u[f])<d(u[E])&&(E=f),f+1<u.length&&d(u[f+1])<d(u[E])&&(E=f+1),E===g)return;p(g,E),g=E}};for(let g=0;g<a.length;g++)u.push(g);for(let g=(u.length>>1)-1;g>=0;g--)h(g);let m=[],b=0,v=!1,y=0;for(;u.length>0;){let g=u[0],f=d(g),E=ir(s,f),R=ir(s,f+a[g].length);if(l[g]=l[g]+1,l[g]>=a[g].at.length&&(u[0]=u[u.length-1],u.pop()),u.length>0&&h(0),!(R<=b)){if(v&&E<=b){b=R;continue}y+=E-b+G,o&&ae(y-c),m.push(e.slice(b,E),"[REDACTED]"),b=R,v=!0}}return o&&ae(y+e.length-b-c),m.push(e.slice(b)),m.join("")}function $e(e,t){e=Yo(e,t);for(let o of t.plain)e.includes(o)&&(e=e.split(o).join("[REDACTED]"));let n=_(e),r=()=>n,s=[...t.bounded,...t.words.map(({value:o})=>o)],i=new Array(s.length);for(let o=s.length-1,c=!0;o>=0;o--){let l=s[o];c=c&&(l.length<=G||!Me(n,l)),i[o]=c}let a=0;for(let o of t.bounded){if(r().includes(o)){let c=e;[e,r]=tr(e,r(),o,(l,d)=>Mr(c,l,d),i[a])}a++}for(let o of t.words){if(r().includes(o.value)){let c=r();[e,r]=tr(e,c,o.value,(l,d)=>zr(c,l,d,o),i[a])}a++}return e}function Qo(e,t){let n=e.length,r={},s=(l,d)=>{let u=r[d]??=new Int32Array(n+2).fill(-2),p=[],h=l,m=-1;for(;!(h>=n);){if(u[h]!==-2){m=u[h];break}p.push(h),L.scanned++;let b=e[h];if(b===d){m=h+1;break}h+=b==="\\"?2:1}for(let b of p)u[b]=m;return m},i=-1,a=l=>{for(i<l&&(i=l);i<n&&!`)"'`.includes(e[i]);)L.scanned++,i++;return i},o=l=>{let d=l;for(;d<n&&/\s/.test(e[d]);)L.scanned++,d++;return d},c=0;for(;c<n;){L.scanned++;let l=e[c];if(l==="/"&&e[c+1]==="*"){let d=e.indexOf("*/",c+2),u=d<0?n:d+2;L.scanned+=u-c,t(c,u),c=u;continue}if((l==="u"||l==="U")&&e.slice(c,c+4).toLowerCase()==="url("){let d=o(c+4),u=e[d],p=-1;if(u==='"'||u==="'"){let h=s(d+1,u);if(h>=0){let m=o(h);e[m]===")"&&(p=m+1)}}else{let h=a(c+4);e[h]===")"&&(p=h+1)}if(p>=0){t(c,p),c=p;continue}}if(l==='"'||l==="'"){let d=s(c+1,l);if(d>=0){t(c,d),c=d;continue}}c++}}function ea(e,t){let n=e.length>=4&&e.endsWith("*/");return`/*${$e(e.slice(2,n?-2:void 0),t)}${n?"*/":""}`}function ta(e,t){if(!Jt(e,t))return e;for(let s of t.plain)e.includes(s)&&(e=e.split(s).join("[REDACTED]"));let n="",r=0;return Qo(e,(s,i)=>{let a=e.slice(s,i);n+=e.slice(r,s)+(a.startsWith("/*")?ea(a,t):$e(a,t)),ae(n.length),r=i}),n+e.slice(r)}function Qt(e){if(e.length===0)return null;let t=(a,o)=>o.length-a.length,n=[],r=[],s=new Map;for(let a of e){let o=_(a.value);if(a.kind===0)n.push(a.value);else if(a.kind===1)r.push(o);else{let c=s.get(o);c===void 0&&s.set(o,c=new Set),c.add(a.before.length>qo?"":a.before)}}n.sort(t),r.sort(t);let i=[...s].map(([a,o])=>{let c=new Set([...o].filter(l=>l!=="").map(l=>l.length));return{value:a,befores:o,lengths:c,longest:c.size===0?0:Math.max(...c)}}).sort((a,o)=>o.value.length-a.value.length);return{json:n.map(a=>JSON.stringify(a).slice(1,-1)),jsonLower:[...r,...i.flatMap(({value:a})=>Gt.map(([o])=>o+a))].map(a=>JSON.stringify(a).slice(1,-1)),plain:n,bounded:r,words:i}}function na(e,t){if(t.json.some(i=>e.includes(i)))return!0;let n=_(e);if(t.jsonLower.some(i=>n.includes(i)))return!0;if(!e.includes("\\"))return!1;let r=Yt(e);if(t.plain.some(i=>r.includes(i)))return!0;let s=_(r);return t.bounded.some(i=>s.includes(i))||t.words.some(({value:i})=>s.includes(i))}var ra=16383;function sa(e,t){let n=`${e}\0${t}`;if(n.length<=ra)return n;let r=2166136261;for(let s=0;s<t.length;s++)r^=t.charCodeAt(s),r=Math.imul(r,16777619);return`${e}${t.length}\0${r>>>0}`}var ia=13,oa=8,aa=new Set(["type","rel","method","enctype","autocomplete","inputmode","enterkeyhint","dir","role","crossorigin","referrerpolicy","loading","decoding","fetchpriority","contenteditable","draggable","spellcheck","translate"]),ca=2,Lt=3,ar=2,cr=3,lr=0,it=class{constructor(t){this.page=t}styles=new Map;texts=new Map;gone(t){return this.page===void 0||!this.page.present(t)}get size(){let t=0;for(let n of this.styles.values())t+=n.size;return this.styles.size+this.texts.size+t}addText(t,n){this.dropText(t),this.texts.set(t,n),this.styles.get(n)?.add(t),this.page?.note(t)}dropText(t){let n=this.texts.get(t);n!==void 0&&this.styles.get(n)?.delete(t),this.texts.delete(t)&&this.page?.forget(t)}drop(t){let n=this.styles.get(t);if(n!==void 0)for(let r of n)this.texts.delete(r)&&this.page?.forget(r);this.styles.delete(t)&&this.page?.forget(t),this.dropText(t)}observe(t){if(!D(t)||!D(t.data))return;let n=t.data;if(t.type===ar){for(let i of[...this.styles.keys(),...this.texts.keys()])this.page?.forget(i);this.styles.clear(),this.texts.clear(),this.walk(n.node,null);return}if(t.type!==cr||n.source!==lr)return;let r=Array.isArray(n.removes)?n.removes:[];for(let i of r)D(i)&&typeof i.id=="number"&&this.gone(i.id)&&this.drop(i.id);let s=Array.isArray(n.adds)?n.adds.filter(D):[];for(let i of s)this.walk(i.node,null);for(let i of s){let a=i.node;D(a)&&a.type===Lt&&typeof a.id=="number"&&(typeof i.parentId=="number"&&this.styles.has(i.parentId)?this.addText(a.id,i.parentId):this.dropText(a.id))}r.length>0&&this.page!==void 0&&this.prune()}prune(){for(let t of this.styles.keys())this.gone(t)&&this.drop(t);for(let t of this.texts.keys())this.gone(t)&&this.dropText(t)}walk(t,n){let r=[[t,n]],s=new Set;for(;r.length>0;){let[i,a]=r.pop();if(s.has(i)||(s.add(i),!D(i)||typeof i.id!="number"))continue;let o=i.id,c=i.type===ca&&typeof i.tagName=="string"&&i.tagName.toLowerCase()==="style";if(c&&!this.styles.has(o)&&(this.styles.set(o,new Set),this.page?.note(o)),i.type===Lt&&a!==null&&this.addText(o,a),Array.isArray(i.childNodes))for(let l of i.childNodes)r.push([l,c?o:null])}}recordsIn(t){let n=new Set;if(!D(t)||!D(t.data))return n;let r=t.data,s=[];if(t.type===ar)s.push(r.node);else if(t.type===cr&&r.source===lr){if(Array.isArray(r.adds))for(let i of r.adds)D(i)&&s.push(i.node);if(Array.isArray(r.texts))for(let i of r.texts)D(i)&&typeof i.id=="number"&&this.texts.has(i.id)&&n.add(i)}for(;s.length>0;){let i=s.pop();D(i)&&(i.type===Lt&&typeof i.id=="number"&&this.texts.has(i.id)&&n.add(i),Array.isArray(i.childNodes)&&s.push(...i.childNodes))}return n}},Se=class extends Error{constructor(n,r){super(`the scrubbed event passed ${r} units (at least ${n})`);this.atLeast=n;this.cap=r;this.name="ScrubOverCap"}};function Mt(e,t){if(t.length===0)return 0;let n=new Int32Array(t.length);for(let s=1,i=0;s<t.length;s++){for(;i>0&&t.charCodeAt(s)!==t.charCodeAt(i);)i=n[i-1];t.charCodeAt(s)===t.charCodeAt(i)&&i++,n[s]=i}let r=0;for(let s=0,i=0;s<e.length;s++){for(;i>0&&e.charCodeAt(s)!==t.charCodeAt(i);)i=n[i-1];e.charCodeAt(s)===t.charCodeAt(i)&&i++,i===t.length&&(r++,i=n[i-1])}return r}function la(e,t){if(Lr(t,e))return null;let n=e.includes("\\"),r=n?jr(e).text:e,s=n?[r,e]:[r],i=r.length;for(let a of s){let o=_(a);for(let c of t.plain)i-=Mt(a,c)*c.length;for(let c of t.bounded)i-=Mt(o,c)*c.length;for(let{value:c}of t.words)i-=Mt(o,c)*c.length}return i}function ur(e,t,n){if(M===1/0||V+e.length<=M||t==="body"||t==="text"&&/^[ \t\n\r]*[{[]/.test(e)||t==="css"&&e.includes("\\"))return;if(!e.includes("\\")&&zo(n,e)){ae(e.length);return}let r=la(e,n);r!==null&&ae(r)}function ot(e,t,n="custom",r,s){if(n==="dom"&&r?.observe(e),t===null)return e;let i;try{i=JSON.stringify(e)}catch{return e}let a=i;if(a===void 0||!na(a,t))return e;let o=JSON.parse(a);if(typeof o=="string")return L.strings++,b(0,()=>(ur(o,"text",t),st(o,t)));let c=n==="dom"&&r!==void 0?r.recordsIn(o):new Set,l=n==="dom"&&D(o)&&o.type===3&&D(o.data)&&o.data.source===ia,d=(g,f,E,R,w)=>n==="network"?w&&(f==="method"||f==="type")?"keep":w&&(f==="requestBody"||f==="responseBody")?"body":"text":n!=="dom"?"text":f==="tagName"||l&&f==="property"||R&&aa.has(f)?"keep":E||R&&f==="style"||f==="_cssText"||f==="rule"||(f==="replace"||f==="replaceSync")&&g.source===oa||l&&f==="value"||(f==="textContent"||f==="value")&&c.has(g)?"css":"text",u=new Map,p=![...t.plain,...t.bounded,...t.words.map(g=>g.value)].some(g=>g.includes("#")),h=0,m=g=>{if(h+=g.length,s!==void 0&&h>s)throw new Se(h,s);return g};function b(g,f){M=s??1/0,V=g;try{return f()}finally{M=1/0,V=0}}let v=(g,f)=>{if(f==="keep")return g;if(f==="text"&&p){let k=g.indexOf("#");if(k>0&&!/^[ \t\n\r]*[{[]/.test(g))return v(g.slice(0,k),f)+v(g.slice(k),f)}ur(g,f,t);let E=sa(f,g),R=u.get(E),w=R?.find(([k])=>k===g);if(w!==void 0)return w[1];L.strings++;let S=f==="css"?ta(g,t):f==="body"?Xo(g,t):st(g,t);return R!==void 0?R.push([g,S]):u.set(E,[[g,S]]),S},y=[{node:o,css:!1,attributes:!1,names:n==="custom",root:!0}];for(;y.length>0;){let{node:g,css:f,attributes:E,names:R,root:w}=y.pop();if(Array.isArray(g)){for(let S=0;S<g.length;S++){let k=g[S];typeof k=="string"?g[S]=m(b(h,()=>v(k,f?"css":"text"))):k!==null&&typeof k=="object"&&y.push({node:k,css:f,attributes:!1,names:n==="custom",root:!1})}continue}if(D(g))for(let S of Object.keys(g)){let k=g[S];if(n==="dom"&&R&&!S.startsWith("rr_")&&S!=="_cssText"&&t.plain.some(z=>S.includes(z))){delete g[S];continue}let A=d(g,S,f,E,w);if(typeof k=="string")g[S]=m(b(h,()=>v(k,A)));else if(k!==null&&typeof k=="object"){let z=n==="dom"&&S==="attributes";y.push({node:k,css:A==="css",attributes:z,names:n==="custom"||z||n==="dom"&&E&&S==="style"||n==="network"&&w&&(S==="requestHeaders"||S==="responseHeaders"),root:!1})}if(!R||S.startsWith("rr_")||S==="_cssText")continue;let I=S;for(let z of t.plain)I.includes(z)&&(I=I.split(z).join("[REDACTED]"));if(I===S)continue;let x=g[S];delete g[S];let C=I;for(let z=2;Object.prototype.hasOwnProperty.call(g,C);z++)C=`${I}#${z}`;g[C]=x}}return o}function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function qr(e){let[,t,n]=Ur(e);if(t)return`${Or(e)}/[REDACTED]`;let r=e.indexOf("#"),s=Kt(Xt(e),Ir(wr(e))),i=Zn(r===-1?e:e.slice(0,r),s);if(r!==-1){let a=e.slice(r+1).split("#")[0];Ht.test(a)&&(i+=`#${Zn(a,s)}`)}return n===null?i:st(i,n)}function dr(e){if(e){for(let[t,n]of Object.entries(e))if(t.toLowerCase()==="content-type")return n}}var ua=[{name:"phone_us",pattern:/(?:\+\d{1,3}[ .-]?)?(?:\(\d{3}\)[ .-]?|\b\d{3}[ .-])\d{3}[ .-]\d{4}\b/g},{name:"ssn",pattern:/\b\d{3}-\d{2}-\d{4}\b/g},{name:"ipv4",pattern:/\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b/g}],Hr=["authorization","cookie","set-cookie","x-api-key","x-auth-token","proxy-authorization"];function Kr(e){return P(e,"page").join("")}var Fr=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Vr=/^eyJ[\w-]+\.[\w-]+\.[\w-]*$/,da=/(?:^|-)[A-Za-z]{3,}-(?:[A-Za-z0-9]+-)*[A-Za-z]{3,}(?:-|$)/;function Le(e){return Vr.test(e)?!0:e.length<32||Fr.test(e)||da.test(e)?!1:/^[A-Za-z0-9_\-.~+/=]+$/.test(e)&&/[0-9]/.test(e)&&/[A-Za-z]/.test(e)}var en=/@|\d[\d .()-]{5,}\d|\d\.\d|eyJ/;function fa(e){return e.split("/").some(t=>{if(/callback|oauth/i.test(t))return!0;let n=X(t);return[...n,n.join("")].some(r=>Ar.has(r))})}var pa=new Set(["code","state","accesstoken","idtoken","refreshtoken"]);function ha(e,t){let n=new Map;for(let o of e){let c=o.indexOf("=");if(c===-1)continue;let l=Kr(re(o.slice(0,c)));if(!pa.has(l))continue;let d=n.get(l),u=re(o.slice(c+1));d===void 0?n.set(l,[u]):d.push(u)}let r=o=>n.get(o)??[],s=new Set,i=r("code").filter(o=>o!==""&&!F(o)),a=r("state").filter(o=>o!==""&&!Tt(o)&&!F(o));return i.length>0&&(t||a.length>0)&&(s.add("code"),s.add("state"),s.add("sessionstate")),(r("accesstoken").length>0||r("idtoken").length>0||r("refreshtoken").length>0)&&(s.add("state"),s.add("sessionstate")),s}var W=[],B=!1,rt=!1;function jt(e,t,n){let r=rt;rt=e;try{return We(t,n)}finally{rt=r}}function ga(e,t){return e==="href"||e==="xlink:href"?t===""||t==="a"||t==="area":e==="action"||e==="formaction"}var Xr=/reset|verif|confirm|activat|invit|magic|log-?in|passw|unlock|forgot|recover|sign-?up/i;function ya(e){let t=new Set,n=e.startsWith("/")?e:`/${e}`;for(let r of Be(`https://link.invalid${n}`))t.add(r.value);return t}function ma(e){let t=T(e);return Fr.test(t)?!0:t.split(/[-_.~]+/).some(K)}function ba(e){let t=0,n=null;for(let r of W)if(!(r.length<=t||e.charAt(r.length)!=="/")){if(e.startsWith(r)){t=r.length;continue}n===null&&(n=_(e)),n.startsWith(r)&&(t=r.length)}return t}function va(e){return e.split(/[^A-Za-z0-9_\-.~+/=]+/)}function Ea(e){return Le(e)?!0:/^(?:https?:|\/)[^\s"<>\\^`{|}[\]]*$/i.test(e)?!1:va(e).some(Le)}function wa(e,t){let n=t.map(r=>{let s=r.indexOf("=");return s===-1?[r,""]:[r.slice(0,s),r.slice(s+1)]});return Kt([e.split("/").map(r=>r.split(";")[0])],Ir(n))}var Gr=new Set(["href","xlink:href","src","action","formaction","srcset","poster","cite","data","data-src","data-href","background","longdesc"]),Sa=new Set(["title","alt","placeholder","label","content","summary","abbr","aria-label","aria-description","aria-valuetext","aria-placeholder","aria-roledescription","aria-braillelabel","aria-brailleroledescription"]),Ra=new Set(["input","textarea","select"]);function ka(e,t){return e==="value"?t!==""&&!Ra.has(t):Sa.has(e)||e.startsWith("data-")&&!Gr.has(e)&&e!=="data-srcset"}var Aa=/^(\s*[\d.]*\s*[;,]\s*(?:url\s*=\s*)?)(['"]?)(.*?)(\2\s*)$/is,Ia=/[?#;@]|eyJ/;function ze(e){return Ia.test(e)||B&&Xr.test(e)}var fr=new WeakMap;function xa(e){let t=fr.get(e.pairs);return t===void 0&&(t={oauth:ha([...e.pairs],fa(e.path))},fr.set(e.pairs,t)),t}function Ta(e){return(t,n,r)=>{let s=xa(r);if(s.oauth.has(Kr(re(t)))||Ft(P(t,"page"),n)&&(s.linkPage??=wa(r.path,[...r.pairs])))return"[REDACTED]";let i=e?0:ba(n);if(i>0){let a=re(n.slice(i));if(!en.test(a)||ve(a)===a)return`[REDACTED]${n.slice(i)}`}return null}}function Zr(e){let t,n=null;return{kind:"page",strict:e,whole:!1,before:Ta(e),value:(r,s,i)=>{let a=P(r,"key");return!(!/[[\]]/.test(T(r))&&/ids?$/.test(a[0]??""))&&(Ea(i)||Le(s))||en.test(i)&&ve(i)!==i},bare:r=>Le(r)||Le(re(r)),segment:r=>Vr.test(r),head:(r,s,i,a)=>{if(!B)return!1;a!==t&&(t=a,n=Xr.test(r)?ya(r):null);let o=n;return o!==null&&o.has(s)&&(ma(s)||rt&&kr(a,i))}}}var Jr=Zr(!1),Yr=Zr(!0);function We(e,t){return ze(e)?Q(e,t?Yr:Jr):e}function Ca(e,t){if(!ze(e))return e;let n=e.split(",").map(r=>{let s=/^(\s*)(\S+)([\s\S]*)$/.exec(r);return s===null?r:s[1]+We(s[2],t)+s[3]}).join(",");return n===e?e:n}var Bt=/(?:[A-Za-z0-9_-]|[\u0080-\uffff]|\\(?:[0-9A-Fa-f]{1,6}[ \t\n]?|[^\n0-9A-Fa-f]))+/y;function _a(e,t){return Bt.lastIndex=t,Bt.test(e)?Bt.lastIndex:t}function pr(e){return e.replace(/\\(?:([0-9A-Fa-f]{1,6})[ \t\n]?|([\s\S]))/g,(t,n,r)=>{if(n===void 0)return r===`
8
- `?"":r??"";let s=parseInt(n,16);return s===0||s>1114111||s>=55296&&s<=57343?"\uFFFD":String.fromCodePoint(s)})}function Na(e,t){return e.replace(t?/[\\"'\n]/g:/[\\"'()\s]/g,n=>/\s/.test(n)?`\\${n.charCodeAt(0).toString(16)} `:`\\${n}`)}function je(e,t){if(!/url\(|["'\\]/i.test(e)||!ze(e)&&!e.includes("\\"))return e;let n=e.length,r=/[\t\n\f\r ]/,s="",i=0,a=(c,l,d)=>{let u=e.slice(c,l),p=u.includes("\\")?pr(u):u,h=We(p,t);h!==p&&(s+=e.slice(i,c)+(p===u?h:Na(h,d)),i=l)},o=0;for(;o<n;){let c=e[o];if(c==="/"&&e[o+1]==="*"){let l=e.indexOf("*/",o+2);o=l===-1?n:l+2}else if(e.startsWith("<!--",o))o+=4;else if(c==='"'||c==="'"){let l=o+1;for(;l<n&&e[l]!==c&&e[l]!==`
9
- `;)l+=e[l]==="\\"?2:1;l=Math.min(l,n),a(o+1,l,!0),o=l+1}else{let l=_a(e,o);if(l===o){o++;continue}if(e[l]!=="("||pr(e.slice(o,l)).toLowerCase()!=="url"){o=l;continue}let d=l+1;for(;d<n&&r.test(e[d]);)d++;if(e[d]==='"'||e[d]==="'"){o=d;continue}let u=d;for(;u<n&&e[u]!==")";)u+=e[u]==="\\"?2:1;u=Math.min(u,n);let p=u;for(;p>d&&r.test(e[p-1]);)p--;a(d,p,!1),o=u+1}}return i===0?e:s+e.slice(i)}var Da={Tab:" ",NewLine:`
10
- `,excl:"!",quot:'"',QUOT:'"',num:"#",dollar:"$",percnt:"%",amp:"&",AMP:"&",apos:"'",lpar:"(",rpar:")",ast:"*",midast:"*",plus:"+",comma:",",period:".",sol:"/",colon:":",semi:";",lt:"<",LT:"<",equals:"=",gt:">",GT:">",quest:"?",commat:"@",lsqb:"[",lbrack:"[",bsol:"\\",rsqb:"]",rbrack:"]",Hat:"^",lowbar:"_",UnderBar:"_",grave:"`",DiacriticalGrave:"`",lcub:"{",lbrace:"{",verbar:"|",vert:"|",VerticalLine:"|",rcub:"}",rbrace:"}",nbsp:"\xA0",NonBreakingSpace:"\xA0"};function Pa(e){return e.includes("&")?e.replace(/&(?:#(\d+);?|#[xX]([0-9A-Fa-f]+);?|([A-Za-z][A-Za-z0-9]*);|(amp|AMP|lt|LT|gt|GT|quot|QUOT)(?![A-Za-z0-9=]))/g,(t,n,r,s,i)=>{if(n!==void 0||r!==void 0){let a=n!==void 0?Number(n):parseInt(r,16);return a===0||a>1114111||a>=55296&&a<=57343?"\uFFFD":String.fromCodePoint(a)}return Da[s??i??""]??t}):e}function Oa(e,t){let n=e.replace(/&/g,"&amp;");return t==='"'?n.replace(/"/g,"&quot;"):t==="'"?n.replace(/'/g,"&#39;"):n.replace(/[\s"'`>]/g,r=>`&#${r.charCodeAt(0)};`)}var Ua=new Set(["textarea","title","xmp"]),La=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes"]),Ma=/(^|[\s/"'])(href|xlink:href|src|action|formaction|poster|cite|data|background|longdesc|data-src|data-href|srcset|imagesrcset|data-srcset|ping|content|style|srcdoc)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi;function Ba(e,t){if(!t&&!ze(e)&&!/url\(/i.test(e))return e;let n=e.length,r=/[\t\n\f\r ]/,s=[],i=new Set,a=(y,g,f,E)=>{let R=Pa(e.slice(g,f)),w=ns(y,R,t,"");w!==R&&s.push([g,f,Oa(w,E)])},o=(y,g)=>{let f=y;for(;;){for(;f<n&&(r.test(e[f])||e[f]==="/");)f++;if(f>=n||e[f]===">")return f;let E=f;for(f++;f<n&&!r.test(e[f])&&!"/>=".includes(e[f]);)f++;let R=e.slice(E,f).toLowerCase(),w=f;for(;w<n&&r.test(e[w]);)w++;if(e[w]!=="="){f=w;continue}for(w++;w<n&&r.test(e[w]);)w++;let S=e[w]==='"'||e[w]==="'"?e[w]:"",k=S===""?w:w+1,A=k;if(S!=="")A=e.indexOf(S,k),A===-1&&(A=n),f=Math.min(A+1,n);else{for(;A<n&&!r.test(e[A])&&e[A]!==">";)A++;f=A}g&&(i.add(`${k}:${A}`),a(R,k,A,S))}},c=(y,g)=>{let f=e.slice(y,g);t&&/\S/.test(f)&&s.push([y,g,f.replace(/\S/g,"*")])},l=0,d=e.indexOf("<");for(;d!==-1&&d<n;){let y,g=!0;if(e.startsWith("<!--",d))if(e.startsWith(">",d+4))y=d+5;else if(e.startsWith("->",d+4))y=d+6;else{let f=/--!?>/g;f.lastIndex=d+4;let E=f.exec(e);y=E===null?n:E.index+E[0].length}else if(e[d+1]==="!"||e[d+1]==="?"){let f=e.indexOf(">",d+2);y=f===-1?n:f+1}else if(e[d+1]==="/"&&/[A-Za-z]/.test(e[d+2]??"")){let f=d+2;for(;f<n&&!r.test(e[f])&&!"/>".includes(e[f]);)f++;y=o(f,!1)+1}else if(/[A-Za-z]/.test(e[d+1]??"")){let f=d+1;for(;f<n&&!r.test(e[f])&&!"/>".includes(e[f]);)f++;let E=e.slice(d+1,f).toLowerCase(),R=o(f,!0);if(y=R+1,La.has(E)&&R<n){let w=new RegExp(`</${E}[\\t\\n\\f\\r />]`,"gi");w.lastIndex=R+1;let S=w.exec(e),k=S===null?n:S.index;if(E==="style"){let A=e.slice(R+1,k),I=je(A,t);I!==A&&s.push([R+1,k,I])}else Ua.has(E)&&c(R+1,k);y=k}}else y=d+1,g=!1;g&&(c(l,d),l=y),d=e.indexOf("<",y)}c(l,n);let u=s.length,p=new RegExp(Ma.source,"gi"),h=0,m=0;for(let y=p.exec(e);y!==null;y=p.exec(e)){let g=y[3]??y[4]??y[5]??"",f=y.index+y[0].length-(y[5]===void 0?1:0),E=f-g.length;for(p.lastIndex=E;h<u&&s[h][1]<=E;)h++;if(i.has(`${E}:${f}`)||h<u&&s[h][0]<f||E<m)continue;let R=y[3]!==void 0?'"':y[4]!==void 0?"'":"",w=s.length;a(y[2].toLowerCase(),E,f,R),s.length>w&&(m=f)}if(s.length===0)return e;s.sort((y,g)=>y[0]-g[0]);let b="",v=0;for(let[y,g,f]of s)b+=e.slice(v,y)+f,v=g;return b+e.slice(v)}function $a(e,t){if(!ze(e))return e;let n=Aa.exec(e);if(n!==null&&n[3]!==""){let r=jt(!0,n[3],t);return r===n[3]?e:n[1]+n[2]+r+n[4]}return/^\s*https?:\/\//i.test(e)?We(e,t):e}function Qr(e,t,n=[]){let r=[W,B];W=n,B=!0;try{es(e,t)}finally{[W,B]=r}}function es(e,t,n=""){for(let r of Object.keys(e)){let s=e[r],i=r.toLowerCase();if(typeof s!="string"){i==="style"&&D(s)&&za(s,t);continue}let a=ts(i,ns(i,s,t,n),n);a!==s&&(e[r]=a)}}function za(e,t){let n=r=>ts("style",je(r,t),"");for(let r of Object.keys(e)){let s=e[r];if(typeof s=="string"){let i=n(s);i!==s&&(e[r]=i)}else if(Array.isArray(s)&&typeof s[0]=="string"){let i=n(s[0]);i!==s[0]&&(e[r]=[i,...s.slice(1)])}}}function ts(e,t,n){return e.startsWith("rr_")?t:ka(e,n)&&en.test(t)?ve(t):Ct(t)}function at(e){return Ct(e)}function ns(e,t,n,r){let s=t;return e==="srcset"||e==="data-srcset"||e==="imagesrcset"?s=Ca(t,n):e==="style"||e==="_csstext"?s=je(t,n):e==="ping"?s=t.replace(/\S+/g,i=>We(i,n)):e==="srcdoc"?s=Ba(t,n):e==="content"?s=$a(t,n):Gr.has(e)?s=jt(ga(e,r),t,n):Wa.test(t)&&(s=jt(!1,t,n)),s}var Wa=/^(?:(?:[a-z][a-z0-9+.-]{0,31}:\/|[a-z][a-z0-9-]{0,30}[+.][a-z0-9+.-]{0,30}:|localhost:\d{1,5}[/?#]|(?:mailto|tel|sms|urn|data|javascript|vbscript|blob|about|xmpp|sip|sips|magnet|intent|bitcoin|geo|market|news):|\.{0,2}\/)[^\s?#;]*[?#;]|[?#])\S*$/i;function ce(e,t,n=[]){let r=[W,B];W=n,B=!0;try{return je(e,t)}finally{[W,B]=r}}var rs=3,ss=5;function qt(e){let t=e.map(i=>i.textContent).join(""),n=_t(t).sort((i,a)=>i[0]-a[0]),r=0,s=0;for(let i of e){let a=s+i.textContent.length,o="",c=s;for(;r<n.length&&n[r][0]<a;){let[l,d]=n[r];if(l>=c&&(o+=`${t.slice(c,l)}[REDACTED]`),c=Math.max(c,Math.min(d,a)),d>a)break;r++}i.textContent=o+t.slice(c,a),s=a}}function is(e){let t=e;return t?.type===rs&&typeof t.textContent=="string"}function ja(e){let t=[];for(let n of e)is(n)?t.push(n):n?.type!==ss&&(t.length>1&&qt(t),t=[]);t.length>1&&qt(t)}function os(e){let t=new Map;for(let r of e){let s=r?.node?.type;(s===rs||s===ss)&&t.set(r.node.id,r)}let n=new Set;for(let r of t.values())n.add(t.get(r.nextId));for(let r of t.values()){if(n.has(r))continue;let s=[];for(let i=r;i;i=t.get(i.nextId))is(i.node)&&s.push(i.node);s.length>1&&qt(s)}}function tn(e,t,n=[]){let r=[W,B];W=n,B=!0;try{qa(e,t)}finally{[W,B]=r}}function qa(e,t){let n=[e],r=new Set;for(;n.length>0;){let s=n.pop();if(s===null||typeof s!="object"||r.has(s))continue;if(r.add(s),typeof s.textContent=="string"){let a=s.isStyle===!0?je(s.textContent,t):at(s.textContent);a!==s.textContent&&(s.textContent=a)}let i=s.attributes;if(i!==null&&typeof i=="object"&&es(i,t,typeof s.tagName=="string"?s.tagName.toLowerCase():""),Array.isArray(s.childNodes)){ja(s.childNodes);for(let a of s.childNodes)n.push(a)}}}function as(e,t=!1){return e&&Q(e,t?Yr:Jr)}function Ha(e,t,n){switch(e){case"location":case"content-location":return n(t);case"link":return t.replace(/<([^>]*)>/g,(r,s)=>`<${n(s)}>`);case"refresh":{let r=/^\s*(?:\d[\d.]*\s*[;,]\s*)?url\s*=\s*/i.exec(t);if(r===null)return Nt(t);let s=t.slice(r[0].length),i=/^(["'])(.*)\1$/.exec(s);return i?`${r[0]}${i[1]}${n(i[2])}${i[1]}`:`${r[0]}${n(s)}`}}return Nt(t)}var Ka=new Set(["accept","accept-encoding","accept-ranges","age","cache-control","connection","content-encoding","content-language","content-length","content-type","date","etag","expires","keep-alive","last-modified","pragma","transfer-encoding","vary"]);function Fa(e){if(e.startsWith("access-control-"))return!1;if(ie(e))return!0;let t=e.split(/[-_\s]+/).filter(s=>s!=="");t.length>1&&/^v?\d+$/.test(t[t.length-1])&&t.pop();let n=t[t.length-1]??"",r=t[t.length-2]??"";return ie(n)||r!==""&&ie(r+n)}function nn(){return{maskSelectors:[],unmaskSelectors:[],blockSelectors:[],maskNetworkBodies:!1,sensitiveHeaders:[...Hr],piiPatterns:[],secretRoutes:[],keepRoutes:[]}}function hr(e,t){let n=Object.fromEntries(Object.entries(t).filter(([,s])=>s!==void 0)),r={...e,...n};if(n.sensitiveHeaders){let s=new Set;r.sensitiveHeaders=[...Hr,...e.sensitiveHeaders,...n.sensitiveHeaders].filter(i=>{let a=i.toLowerCase();return s.has(a)?!1:(s.add(a),!0)})}return r}function $t(e){return e.map(({pattern:t})=>t.flags.includes("g")?new RegExp(t.source,t.flags):new RegExp(t.source,t.flags+"g"))}var Re=class{config;builtinPatterns;userPatterns;strict;constructor(t={},n="balanced"){this.strict=n==="strict",this.config=this.settle(hr(nn(),t)),this.builtinPatterns=$t(ua),this.userPatterns=$t(this.config.piiPatterns)}settle(t){return this.strict?{...t,maskNetworkBodies:!0}:t}maskText(t){if(!t)return t;let n=ve(t,this.userPatterns);for(let r of this.builtinPatterns)n=n.replace(r,"[REDACTED]");return n}maskUrl(t){if(!t)return t;let n=t.indexOf("#");return yo(n===-1?t:t.slice(0,n),this.strict)}maskNetworkData(t){let n={...t};if(n.requestHeaders=this.maskHeaders(t.requestHeaders),n.responseHeaders=this.maskHeaders(t.responseHeaders),this.config.maskNetworkBodies)n.requestBody=t.requestBody?"[MASKED]":null,n.responseBody=t.responseBody?"[MASKED]":null;else{let r=dr(t.requestHeaders),s=dr(t.responseHeaders);n.requestBody=Dt(t.requestBody,r,this.userPatterns),n.responseBody=Dt(t.responseBody,s,this.userPatterns)}return n.url=this.maskUrl(t.url),n}getConfig(){return this.config}updateConfig(t){this.config=this.settle(hr(this.config,t)),this.userPatterns=$t(this.config.piiPatterns)}maskHeaders(t){let n={},r=new Set(this.config.sensitiveHeaders.map(s=>s.toLowerCase()));for(let[s,i]of Object.entries(t)){let a=s.toLowerCase();r.has(a)||Fa(a)||this.strict&&!Ka.has(a)?n[s]="[REDACTED]":n[s]=this.maskText(Ha(a,i,o=>this.maskUrl(o)))}return n}};function ct(e){return"default"in e?e.default:e}var Va=/^[\t\n\r ]*\{/,cs=/[^\t\n\r ]/;function Xa(e){return Va.test(e)&&(e.includes('"query"')||e.includes("persistedQuery")||e.includes("\\u"))}function ls(e){return e==null||e===""?"":typeof e=="string"?e.length>4194304?"body:*":Xa(e)?null:"":e instanceof URLSearchParams||typeof FormData<"u"&&e instanceof FormData?"":"body:*"}var us=200,rn=/^[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*$/,qe="must be 1-200 characters of letters, digits, dot, dash and underscore, with no empty dot-separated segment";function lt(e){return typeof e=="string"&&e.length>0&&e.length<=200&&rn.test(e)}var ut=["status","serverMessage","endpoint","sessionId"],dt=["issues"],Ga="https://keploy.io/docs/ui-capture/errors#";function fs(e){let t={};for(let n of Object.keys(e)){let r=e[n],s=Ga+n.toLowerCase().replace(/_/g,"-");t[n]={summary:r.summary,remedy:{command:null,manual:s,docs:s},evidence:r.evidence,optionalEvidence:r.optionalEvidence??[]}}return t}var pt=fs({KUI_E_INGEST_KEY_REJECTED:{summary:"The ingest server refused the SDK's API key (401 or 403). Capture has stopped.",evidence:ut,optionalEvidence:dt},KUI_E_INGEST_ENDPOINT_NOT_FOUND:{summary:"The ingest server answered 404 or 405: nothing at `endpoint` accepts a POST. Capture has stopped.",evidence:ut,optionalEvidence:dt},KUI_E_SESSION_CONFLICT:{summary:"The ingest server answered 409: this session id is already claimed, or a batchId was re-used. Capture has stopped.",evidence:ut,optionalEvidence:dt},KUI_E_INGEST_REJECTED:{summary:"The ingest server refused a batch with a terminal 4xx (400, 413 or 415). Capture has stopped.",evidence:ut,optionalEvidence:dt},KUI_E_SESSION_ID_INVALID:{summary:"The configured `sessionIdGenerator` did not produce a session id the ingest server would accept. Capture did not start.",evidence:["sessionId","received","rule"]},KUI_E_DOM_RECORDER_UNAVAILABLE:{summary:"The capture SDK could not load rrweb, the library it records the page with. The capture ended before anything was sent.",evidence:["reason"]},KUI_E_PRIVACY_ROUTE_INVALID:{summary:"A route in `privacy.secretRoutes` or `privacy.keepRoutes` is not one the SDK can match. Capture did not start.",evidence:["option","received","rule"]},KUI_E_CAPTURE_DECLINED:{summary:"The browser sent Do Not Track or Global Privacy Control, and `honorPrivacySignals` is on. Capture did not start; nothing was recorded or sent.",evidence:["signal"]},KUI_E_PRIVACY_CONFLICT:{summary:'`privacyMode: "strict"` records no body, and `privacy.maskNetworkBodies` is `false`, which asks for them. Capture did not start.',evidence:["privacyMode","option"]}}),ps=fs({KUI_E_EVENT_UNSERIALISABLE:{summary:"The SDK dropped one captured event because it could not be serialised to JSON. The capture continues without it.",evidence:["eventId","eventType","reason"]},KUI_E_EVENT_OVERSIZED:{summary:"The SDK dropped one captured event that alone is over the ingest server's decoded cap (`evidence.cap` bytes). The capture continues without it.",evidence:["eventId","eventType","bytes","cap"]},KUI_E_EVENT_OVERSIZED_SCRUBBING:{summary:"The SDK dropped one captured event whose scrub of the page URL's credentials passed the ingest server's decoded cap (`evidence.cap` bytes). The capture continues without it.",evidence:["eventType","atLeast","cap"]},KUI_E_NAVIGATION_UNWRAPPED:{summary:"The page made a History or Navigation API method the SDK wraps (`evidence.method`) impossible to replace and put back, so the SDK wrapped none of them. The capture continues.",evidence:["method"]},KUI_E_REQUEST_TERM_FAILED:{summary:"The SDK recorded a request without its canonical-key.v2 term (computing it threw: `evidence.reason`), or body:* (its term code did not load). The page's request was unaffected.",evidence:["method","reason"]}});function hs(e,t){return on({code:"KUI_E_REQUEST_TERM_FAILED",method:e,reason:t},"recorded a request without its term, or body:*: computing it failed; the request itself was not affected. The capture continues; any further such requests in this capture are recorded that way, silently.")}function gs(e){return e.replace(/\s+/g," ").trim()}function sn(e,t){let{code:n,...r}=e;return`[keploy] ${n}: dropped an event: ${gs(t)} The capture continues; any further such events in this capture are dropped silently. evidence=${ys(r)}`}function on(e,t){let{code:n,...r}=e;return`[keploy] ${n}: ${gs(t)} evidence=${ys(r)}`}function ys(e){try{return JSON.stringify(e)}catch{let t={};for(let[n,r]of Object.entries(e))t[n]=typeof r=="string"||typeof r=="number"?r:j(r);return JSON.stringify(t)}}function ht(e){return e===401||e===403?"KUI_E_INGEST_KEY_REJECTED":e===404||e===405?"KUI_E_INGEST_ENDPOINT_NOT_FOUND":e===409?"KUI_E_SESSION_CONFLICT":e>=400&&e<500&&e!==429?"KUI_E_INGEST_REJECTED":null}var le={message:null,issues:null},ft=500;function gt(e){if(e===null)return le;let t=e.trim();if(t==="")return le;try{let n=JSON.parse(t);if(n!==null&&typeof n=="object"){let r=n;if(typeof r.error=="string"){let s=r.error.trim();return{message:s===""?null:s.slice(0,ft),issues:Ja(r.issues)}}}}catch{}return{message:t.slice(0,ft),issues:null}}function ms(e){if(e===null)return null;try{let n=JSON.parse(e)?.reason;return typeof n=="string"?n.slice(0,100):null}catch{return null}}var Za=100;function Ja(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(t.length===Za)break;if(n===null||typeof n!="object")continue;let{path:r,message:s}=n;typeof r!="string"||typeof s!="string"||t.push({path:r.slice(0,ft),message:s.slice(0,ft)})}return t.length>0?t:null}function j(e){if(typeof e=="string")return e;if(e instanceof Error)return`${e.name}: ${e.message}`;if(typeof e=="function")return`[function ${e.name}]`;if(typeof e!="object"||e===null)return String(e);try{return JSON.stringify(e)}catch{let t=e.constructor;return`[${typeof t?.name=="string"?t.name:"object"} not JSON-serialisable]`}}var ds=5,q=class extends Error{code;status;serverMessage;issues;remedy;evidence;constructor(t,n,r,s,i){super(n),this.name="CaptureError",this.code=t,this.remedy=pt[t].remedy,this.status=r,this.serverMessage=s.message,this.issues=s.issues,this.evidence=i}},ke=class extends q{constructor(t){let{message:n,issues:r}=t.server,s=`[keploy] capture stopped: the server rejected this batch with ${t.status} and will reject the rest, so capture has stopped (${t.code}). ${n===null?"(no response body)":n}`;if(r!==null){let i=r.slice(0,ds).map(o=>`${o.path===""?"body":o.path}: ${o.message}`).join("; "),a=r.length-ds;s+=` -- ${i}${a>0?` (+${a} more)`:""}`}super(t.code,s,t.status,t.server,{status:t.status,serverMessage:n,endpoint:t.endpoint,sessionId:t.sessionId,...r!==null?{issues:r}:{}})}},Z=class extends q{constructor(t){let n=t.sessionId!==null?`returned ${JSON.stringify(t.sessionId)}, which the ingest server would refuse`:t.received.startsWith("threw ")?t.received:`returned ${t.received}, which is not a session id`;super("KUI_E_SESSION_ID_INVALID",`[keploy] capture did not start: sessionIdGenerator ${n} (KUI_E_SESSION_ID_INVALID). A session id ${qe}.`,null,le,{sessionId:t.sessionId,received:t.received,rule:qe})}},J=class extends q{constructor(t){super("KUI_E_DOM_RECORDER_UNAVAILABLE",`[keploy] capture ended before anything was sent: rrweb, the library the SDK records the page with, could not be loaded (KUI_E_DOM_RECORDER_UNAVAILABLE): ${t.reason}. What to do: ${pt.KUI_E_DOM_RECORDER_UNAVAILABLE.remedy.docs}`,null,le,{reason:t.reason})}},Y=class extends q{constructor(t){super("KUI_E_PRIVACY_ROUTE_INVALID",`[keploy] capture did not start: privacy.${t.option} has ${t.received}, which is no route (KUI_E_PRIVACY_ROUTE_INVALID). ${Vt}.`,null,le,{option:t.option,received:t.received,rule:Vt})}},Ae=class extends q{constructor(t){super("KUI_E_CAPTURE_DECLINED",`[keploy] capture did not start: the browser sent ${t==="doNotTrack"?"Do Not Track":"Global Privacy Control"}, and honorPrivacySignals is on (KUI_E_CAPTURE_DECLINED). Nothing was recorded or sent.`,null,le,{signal:t})}},Ie=class extends q{constructor(){super("KUI_E_PRIVACY_CONFLICT",'[keploy] capture did not start: privacyMode "strict" records no request or response body, and privacy.maskNetworkBodies is false, which asks for them (KUI_E_PRIVACY_CONFLICT). Remove privacy.maskNetworkBodies, or use privacyMode "balanced".',null,le,{privacyMode:"strict",option:"privacy.maskNetworkBodies"})}};function He(e){if("threw"in e)return`threw ${j(e.threw)}`;let t=e.returned;if(typeof t=="object"&&t!==null){if(typeof t.then=="function")return"a Promise (sessionIdGenerator must return a string synchronously)";let n=t.constructor,r=typeof n?.name=="string"?n.name:"";if(r!==""&&r!=="Object")return`object ${r} ${j(t)}`}return`${typeof t} ${j(t)}`}var Ya,Qa=()=>import("@keploy/capture-sdk/request-term").then(ct),ec=Qa,tc=()=>Ya??=ec();function bs(e){try{let t=typeof document<"u"?document.baseURI:void 0;return new URL(e,t).href}catch{return e}}function vs(e){let t={};if(!e)return t;if(e instanceof Headers)e.forEach((n,r)=>{t[r]=n});else if(Array.isArray(e))for(let[n,r]of e)t[n]=r;else Object.assign(t,e);return t}function O(e,t){return e.length>t?e.slice(0,t)+N:e}function cn(e){let t=r=>encodeURIComponent(r).replace(/%20/g,"+"),n=[];return e.forEach((r,s)=>{n.push(typeof r=="string"?`${t(s)}=${t(r)}`:`${t(s)}=${t(`[File: ${r.name}, ${r.size} bytes]`)}`)}),n.join("&")}function nc(e,t){if(e==null)return null;if(typeof e=="string")return O(e,t);if(e instanceof FormData)return O(cn(e),t);if(e instanceof URLSearchParams)return O(e.toString(),t);if(typeof Blob<"u"&&e instanceof Blob)return`[Blob: ${e.size} bytes]`;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return As(e,t);if(typeof Document<"u"&&e instanceof Document)try{return O(new XMLSerializer().serializeToString(e),t)}catch{return"[Unreadable body]"}return"[Unreadable body]"}function As(e,t){let n=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(n.byteLength>t)return`[Binary: ${n.byteLength} bytes]`;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{return`[Binary: ${n.byteLength} bytes]`}}async function rc(e,t){if(e==null)return null;try{return typeof e=="string"?O(e,t):e instanceof URLSearchParams?O(e.toString(),t):e instanceof FormData?O(cn(e),t):e instanceof Blob?e.size>t?`[Blob: ${e.size} bytes, truncated]`:await e.text():e instanceof ArrayBuffer||ArrayBuffer.isView(e)?As(e,t):"[ReadableStream]"}catch{return"[Unreadable body]"}}function an(e){return typeof e=="object"&&e!==null&&e[Symbol.toStringTag]==="Request"}var sc=/^\s*multipart\/form-data\s*(?:;|$)/i;function ic(e,t){if(sc.test(e.headers.get("content-type")??""))return e.formData().then(cn);let n=e.body;if(n)return oc(n,t);let r=t*3+4;return e.blob().then(async s=>{if(s.size===0)return;let i=await Es(s.slice(0,r));return s.size>r&&/^[\t\n\r ]*(?:\{|$)/.test(i)?Es(s.slice(0,4194304*3+4)):i}).catch(()=>null)}var Is=()=>new TextDecoder("utf-8",{ignoreBOM:!0}),Es=async e=>Is().decode(await e.arrayBuffer());async function oc(e,t){let n=e.getReader(),r=Is(),s="",i="";try{for(;;){let a=await n.read();if(a.done)return s+r.decode();let o=r.decode(a.value,{stream:!0});if(i||(i=cs.exec(o)?.[0]??""),s+=o,s.length>t&&(s.length>4194304||i!==""&&i!=="{"))return n.cancel().catch(()=>{}),s}}catch{return null}}function ws(e){return e+N}function ac(e){if(cc(e)==="Uint8Array")return e;throw new TypeError("a response body chunk is not a Uint8Array")}var Ss=Reflect.get(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag)??{},"get");function cc(e){return typeof Ss=="function"?Reflect.apply(Ss,e,[]):void 0}var lc="bytes",uc=["url","redirected","type","headers"];function xs(e,t){for(let r of uc)Object.defineProperty(e,r,{get:()=>t[r],configurable:!0});let n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),"clone")?.value;n&&Object.defineProperty(e,"clone",{value:function(){let r=n.call(this);return xs(r,t),r},writable:!0,configurable:!0})}function dc(e,t,n){let r=e.body;if(!r)return null;let s=Object.getPrototypeOf(r).constructor,i=Object.getPrototypeOf(e).constructor,a=new TextDecoder,o="",c=!1,l=!1,d=!1,u=!1,p=!1,h=[],m=0,b=null,v=null,y,g=new Promise(x=>y=x),f=x=>{u||(u=!0,n(x))},E=()=>{if(!b||!v)return;let x=h.shift();if(x)v.enqueue(new Uint8Array(x.chunk)),m=x.textEnd;else if(l)v.close(),v.byobRequest?.respond(0);else return;let C=b;b=null,C()},R=()=>{p||l||d||c&&!b||(p=!0,I.read().then(x=>{if(p=!1,!d)try{if(x.done)l=!0,y(),c||f(O(o+a.decode(),t));else{let C=ac(x.value);C.byteLength>0&&(c||(o+=a.decode(C,{stream:!0}),o.length>t&&(c=!0,setTimeout(y,1e3),f(O(o,t)),o="")),h.push({chunk:C,textEnd:o.length}))}E(),R()}catch(C){w(C),I.cancel(C).catch(()=>{})}},x=>{p=!1,!d&&w(x)}))},w=x=>{d=!0,y(),f(ws(o)),h.length=0;try{v?.error(x)}catch{}let C=b;b=null,C?.()},S={start(x){v=x},pull(){return new Promise(x=>{b=x,E(),R()})},cancel(x){return d=!0,y(),f(o.slice(0,m)),h.length=0,I.cancel(x)}},k;try{k=new s({...S,type:lc},{highWaterMark:0})}catch{k=new s(S,{highWaterMark:0})}let A;try{A=new i(k,{status:e.status,statusText:e.statusText,headers:e.headers})}catch{return null}let I=r.getReader();return xs(A,e),R(),{page:A,cut:()=>{c||f(ws(o))},done:g}}function Rs(e){let t=typeof document<"u"&&document.baseURI?document.baseURI:typeof location<"u"?location.href:void 0;return new URL(e,t).href}var xe=class{callback=null;privacyEngine;maxBodySize;ignored;active=!1;inflight=new Set;unloadCuts=new Set;due=new Set;place;admit=null;run=0;originalFetch=null;originalXhrOpen=null;originalXhrSend=null;originalXhrSetHeader=null;constructor(t={},n=524288,r=[],s="balanced"){this.privacyEngine=new Re(t,s),this.maxBodySize=n,this.ignored=new Set(r.map(bs))}ignores(t){return this.ignored.size>0&&this.ignored.has(bs(t))}start(t,n,r){this.active||(this.active=!0,this.run++,this.callback=t,this.admit=n??null,this.place=r,this.termWarned=!1,this.patchFetch(),this.patchXHR())}stop(){this.active&&(this.active=!1,this.inflight.size===0&&(this.callback=null),this.restoreFetch(),this.restoreXHR())}settle(t){let n=Promise.allSettled([...this.inflight]),r,s=new Promise(i=>{r=setTimeout(i,t)});return Promise.race([n,s]).then(()=>{clearTimeout(r),!this.active&&(this.cutInflight(),this.callback=null)})}cutInflight(){for(let t of[...this.unloadCuts])t();this.reportDue()}reportDue(){for(let t of this.due)t()}hasInflight(){return this.inflight.size>0}admits(){if(!this.active)return!1;try{return this.admit?this.admit():!0}catch{return!1}}emitFor(t,n,r,s){t===this.run&&this.emit(n,r,s)}track(t){this.inflight.add(t),t.finally(()=>{this.inflight.delete(t),!this.active&&this.inflight.size===0&&(this.callback=null)})}recordResponse(t,n){let r=Number(t.headers.get("content-length")??0);if(r>this.maxBodySize)return n(`[Response body too large: ${r} bytes]`),{page:t,cut:null};if(t.body===null)return n(""),{page:t,cut:null};let s=null;if(t.body!==void 0)try{s=dc(t,this.maxBodySize,n)}catch{return n(null),{page:t,cut:null}}if(s)return s;try{t.clone().text().then(i=>n(O(i,this.maxBodySize)),()=>n(null))}catch{n(null)}return{page:t,cut:null}}patchFetch(){if(typeof globalThis.fetch!="function")return;let t=globalThis.fetch;this.originalFetch=t;let n=(r,s)=>{if(!this.active||!this.admits())return t.call(globalThis,r,s);let i;try{i=an(r)?r.url:r instanceof URL?r.href:String(r)}catch{return t.call(globalThis,r,s)}if(this.ignores(i))return t.call(globalThis,r,s);let a=r;if(an(r)&&s?.body==null)try{a=r.clone()}catch{return t.call(globalThis,r,s)}let o;try{o=new Request(a,s)}catch{return t.call(globalThis,r,s)}let c=this.run,l=performance.now(),d=o.method,u=Rs(o.url),p=vs(o.headers),h=t.call(globalThis,r,s),m=s?.body==null&&(o.body||an(r)&&o.body===void 0&&!/^(?:GET|HEAD)$/.test(d))?ic(o,this.maxBodySize):null,b=s?.body!=null?rc(s.body,this.maxBodySize):m?m.then(y=>y==null?null:O(y,this.maxBodySize),()=>"[Unreadable body]"):Promise.resolve(null),v=s?.body!=null?this.termFor(s.body,d):m?m.then(y=>y===null?"body:*":this.termFor(y,d),()=>"body:*"):this.termFor(null,d);return Promise.resolve(h).then(y=>{if(c!==this.run||!this.admits())return y;try{let g;return this.reportWhenKnown(c,Date.now(),{method:d,url:u,requestHeaders:p,requestBody:null,responseHeaders:vs(y.headers),responseBody:null,statusCode:y.status,duration:performance.now()-l,type:"fetch"},b,v,f=>g=this.recordResponse(y,f)),g.page}catch{return y}},y=>{throw c!==this.run||!this.admits()||this.reportWhenKnown(c,Date.now(),{method:d,url:u,requestHeaders:p,requestBody:null,responseHeaders:{},responseBody:null,statusCode:0,duration:performance.now()-l,type:"fetch"},b,v),y})};globalThis.fetch=n}restoreFetch(){this.originalFetch&&(globalThis.fetch=this.originalFetch,this.originalFetch=null)}patchXHR(){if(typeof XMLHttpRequest>"u")return;let t=XMLHttpRequest.prototype.open,n=XMLHttpRequest.prototype.send;this.originalXhrOpen=t,this.originalXhrSend=n;let r=this.maxBodySize,s=()=>this.admits(),i=()=>this.run,a=(p,h)=>this.termFor(p,h),o=(...p)=>this.reportWhenKnown(...p),c=p=>this.ignores(p),l=new WeakMap,d=XMLHttpRequest.prototype.setRequestHeader;this.originalXhrSetHeader=d,XMLHttpRequest.prototype.setRequestHeader=function(p,h){let m=l.get(this);return m&&(m.requestHeaders[p]=h),d.call(this,p,h)};let u=t;XMLHttpRequest.prototype.open=function(p,h,...m){let b=typeof h=="string"?h:h.toString(),v=u.call(this,p,h,...m);return c(b)||l.set(this,{method:p,url:Rs(b),requestHeaders:{},startTime:0}),v},XMLHttpRequest.prototype.send=function(p){let h=l.get(this);h&&(h.startTime=performance.now());let m=i(),b=s(),v=()=>{if(!h||!b||!s())return;let y=performance.now()-h.startTime,g=this.getAllResponseHeaders(),f={};if(g)for(let w of g.trim().split(/[\r\n]+/)){let S=w.indexOf(": ");S>0&&(f[w.slice(0,S)]=w.slice(S+2))}let E=null;try{typeof this.responseText=="string"&&(E=O(this.responseText,r))}catch{E=`[${this.responseType} response]`}let R=nc(p,r);o(m,Date.now(),{method:h.method,url:h.url,requestHeaders:h.requestHeaders,requestBody:R,responseHeaders:f,responseBody:E,statusCode:this.status,duration:y,type:"xhr"},null,a(p,h.method))};return this.addEventListener("loadend",v,{once:!0}),n.call(this,p)}}restoreXHR(){typeof XMLHttpRequest>"u"||(this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,this.originalXhrOpen=null),this.originalXhrSend&&(XMLHttpRequest.prototype.send=this.originalXhrSend,this.originalXhrSend=null),this.originalXhrSetHeader&&(XMLHttpRequest.prototype.setRequestHeader=this.originalXhrSetHeader,this.originalXhrSetHeader=null))}reportWhenKnown(t,n,r,s,i,a){let o=s?null:{value:r.requestBody},c=typeof i=="object"?null:{value:i},l=a?null:{value:r.responseBody},d,u=!1,p=()=>{},h=(v,y,g)=>{u||(u=!0,this.unloadCuts.delete(b),p(),this.emitFor(t,{...r,requestBody:v.value,responseBody:g.value,...y.value===void 0?{}:{requestTerm:y.value}},n,d?.done))},m=()=>{o&&c&&l&&h(o,c,l)},b=()=>{d?.cut?.(),h(o??{value:"[Unreadable body]"},c??{value:"body:*"},l??{value:null})};if(o&&c&&l)return m();this.unloadCuts.add(b),this.track(new Promise(v=>p=v)),s?.then(v=>{o={value:v},m()}),typeof i=="object"&&i.then(v=>{c={value:v},m()}),d=a?.(v=>{l={value:v},m()})}termWarned=!1;termFor(t,n){try{let r=ls(t);if(r!==null)return r;let s=globalThis.crypto?.subtle;return tc().then(i=>i.recordTermFor(t,s),i=>(this.termFailed(n,i),"body:*")).catch(i=>this.termFailed(n,i))}catch(r){return this.termFailed(n,r)}}termFailed(t,n){if(!this.termWarned){this.termWarned=!0;try{console.error(hs(t,j(n)))}catch{}}}emit(t,n,r){let s=this.callback;if(!s)return;let i=this.place?.(),a=()=>{if(this.due.delete(a))try{s(this.privacyEngine.maskNetworkData(t),n,i)}catch{}};this.due.add(a),this.track(Promise.resolve(r).then(()=>new Promise(o=>(typeof requestIdleCallback<"u"?requestIdleCallback:setTimeout)(o,{timeout:1e3,valueOf:()=>0})).then(a)))}};var Ts="3.1.0-rc.1";var pc="@keploy/capture-sdk",hc=Ts,Cs=3,gc=1e3,yc=2e3,mc=6e4,yt=65536;function ue(e){return new TextEncoder().encode(e).length}async function bc(e){if(typeof CompressionStream<"u"&&typeof Response<"u")try{let t=new Response(e).body.pipeThrough(new CompressionStream("gzip")),n=await new Response(t).arrayBuffer(),r=ue(e);return n.byteLength<r?{body:n,bytes:n.byteLength,encoding:"gzip"}:{body:e,bytes:r,encoding:null}}catch{}return{body:e,bytes:ue(e),encoding:null}}var vc=5e3,Te=10*1024*1024,_s=16*1024*1024,Ce=class{config;queue=[];retryQueue=[];batchCounter=0;flushTimer=null;current=null;sessionId=null;metadata=null;captureIdentity=null;get online(){return typeof navigator>"u"||navigator.onLine!==!1}started=!1;nextSeq=1;drainPending=!1;holding=!1;rushDeferred=!1;wakeSender=null;inflightKeepaliveBytes=0;envelopeBytes=0;reportedUnserialisable=!1;reportedOversized=!1;reportedScrubOversized=!1;reportedNavigationUnwrapped=!1;jsonOf=new WeakMap;inFlight=null;held=0;failures=0;notBefore=0;constructor(t){this.config={...t,batchSize:Math.min(t.batchSize,vc)}}fail(t,n,r){this.discard();let s=new ke({code:t,status:n,server:gt(r),endpoint:this.config.endpoint,sessionId:this.sessionId??null});if(this.config.endsSessionOnly?.(t,ms(r))){this.stop();try{this.config.onSessionEnd?.()}catch{}return}console.error(s.message),this.stop();try{this.config.onCaptureEnd?.()}catch{}try{this.config.onError?.(s)}catch{}}start(t,n,r=null){this.started||(this.started=!0,this.sessionId=t,this.metadata=n,this.captureIdentity=r,this.envelopeBytes=ue(JSON.stringify(this.payload([],this.mintBatchId()))),this.flushTimer=setInterval(()=>{this.paced||this.flush(this.rushDeferred&&this.online)},this.config.batchInterval),typeof window<"u"&&(window.addEventListener("online",this.handleOnline),window.addEventListener("pagehide",this.handleUnload),window.addEventListener("beforeunload",this.handleUnload),document.addEventListener("visibilitychange",this.handleVisibility)))}hold(){this.holding=!0}release(){this.holding=!1,this.flush(!0)}discard(){this.queue=[],this.retryQueue=[]}stop(){if(!this.started)return this.current??Promise.resolve();this.started=!1,this.holding&&this.discard(),this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null);let t=this.flush(!0);return typeof window<"u"&&(window.removeEventListener("online",this.handleOnline),t.finally(()=>this.disarmWhenDrained())),t}disarmWhenDrained(){this.started||this.pendingCount()>0||typeof window>"u"||(window.removeEventListener("pagehide",this.handleUnload),window.removeEventListener("beforeunload",this.handleUnload),document.removeEventListener("visibilitychange",this.handleVisibility))}enqueue(t){if(!this.started)return;t.seq??=this.nextSeq++;let n;try{let s=JSON.stringify(t),i=ue(s);this.jsonOf.set(t,[s,i]),n=this.envelopeBytes+i}catch(s){this.reportUnserialisable(t,s),this.dropped([t]);return}if(n>Te){this.reportOversized(t,n),this.dropped([t]);return}this.queue.push(t),this.held+=n;let r=[];for(;this.queue.length>this.config.maxQueueSize;)r.push(this.queue.shift());r.length>0&&this.dropped(r),this.fit(),!this.paced&&(n>yt?this.online?this.flush(!0):this.rushDeferred=!0:this.queue.length>=this.config.batchSize&&this.flush())}place(){return this.nextSeq++}get paced(){return performance.now()<this.notBefore}fit(){if(this.held<=_s)return;let t=0;for(let r of this.retryQueue)t+=r.bytes;for(let r of this.queue)t+=this.eventBytes(r);let n=[];for(;t>_s;){let r=this.retryQueue.shift();if(r)t-=r.bytes,n.push(...r.events);else{let s=this.queue.shift();t-=this.eventBytes(s),n.push(s)}}this.held=t,n.length>0&&this.dropped(n)}dropped(t){!this.online&&this.failures===0&&(this.failures=1,this.config.onFailing?.(!0));let n=1/0;for(let s of t)s.type==="dom"&&(n=Math.min(n,s.seq??-1/0));let r=!1;if(n!==1/0){let s=[];for(let i of this.queue){let a=(i.seq??-1/0)>n,o=i.type==="dom"?i.data?.type:void 0;a&&o===2&&(r=!0),a&&!r&&o===3?t.push(i):s.push(i)}this.queue=s}this.config.onDropped?.(t,r)}reportUnserialisable(t,n){if(this.reportedUnserialisable)return;this.reportedUnserialisable=!0;let r=n instanceof Error?n.message:String(n);console.error(sn({code:"KUI_E_EVENT_UNSERIALISABLE",eventId:t.id,eventType:t.type,reason:r},"it cannot be serialised to JSON."))}reportOversized(t,n){this.reportedOversized||(this.reportedOversized=!0,this.warnOversized({code:"KUI_E_EVENT_OVERSIZED",eventId:t.id,eventType:t.type,bytes:n,cap:Te},`${n} bytes in a body, over the ingest server's ${Te}-byte cap, so no batch could carry it.`))}reportScrubOversized(t,n,r){this.reportedScrubOversized||(this.reportedScrubOversized=!0,this.warnOversized({code:"KUI_E_EVENT_OVERSIZED_SCRUBBING",eventType:t,atLeast:n,cap:r},`scrubbing the page URL's credentials out of it was certain to write at least ${n} characters, over the ingest server's ${r}-byte cap, so no batch could carry it.`))}reportNavigationUnwrapped(t){this.reportedNavigationUnwrapped||(this.reportedNavigationUnwrapped=!0,this.warn(on({code:"KUI_E_NAVIGATION_UNWRAPPED",method:t},"the page made a History or Navigation API method impossible to replace and put back, so the SDK wrapped none of them. The capture continues: route changes are still recorded, with less detail, and none says that the page's script asked for it.")))}warnOversized(t,n){this.warn(sn(t,n))}warn(t){console.error(t)}payload(t,n){return{sessionId:this.sessionId,batchId:n,events:t,metadata:this.metadata,sdk:{name:pc,version:hc},captureIdentity:this.captureIdentity}}flush(t=!1){return this.holding?Promise.resolve():(t&&(this.drainPending=!0),this.current?this.current:this.pendingCount()===0||!this.online&&!this.drainPending?(this.drainPending=!1,this.failures>0&&this.pendingCount()===0&&this.online&&(this.failures=this.notBefore=0,this.config.onFailing?.(!1)),Promise.resolve()):(this.current=this.run(),this.current))}async run(){try{do{let t=this.reviveNext()??this.formFlight();if(t===null)return;this.inFlight=t;try{await this.sendWithRetry(t)}catch{this.notBefore=performance.now()+Math.min(yc*2**this.failures,mc)*(1+Math.random()/2),this.failures++===0&&this.config.onFailing?.(!0),this.held+=t.bytes,this.retryQueue.unshift(t),this.trimToCapacity();return}finally{this.inFlight===t&&(this.inFlight=null)}}while(this.drainPending&&this.pendingCount()>0)}finally{this.drainPending=!1,this.pendingCount()===0&&(this.rushDeferred=!1),this.current=null,this.disarmWhenDrained()}}backoff(t){return new Promise(n=>{let r=()=>{clearTimeout(s),this.wakeSender===r&&(this.wakeSender=null),n()},s=setTimeout(r,t);this.wakeSender=r})}async sendWithRetry(t){let n=t.json,r=t.wire??=bc(n);for(let s=0;s<Cs;s++){if(t.abandoned)return;try{let{body:a,bytes:o,encoding:c}=await r;if(t.abandoned)return;let l={"Content-Type":"application/json","X-API-Key":this.config.apiKey};c&&(l["Content-Encoding"]=c);let d=o<=yt;d&&(this.inflightKeepaliveBytes+=o);let u,p;t.onWire=!0,t.dispatched=!0;try{u=await fetch(this.config.endpoint,{method:"POST",headers:l,body:a,keepalive:d});try{p=await u.text()}catch{p=null}}finally{t.onWire=!1,d&&(this.inflightKeepaliveBytes-=o)}if(u.ok){this.failures>0&&(this.failures=this.notBefore=0,this.drainPending=!0,this.config.onFailing?.(!1)),this.config.onDelivered?.(t.events);return}let h=ht(u.status);if(h!==null){this.fail(h,u.status,p);return}}catch{}if(this.failures>0||s===Cs-1)break;let i=gc*Math.pow(2,s)*(.5+Math.random()*.5);await this.backoff(i)}throw new Error("Transport: all retry attempts failed")}reclaimInFlight(){let t=this.inFlight;if(!(!t||t.onWire||t.abandoned)){if(t.abandoned=!0,this.inFlight=null,this.held+=t.bytes,t.dispatched){this.retryQueue.unshift(t),this.trimToCapacity();return}this.queue.unshift(...t.events),this.trimToCapacity()}}reviveNext(){let t=this.retryQueue.shift();return t?{events:t.events,batchId:t.batchId,json:t.json,bytes:t.bytes,wire:t.wire,dispatched:t.dispatched,onWire:!1,abandoned:!1}:null}formFlight(){if(this.queue.length===0)return null;let t=this.envelopeBytes,n=0,r=Math.min(this.config.batchSize,this.queue.length);for(;n<r;){let o=this.eventBytes(this.queue[n])+(n===0?0:1);if(t+o>Te)break;t+=o,n++}let s=this.queue.splice(0,Math.max(n,1)),i=this.mintBatchId(),a=this.body(s,i);for(let o of s)this.jsonOf.delete(o);return{events:s,batchId:i,json:a,dispatched:!1,onWire:!1,abandoned:!1,bytes:t}}body(t,n){return JSON.stringify(this.payload([],n)).replace('"events":[]',()=>`"events":[${t.map(r=>this.jsonOf.get(r)?.[0]??JSON.stringify(r)).join()}]`)}eventBytes(t){return this.jsonOf.get(t)?.[1]??ue(JSON.stringify(t))}mintBatchId(){let t=typeof crypto<"u"?crypto:void 0;if(t&&typeof t.randomUUID=="function")return t.randomUUID();this.batchCounter+=1;let n=Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0");return`${Date.now().toString(16).padStart(12,"0")}-${(this.batchCounter%4294967296).toString(16).padStart(8,"0")}-`+n}pendingCount(){let t=this.queue.length;for(let n of this.retryQueue)t+=n.events.length;return t}trimToCapacity(){let t=0;for(let r of this.retryQueue)t+=r.events.length;let n=[];for(;this.queue.length>0&&t+this.queue.length>this.config.maxQueueSize;)n.push(this.queue.pop());n.length>0&&this.dropped(n.reverse()),this.fit()}flushOnUnload(){if(this.holding||(this.reclaimInFlight(),this.queue.sort((a,o)=>a.seq-o.seq),typeof fetch!="function"))return;for(;this.retryQueue.length>0;){let a=this.retryQueue[0],o=ue(a.json);if(o>yt-this.inflightKeepaliveBytes)return;this.retryQueue.shift(),a.dispatched=!0,this.postKeepalive(a.json,o)}if(this.queue.length===0)return;let t=yt-this.inflightKeepaliveBytes,n=this.mintBatchId(),r=this.envelopeBytes,s=0;for(let a of this.queue){let o=this.eventBytes(a)+(s===0?0:1);if(r+o>t)break;r+=o,s++}if(s===0)return;let i=this.body(this.queue.splice(0,s),n);this.postKeepalive(i,ue(i))}postKeepalive(t,n){try{this.inflightKeepaliveBytes+=n,fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:t,keepalive:!0}).then(r=>r.arrayBuffer()).catch(()=>{}).finally(()=>{this.inflightKeepaliveBytes-=n})}catch{this.inflightKeepaliveBytes-=n}}handleOnline=()=>{this.wakeSender?.(),this.flush(this.rushDeferred)};handleUnload=t=>{if(t.type==="pagehide")try{this.config.beforeUnloadFlush?.()}catch{}this.flushOnUnload(),this.disarmWhenDrained()};handleVisibility=()=>{document.visibilityState==="hidden"&&(this.config.beforeHiddenFlush?.(),this.flush(!0))};get queueSize(){return this.pendingCount()}};function Ns(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Ec(e){let t=typeof window<"u"?window:void 0,n=t?.location?.href??"",r=n===""?null:Ke(n);return{url:ot(e(n),r),userAgent:typeof navigator<"u"?navigator.userAgent:"",viewport:{width:t?.innerWidth??0,height:t?.innerHeight??0},referrer:typeof document<"u"&&document.referrer?ot(e(document.referrer),r):"",language:typeof navigator<"u"?navigator.language:"",devicePixelRatio:t?.devicePixelRatio??1,timestamp:Date.now()}}var mt=null,pn=!1;function wc(){try{return!!navigator.serviceWorker?.controller}catch{return!1}}function Ds(){return mt||(mt=import("rrweb").then(e=>(pn=!0,{record:ct(e).record}),e=>(mt=null,{failed:j(e)}))),mt}var ln=4,Ps=5e3,Sc=6e4,Rc=1e3;function kc(){let e=document.documentElement;return{width:window.innerWidth||e?.clientWidth||document.body?.clientWidth||0,height:window.innerHeight||e?.clientHeight||document.body?.clientHeight||0}}function Os(e){return e.split("#").map(t=>{let n=t.indexOf("?");return n===-1?t:t.slice(0,n)}).join("#")}var Ac=256,Ic=64*1024,de=new Map,un="",dn=-1,Us=null;function Ls(e){return e.kind===2?`2${e.before}/${e.value}`:`${e.kind}${e.value}`}function fn(e){let t=!1;for(let s=e.length-1;s>=0;s--){let i=Ls(e[s]);de.delete(i)||(t=!0),de.set(i,e[s])}let n=new Set(e.map(Ls)),r=0;for(let s of de.keys())r+=s.length;for(let s of de.keys()){if(n.has(s)||de.size<=Ac&&r<=Ic)break;de.delete(s),r-=s.length,t=!0}return t}var xc=64,Tc=512*1024,fe=new Set;function Cc(e){fe.delete(e),fe.add(e);let t=0;for(let n of fe)t+=n.length;for(let n of fe){if(n===e||fe.size<=xc&&t<=Tc)break;fe.delete(n),t-=n.length}}function Ke(e){let t=Cr();if(e!==un||t!==dn){let n=!1;if(un===""||t!==dn){let r=globalThis.performance?.getEntriesByType?.("navigation");r?.[0]&&(n=fn(Be(r[0].name)));for(let s of fe)fn(Be(s))&&(n=!0)}un=e,dn=t,Cc(e),(fn(Be(e))||n)&&(Us=Qt([...de.values()]))}return Us}var vt=new Set,U=null,pe=null,Et=null,$=[],gn=null,he=null,ne=new Map,bt=!1;function Ms(e){let t=e,n=t.destination?.url;Et=typeof n=="string"&&typeof t.userInitiated=="boolean"?{href:n,userInitiated:t.userInitiated}:null;let r=t.destination?.key;if(t.navigationType!=="replace"){if(t.navigationType==="traverse"&&typeof r=="string"){let s=$[0]===r&&t.userInitiated===!1;s||r===he?ne.set(r,(ne.get(r)??0)+1):ne.delete(r),$=s?$.slice(1):[],he=null}else{let s=[];if(t.navigationType==="push")try{let i=e.currentTarget;s=i.entries().slice(0,i.currentEntry.index).map(a=>a.key)}catch{}$=$.filter(i=>s.includes(i)),gn=null,(t.userInitiated!==!0||!s.includes(he))&&(he=null),ne.clear()}bt=!1}}function _e(e,t,n){if(typeof t=="object"||typeof t=="function")return null;let r=e;try{let s=Number(t)|0,i=r?.entries()??[],a=n===null?Number(r?.currentEntry?.index):i.findIndex(o=>o.key===n);return a<0?null:i[a+s]?.key??null}catch{return null}}function _c(e,t){return function(...n){if(bt)return Reflect.apply(e,this,n);let{next:r,now:s}=t(n);he=s,s!==null&&r!==null&&(gn=r,r!==_e(U?.navigation??null,0,null)&&$.push(r)),bt=!0;try{return Reflect.apply(e,this,n)}catch(i){throw $=[],he=null,i}finally{bt=!1}}}function Nc(e){let t=e?.currentEntry?.key;if(typeof t!="string")return;for(;$[0]===t;)$.shift();let n=ne.get(t)??0;return n>1?ne.set(t,n-1):ne.delete(t),n?"script":void 0}function Dc(){let e=Et;return Et=null,e!==null&&e.href===location.href?e.userInitiated:void 0}function Pc(e,t){return e!==t&&e.split("#")[0]===t.split("#")[0]}function Bs(e){let t=e,n=t.navigationType,r=Dc(),s=Nc(U?.navigation??null);if(n==="traverse")wt("traverse",r,s);else if(n==="push"||n==="replace"){let i=typeof t.from?.url=="string"?t.from.url:"";wt(pe??(Pc(i,location.href)?"hash":n),r)}}function hn(){let e=Reflect.get(window,"event")?.type;return e==="popstate"||e==="hashchange"?"traverse":"push"}function wt(e,t,n){Ke(location.href);for(let r of vt)try{r(e,t,n)}catch{}}function Oc(){if(U)return;let e=window.history,t=e.pushState,n=e.replaceState,r=function(...u){let p=location.href,h=pe;pe="push";try{t.apply(this,u)}finally{pe=h}wt(location.href===p?hn():"push")},s=function(...u){let p=location.href,h=pe;pe="replace";try{n.apply(this,u)}finally{pe=h}wt(location.href===p?hn():"replace")},i=Reflect.get(window,"navigation")??null;i?.addEventListener("currententrychange",Bs,{capture:!0}),i?.addEventListener("navigate",Ms,{capture:!0});let a=u=>p=>{let h=u(p);return{next:_e(i,h,$.length?gn:null),now:_e(i,h,null)}},o=u=>p=>{let h=u(p);return{next:h,now:h}},c=[[e,"back",a(()=>-1)],[e,"forward",a(()=>1)],[e,"go",a(u=>u[0])],[i,"back",o(()=>_e(i,-1,null))],[i,"forward",o(()=>_e(i,1,null))],[i,"traverseTo",o(u=>typeof u[0]=="string"?_e(i,0,u[0]):null)]],l=[[e,"pushState",r],[e,"replaceState",s]];for(let[u,p,h]of c){let m=u&&Reflect.get(u,p);typeof m=="function"&&l.push([u,p,_c(m,h)])}let d=l.find(([u,p])=>!Uc(u,p));U={navigation:i,methods:d?[]:l.map(([u,p,h])=>Lc(u,p,h)),refused:d?`${d[0]===e?"history":"navigation"}.${d[1]}`:null}}function Uc(e,t){let n=Object.getOwnPropertyDescriptor(e,t);return n===void 0?Object.isExtensible(e):n.configurable===!0||n.writable===!0}function Lc(e,t,n){let r=Object.getOwnPropertyDescriptor(e,t);return Object.defineProperty(e,t,r?.configurable===!1?{value:n}:{value:n,writable:!0,enumerable:r?.enumerable??!0,configurable:!0}),[e,t,r,Object.getOwnPropertyDescriptor(e,t)]}function Mc([e,t,,n]){let r=Object.getOwnPropertyDescriptor(e,t);return r!==void 0&&r.value===n.value&&r.configurable===n.configurable&&(r.configurable===!0||r.writable===!0)}function Bc([e,t,n]){n?Object.defineProperty(e,t,n):Reflect.deleteProperty(e,t)}function $c(){if(!(!U||vt.size>0)&&U.methods.every(Mc)){for(let e of U.methods)Bc(e);U.navigation?.removeEventListener("currententrychange",Bs,{capture:!0}),U.navigation?.removeEventListener("navigate",Ms,{capture:!0}),Et=null,$=[],he=null,ne.clear(),U=null}}function $s(){return zs(()=>{})}function zs(e){if(typeof window>"u"||!window.history)return()=>{};vt.add(e),Oc();let t=()=>{Ke(location.href),e("traverse")};return window.addEventListener("popstate",t,{capture:!0}),window.addEventListener("hashchange",t,{capture:!0}),()=>{vt.delete(e),window.removeEventListener("popstate",t,{capture:!0}),window.removeEventListener("hashchange",t,{capture:!0}),$c()}}var Ne=class{phase="idle";userPaused=!1;hidden=!1;droppedWhileShut=!1;baselineLost=!1;retakeTimer=null;retakeAtOnce=!1;retakeDelay=Ps;outage=!1;failing(t){this.outage=t,this.retakeTimer!==null&&clearTimeout(this.retakeTimer),this.retakeTimer=null,!t&&this.baselineLost&&this.rebaseline(!1)}lost(t,n){n||!t.some(r=>r.type==="dom")||(this.baselineLost=!0,this.rebaseline(t.some(r=>r.type==="dom"&&r.data?.type===2)))}rebaseline(t){if(this.outage)return;if(this.retakeTimer!==null){if(!t||!this.retakeAtOnce)return;clearTimeout(this.retakeTimer)}this.retakeAtOnce=!t;let n=t?this.retakeDelay:0;t&&(this.retakeDelay=Math.min(this.retakeDelay*2,Sc)),this.retakeTimer=setTimeout(()=>{if(this.retakeTimer=null,!this.baselineLost||this.getState()!=="recording")return;let r=this.rrwebRecord?.takeFullSnapshot;if(r){this.droppedWhileShut=!1;try{r.call(this.rrwebRecord)}catch{this.droppedWhileShut=!0}}},n)}delivered(t){t.some(n=>n.type==="dom"&&n.data?.type===2)&&(this.retakeDelay=Ps)}styles=new it({note:t=>{let n=this.rrwebRecord?.mirror?.getNode(t);n&&this.styleNodes.set(t,n)},present:t=>this.inPage(t),forget:t=>{this.styleNodes.delete(t)}});styleNodes=new Map;sessionId=null;metadata=null;config;onEvent=null;onSessionEnd=null;onScrubOversized=null;onRRWeb=null;onlineRetry=null;onlinePoll=null;rrwebStopFn=null;rrwebRecord=null;rrwebRequested=!1;generation=0;sessionTimer=null;visibilityHandler=null;stopNavigation=null;lastHref="";seenHref="";constructor(t){this.config=t}async start(t,n=null,r=!1,s=null,i=null,a=null){if(this.phase==="active")return this.sessionId;this.phase==="stopping"&&this.stop();let o={secretRoutes:[],keepRoutes:[]};for(let h of["secretRoutes","keepRoutes"]){let m=this.config.privacy?.[h]??[];if(!Array.isArray(m))throw this.phase="stopped",new Y({option:h,received:He({returned:m})});for(let b of m){let v=xr(b,h==="keepRoutes");if(v===null)throw this.phase="stopped",new Y({option:h,received:He({returned:b})});o[h].push(v)}}_r(o.secretRoutes,o.keepRoutes);let c=this.config.sampleRate??1;if(Math.random()>c)return this.phase="stopped","";this.onEvent=t,this.onSessionEnd=n,this.onScrubOversized=s,this.onRRWeb=i;let l;try{l=this.config.sessionIdGenerator?this.config.sessionIdGenerator():Ns()}catch(h){throw this.phase="stopped",new Z({sessionId:null,received:He({threw:h})})}if(!lt(l))throw this.phase="stopped",new Z({sessionId:typeof l=="string"?l:null,received:He({returned:l})});this.sessionId=l,this.metadata=Ec(this.scrubUrl),this.phase="active",this.userPaused=r,this.droppedWhileShut=!1,this.hidden=typeof document<"u"&&document.visibilityState==="hidden",this.rrwebRequested=!1;let d=++this.generation;typeof document<"u"&&(this.visibilityHandler=()=>{this.hidden=document.visibilityState==="hidden",this.getState()==="recording"&&this.openDomGate()},document.addEventListener("visibilitychange",this.visibilityHandler)),this.seenHref=typeof location<"u"?location.href:"",this.lastHref=typeof location<"u"?this.scrubUrl(location.href):"",this.stopNavigation=zs((h,m,b)=>this.navigated(h,m,b));let u=await this.startRRWeb();if(d!==this.generation||this.phase!=="active")return"";if(u!==null&&typeof window<"u")throw this.stop(),new J({reason:u});let p=this.config.maxSessionDuration??6e5;return this.sessionTimer=setTimeout(()=>{this.onSessionEnd?.(),this.stop()},p),U?.refused&&a?.(U.refused),this.sessionId}stopDom(){this.phase==="active"&&(this.phase="stopping"),this.rrwebStopFn&&(this.rrwebStopFn(),this.rrwebStopFn=null),this.sessionTimer&&(clearTimeout(this.sessionTimer),this.sessionTimer=null)}stop(){this.phase!=="active"&&this.phase!=="stopping"||(this.onlineRetry!==null&&(window.removeEventListener("online",this.onlineRetry),this.onlineRetry=null,this.stopOnlinePoll()),this.stopDom(),this.rrwebRecord=null,this.retakeTimer&&(clearTimeout(this.retakeTimer),this.retakeTimer=null),this.visibilityHandler&&typeof document<"u"&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null),this.stopNavigation?.(),this.stopNavigation=null,this.phase="stopped")}navigated(t,n,r){if(this.phase!=="active")return;this.seenHref=location.href;let s=this.scrubUrl(location.href);Os(s)!==Os(this.lastHref)&&(this.lastHref=s,this.emitEvent("dom",{type:ln,data:{href:s,...kc(),cause:t,...n===void 0?{}:{userInitiated:n},...r===void 0?{}:{initiator:r}},timestamp:Date.now()}))}recordedRRWebEvent(t){if(typeof t!="object"||t===null)return t;let n=t,r=n.data?.href;return n.type!==ln||typeof r!="string"?t:(this.lastHref=this.scrubUrl(r),{...n,data:{...n.data,href:this.lastHref}})}isUserPaused(){return this.userPaused}pause(){this.phase==="active"&&(this.userPaused=!0)}resume(){this.phase==="active"&&(this.userPaused=!1,this.getState()==="recording"&&this.openDomGate())}openDomGate(){if(!this.rrwebStopFn){this.droppedWhileShut=!1;let n=this.generation;this.startRRWeb().then(r=>{r!==null?this.refuseLate(n,r):this.landedBeforeTheRetry(n)});return}if(!this.droppedWhileShut&&!this.baselineLost)return;let t=this.rrwebRecord?.takeFullSnapshot;if(t){if(this.outage){this.baselineLost=!0;return}this.droppedWhileShut=!1;try{t.call(this.rrwebRecord)}catch{this.droppedWhileShut=!0}}}getSessionId(){return this.phase==="active"?this.sessionId:null}get sessionOpen(){return this.phase==="active"&&!this.userPaused}getState(){return this.phase==="idle"?"idle":this.phase==="stopped"||this.phase==="stopping"?"stopped":this.userPaused||this.hidden?"paused":"recording"}getMetadata(){return this.metadata}async startRRWeb(){if(this.rrwebRequested)return null;this.rrwebRequested=!0;let t=this.generation;if(!pn&&typeof window<"u"&&navigator.onLine===!1&&!wc())return this.rrwebRequested=!1,this.retryWhenOnline(t),null;let n=await Ds();if(t!==this.generation)return null;if("failed"in n)return this.rrwebRequested=!1,n.failed;let r=n.record;return this.getState()!=="recording"?(this.rrwebRequested=!1,null):(this.rrwebRecord=r,this.rrwebStopFn=r(this.rrwebOptions())??null,null)}retryWhenOnline(t){if(this.onlineRetry!==null)return;let n=()=>{if(window.removeEventListener("online",n),this.stopOnlinePoll(),this.onlineRetry=null,!(t!==this.generation||this.phase!=="active")){if(navigator.onLine===!1){this.retryWhenOnline(t);return}Ds().then(r=>{if(!(t!==this.generation||this.phase!=="active")){if("failed"in r){this.refuseLate(t,r.failed);return}this.startRRWeb(),this.onRRWeb?.(null)}})}};this.onlineRetry=n,window.addEventListener("online",n,{once:!0}),this.onlinePoll=setInterval(()=>{navigator.onLine!==!1&&n()},Rc)}stopOnlinePoll(){this.onlinePoll!==null&&(clearInterval(this.onlinePoll),this.onlinePoll=null)}refuseLate(t,n){t!==this.generation||this.phase!=="active"||(this.stop(),this.onRRWeb?.(new J({reason:n})))}landedBeforeTheRetry(t){t!==this.generation||this.phase!=="active"||!pn||this.onlineRetry===null||(window.removeEventListener("online",this.onlineRetry),this.onlineRetry=null,this.stopOnlinePoll(),this.onRRWeb?.(null))}awaitingRRWeb(){return this.onlineRetry!==null}rrwebOptions(){let t=this.config.privacyMode??"balanced",n=this.config.privacy??{},r=[...this.config.maskSelectors??[],...n.maskSelectors??[]],s=[...this.config.unmaskSelectors??[],...n.unmaskSelectors??[]],i=t!=="off",a={color:i,date:i,"datetime-local":i,email:i,file:i,month:i,number:i,range:i,search:i,tel:i,text:i,time:i,url:i,week:i,textarea:i,select:i,password:!0,hidden:!0},o='[contenteditable]:not([contenteditable="false"])',c=i?[o]:[],l=[...r,...c].join(","),d=s.join(","),u=d?(p,h)=>{try{if(i&&h?.closest(o))return p.replace(/[\S]/g,"*");if(h?.closest(d))return p}catch{}return p.replace(/[\S]/g,"*")}:void 0;return{emit:p=>this.emitEvent("dom",p,h=>this.recordedRRWebEvent(h)),maskTextSelector:t==="strict"?"*":l||void 0,...u?{maskTextFn:u}:{},blockSelector:n.blockSelectors?.join(",")||void 0,maskInputOptions:a,userTriggeredOnInput:!0}}inPage(t){let n=this.rrwebRecord?.mirror;if(n===void 0)return!0;let r=this.styleNodes.get(t)??n.getNode(t);if(!r||!r.isConnected)return!1;for(let s=r.ownerDocument;s!==null&&s!==document;){let i=s.defaultView?.frameElement??null;if(i===null||!i.isConnected)return!1;s=i.ownerDocument}return!0}noticeUnheardMove(t){if(!(typeof location>"u"||location.href===this.seenHref)){if(t?.type===ln){this.seenHref=location.href;return}this.navigated(hn())}}scrubUrl=t=>as(qr(t),(this.config.privacyMode??"balanced")==="strict");scrubDomUrls(t,n){let r=t;if(r===null||typeof r!="object")return t;let s=r.data;if(s===null||typeof s!="object")return t;let i=(this.config.privacyMode??"balanced")==="strict",a=n===null?[]:[...n.plain,...n.bounded];if(r.type===2&&tn(s.node,i,a),r.type===3&&s.source===0){if(Array.isArray(s.adds)){os(s.adds);for(let o of s.adds)o!==null&&typeof o=="object"&&tn(o.node,i,a)}if(Array.isArray(s.attributes))for(let o of s.attributes){let c=o?.attributes;c!==null&&typeof c=="object"&&Qr(c,i,a)}if(Array.isArray(s.texts)){let o=this.styles.recordsIn(r);for(let c of s.texts)typeof c?.value=="string"&&(c.value=o.has(c)?ce(c.value,i,a):at(c.value))}}if(r.type===3&&(s.source===8||s.source===15)){let o=[...Array.isArray(s.adds)?s.adds:[],...Array.isArray(s.styles)?s.styles.flatMap(c=>Array.isArray(c?.rules)?c.rules:[]):[]];for(let c of o)c!==null&&typeof c?.rule=="string"&&(c.rule=ce(c.rule,i,a));typeof s.replace=="string"&&(s.replace=ce(s.replace,i,a)),typeof s.replaceSync=="string"&&(s.replaceSync=ce(s.replaceSync,i,a))}if(r.type===3&&s.source===5&&typeof s.text=="string"&&(s.text=at(s.text)),r.type===3&&s.source===9&&typeof s.fontSource=="string"&&(s.fontSource=ce(s.fontSource,i,a)),r.type===3&&s.source===13){let o=s.set;o!==null&&typeof o?.value=="string"&&(o.value=ce(o.value,i,a))}return t}acceptsNetwork(){return this.sessionOpen}emitEvent(t,n,r,s=!1,i,a){if(t==="dom"&&this.phase==="active"&&this.getState()!=="recording"&&(this.droppedWhileShut=!0),(s?this.phase!=="active"&&this.phase!=="stopping":!this.sessionOpen)||t==="dom"&&this.hidden||!this.onEvent||!this.sessionId)return;this.noticeUnheardMove(t==="dom"?n:null);let o=r?r(n):n,c=t==="dom"&&o!==null&&typeof o=="object"?o.type:void 0;if(this.baselineLost&&c===3)return;let l=o;if(typeof location<"u")try{t==="dom"&&(l=this.scrubDomUrls(o,Ke(location.href))),l=ot(l,Ke(location.href),t,this.styles,Te)}catch(u){t==="dom"&&(this.baselineLost=!0,this.rebaseline(c===2)),u instanceof Se&&this.onScrubOversized?.(t,u.atLeast,u.cap);return}c===2&&(this.baselineLost=!1,this.retakeTimer!==null&&(clearTimeout(this.retakeTimer),this.retakeTimer=null));let d={id:Ns(),sessionId:this.sessionId,timestamp:i??Date.now(),type:t,data:l,seq:a};this.onEvent(d)}};function yn(){let e=typeof crypto<"u"?crypto:void 0;if(!e||typeof e.getRandomValues!="function")return null;let t=new Uint8Array(16);e.getRandomValues(t);let n="";for(let r of t)n+=r.toString(16).padStart(2,"0");return n}function mn(){if(typeof window>"u"||!window.location)return null;let e=window.location.origin;return typeof e!="string"||e===""||e==="null"?null:e}var De=class{captureId;nonce;t0WallMs;origins;constructor(t,n=Date.now()){this.captureId=t,this.nonce=yn(),this.t0WallMs=n;let r=mn();this.origins=r===null?[]:[r]}build(){return this.nonce===null?{refusal:"no-csprng"}:{identity:{captureId:this.captureId,sessionNonce:this.nonce,t0WallMs:this.t0WallMs,appOrigins:[...this.origins]}}}};var zc=1e4,Ws=!1;function Wc(){try{if(typeof navigator>"u")return null;let e=navigator;if(e.globalPrivacyControl===!0)return"globalPrivacyControl";if(e.doNotTrack==="1"||e.doNotTrack==="yes"||typeof window<"u"&&window.doNotTrack==="1"||e.msDoNotTrack==="1")return"doNotTrack"}catch{}return null}var bn=class e{static instance=null;recorder;network;transport;config;started=!1;identity=null;constructor(t){this.config=t,this.recorder=new Ne(t),this.network=new xe(t.privacy??{},t.maxBodySize??524288,[t.endpoint],t.privacyMode);let n={endpoint:t.endpoint,apiKey:t.apiKey,batchSize:t.batchSize??50,batchInterval:t.batchInterval??5e3,maxQueueSize:t.maxQueueSize??5e3,...t.onError!==void 0?{onError:t.onError}:{},onCaptureEnd:()=>this.endCapture(),endsSessionOnly:(r,s)=>t.continuous===!0&&t.sessionIdGenerator===void 0&&(r==="KUI_E_SESSION_CONFLICT"&&s==="session_completed"||r==="KUI_E_INGEST_REJECTED"&&s==="session_full"),onSessionEnd:()=>this.endSession(),onDropped:(r,s)=>this.recorder.lost(r,s),onDelivered:r=>this.recorder.delivered(r),onFailing:r=>this.recorder.failing(r),beforeUnloadFlush:()=>this.network.cutInflight(),beforeHiddenFlush:()=>this.network.reportDue()};this.transport=new Ce(n)}static async init(t){if(e.instance)return e.instance;let n=e.nextSessionPaused;return e.cancelNextSession(),e.nextSessionPaused=!1,e.begin(t,n)}static async begin(t,n){let r=new e(t);e.instance=r;try{await r.start(n)}catch(s){throw e.instance===r&&(e.instance=null),s}return r}static stop(){e.cancelNextSession(),e.nextSessionPaused=!1;let t=e.instance;e.instance=null;let n=Promise.all(e.ending),r=new Promise(s=>{let i=setTimeout(s,zc);n.then(()=>{clearTimeout(i),s()})});return Promise.all([t?t.stop():void 0,r]).then(()=>{})}static pause(){e.instance?.pause(),e.instance===null&&e.restartPending&&(e.nextSessionPaused=!0)}static resume(){e.instance?.resume(),e.nextSessionPaused=!1}static getSessionId(){return e.instance?.recorder.getSessionId()??""}static getInstance(){return e.instance}static getCaptureIdentity(){let t=e.instance?.identity;return t?t.build():null}async start(t){if(this.started)return;if(this.started=!0,this.config.privacyMode==="strict"&&this.config.privacy?.maskNetworkBodies===!1){this.refuse(new Ie);return}let n=this.config.honorPrivacySignals!==!1?Wc():null;if(n!==null){this.decline(new Ae(n));return}let r=[],s=l=>{r?r.push(l):this.transport.enqueue(l)},i;try{i=await this.recorder.start(s,()=>this.config.continuous===!0&&this.config.sessionIdGenerator===void 0?this.endSession():this.endCapture(),t,(l,d,u)=>this.transport.reportScrubOversized(l,d,u),l=>{l===null?this.transport.release():this.refuse(l)},l=>this.transport.reportNavigationUnwrapped(l))}catch(l){if(!(l instanceof Z||l instanceof J||l instanceof Y))throw l;this.refuse(l);return}if(!i){this.started=!1;return}let a=this.recorder.getMetadata();this.identity=new De(i);let o=this.identity.build();this.recorder.awaitingRRWeb()&&this.transport.hold(),this.transport.start(i,a,"identity"in o?o.identity:null);let c=r;r=null;for(let l of c)this.transport.enqueue(l);this.config.networkCapture!==!1&&this.network.start((l,d,u)=>{this.recorder.emitEvent("network",l,void 0,!0,d,u)},()=>this.recorder.acceptsNetwork(),()=>this.transport.place())}stop(){return this.network.reportDue(),this.recorder.stopDom(),this.network.stop(),this.started=!1,this.network.settle(1e3).then(()=>(this.recorder.stop(),this.transport.stop()))}decline(t){Ws||console.info(t.message),Ws=!0,this.endCapture();try{this.config.onError?.(t)}catch{}}refuse(t){console.error(t.message),this.endCapture();try{this.config.onError?.(t)}catch{}}endCapture(){let t=this.stop().catch(()=>{}).finally(()=>e.ending.delete(t));e.ending.add(t),e.instance===this&&(e.instance=null)}static cancelNextSession=()=>{};static nextSessionPaused=!1;static ending=new Set;static restartPending=!1;endSession(){let t=e.instance===this,n=this.recorder.isUserPaused();if(this.endCapture(),!t||typeof document>"u")return;e.cancelNextSession(),e.nextSessionPaused=n;let r={...this.config,sampleRate:1},s=()=>{let o=e.nextSessionPaused;e.cancelNextSession(),e.nextSessionPaused=!1,e.instance===null&&e.begin(r,o).catch(c=>{console.error("[keploy] the capture's next session could not start:",c)})},i={capture:!0,passive:!0};document.addEventListener("pointerdown",s,i),document.addEventListener("keydown",s,i);let a=$s();e.restartPending=!0,e.cancelNextSession=()=>{a(),document.removeEventListener("pointerdown",s,i),document.removeEventListener("keydown",s,i),e.restartPending=!1,e.cancelNextSession=()=>{}}}pause(){this.recorder.pause(),this.network.cutInflight()}resume(){this.recorder.resume()}};
11
- //# sourceMappingURL=index.js.map
1
+ Object.create;var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=(Object.getPrototypeOf,Object.prototype.hasOwnProperty),s={};((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(s,{CaptureDeclined:()=>Kr,CaptureError:()=>Br,CaptureIdentityBuilder:()=>mo,DomRecorderRefusal:()=>jr,IngestRejection:()=>Ur,KeployCapture:()=>bo,KeployCaptureRecorder:()=>go,NetworkInterceptor:()=>Ss,PrivacyConflict:()=>Wr,PrivacyEngine:()=>yr,PrivacyRouteRefusal:()=>Mr,SDK_ERRORS:()=>Er,SDK_WARNINGS:()=>Ir,SESSION_ID_MAX_LENGTH:()=>vr,SESSION_ID_PATTERN:()=>mr,SESSION_ID_RULE:()=>wr,SessionIdRefusal:()=>Pr,StrictAttributesRefusal:()=>qr,Transport:()=>_s,codeForStatus:()=>Cr,currentOrigin:()=>vo,defaultPrivacyConfig:()=>dr,describeValue:()=>Lr,isValidSessionId:()=>br,mintSessionNonce:()=>yo,parseServerError:()=>Dr}),module.exports=(e=s,((e,s,o,a)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let l of r(s))!i.call(e,l)&&l!==o&&t(e,l,{get:()=>s[l],enumerable:!(a=n(s,l))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var o=/%[0-7][\da-f]|%(?:c[2-9a-f]|d[\da-f])%[89ab][\da-f]|%e0%[ab][\da-f]%[89ab][\da-f]|%e[1-9a-ce-f](?:%[89ab][\da-f]){2}|%ed%[89][\da-f]%[89ab][\da-f]|%f0%[9ab][\da-f](?:%[89ab][\da-f]){2}|%f[1-3](?:%[89ab][\da-f]){3}|%f4%8[\da-f](?:%[89ab][\da-f]){2}/gi;function a(e){return e.includes("%")?e.replace(o,e=>decodeURIComponent(e)):e}var l=new Set(["password","passwd","pwd","secret","token","accesstoken","refreshtoken","idtoken","authorization","auth","apikey","clientsecret","privatekey","session","sessionid","cookie","ssn","socialsecuritynumber","creditcard","cardnumber","cvv","cvc","pin","passphrase","pass1","pass2","currentpass","rpkey","codeverifier","rawkey","apikeyauth","setcookie","proxyauthorization","samlresponse","confirmkey","tokenhash","clerkticket","nonce","hmac","loginhash","magiclink","phpsessid","oauthverifier","sig","sid","sessid","csrf","xsrf","bearer","authentication","credentials","pass","tokenid","authkey","secretkey","accesskey","clientkey","signingkey","sessionkey","subscriptionkey","functionskey","factorcode","jwtassertion","samlassertion","clientassertion","secretaccesskey","accesskeysecret"]),u=new Set(["invitecode","invitationcode","authcode","authorizationcode","verificationcode","verifycode","confirmationcode","confirmcode","resetcode","mfacode","smscode","otpcode","totpcode","twofactorcode","2facode","logincode","passcode","oobcode","linkcode"]),c=new Set(["cardexpiry","cardexpiration","cardexpirydate","cardexpirationdate","cardexp","cardexpdate","cardexpmonth","cardexpyear","ccexp","ccexpiry","ccexpiration","ccexpdate","ccexpmonth","ccexpyear","creditcardexpiry","creditcardexpiration","expmonth","expyear","expirymonth","expiryyear","expirationmonth","expirationyear"]),d=/(?:password(?:\d|confirm|confirmation|new|old|repeat|again|verify|retype)?|passwd|secret|token|apikey|privatekey|passphrase|signature|sessionid|jwt|otp|credential|curl)$/,h=new Set(["pagetoken","nextpagetoken","prevpagetoken","previouspagetoken","pagingtoken","paginationtoken","nexttoken","prevtoken","previoustoken","continuationtoken","nextcontinuationtoken","cursortoken","synctoken","nextsynctoken","startingtoken","starttoken","skiptoken","deltatoken","resumptiontoken","scrolltoken","aftertoken","beforetoken"]),f=new Set(["auth","session","cookie","pin","sig"]);function p(e,t){return a(e).split("key"===t?/[[\]]+/:/[[\].]+/).map(e=>e.toLowerCase().replace(/[-_$+\s]/g,"")).filter(e=>""!==e)}function g(e,t){return!(h.has(e)||"page"===t&&f.has(e))&&(l.has(e)||u.has(e)||c.has(e)||d.test(e))}function y(e,t){return v(p(e,t),t)}function v(e,t){return e.some(e=>g(e,t))||e.length>1&&g(e.join(""),t)}var m=/(&|;(?=[^;&=#]+=|end$))/;function w(e){let t=e.replace(/\+/g," ");if(!/%/.test(t))return t;if(/%(?![0-9A-Fa-f]{2})/.test(t))return e;try{return decodeURIComponent(t)}catch{return e}}var b=/^(?:[a-z][a-z0-9+.-]*:\/\/|\/)[^?#]*[?#]./i,k=/[&;?#][^&;=?#]+=/;function S(e,t,n){let r=e.indexOf("#"),i=-1===r?e:e.slice(0,r),s=i.indexOf("?"),o=-1===s?i:i.slice(0,s),a=-1===s?null:i.slice(s+1),l=-1===r?null:e.slice(r+1),u=A(o,t)+(null===a?"":`?${I(a,t,n,o)}`)+(null===l?"":`#${T(l,t,n,o)}`);return u===e?e:u}function x(e,t=!1){if(t){let t=e.search(/\s/);return-1===t?e.length:t}let n=0,r=0,i=0;for(let t=0;t<e.length;t++){let s=e[t];if(/[\s,;"'<>\\`]/.test(s))return t;if("("===s)n++;else if("["===s)r++;else if("{"===s)i++;else{if(")"===s&&0===n--)return t;if("]"===s&&0===r--)return t;if("}"===s&&0===i--)return t}}return e.length}function E(e,t){let n=e;for(let e=0;e<4;e++){let e=a(n);if(e===n)break;n=e}for(let e of n.matchAll(/(?:^|[?&;#])([^?&;#=/\s]+)=/g))if(y(e[1],t))return!0;return!1}function I(e,t,n=0,r=""){let i=e.split(t.whole?/(&)/:m),s=i.filter((e,t)=>t%2==0),o={path:r,pairs:s,depth:n};return s.map(e=>{let r=e.indexOf("=");if(-1===r)return!0===t.bare?.(e)?"[REDACTED]":e;let i=e.slice(0,r),s=e.slice(r+1);if(""===s)return e;let l=w(s),u=()=>`${i}=[REDACTED]`,c=t.before?.(i,s,o)??null;if(null!==c)return`${i}=${c}`;if(t.strict||(t.whole?function(e){let t=[],n=e.split(m);for(let e=0;e<n.length;e+=2){let r=n[e].indexOf("=");r>0&&t.push(n[e].slice(0,r))}return t}(e):[i]).some(e=>y(e,t.kind))||!0===t.value?.(i,s,l)){if(!0!==t.spaced)return u();let e=x(s,t.form),n=s.slice(e);return`${i}=${0!==e||t.form?"[REDACTED]":""}${t.tail?.(n)??n}`}if(n>=1&&(b.test(l)||k.test(l)))return"page"===t.kind||E(l,t.kind)?u():e;let d=function(e,t,n){return/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?R(e,t,n+1):e.startsWith("/")?S(e,t,n+1):k.test(e)?/[?#]/.test(e)?S(e,t,n+1):I(e,t,n+1):null}(l,t,n);return null!==d&&d!==l?t.whole?u():!0!==t.raw?`${i}=${encodeURIComponent(d)}`:s===l?`${i}=${d}`:encodeURIComponent(l)===s?`${i}=${encodeURIComponent(d)}`:u():a(l)!==l&&E(l,t.kind)?u():e}).map((e,t)=>(0===t?"":i[2*t-1])+e).join("")}function A(e,t){let n=e.split("/"),r=n.map(e=>e.split(";")[0]);return n.map((n,i)=>{if(!0===t.segment?.(n))return"[REDACTED]";let s=n.indexOf(";"),o=r[i],a=!0===t.head?.(e,o,i,r)?"[REDACTED]":o;return-1===s?a:a+n.slice(s).replace(/;([^;=]+)=([^;]*)/g,(e,n,r)=>{let i=!0===t.spaced?x(r,t.form):r.length;return i>0&&y(n,t.kind)?`;${n}=[REDACTED]${r.slice(i)}`:e})}).join("/")}function T(e,t,n,r=""){let i=e.indexOf("?");if(-1!==i){let s=e.slice(0,i);return`${A(s,t)}?${I(e.slice(i+1),t,n,`${r}/${s}`)}`}let s=e.indexOf("=");if(-1!==s&&!e.slice(0,s).includes("/"))return I(e,t,n,r);let o=-1===s?null:/^([^&;]*)([&;])/.exec(e);return null!==o?`${A(o[1],t)}${o[2]}${I(e.slice(o[0].length),t,n,`${r}/${o[1]}`)}`:A(e,t)}function R(e,t,n){if(t.whole||!0===t.raw||!_.test(e))return C(e,t,n);let r;try{r=new URL(e)}catch{return C(e,t,n)}let i=r.search.slice(1),s=r.hash.slice(1),o=A(r.pathname,t),a=r.search?I(i,t,n,r.pathname):"",l=r.hash?T(s,t,n,r.pathname):"";return o===r.pathname&&a===i&&l===s&&""===r.username&&""===r.password?e:`${r.protocol}//${r.host}`+o+(r.search?`?${a}`:"")+(r.hash?`#${l}`:"")}var _=/^(?:https?:|[a-z][a-z0-9+.-]*:[/\\]{2})/i;function C(e,t,n){let r=/^([a-z][a-z0-9+.-]*:)([/\\]*)([^/\\?#]*)/i.exec(e),[i,s,o,a]=r,l=""===o?-1:a.lastIndexOf("@"),u=s+o+a.slice(l+1)+S(e.slice(i.length),t,n);return u===e?e:u}function O(e,t){let n,r=e.length-e.trimStart().length,i=e.length-e.trimEnd().length,s=e.slice(r,e.length-i);return/^(?:javascript|vbscript|data|blob):/i.test(s)?e:(n=/^[a-z][a-z0-9+.-]*:/i.test(s)?R(s,t,0):S(s,t,0),n===s?e:e.slice(0,r)+n+e.slice(e.length-i))}var $=/[a-z][a-z0-9+.-]{0,31}:[/\\]{2}|(?<attr>\bcontent\s*=\s*(?:["']\s*)?\d[\d.]*\s*[;,]\s*url\s*=\s*["']?|\b(?:href|src|action|formaction|poster|cite|data|background|longdesc|content|data-src|data-href|xlink:href)\s*=\s*["']?|(?<![\w:.-])[\w:.-]{1,40}\s*=\s*["'](?=\.{0,2}\/|[?#]|[a-z][a-z0-9+.-]{0,31}:\/|[a-z][a-z0-9-]{0,30}[+.][a-z0-9+.-]{0,30}:|localhost:\d{1,5}[/?#]|(?:mailto|tel|sms|urn|data|javascript|vbscript|blob|about|xmpp|sip|sips|magnet|intent|bitcoin|geo|market|news):)|\burl\(\s*["']?)(?=[^\s"'<>])/gi,D=/[\s"'<>\\^`{|}]/,N=/[a-z][a-z0-9+.-]{0,31}:\/\//iy;function z(e,t,n,r){let i=t,s=0,o=0;for(;i<e.length;i++){let t=e[i];if(D.test(t)||r&&","===t&&(N.lastIndex=i+1,N.test(e)))break;if(n)if("("===t)s++;else if("["===t)o++;else if(")"===t||"]"===t){if(0===(")"===t?s:o))break;")"===t?s--:o--}}return function(e,t,n){let r=0,i=0;for(let s=t;s<n;s++){let t=e[s];"("===t?r++:")"===t?r--:"["===t?i++:"]"===t&&i--}for(;n>t;){let t=e[n-1];if(")"===t){if(r>=0)break;r++}else if("]"===t){if(i>=0)break;i++}else if(!".,;:!?".includes(t))break;n--}return n}(e,t,i)}var L=/url\(\s*["']?/iy;function B(e){return{kind:"param",strict:e,whole:!0}}var U={left:"the page left or the capture stopped before redaction was ready","code-failed":"the redaction code could not load"},P="[REDACTED]",q=/^[A-Za-z]+(?:[-_][A-Za-z]+)*$/,j=/^[A-Za-z][a-z]+(?:[A-Z][a-z]+)+$/,M=new Set(["code","devicecode"]);function K(e){return y(e,"key")}new Set([...M,"state"]);var W=/[a-zA-Z0-9.-]{1,253}\.[a-zA-Z]{2,63}/y;function F(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||46===e||95===e||37===e||43===e||45===e}var H=/(?<![A-Za-z0-9])(?:kep_[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{36,}|github_pat_[A-Za-z0-9_]{22,}|glpat-[A-Za-z0-9_-]{20,}|xox[abprse]-[A-Za-z0-9-]{10,}|[sr]k_(?:live|test)_[A-Za-z0-9]{16,}|sk-(?:proj|ant)-[A-Za-z0-9_-]{20,}|npm_[A-Za-z0-9]{36,}|whsec_[A-Za-z0-9+/=]{24,}|(?:AKIA|ASIA)[0-9A-Z]{16,}|AIza[0-9A-Za-z_-]{35,})/g,Z=/\b\d{3}-\d{2}-\d{4}\b/g,V=/(?:\+\d{1,3}[ .-]?)?(?:\(\d{3}\)[ .-]?|\b\d{3}[ .-])\d{3}[ .-]\d{4}\b/g,J=/(?<![A-Za-z0-9_-])eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g,X=/(?<![\d.])(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)(?![\d.])/g;function G(e){if(e.length<13||e.length>19)return!1;let t="4"===e[0]&&(13===e.length||16===e.length||19===e.length),n=/^(5[1-5]|2[2-7])/.test(e)&&16===e.length,r=/^3[47]/.test(e)&&15===e.length,i=/^6(?:011|5)/.test(e)&&16===e.length,s=/^(?:35|3[068])/.test(e)&&e.length>=14&&e.length<=19;return!!(t||n||r||i||s)&&function(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let i=e.charCodeAt(r)-48;if(i<0||i>9)return!1;n&&(i*=2,i>9&&(i-=9)),t+=i,n=!n}return t%10==0}(e)}function Q(e,t,n){for(let r of e.matchAll(t))""!==r[0]&&n.push([r.index,r.index+r[0].length])}function Y(e,t){if(0===t.length)return e;t.sort((e,t)=>e[0]-t[0]||t[1]-e[1]);let n="",r=0,[i,s,o]=t[0];for(let a=1;a<=t.length;a++){let l=t[a];void 0!==l&&l[0]<s?(l[1]>s&&(s=l[1]),o=void 0):(n+=e.slice(r,i)+(o??P),r=s,void 0!==l&&([i,s,o]=l))}return n+e.slice(r)}function ee(e,t=[]){if(!e)return e;let n=[];return function(e,t,n){Q(e,J,n),Q(e,H,n),function(e,t){let n=0,r=e.indexOf("@");for(;-1!==r;){let i=Math.max(n,r-64),s=r;for(;s>i&&F(e.charCodeAt(s-1));)s--;if(s<r){W.lastIndex=r+1;let i=W.exec(e);if(i){n=r+1+i[0].length,t.push([s,n]),r=e.indexOf("@",n);continue}}r=e.indexOf("@",r+1)}}(e,n),Q(e,Z,n),Q(e,V,n),Q(e,X,n),function(e,t){for(let n of e.matchAll(/\b(?:\d[ -]?){12,18}\d\b/g))G(n[0].replace(/[^0-9]/g,""))&&t.push([n.index,n.index+n[0].length])}(e,n);for(let r of t)Q(e,r,n)}(e,t,n),Y(e,n)}function te(e){return e&&Y(e,re(e))}var ne=/eyJ|kep_|gh[pousr]_|github_pat_|glpat-|xox[abprse]-|[sr]k_(?:live|test)_|sk-(?:proj|ant)-|npm_|whsec_|AKIA|ASIA|AIza/;function re(e){let t=[];return ne.test(e)&&(Q(e,J,t),Q(e,H,t)),t}JSON.stringify(P);var ie={kind:"param",strict:!1,whole:!1,raw:!0},se={...ie,spaced:!0,tail:e=>ce(e,oe)},oe={...ie,spaced:!0,list:!0},ae=/^(?=[^={}<>"'\\^`|]*(?:=|$))(?:(?:[a-z][a-z0-9+.-]*:\/|[a-z][a-z0-9-]*[+.][a-z0-9+.-]*:|localhost:\d{1,5}[/?#]|(?:mailto|tel|sms|urn|data|javascript|vbscript|blob|about|xmpp|sip|sips|magnet|intent|bitcoin|geo|market|news):|\.{0,2}\/)[^\s?#]*[?#]|(?:[\w.~%-][\w.~%/-]*)?[?#][^\s=&#]+=|\.{0,2}\/[^\s?#;=]*;)/i,le=/^\S*/,ue=/^[^\r\n]*/gm;function ce(e,t=ie){let n=e.replace(ue,e=>ae.test(le.exec(e)[0])?O(e,t):e),r=function(e,t){let n=[];for(let[r,i]of function(e,t=!1){let n=[];$.lastIndex=0;for(let r=$.exec(e);null!==r;r=$.exec(e)){let i=r.index+(r.groups?.attr?.length??0);L.lastIndex=i;let s=void 0!==r.groups?.attr&&L.test(e);s&&(i=L.lastIndex);let o=r.groups?.attr??"",a=z(e,i,!/["']$/.test(o)||/^url\(/i.test(o)||s,t);"{"===e[a]&&a>i&&"$"===e[a-1]&&a--,a>i&&n.push([i,a]),$.lastIndex=Math.max(a,r.index+r[0].length,i+1)}return n}(e,!0===t.list)){let s=e.slice(r,i),o=O(s,t);o!==s&&n.push([r,i,o])}return n}(n,t);if(0===r.length)return he(n,t);let i="",s=0;for(let[e,t,o]of r)i+=n.slice(s,e)+o,s=t;return he(i+n.slice(s),t)}var de=/[a-z][a-z0-9+.-]{0,31}:(?:\\\/|\\u002[fF]){2}(?:[^\s"'<>\\^`{|}()[\]/]|\/(?![dgimsuvy]*(?![\w$]))|\\\/|\\u002[fF])*/gi;function he(e,t){return/:(?:\\\/|\\u002[fF])/.test(e)?e.replace(de,e=>{let n="",r=[];for(let t=0;t<e.length;){r.push(t);let i=fe.exec(e.slice(t,t+6));n+=null===i?e[t]:"/",t+=null===i?1:i[0].length}r.push(e.length);let i=O(n,t);if(i===n)return e;let s=0;for(;s<i.length&&i[s]===n[s];)s++;let o=0;for(;o<i.length-s&&o<n.length-s&&i[i.length-1-o]===n[n.length-1-o];)o++;let a=/\\\/|\\u002[fF]/.exec(e)[0];return e.slice(0,r[s])+i.slice(s,i.length-o).replace(/\//g,a)+e.slice(r[n.length-o])}):e}var fe=/^(?:\\\/|\\u002[fF])/;function pe(e){let t=ce(e,se),n=[];return function(e,t,n="text"){let r="code"===n?ve:"string"===n?me:"header"===n?we:ye,i="text"===n&&/<script/i.test(e)?function(e){let t=[],n=/<script\b/gi,r=/<\/script\s*>/gi;for(let i=n.exec(e);null!==i;i=n.exec(e)){let s=e.indexOf(">",i.index);if(-1===s)break;r.lastIndex=s+1;let o=r.exec(e),a=null===o?e.length:o.index;t.push([s+1,a]),n.lastIndex=a}return t}(e):[],s=0;r.lastIndex=0;for(let o=r.exec(e);null!==o;o=r.exec(e)){if(!y(o[2],"param"))continue;if(i.length>0&&(/^[ \t\r\f\v>]$/.test(o[1])||"#"===o[1]&&(!/[\w/%~-]/.test(e[o.index-1]??"")||e.startsWith("*/",o.index-2)||/(?:^|[^\w$/%~.-])(?:static|accessor)$/.test(e.slice(Math.max(0,o.index-9),o.index))))){for(;s<i.length&&i[s][1]<=o.index;)s++;if(s<i.length&&i[s][0]<=o.index)continue}let a=o.index+o[0].length;be.lastIndex=a;let l=be.exec(e);if(null===l)continue;"string"===n&&(ke.lastIndex=a,l=ke.exec(e)??l);let u=a+l[0].length;t.push([a,u]),r.lastIndex=u}}(t,n,"header"),Y(t,n)}var ge="...[truncated]",ye=/(^|[?&;\n>#]|(?<!\b(?:var|let|const)|[(){}])[ \t\r\f\v])([\w%-]*(?:\[[\w%-]*\][\w%-]*)*)=/g,ve=/(^|[?&;\n]|(?<=[\w/%~-])(?<!\*\/|(?:^|[^\w$/%~.-])(?:static|accessor))#)([\w%-]*(?:\[[\w%-]*\][\w%-]*)*)=/g,me=/(^|[?&]|(?<=[\w/%~-])(?<!\*\/|(?:^|[^\w$/%~.-])(?:static|accessor))#)([\w%-]*(?:\[[\w%-]*\][\w%-]*)*)=/g,we=/(^|[?&;,\s]|(?<=[\w/%~-])#)([\w%-]*(?:\[[\w%-]*\][\w%-]*)*)=/g,be=/(?:[^\s&"'`<>\\,;(){}[\]$]|\$(?!\{))+/y,ke=/[^&]+/y,Se=B(!1),xe=B(!0),Ee={scanned:0};function Ie(e){return 47===e||38===e||59===e||63===e||35===e}function Ae(e,t){let n=e.length,r=0;for(;r<=n;){let i,s=r,o=0;for(;s<n&&61!==(o=e.charCodeAt(s))&&!Ie(o);)s++;Ee.scanned+=s-r+1,i=s<n&&61===o?s>r?t(r,s):s+1:s;let a=i;for(;i<n&&!Ie(e.charCodeAt(i));)i++;if(Ee.scanned+=i-a+1,i>=n)return;r=i+1}}function Te(e,t,n){let r=t;for(;r<e.length;r++){let t=e.charCodeAt(r);if(38===t||59===t||35===t||!n&&63===t)break}return Ee.scanned+=r-t+1,r}function Re(e){let t=[];return Ae(e,(n,r)=>{let i=Te(e,r+1,!0);return t.push([e.slice(n,r),e.slice(r+1,i)]),i}),t}function _e(e,t,n=!1){let r="",i=0;return Ae(e,(s,o)=>{let a=p(e.slice(s,o),"page"),l=o+1;if(!(v(a,"page")||n&&Ye(a,e.slice(l,l+256))))return l;let u=Te(e,l,t);return r+=e.slice(i,l)+"[REDACTED]",i=u,u}),r+e.slice(i)}function Ce(e,t){let n=e.indexOf("?");return-1===n?_e(e,!1):`${_e(e.slice(0,n),!1)}?${_e(e.slice(n+1),!0,t)}`}var Oe=/^!?\//;function $e(e){return!(e.length<8)&&Number(/[a-z]/.test(e))+Number(/[A-Z]/.test(e))+Number(/\d/.test(e))>=2&&!/^[A-Z][a-z]+$/.test(e)&&!/^[A-Za-z][a-z]*(?:[-_](?:[A-Za-z][a-z]*|\d+))+$/.test(e)&&!/^[A-Za-z][a-z]{2,}(?:[A-Z][a-z]{2,})+$/.test(e)}function De(e,t=!0){return(t?/^(?:\/|[a-z][a-z\d+.-]*:\/\/)/i:/^[a-z][a-z\d+.-]*:\/\//i).test(a(e))}function Ne(e){return a(e).replace(/([a-z\d])([A-Z])/g,"$1 $2").split(/[\s\-_.]+/).filter(e=>""!==e).map(e=>e.toLowerCase())}var ze=new Set(["reset","resets","verify","unlock","activate","invite","forgot","forgotten","recover","recovery"]),Le=new Set(["passwordreset","passwordresets","resetpassword","verifyemail","emailverification","magiclink","magiclogin","emaillogin","loginlink","lostpassword","setpassword","createpassword"]),Be=new Set(["setpassword","createpassword","resetpassword","passwordreset","forgotpassword","forgottenpassword","lostpassword","verifyemail","emailverification"]),Ue=new Set(["sent","done","success","complete","new","error","expired","failed","invalid"]),Pe=new Set(["confirm","confirmation","confirmations","invites","invitation","invitations","verification","verifications","activation","activations","password","passwords","signup","login"]),qe=new Set(["email","account","registration","registrations","signup"]),je=new Set(["accept","link","new","old","sign","up","email","account","registration","admin","change","php","asp","aspx","htm","html","jsp","cgi"]),Me=e=>e.some(e=>qe.has(e))||e.join("").includes("signup");function Ke(e,t){let n=Ne(e),r=n.join("");if(Le.has(r))return 2;Pe.has(r)&&(n=[r]);let i=0;for(let e of n)if(ze.has(e))i=2;else if(Pe.has(e))i||=1;else if(!je.has(e))return 0;return 1===i&&(n.includes("accept")||n.includes("confirm")&&(Me(n)||Me(Ne(t))))?2:i}function We(e){return/^(?:\d+|[\da-f]{24}|[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12})$/i.test(e)||/^(?:[0-7][\dA-HJKMNP-TV-Z]{25}|c[a-z\d]{24})$/.test(e)}function Fe(e){if(e.length%4==1||!/^[\w-]+$/.test(e))return!1;try{return/^[\x20-\x7e]+$/.test(atob(e.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((e.length+3)%4)))}catch{return!1}}function He(e){return e.length<=4||Ze(e)}function Ze(e){return Ne(e).every(e=>e.startsWith("confirm")||"accept"===e||"edit"===e)}function Ve(e,t){let n=e[t]??"";return Be.has(Ne(e[t-1]??"").join(""))&&!Ze(n)&&!Ue.has(n.toLowerCase())&&!/\.[A-Za-z][A-Za-z\d]{0,4}$/.test(n)&&!(We(n)&&""!==(e[t+1]??""))}var Je=new Set(["cb","auth","sso","signin","authorize","authorized","redirect"]);function Xe(e){return Ne(e).some(e=>e.startsWith("invit"))}function Ge(e,t){return/^(?:rp|resetpass)$/.test(t)||e.some(e=>e.some(e=>0!==Ke(e,"")))}function Qe(e){return e.find(([e])=>p(e,"page").includes("action"))?.[1]??""}function Ye(e,t){return e.some(e=>/^(?:key|t|hash|code)$/.test(e))&&!De(t,!1)}function et(e){let t=Ne(e);return t.length>0&&t.every(e=>"accept"===e||"join"===e)}var tt="a route is `/`-separated segments from the path's start, each a literal, `*` (any one segment) or `:name` (the value it names), with no `?` or `#`; a secret route names at least one `:name`, a keep route has at least one literal";function nt(e,t=!1){if("string"!=typeof e||!/^\/[^?#]*$/.test(e))return null;let n=e.split("/").filter(e=>""!==e),r=e=>/^:\w+$/.test(e);return n.every(e=>"*"===e||r(e)||!/[:*]/.test(e))&&n.some(e=>t?"*"!==e&&!r(e):r(e))?n:null}var rt={secret:[],keep:[]},it=new Set,st=0;function ot(e,t){return"*"===e||":"===e[0]||a(t).toLowerCase()===a(e).toLowerCase()}function at(e,t){let n=[];return e.every((e,r)=>{let i=t[r];return void 0!==i&&(":"===e[0]&&n.push([i,t[r-1]??"",r]),ot(e,i))})?n:null}function lt(e,t){return rt.keep.some(n=>t<n.length&&"*"!==n[t]&&":"!==n[t][0]&&n.slice(0,t+1).every((t,n)=>ot(t,e[n])))}function ut(e){let t=!1,n=new Set;for(let r of rt.keep){let i=at(r,e);if(null!==i){0===i.length&&(t||=r.length===e.length&&!r.includes("*"));for(let[e]of i)n.add(e)}}let r=[];for(let t of rt.secret)for(let[n,i,s]of at(t,e)??[])!lt(e,s)&&ct(n)&&r.push([n,i]);return{secret:r,kept:n,own:t}}function ct(e){let t=e;for(let e=0;e<=dt;e++){let e=a(t);if(e===t)return/[\p{L}\p{N}]/u.test(t);t=e}return!1}var dt=16;function ht(e){let t=e.indexOf("#"),n=[e.slice(0,-1===t?e.length:t).replace(/^[a-z][a-z\d+.-]*:\/\/[^/?#]*/i,"")],r=-1===t?"":e.slice(t+1);return Oe.test(r)&&n.push(r.replace(/^!/,"")),n.map(e=>e.split(/[?#]/)[0].split("/").map(e=>e.split(";")[0]))}function ft(e,t,n){let r=e.get(t);void 0===r&&e.set(t,r=new Set),r.add(function(e){return wt(a(e))}(n))}function pt(e,t,n,r,i,s){let o=ht(e);for(let e of o){let o=e.length,{secret:l,kept:u,own:c}=ut(e.filter(e=>""!==e));for(let[e,s]of l)n.add(e),ft(r,e,s),0===t&&ft(i,e,s);for(let t=0;t<o;t++){let i=Ke(e[t],e[t-1]??"");if(0===i)continue;let l=Xe(e[t]),d=e[t+1];Ve(e,t+1)&&!u.has(d)&&!c&&(n.add(d),$e(a(d))||(r.has(d)||s.add(d),ft(r,d,e[t])));let h="",f="",p=t+1;for(;p<o;p++){let t=e[p],n=e[p+1]??"";if(We(t)||(2===i||n.length>=16&&$e(n))&&Fe(t)){f=t;continue}if(t.length>=(2===i?16:20)&&$e(t)){h=t;break}if(l&&$e(t)){f=t;continue}let r=Ke(t,e[p-1]);if(r>i)i=r,f="";else{if(""!==f&&et(t)){h=f;break}if(!He(t))break}}""===h&&2===i&&p===o&&(h=f),""!==h&&!u.has(h)&&!c&&n.add(h),t=""===h?p-1:p}}let l=Re(e).map(([e,t])=>[p(e,"page"),t]),u=e=>l.find(([t])=>t.includes(e))?.[1]??"",c=Ge(o,u("action")),d=""!==u("organization"),h=u("code"),f=u("state"),g=!De(h)&&(h.length>=10&&$e(f)&&!/^[A-Za-z][a-z]+(?:[A-Z][a-z]+)+$/.test(f)&&!De(f)||h.length>=20&&$e(h)&&o.some(e=>e.some(e=>/callback|oauth/i.test(e)||[...Ne(e),Ne(e).join("")].some(e=>Je.has(e)))));for(let[e,o]of l){let l=g&&(e.includes("code")||e.includes("state"));if((l||v(e,"page")||c&&Ye(e,o)||d&&e.includes("invitation")||e.includes("ticket")&&/^(?:ST|PT|TGT)-/.test(o))&&!De(o,l)){n.add(o);continue}let u=a(o);t<2&&(/[?#=]/.test(u)||De(u))&&pt(u,t+1,n,r,i,s)}}function gt(e){try{return new URL(e).origin}catch{return""}}function yt(e){return mt(e)[0]}var vt=["",[],!1,null];function mt(e){if(vt[0]===e)return[vt[1],vt[2],vt[3]];let t=new Set,n=new Map,r=new Map,i=new Set,s=e.indexOf("#"),o=-1===s?e:e.slice(0,s),l=-1===s?"":e.slice(s+1),u=Oe.test(l),c=o.length+(u?l.length:0)>65536;if(c)for(let i of ht(e))for(let[e,s]of ut(i.filter(e=>""!==e)).secret)t.add(e),ft(n,e,s),ft(r,e,s);else pt(e,0,t,n,r,i);let d=c,h=gt(e),f=new Set,p=[],g=0,y=(e,t)=>null!==t&&!0===r.get(e)?.has(t)||(g<32?(g++,!0):(d=!0,!1));for(let e of[...r.keys(),...[...t].filter(e=>!r.has(e))]){let t=n.get(e),r=void 0===t?void 0:[...t].filter(t=>y(e,t));if(0===r?.length||void 0===r&&!y(e,null))break;if(void 0!==r){let t=a(e),n=t.length>=6&&!i.has(e),s=[];for(let t=e,n=0;n<Nt;n++)s.push(t=encodeURIComponent(t));for(let i of new Set([e,t,...s,encodeURIComponent(t),t.replace(/[\u0080-\uffff]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)])){if(""===i)continue;let e=!h.includes(i),t=e&&$e(i)&&!De(i,!1);if(n&&t&&p.push({kind:0,value:i}),n&&e)p.push({kind:1,value:i});else for(let e of r)p.push({kind:2,value:i,before:e})}continue}f.add(e);for(let t=e.lastIndexOf("/"),n=0;t>0&&n<4;t=e.lastIndexOf("/",t-1),n++)f.add(e.slice(0,t));f.add(encodeURIComponent(e));for(let t of[e,e.replace(/\+/g," ")])try{let e=decodeURIComponent(t);f.add(e),f.add(encodeURIComponent(e));for(let t=e.lastIndexOf("/"),n=0;t>0&&n<4;t=e.lastIndexOf("/",t-1),n++)f.add(e.slice(0,t))}catch{}}for(let e of f)$e(e)&&!De(e,!1)&&!h.includes(e)&&p.push({kind:0,value:e});return p.sort((e,t)=>t.value.length-e.value.length),vt=[e,p,d,en(p)],[p,d,vt[3]]}function wt(e){if(!/[A-Z]/.test(e))return e;if(qt.lowered+=e.length,!/[^\0-\x7f]/.test(e))return e.toLowerCase();let t=new Uint16Array(Math.min(e.length,bt)),n="";for(let r=0;r<e.length;r+=bt){let i=Math.min(bt,e.length-r);for(let n=0;n<i;n++){let i=e.charCodeAt(r+n);t[n]=i>=65&&i<=90?i+32:i}n+=String.fromCharCode(...t.subarray(0,i))}return n}var bt=8192;function kt(e,t){let n=new Int32Array(t.length);for(let e=1,r=0;e<t.length;e++){for(;r>0&&t.charCodeAt(e)!==t.charCodeAt(r);)r=n[r-1];t.charCodeAt(e)===t.charCodeAt(r)&&r++,n[e]=r}let r=[];for(let i=0,s=0;i<e.length;i++){for(;s>0&&e.charCodeAt(i)!==t.charCodeAt(s);)s=n[s-1];e.charCodeAt(i)===t.charCodeAt(s)&&s++,s===t.length&&(r.push(i-s+1),s=n[s-1])}return r}var St=1/0,xt=0;function Et(e){let t=St;St=1/0;try{return e()}finally{St=t}}function It(e){if(xt+e>St)throw new rn(xt+e,St)}function At(e,t,n="[redacted]"){if(e.includes(t))return!0;if(!/[[\]]/.test(t))return!1;let r=t.split(n),i=r[0],s=i.lastIndexOf("[");s>=0&&n.startsWith(i.slice(s))&&(r[0]=i.slice(0,s));let o=r[r.length-1],a=o.indexOf("]");return a>=0&&n.endsWith(o.slice(0,a+1))&&(r[r.length-1]=o.slice(a+1)),r.every(t=>e.includes(t))}var Tt=10;function Rt(e,t){let n=e=>e.length>Tt&&/[[\]]/.test(e);if(e.plain.some(e=>n(e)&&At(t,e,"[REDACTED]")))return!0;let r=wt(t);return[...e.bounded,...e.words.map(({value:e})=>e)].some(e=>n(e)&&At(r,e))}function _t(e,t,n,r,i=!1){let s=[],o=0,a=Tt-n.length;for(let l of kt(t,n))l<o||!r(l,l+n.length)||(s.push(l),o=l+n.length,i&&It(e.length+s.length*a));if(0===s.length)return[e,()=>t];let l,u=(e,t)=>{let r=[],i=0;for(let t of s)r.push(e.slice(i,t)),i=t+n.length;return r.push(e.slice(i)),r.join(t)};return[u(e,"[REDACTED]"),()=>l??=u(t,"[redacted]")]}var Ct=/[A-Za-z0-9]/,Ot=/(?:%(?:25)*[\da-f]{2}|(?:\\|%(?:25)*5c)(?:[nrtbf]|u[\da-f]{4}))$/i;function $t(e,t,n){return(0===t||!Ct.test(e[t-1])||Ot.test(e.slice(Math.max(0,t-16),t)))&&(n===e.length||!Ct.test(e[n]))}var Dt=[["%25252f",3],["%252f",2],["%2f",1],["\\/",0],["/",0]],Nt=Math.max(...Dt.map(([,e])=>e)),zt=/[/\\?#\s"<>`{}|^[\]]/,Lt=/[!$&'()*+,;=:@]/,Bt=64;function Ut(e,t,n){return Dt.find(([r,i])=>i<=n&&t>=r.length&&e.startsWith(r,t-r.length))}function Pt(e,t,n){if(";"===e[t])return!0;for(let r=1;r<=n;r++)if(e.startsWith(`%${"25".repeat(r-1)}3b`,t))return!0;return!1}var qt={pieces:0,strings:0,scanned:0,lowered:0};function jt(e,t,n,r){if(n!==e.length&&/[a-z0-9_~-]/.test(e[n]))return!1;let i=Ut(e,t,3);if(void 0===i)return!1;let[s,o]=i,l=function(e,t,n){let r=t;for(;;){let t=Ut(e,r,n);if(void 0===t)return r;r-=t[0].length,qt.scanned++}}(e,t-s.length,o);return(l===t-s.length||!function(e,t){return 0===t||zt.test(e[t-1])||Lt.test(e[t-1])||/(?::|%(?:25)*3a)$/.test(e.slice(Math.max(0,t-9),t))}(e,l))&&(!!r.befores.has("")||0!==r.longest&&function(e,t,n,r){let i=t;for(;i>0&&!zt.test(e[i-1])&&void 0===Ut(e,i,n);)i--;qt.scanned+=t-i;let s=t,o="",l=!1;for(let u=t;u>=i;u--){if(u<t&&Pt(e,u,n)&&(s=u,o="",l=!1),l||u!==i&&!Lt.test(e[u-1]))continue;let c=e.slice(u,s);for(let e=0;e<=n;e++)c=a(c);if(qt.pieces++,o=wt(c)+o,s=u,o.length>r.longest)l=!0;else if(r.lengths.has(o.length)&&r.befores.has(o))return!0}return!1}(e,l,o,r))}function Mt(e,t){if(!Kt(e,t))return e;if(/^[ \t\n\r]*[{[]/.test(e)){let n=Vt(e,t);if(null!==n)return n}return Yt(e,t)}function Kt(e,t){return!!Wt(e,t)||e.includes("\\")&&Wt(Ft(e),t)}function Wt(e,t){if(t.plain.some(t=>e.includes(t)))return!0;if(0===t.bounded.length&&0===t.words.length)return!1;let n=wt(e);return t.bounded.some(e=>n.includes(e))||t.words.some(({value:e})=>n.includes(e))}function Ft(e){return e.replace(/\\+u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/\\+\//g,"/")}var Ht=/"(?:[^"\\]|\\[\s\S])*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|[{}]/g,Zt=/[ \t\n\r]*:/y;function Vt(e,t){try{JSON.parse(e)}catch{return null}let n=function(e,t){let n=wt(e),r=e.includes("\\")?wt(Ft(e)):n,i=e=>n.includes(wt(e))||n.includes(wt(function(e){return JSON.stringify(e).slice(1,-1).replace(/[\u0080-\uffff]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)}(e)))||r.includes(wt(e));return{...t,plain:t.plain.filter(i),bounded:t.bounded.filter(i),words:t.words.filter(({value:e})=>i(e))}}(e,t),r=[],i=[];for(let t of e.matchAll(Ht)){let n=t[0];"{"===n?(i.push(r.length),r.push(new Set)):"}"===n?i.pop():'"'===n[0]&&i.length>0&&(Zt.lastIndex=t.index+n.length,Zt.test(e)&&r[i[i.length-1]].add(JSON.parse(n)))}let s=xt,o="",a=0,l=0,u=[];for(let t of e.matchAll(Ht)){let i=t[0];if("{"===i){u.push(new Set(r[l++]));continue}if("}"===i){u.pop();continue}let c=i;if('"'===i[0]){let r,l=JSON.parse(i);xt=s+o.length+(t.index-a);try{r=Mt(l,n)}finally{xt=s}Zt.lastIndex=t.index+i.length;let d=Zt.test(e)?u[u.length-1]:void 0;if(void 0!==d&&r!==l){let e=r;for(let t=2;d.has(r);t++)r=`${e}#${t}`;d.add(r)}r!==l&&(c=JSON.stringify(r))}else Et(()=>Yt(i,n))!==i&&(c='"[REDACTED]"');c!==i&&(o+=e.slice(a,t.index)+c,a=t.index+i.length,It(o.length))}return o+e.slice(a)}function Jt(e){let t="",n=[],r=0;for(let i of e.matchAll(/\\+u([0-9a-fA-F]{4})|\\+\//g))t+=e.slice(r,i.index),n.push(t.length,i.index+i[0].length),t+=void 0===i[1]?"/":String.fromCharCode(parseInt(i[1],16)),r=i.index+i[0].length;return{text:t+e.slice(r),escapes:n}}function Xt(e,t){let n=0,r=e.length/2;for(;n<r;){let i=n+r>>1;e[2*i]<t?n=i+1:r=i}if(0===n)return t;let i=2*(n-1);return e[i+1]+(t-e[i]-1)}function Gt(e,t,n=!1){let r=[],i=[],s=(e,t,s)=>{let o=new Int32Array(e.length),a=0,l=t>Tt,u=-1,c=-1;for(let r of e)!n&&s(r)?o[a++]=r:l&&(r<c||(u>=0&&i.push(u,c),u=r),c=r+t);u>=0&&i.push(u,c),a>0&&r.push({at:o.subarray(0,a),length:t})};for(let n of t.plain)s(kt(e,n),n.length,()=>!0);let o=wt(e);for(let n of t.bounded)s(kt(o,n),n.length,t=>$t(e,t,t+n.length));for(let e of t.words)s(kt(o,e.value),e.value.length,t=>jt(o,t,t+e.value.length,e));return{lists:r,slack:Qt(i)}}function Qt(e){if(0===e.length)return 0;let t=Array.from({length:e.length/2},(e,t)=>t).sort((t,n)=>e[2*t]-e[2*n]),n=0,r=e[2*t[0]],i=e[2*t[0]+1],s=()=>{i-r>Tt&&(n+=i-r-Tt)};for(let n of t){let t=e[2*n],o=e[2*n+1];t<i?o>i&&(i=o):(s(),r=t,i=o)}return s(),n}function Yt(e,t){e=function(e,t){let n=St!==1/0&&xt+Tt*e.length>St,{text:r,escapes:i}=e.includes("\\")?Jt(e):{text:e,escapes:[]},s=Gt(r,t),{lists:o}=s;if(0===o.length)return e;let a=n&&!Rt(t,e),l=s.slack+(a&&i.length>0?Gt(e,t,!0).slack:0),u=new Int32Array(o.length),c=e=>o[e].at[u[e]],d=[],h=(e,t)=>{let n=d[e];d[e]=d[t],d[t]=n},f=e=>{for(;;){let t=2*e+1,n=e;if(t<d.length&&c(d[t])<c(d[n])&&(n=t),t+1<d.length&&c(d[t+1])<c(d[n])&&(n=t+1),n===e)return;h(e,n),e=n}};for(let e=0;e<o.length;e++)d.push(e);for(let e=(d.length>>1)-1;e>=0;e--)f(e);let p=[],g=0,y=!1,v=0;for(;d.length>0;){let t=d[0],n=c(t),r=Xt(i,n),s=Xt(i,n+o[t].length);if(u[t]=u[t]+1,u[t]>=o[t].at.length&&(d[0]=d[d.length-1],d.pop()),d.length>0&&f(0),!(s<=g)){if(y&&r<=g){g=s;continue}v+=r-g+Tt,a&&It(v-l),p.push(e.slice(g,r),"[REDACTED]"),g=s,y=!0}}return a&&It(v+e.length-g-l),p.push(e.slice(g)),p.join("")}(e,t);for(let n of t.plain)e.includes(n)&&(e=e.split(n).join("[REDACTED]"));let n=wt(e),r=()=>n,i=[...t.bounded,...t.words.map(({value:e})=>e)],s=new Array(i.length);for(let e=i.length-1,t=!0;e>=0;e--){let r=i[e];t=t&&(r.length<=Tt||!At(n,r)),s[e]=t}let o=0;for(let n of t.bounded){if(r().includes(n)){let t=e;[e,r]=_t(e,r(),n,(e,n)=>$t(t,e,n),s[o])}o++}for(let n of t.words){if(r().includes(n.value)){let t=r();[e,r]=_t(e,t,n.value,(e,r)=>jt(t,e,r,n),s[o])}o++}return e}function en(e){if(0===e.length)return null;let t=(e,t)=>t.length-e.length,n=[],r=[],i=new Map;for(let t of e){let e=wt(t.value);if(0===t.kind)n.push(t.value);else if(1===t.kind)r.push(e);else{let n=i.get(e);void 0===n&&i.set(e,n=new Set),n.add(t.before.length>Bt?"":t.before)}}n.sort(t),r.sort(t);let s=[...i].map(([e,t])=>{let n=new Set([...t].filter(e=>""!==e).map(e=>e.length));return{value:e,befores:t,lengths:n,longest:0===n.size?0:Math.max(...n)}}).sort((e,t)=>t.value.length-e.value.length);return{json:n.map(e=>JSON.stringify(e).slice(1,-1)),jsonLower:[...r,...s.flatMap(({value:e})=>Dt.map(([t])=>t+e))].map(e=>JSON.stringify(e).slice(1,-1)),plain:n,bounded:r,words:s}}var tn=new Set(["type","rel","method","enctype","autocomplete","inputmode","enterkeyhint","dir","role","crossorigin","referrerpolicy","loading","decoding","fetchpriority","contenteditable","draggable","spellcheck","translate"]),nn=class{constructor(e){this.page=e}styles=new Map;texts=new Map;gone(e){return void 0===this.page||!this.page.present(e)}get size(){let e=0;for(let t of this.styles.values())e+=t.size;return this.styles.size+this.texts.size+e}addText(e,t){this.dropText(e),this.texts.set(e,t),this.styles.get(t)?.add(e),this.page?.note(e)}dropText(e){let t=this.texts.get(e);void 0!==t&&this.styles.get(t)?.delete(e),this.texts.delete(e)&&this.page?.forget(e)}drop(e){let t=this.styles.get(e);if(void 0!==t)for(let e of t)this.texts.delete(e)&&this.page?.forget(e);this.styles.delete(e)&&this.page?.forget(e),this.dropText(e)}observe(e){if(!ln(e)||!ln(e.data))return;let t=e.data;if(2===e.type){for(let e of[...this.styles.keys(),...this.texts.keys()])this.page?.forget(e);return this.styles.clear(),this.texts.clear(),void this.walk(t.node,null)}if(3!==e.type||0!==t.source)return;let n=Array.isArray(t.removes)?t.removes:[];for(let e of n)ln(e)&&"number"==typeof e.id&&this.gone(e.id)&&this.drop(e.id);let r=Array.isArray(t.adds)?t.adds.filter(ln):[];for(let e of r)this.walk(e.node,null);for(let e of r){let t=e.node;ln(t)&&3===t.type&&"number"==typeof t.id&&("number"==typeof e.parentId&&this.styles.has(e.parentId)?this.addText(t.id,e.parentId):this.dropText(t.id))}n.length>0&&void 0!==this.page&&this.prune()}prune(){for(let e of this.styles.keys())this.gone(e)&&this.drop(e);for(let e of this.texts.keys())this.gone(e)&&this.dropText(e)}walk(e,t){let n=[[e,t]],r=new Set;for(;n.length>0;){let[e,t]=n.pop();if(r.has(e)||(r.add(e),!ln(e)||"number"!=typeof e.id))continue;let i=e.id,s=2===e.type&&"string"==typeof e.tagName&&"style"===e.tagName.toLowerCase();if(s&&!this.styles.has(i)&&(this.styles.set(i,new Set),this.page?.note(i)),3===e.type&&null!==t&&this.addText(i,t),Array.isArray(e.childNodes))for(let t of e.childNodes)n.push([t,s?i:null])}}recordsIn(e){let t=new Set;if(!ln(e)||!ln(e.data))return t;let n=e.data,r=[];if(2===e.type)r.push(n.node);else if(3===e.type&&0===n.source){if(Array.isArray(n.adds))for(let e of n.adds)ln(e)&&r.push(e.node);if(Array.isArray(n.texts))for(let e of n.texts)ln(e)&&"number"==typeof e.id&&this.texts.has(e.id)&&t.add(e)}for(;r.length>0;){let e=r.pop();ln(e)&&(3===e.type&&"number"==typeof e.id&&this.texts.has(e.id)&&t.add(e),Array.isArray(e.childNodes)&&r.push(...e.childNodes))}return t}},rn=class extends Error{constructor(e,t){super(`the scrubbed event passed ${t} units (at least ${e})`),this.atLeast=e,this.cap=t,this.name="ScrubOverCap"}};function sn(e,t){if(0===t.length)return 0;let n=new Int32Array(t.length);for(let e=1,r=0;e<t.length;e++){for(;r>0&&t.charCodeAt(e)!==t.charCodeAt(r);)r=n[r-1];t.charCodeAt(e)===t.charCodeAt(r)&&r++,n[e]=r}let r=0;for(let i=0,s=0;i<e.length;i++){for(;s>0&&e.charCodeAt(i)!==t.charCodeAt(s);)s=n[s-1];e.charCodeAt(i)===t.charCodeAt(s)&&s++,s===t.length&&(r++,s=n[s-1])}return r}function on(e,t,n){if(St===1/0||xt+e.length<=St||"body"===t||"text"===t&&/^[ \t\n\r]*[{[]/.test(e)||"css"===t&&e.includes("\\"))return;if(!e.includes("\\")&&function(e,t){let n=e=>e.length>Tt;if(e.plain.some(e=>n(e)&&At(t,e,"[REDACTED]"))||e.plain.some(e=>t.includes(e)))return!1;let r=[...e.bounded,...e.words.map(({value:e})=>e)],i=r.filter(n),s=r.filter(e=>/[^a-z0-9]/.test(e));if(0===i.length&&0===s.length)return!0;let o=wt(t);return!i.some(e=>At(o,e))&&!s.some(e=>o.includes(e))}(n,e))return void It(e.length);let r=function(e,t){if(Rt(t,e))return null;let n=e.includes("\\"),r=n?Jt(e).text:e,i=n?[r,e]:[r],s=r.length;for(let e of i){let n=wt(e);for(let n of t.plain)s-=sn(e,n)*n.length;for(let e of t.bounded)s-=sn(n,e)*e.length;for(let{value:e}of t.words)s-=sn(n,e)*e.length}return s}(e,n);null!==r&&It(r)}function an(e,t,n="custom",r,i){if("dom"===n&&r?.observe(e),null===t)return e;let s;try{s=JSON.stringify(e)}catch{return e}let o=s;if(void 0===o||!function(e,t){if(t.json.some(t=>e.includes(t)))return!0;let n=wt(e);if(t.jsonLower.some(e=>n.includes(e)))return!0;if(!e.includes("\\"))return!1;let r=Ft(e);if(t.plain.some(e=>r.includes(e)))return!0;let i=wt(r);return t.bounded.some(e=>i.includes(e))||t.words.some(({value:e})=>i.includes(e))}(o,t))return e;let a=JSON.parse(o);if("string"==typeof a)return qt.strings++,g(0,()=>(on(a,"text",t),Mt(a,t)));let l="dom"===n&&void 0!==r?r.recordsIn(a):new Set,u="dom"===n&&ln(a)&&3===a.type&&ln(a.data)&&13===a.data.source,c=(e,t,r,i,s)=>"network"===n?!s||"method"!==t&&"type"!==t?!s||"requestBody"!==t&&"responseBody"!==t?"text":"body":"keep":"dom"!==n?"text":"tagName"===t||u&&"property"===t||i&&tn.has(t)?"keep":r||i&&"style"===t||"_cssText"===t||"rule"===t||("replace"===t||"replaceSync"===t)&&8===e.source||u&&"value"===t||("textContent"===t||"value"===t)&&l.has(e)?"css":"text",d=new Map,h=![...t.plain,...t.bounded,...t.words.map(e=>e.value)].some(e=>e.includes("#")),f=0,p=e=>{if(f+=e.length,void 0!==i&&f>i)throw new rn(f,i);return e};function g(e,t){St=i??1/0,xt=e;try{return t()}finally{St=1/0,xt=0}}let y=(e,n)=>{if("keep"===n)return e;if("text"===n&&h){let t=e.indexOf("#");if(t>0&&!/^[ \t\n\r]*[{[]/.test(e))return y(e.slice(0,t),n)+y(e.slice(t),n)}on(e,n,t);let r=function(e,t){let n=`${e}\0${t}`;if(n.length<=16383)return n;let r=2166136261;for(let e=0;e<t.length;e++)r^=t.charCodeAt(e),r=Math.imul(r,16777619);return`${e}\x01${t.length}\0${r>>>0}`}(n,e),i=d.get(r),s=i?.find(([t])=>t===e);if(void 0!==s)return s[1];qt.strings++;let o="css"===n?function(e,t){if(!Kt(e,t))return e;for(let n of t.plain)e.includes(n)&&(e=e.split(n).join("[REDACTED]"));let n="",r=0;return function(e,t){let n=e.length,r={},i=(t,i)=>{let s=r[i]??=new Int32Array(n+2).fill(-2),o=[],a=t,l=-1;for(;!(a>=n);){if(-2!==s[a]){l=s[a];break}o.push(a),qt.scanned++;let t=e[a];if(t===i){l=a+1;break}a+="\\"===t?2:1}for(let e of o)s[e]=l;return l},s=-1,o=t=>{for(s<t&&(s=t);s<n&&!")\"'".includes(e[s]);)qt.scanned++,s++;return s},a=t=>{let r=t;for(;r<n&&/\s/.test(e[r]);)qt.scanned++,r++;return r},l=0;for(;l<n;){qt.scanned++;let r=e[l];if("/"===r&&"*"===e[l+1]){let r=e.indexOf("*/",l+2),i=r<0?n:r+2;qt.scanned+=i-l,t(l,i),l=i;continue}if(("u"===r||"U"===r)&&"url("===e.slice(l,l+4).toLowerCase()){let n=a(l+4),r=e[n],s=-1;if('"'===r||"'"===r){let t=i(n+1,r);if(t>=0){let n=a(t);")"===e[n]&&(s=n+1)}}else{let t=o(l+4);")"===e[t]&&(s=t+1)}if(s>=0){t(l,s),l=s;continue}}if('"'===r||"'"===r){let e=i(l+1,r);if(e>=0){t(l,e),l=e;continue}}l++}}(e,(i,s)=>{let o=e.slice(i,s);n+=e.slice(r,i)+(o.startsWith("/*")?function(e,t){let n=e.length>=4&&e.endsWith("*/");return`/*${Yt(e.slice(2,n?-2:void 0),t)}${n?"*/":""}`}(o,t):Yt(o,t)),It(n.length),r=s}),n+e.slice(r)}(e,t):"body"===n?function(e,t){return Kt(e,t)?Vt(e,t)??Yt(e,t):e}(e,t):Mt(e,t);return void 0!==i?i.push([e,o]):d.set(r,[[e,o]]),o},v=[{node:a,css:!1,attributes:!1,names:"custom"===n,root:!0}];for(;v.length>0;){let{node:e,css:r,attributes:i,names:s,root:o}=v.pop();if(Array.isArray(e))for(let t=0;t<e.length;t++){let i=e[t];"string"==typeof i?e[t]=p(g(f,()=>y(i,r?"css":"text"))):null!==i&&"object"==typeof i&&v.push({node:i,css:r,attributes:!1,names:"custom"===n,root:!1})}else if(ln(e))for(let a of Object.keys(e)){let l=e[a];if("dom"===n&&s&&!a.startsWith("rr_")&&"_cssText"!==a&&t.plain.some(e=>a.includes(e))){delete e[a];continue}let u=c(e,a,r,i,o);if("string"==typeof l)e[a]=p(g(f,()=>y(l,u)));else if(null!==l&&"object"==typeof l){let e="dom"===n&&"attributes"===a;v.push({node:l,css:"css"===u,attributes:e,names:"custom"===n||e||"dom"===n&&i&&"style"===a||"network"===n&&o&&("requestHeaders"===a||"responseHeaders"===a),root:!1})}if(!s||a.startsWith("rr_")||"_cssText"===a)continue;let d=a;for(let e of t.plain)d.includes(e)&&(d=d.split(e).join("[REDACTED]"));if(d===a)continue;let h=e[a];delete e[a];let m=d;for(let t=2;Object.prototype.hasOwnProperty.call(e,m);t++)m=`${d}#${t}`;e[m]=h}}return a}function ln(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function un(e){if(e)for(let[t,n]of Object.entries(e))if("content-type"===t.toLowerCase())return n}var cn=[{name:"phone_us",pattern:/(?:\+\d{1,3}[ .-]?)?(?:\(\d{3}\)[ .-]?|\b\d{3}[ .-])\d{3}[ .-]\d{4}\b/g},{name:"ssn",pattern:/\b\d{3}-\d{2}-\d{4}\b/g},{name:"ipv4",pattern:/\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b/g}],dn=["authorization","cookie","set-cookie","x-api-key","x-auth-token","proxy-authorization"];function hn(e){return p(e,"page").join("")}var fn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,pn=/^eyJ[\w-]+\.[\w-]+\.[\w-]*$/,gn=/(?:^|-)[A-Za-z]{3,}-(?:[A-Za-z0-9]+-)*[A-Za-z]{3,}(?:-|$)/;function yn(e){return!!pn.test(e)||!(e.length<32||fn.test(e)||gn.test(e))&&/^[A-Za-z0-9_\-.~+/=]+$/.test(e)&&/[0-9]/.test(e)&&/[A-Za-z]/.test(e)}var vn=/@|\d[\d .()-]{5,}\d|\d\.\d|eyJ/;function mn(e){return e.split("/").some(e=>{if(/callback|oauth/i.test(e))return!0;let t=Ne(e);return[...t,t.join("")].some(e=>Je.has(e))})}var wn=new Set(["code","state","accesstoken","idtoken","refreshtoken"]);function bn(e,t){let n=new Map;for(let t of e){let e=t.indexOf("=");if(-1===e)continue;let r=hn(w(t.slice(0,e)));if(!wn.has(r))continue;let i=n.get(r),s=w(t.slice(e+1));void 0===i?n.set(r,[s]):i.push(s)}let r=e=>n.get(e)??[],i=new Set,s=r("code").filter(e=>""!==e&&!De(e)),o=r("state").filter(e=>""!==e&&!function(e){return!!q.test(e)&&(e.length<=16||j.test(e)||/^[A-Za-z][a-z]+(?:[-_][A-Za-z][a-z]+)+$/.test(e))}(e)&&!De(e));return s.length>0&&(t||o.length>0)&&(i.add("code"),i.add("state"),i.add("sessionstate")),(r("accesstoken").length>0||r("idtoken").length>0||r("refreshtoken").length>0)&&(i.add("state"),i.add("sessionstate")),i}var kn=[],Sn=!1,xn=!1;function En(e,t,n){let r=xn;xn=e;try{return jn(t,n)}finally{xn=r}}var In,An=/reset|verif|confirm|activat|invit|magic|log-?in|passw|unlock|forgot|recover|sign-?up/i,Tn=new Set(["href","xlink:href","src","action","formaction","srcset","poster","cite","data","data-src","data-href","background","longdesc"]),Rn=new Set(["title","alt","placeholder","label","content","summary","abbr","aria-label","aria-description","aria-valuetext","aria-placeholder","aria-roledescription","aria-braillelabel","aria-brailleroledescription"]),_n=new Set(["input","textarea","select"]),Cn=/^(?:style|_csstext|srcset|data-srcset|imagesrcset|ping|srcdoc)$/,On=/^[^\s"'`<>{}]*$/;function $n(e,t,n,r,i=!1){if(!("content"===e?In?.(e,n,i,r):Cn.test(e)||In?.(e,n,i)||Tn.has(e)&&On.test(a(t))))return/[^*\s]/.test(t)?"":t}var Dn=/^(\s*[\d.]*\s*[;,]\s*(?:url\s*=\s*)?)(['"]?)(.*?)(\2\s*)$/is,Nn=/[?#;@]|eyJ/;function zn(e){return Nn.test(e)||Sn&&An.test(e)}var Ln=new WeakMap;function Bn(e){return(t,n,r)=>{let i=function(e){let t=Ln.get(e.pairs);return void 0===t&&(t={oauth:bn([...e.pairs],mn(e.path))},Ln.set(e.pairs,t)),t}(r);if(i.oauth.has(hn(w(t)))||Ye(p(t,"page"),n)&&(i.linkPage??=function(e,t){let n=t.map(e=>{let t=e.indexOf("=");return-1===t?[e,""]:[e.slice(0,t),e.slice(t+1)]});return Ge([e.split("/").map(e=>e.split(";")[0])],Qe(n))}(r.path,[...r.pairs])))return"[REDACTED]";let s=e?0:function(e){let t=0,n=null;for(let r of kn)if(!(r.length<=t||"/"!==e.charAt(r.length))){if(e.startsWith(r)){t=r.length;continue}null===n&&(n=wt(e)),n.startsWith(r)&&(t=r.length)}return t}(n);if(s>0){let e=w(n.slice(s));if(!vn.test(e)||ee(e)===e)return`[REDACTED]${n.slice(s)}`}return null}}function Un(e){let t,n=null;return{kind:"page",strict:e,whole:!1,before:Bn(e),value:(e,t,n)=>{let r=p(e,"key");return!(!/[[\]]/.test(a(e))&&/ids?$/.test(r[0]??""))&&(function(e){return!!yn(e)||!/^(?:https?:|\/)[^\s"<>\\^`{|}[\]]*$/i.test(e)&&function(e){return e.split(/[^A-Za-z0-9_\-.~+/=]+/)}(e).some(yn)}(n)||yn(t))||vn.test(n)&&ee(n)!==n},bare:e=>yn(e)||yn(w(e)),segment:e=>pn.test(e),head:(e,r,i,s)=>!!Sn&&(s!==t&&(t=s,n=An.test(e)?function(e){let t=new Set,n=e.startsWith("/")?e:`/${e}`;for(let e of yt(`https://link.invalid${n}`))t.add(e.value);return t}(e):null),null!==n&&n.has(r)&&(function(e){let t=a(e);return!!fn.test(t)||t.split(/[-_.~]+/).some($e)}(r)||xn&&Ve(s,i)))}}var Pn=Un(!1),qn=Un(!0);function jn(e,t){return zn(e)?O(e,t?qn:Pn):e}var Mn=/(?:[A-Za-z0-9_-]|[\u0080-\uffff]|\\(?:[0-9A-Fa-f]{1,6}[ \t\n]?|[^\n0-9A-Fa-f]))+/y;function Kn(e,t){return Mn.lastIndex=t,Mn.test(e)?Mn.lastIndex:t}function Wn(e){return e.replace(/\\(?:([0-9A-Fa-f]{1,6})[ \t\n]?|([\s\S]))/g,(e,t,n)=>{if(void 0===t)return"\n"===n?"":n??"";let r=parseInt(t,16);return 0===r||r>1114111||r>=55296&&r<=57343?"\ufffd":String.fromCodePoint(r)})}function Fn(e,t){if(!/url\(|["'\\]/i.test(e)||!zn(e)&&!e.includes("\\"))return e;let n=e.length,r=/[\t\n\f\r ]/,i="",s=0,o=(n,r,o)=>{let a=e.slice(n,r),l=a.includes("\\")?Wn(a):a,u=jn(l,t);u!==l&&(i+=e.slice(s,n)+(l===a?u:function(e,t){return e.replace(t?/[\\"'\n]/g:/[\\"'()\s]/g,e=>/\s/.test(e)?`\\${e.charCodeAt(0).toString(16)} `:`\\${e}`)}(u,o)),s=r)},a=0;for(;a<n;){let t=e[a];if("/"===t&&"*"===e[a+1]){let t=e.indexOf("*/",a+2);a=-1===t?n:t+2}else if(e.startsWith("\x3c!--",a))a+=4;else if('"'===t||"'"===t){let r=a+1;for(;r<n&&e[r]!==t&&"\n"!==e[r];)r+="\\"===e[r]?2:1;r=Math.min(r,n),o(a+1,r,!0),a=r+1}else{let t=Kn(e,a);if(t===a){a++;continue}if("("!==e[t]||"url"!==Wn(e.slice(a,t)).toLowerCase()){a=t;continue}let i=t+1;for(;i<n&&r.test(e[i]);)i++;if('"'===e[i]||"'"===e[i]){a=i;continue}let s=i;for(;s<n&&")"!==e[s];)s+="\\"===e[s]?2:1;s=Math.min(s,n);let l=s;for(;l>i&&r.test(e[l-1]);)l--;o(i,l,!1),a=s+1}}return 0===s?e:i+e.slice(s)}var Hn={Tab:"\t",NewLine:"\n",excl:"!",quot:'"',QUOT:'"',num:"#",dollar:"$",percnt:"%",amp:"&",AMP:"&",apos:"'",lpar:"(",rpar:")",ast:"*",midast:"*",plus:"+",comma:",",period:".",sol:"/",colon:":",semi:";",lt:"<",LT:"<",equals:"=",gt:">",GT:">",quest:"?",commat:"@",lsqb:"[",lbrack:"[",bsol:"\\",rsqb:"]",rbrack:"]",Hat:"^",lowbar:"_",UnderBar:"_",grave:"`",DiacriticalGrave:"`",lcub:"{",lbrace:"{",verbar:"|",vert:"|",VerticalLine:"|",rcub:"}",rbrace:"}",nbsp:"\xa0",NonBreakingSpace:"\xa0"};function Zn(e,t){let n=e.replace(/&/g,"&amp;");return'"'===t?n.replace(/"/g,"&quot;"):"'"===t?n.replace(/'/g,"&#39;"):n.replace(/[\s"'`>]/g,e=>`&#${e.charCodeAt(0)};`)}var Vn=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes"]),Jn=/(^|[\s/"'])(href|xlink:href|src|action|formaction|poster|cite|data|background|longdesc|data-src|data-href|srcset|imagesrcset|data-srcset|ping|content|style|srcdoc)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi;function Xn(e,t,n=[],r="",i=!1){let s=[kn,Sn];kn=n,Sn=!0;try{Gn(e,t,r,i)}finally{[kn,Sn]=s}}function Gn(e,t,n="",r=!1){for(let i of Object.keys(e)){let s=e[i],o=i.toLowerCase();if(t&&("checked"===o||"selected"===o)){delete e[i];continue}if("string"!=typeof s){"style"===o&&ln(s)&&Qn(s,t);continue}let a=(t?$n(o,s,n,e,r):void 0)??Yn(o,tr(o,s,t,n),n);a!==s&&(e[i]=a)}}function Qn(e,t){let n=e=>Yn("style",Fn(e,t),"");for(let t of Object.keys(e)){let r=e[t];if("string"==typeof r){let i=n(r);i!==r&&(e[t]=i)}else if(Array.isArray(r)&&"string"==typeof r[0]){let i=n(r[0]);i!==r[0]&&(e[t]=[i,...r.slice(1)])}}}function Yn(e,t,n){return e.startsWith("rr_")?t:function(e,t){return"value"===e?""!==t&&!_n.has(t):Rn.has(e)||e.startsWith("data-")&&!Tn.has(e)&&"data-srcset"!==e}(e,n)&&vn.test(t)?ee(t):te(t)}function er(e){return te(e)}function tr(e,t,n,r){let i=t;return"srcset"===e||"data-srcset"===e||"imagesrcset"===e?i=function(e,t){if(!zn(e))return e;let n=e.split(",").map(e=>{let n=/^(\s*)(\S+)([\s\S]*)$/.exec(e);return null===n?e:n[1]+jn(n[2],t)+n[3]}).join(",");return n===e?e:n}(t,n):"style"===e||"_csstext"===e?i=Fn(t,n):"ping"===e?i=t.replace(/\S+/g,e=>jn(e,n)):"srcdoc"===e?i=function(e,t){if(!t&&!zn(e)&&!/url\(/i.test(e))return e;let n=e.length,r=/[\t\n\f\r ]/,i=[],s=new Set,o=(n,r,s,o,a="")=>{let l=function(e){return e.includes("&")?e.replace(/&(?:#(\d+);?|#[xX]([0-9A-Fa-f]+);?|([A-Za-z][A-Za-z0-9]*);|(amp|AMP|lt|LT|gt|GT|quot|QUOT)(?![A-Za-z0-9=]))/g,(e,t,n,r,i)=>{if(void 0!==t||void 0!==n){let e=void 0!==t?Number(t):parseInt(n,16);return 0===e||e>1114111||e>=55296&&e<=57343?"\ufffd":String.fromCodePoint(e)}return Hn[r??i??""]??e}):e}(e.slice(r,s)),u=(t?$n(n,l,a):void 0)??tr(n,l,t,"");u!==l&&i.push([r,s,Zn(u,o)])},a=(t,i,a="")=>{let l=t;for(;;){for(;l<n&&(r.test(e[l])||"/"===e[l]);)l++;if(l>=n||">"===e[l])return l;let t=l;for(l++;l<n&&!r.test(e[l])&&!"/>=".includes(e[l]);)l++;let u=e.slice(t,l).toLowerCase(),c=l;for(;c<n&&r.test(e[c]);)c++;if("="!==e[c]){l=c;continue}for(c++;c<n&&r.test(e[c]);)c++;let d='"'===e[c]||"'"===e[c]?e[c]:"",h=""===d?c:c+1,f=h;if(""!==d)f=e.indexOf(d,h),-1===f&&(f=n),l=Math.min(f+1,n);else{for(;f<n&&!r.test(e[f])&&">"!==e[f];)f++;l=f}i&&(s.add(`${h}:${f}`),o(u,h,f,d,a))}},l=(n,r)=>{let s=e.slice(n,r);t&&/\S/.test(s)&&i.push([n,r,s.replace(/\S/g,"*")])},u=0,c=e.indexOf("<");for(;-1!==c&&c<n;){let s,o=!0;if(e.startsWith("\x3c!--",c))if(e.startsWith(">",c+4))s=c+5;else if(e.startsWith("->",c+4))s=c+6;else{let t=/--!?>/g;t.lastIndex=c+4;let r=t.exec(e);s=null===r?n:r.index+r[0].length,l(c+4,null===r?n:r.index)}else if("!"===e[c+1]||"?"===e[c+1]){let t=e.indexOf(">",c+2);s=-1===t?n:t+1,/^<!doctype/i.test(e.slice(c,c+9))||l(c+2,-1===t?n:t)}else if("/"===e[c+1]&&/[A-Za-z]/.test(e[c+2]??"")){let t=c+2;for(;t<n&&!r.test(e[t])&&!"/>".includes(e[t]);)t++;s=a(t,!1)+1}else if(/[A-Za-z]/.test(e[c+1]??"")){let o=c+1;for(;o<n&&!r.test(e[o])&&!"/>".includes(e[o]);)o++;let u=e.slice(c+1,o).toLowerCase(),d=a(o,!0,u);if(s=d+1,Vn.has(u)&&d<n){let r=new RegExp(`</${u}[\\t\\n\\f\\r />]`,"gi");r.lastIndex=d+1;let o=r.exec(e),a=null===o?n:o.index;if("style"===u){let n=e.slice(d+1,a),r=Fn(n,t);r!==n&&i.push([d+1,a,r])}else l(d+1,a);s=a}}else s=c+1,o=!1;o&&(l(u,c),u=s),c=e.indexOf("<",s)}l(u,n),i.sort((e,t)=>e[0]-t[0]);let d=i.length,h=new RegExp(Jn.source,"gi"),f=0,p=0;for(let t=h.exec(e);null!==t;t=h.exec(e)){let e=t[3]??t[4]??t[5]??"",n=t.index+t[0].length-(void 0===t[5]?1:0),r=n-e.length;for(h.lastIndex=r;f<d&&i[f][1]<=r;)f++;if(s.has(`${r}:${n}`)||f<d&&i[f][0]<n||r<p)continue;let a=void 0!==t[3]?'"':void 0!==t[4]?"'":"",l=i.length;o(t[2].toLowerCase(),r,n,a),i.length>l&&(p=n)}if(0===i.length)return e;i.sort((e,t)=>e[0]-t[0]);let g="",y=0;for(let[t,n,r]of i)g+=e.slice(y,t)+r,y=n;return g+e.slice(y)}(t,n):"content"===e?i=function(e,t){if(!zn(e))return e;let n=Dn.exec(e);if(null!==n&&""!==n[3]){let r=En(!0,n[3],t);return r===n[3]?e:n[1]+n[2]+r+n[4]}return/^\s*https?:\/\//i.test(e)?jn(e,t):e}(t,n):Tn.has(e)?i=En(function(e,t){return"href"===e||"xlink:href"===e?""===t||"a"===t||"area"===t:"action"===e||"formaction"===e}(e,r),t,n):nr.test(t)&&(i=En(!1,t,n)),i}var nr=/^(?:(?:[a-z][a-z0-9+.-]{0,31}:\/|[a-z][a-z0-9-]{0,30}[+.][a-z0-9+.-]{0,30}:|localhost:\d{1,5}[/?#]|(?:mailto|tel|sms|urn|data|javascript|vbscript|blob|about|xmpp|sip|sips|magnet|intent|bitcoin|geo|market|news):|\.{0,2}\/)[^\s?#;]*[?#;]|[?#])\S*$/i;function rr(e,t,n=[]){let r=[kn,Sn];kn=n,Sn=!0;try{return Fn(e,t)}finally{[kn,Sn]=r}}function ir(e){let t=e.map(e=>e.textContent).join(""),n=re(t).sort((e,t)=>e[0]-t[0]),r=0,i=0;for(let s of e){let e=i+s.textContent.length,o="",a=i;for(;r<n.length&&n[r][0]<e;){let[i,s]=n[r];if(i>=a&&(o+=`${t.slice(a,i)}[REDACTED]`),a=Math.max(a,Math.min(s,e)),s>e)break;r++}s.textContent=o+t.slice(a,e),i=e}}function sr(e){let t=e;return 3===t?.type&&"string"==typeof t.textContent}function or(e){let t=[];for(let n of e)sr(n)?t.push(n):5!==n?.type&&(t.length>1&&ir(t),t=[]);t.length>1&&ir(t)}function ar(e,t,n=[]){let r=[kn,Sn];kn=n,Sn=!0;try{!function(e,t){let n=[e],r=new Set;for(;n.length>0;){let e=n.pop();if(null===e||"object"!=typeof e||r.has(e))continue;if(r.add(e),"string"==typeof e.textContent){let n=!0===e.isStyle?Fn(e.textContent,t):t&&5===e.type?"":er(e.textContent);n!==e.textContent&&(e.textContent=n)}let i=e.attributes;if(null!==i&&"object"==typeof i&&Gn(i,t,"string"==typeof e.tagName?e.tagName.toLowerCase():"",!0===e.isSVG),Array.isArray(e.childNodes)){or(e.childNodes);for(let t of e.childNodes)n.push(t)}}}(e,t)}finally{[kn,Sn]=r}}function lr(e,t,n){switch(e){case"location":case"content-location":return n(t);case"link":return t.replace(/<([^>]*)>/g,(e,t)=>`<${n(t)}>`);case"refresh":{let e=/^\s*(?:\d[\d.]*\s*[;,]\s*)?url\s*=\s*/i.exec(t);if(null===e)return pe(t);let r=t.slice(e[0].length),i=/^(["'])(.*)\1$/.exec(r);return i?`${e[0]}${i[1]}${n(i[2])}${i[1]}`:`${e[0]}${n(r)}`}}return pe(t)}var ur=new Set(["accept","accept-encoding","accept-ranges","age","cache-control","connection","content-encoding","content-language","content-length","content-type","date","etag","expires","keep-alive","last-modified","pragma","transfer-encoding","vary"]);function cr(e){if(e.startsWith("access-control-"))return!1;if(K(e))return!0;let t=e.split(/[-_\s]+/).filter(e=>""!==e);t.length>1&&/^v?\d+$/.test(t[t.length-1])&&t.pop();let n=t[t.length-1]??"",r=t[t.length-2]??"";return K(n)||""!==r&&K(r+n)}function dr(){return{maskSelectors:[],unmaskSelectors:[],blockSelectors:[],maskNetworkBodies:!1,sensitiveHeaders:[...dn],piiPatterns:[],secretRoutes:[],keepRoutes:[]}}function hr(e,t){let n=Object.fromEntries(Object.entries(t).filter(([,e])=>void 0!==e)),r={...e,...n};if(n.sensitiveHeaders){let t=new Set;r.sensitiveHeaders=[...dn,...e.sensitiveHeaders,...n.sensitiveHeaders].filter(e=>{let n=e.toLowerCase();return!t.has(n)&&(t.add(n),!0)})}return r}function fr(e){return e.map(({pattern:e})=>e.flags.includes("g")?new RegExp(e.source,e.flags):new RegExp(e.source,e.flags+"g"))}var pr={},gr="[MASKED]",yr=class{config;builtinPatterns;userPatterns;strict;constructor(e={},t="balanced"){this.strict="strict"===t,this.config=this.settle(hr(dr(),e)),this.builtinPatterns=fr(cn),this.userPatterns=fr(this.config.piiPatterns)}settle(e){return this.strict?{...e,maskNetworkBodies:!0}:e}maskText(e){if(!e)return e;let t=ee(e,this.userPatterns);for(let e of this.builtinPatterns)t=t.replace(e,"[REDACTED]");return t}maskUrl(e){if(!e)return e;let t=e.indexOf("#");return function(e,t=!1){return O(e,t?xe:Se)}(-1===t?e:e.slice(0,t),this.strict)}maskNetworkData(e,t){let n={...e};n.requestHeaders=this.maskHeaders(e.requestHeaders),n.responseHeaders=this.maskHeaders(e.responseHeaders);let r=this.bodyJob(e),i=r&&(t??pr.redact?.(r)??{requestBody:e.requestBody?gr:null,responseBody:e.responseBody?gr:null});return n.requestBody=i?i.requestBody:e.requestBody?gr:null,n.responseBody=i?i.responseBody:e.responseBody?gr:null,n.url=this.maskUrl(e.url),n}bodyJob(e){return this.config.maskNetworkBodies?null:{requestBody:e.requestBody,responseBody:e.responseBody,requestType:un(e.requestHeaders),responseType:un(e.responseHeaders),patterns:this.userPatterns}}getConfig(){return this.config}updateConfig(e){this.config=this.settle(hr(this.config,e)),this.userPatterns=fr(this.config.piiPatterns)}maskHeaders(e){let t={},n=new Set(this.config.sensitiveHeaders.map(e=>e.toLowerCase()));for(let[r,i]of Object.entries(e)){let e=r.toLowerCase();n.has(e)||cr(e)||this.strict&&!ur.has(e)?t[r]="[REDACTED]":t[r]=this.maskText(lr(e,i,e=>this.maskUrl(e)))}return t}},vr=200,mr=/^[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*$/,wr="must be 1-200 characters of letters, digits, dot, dash and underscore, with no empty dot-separated segment";function br(e){return"string"==typeof e&&e.length>0&&e.length<=200&&mr.test(e)}var kr=["status","serverMessage","endpoint","sessionId"],Sr=["issues"];function xr(e){let t={};for(let n of Object.keys(e)){let r=e[n],i="https://keploy.io/docs/ui-capture/errors#"+n.toLowerCase().replace(/_/g,"-");t[n]={summary:r.summary,remedy:{command:null,manual:i,docs:i},evidence:r.evidence,optionalEvidence:r.optionalEvidence??[]}}return t}var Er=xr({KUI_E_INGEST_KEY_REJECTED:{summary:"The ingest server refused the SDK's API key (401 or 403). Capture has stopped.",evidence:kr,optionalEvidence:Sr},KUI_E_INGEST_ENDPOINT_NOT_FOUND:{summary:"The ingest server answered 404 or 405: nothing at `endpoint` accepts a POST. Capture has stopped.",evidence:kr,optionalEvidence:Sr},KUI_E_SESSION_CONFLICT:{summary:"The ingest server answered 409: this session id is already claimed, or a batchId was re-used. Capture has stopped.",evidence:kr,optionalEvidence:Sr},KUI_E_INGEST_REJECTED:{summary:"The ingest server refused a batch with a terminal 4xx (400, 413 or 415). Capture has stopped.",evidence:kr,optionalEvidence:Sr},KUI_E_SESSION_ID_INVALID:{summary:"The configured `sessionIdGenerator` did not produce a session id the ingest server would accept. Capture did not start.",evidence:["sessionId","received","rule"]},KUI_E_DOM_RECORDER_UNAVAILABLE:{summary:"The capture SDK could not load rrweb, the library it records the page with. The capture ended before anything was sent.",evidence:["reason"]},KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE:{summary:"Under strict, the capture SDK could not load its attribute allow-list. The capture ended before anything was recorded or sent.",evidence:["reason"]},KUI_E_PRIVACY_ROUTE_INVALID:{summary:"A route in `privacy.secretRoutes` or `privacy.keepRoutes` is not one the SDK can match. Capture did not start.",evidence:["option","received","rule"]},KUI_E_CAPTURE_DECLINED:{summary:"The browser sent Do Not Track or Global Privacy Control, and `honorPrivacySignals` is on. Capture did not start; nothing was recorded or sent.",evidence:["signal"]},KUI_E_PRIVACY_CONFLICT:{summary:'`privacyMode: "strict"` records no body, and `privacy.maskNetworkBodies` is `false`, which asks for them. Capture did not start.',evidence:["privacyMode","option"]}}),Ir=xr({KUI_E_EVENT_UNSERIALISABLE:{summary:"The SDK dropped one captured event because it could not be serialised to JSON. The capture continues without it.",evidence:["eventId","eventType","reason"]},KUI_E_EVENT_OVERSIZED:{summary:"The SDK dropped one captured event that alone is over the ingest server's decoded cap (`evidence.cap` bytes). The capture continues without it.",evidence:["eventId","eventType","bytes","cap"]},KUI_E_EVENT_OVERSIZED_SCRUBBING:{summary:"The SDK dropped one captured event whose scrub of the page URL's credentials passed the ingest server's decoded cap (`evidence.cap` bytes). The capture continues without it.",evidence:["eventType","atLeast","cap"]},KUI_E_NAVIGATION_UNWRAPPED:{summary:"The page made a History or Navigation API method the SDK wraps (`evidence.method`) impossible to replace and put back, so the SDK wrapped none of them. The capture continues.",evidence:["method"]},KUI_E_REQUEST_TERM_FAILED:{summary:"The SDK recorded a request without its canonical-key.v2 term (computing it threw: `evidence.reason`), or body:* (its term code did not load). The page's request was unaffected.",evidence:["method","reason"]},KUI_E_BODY_WORKER_UNAVAILABLE:{summary:"No body worker or chunk (`evidence.part`): no worker, a body over 64 KiB is recorded cut; no chunk, one the main thread redacts keeps nothing; tests over them are unproven.",evidence:["part","reason"]}});function Ar(e){return e.replace(/\s+/g," ").trim()}function Tr(e,t){let{code:n,...r}=e;return`[keploy] ${n}: dropped an event: ${Ar(t)} The capture continues; any further such events in this capture are dropped silently. evidence=${_r(r)}`}function Rr(e,t){let{code:n,...r}=e;return`[keploy] ${n}: ${Ar(t)} evidence=${_r(r)}`}function _r(e){try{return JSON.stringify(e)}catch{let t={};for(let[n,r]of Object.entries(e))t[n]="string"==typeof r||"number"==typeof r?r:Lr(r);return JSON.stringify(t)}}function Cr(e){return 401===e||403===e?"KUI_E_INGEST_KEY_REJECTED":404===e||405===e?"KUI_E_INGEST_ENDPOINT_NOT_FOUND":409===e?"KUI_E_SESSION_CONFLICT":e>=400&&e<500&&429!==e?"KUI_E_INGEST_REJECTED":null}var Or={message:null,issues:null},$r=500;function Dr(e){if(null===e)return Or;let t=e.trim();if(""===t)return Or;try{let e=JSON.parse(t);if(null!==e&&"object"==typeof e){let t=e;if("string"==typeof t.error){let e=t.error.trim();return{message:""===e?null:e.slice(0,$r),issues:zr(t.issues)}}}}catch{}return{message:t.slice(0,$r),issues:null}}var Nr=100;function zr(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(t.length===Nr)break;if(null===n||"object"!=typeof n)continue;let{path:e,message:r}=n;"string"!=typeof e||"string"!=typeof r||t.push({path:e.slice(0,$r),message:r.slice(0,$r)})}return t.length>0?t:null}function Lr(e){if("string"==typeof e)return e;if(e instanceof Error)return`${e.name}: ${e.message}`;if("function"==typeof e)return`[function ${e.name}]`;if("object"!=typeof e||null===e)return String(e);try{return JSON.stringify(e)}catch{let t=e.constructor;return`[${"string"==typeof t?.name?t.name:"object"} not JSON-serialisable]`}}var Br=class extends Error{code;status;serverMessage;issues;remedy;evidence;constructor(e,t,n,r,i){super(t),this.name="CaptureError",this.code=e,this.remedy=Er[e].remedy,this.status=n,this.serverMessage=r.message,this.issues=r.issues,this.evidence=i}},Ur=class extends Br{constructor(e){let{message:t,issues:n}=e.server,r=`[keploy] capture stopped: the server rejected this batch with ${e.status} and will reject the rest, so capture has stopped (${e.code}). ${null===t?"(no response body)":t}`;if(null!==n){let e=n.slice(0,5).map(e=>`${""===e.path?"body":e.path}: ${e.message}`).join("; "),t=n.length-5;r+=` -- ${e}${t>0?` (+${t} more)`:""}`}super(e.code,r,e.status,e.server,{status:e.status,serverMessage:t,endpoint:e.endpoint,sessionId:e.sessionId,...null!==n?{issues:n}:{}})}},Pr=class extends Br{constructor(e){super("KUI_E_SESSION_ID_INVALID",`[keploy] capture did not start: sessionIdGenerator ${null!==e.sessionId?`returned ${JSON.stringify(e.sessionId)}, which the ingest server would refuse`:e.received.startsWith("threw ")?e.received:`returned ${e.received}, which is not a session id`} (KUI_E_SESSION_ID_INVALID). A session id ${wr}.`,null,Or,{sessionId:e.sessionId,received:e.received,rule:wr})}},qr=class extends Br{constructor(e){super("KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE",`[keploy] capture ended before anything was recorded: privacyMode "strict" could not load its attribute allow-list (KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE): ${e.reason}. What to do: ${Er.KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE.remedy.docs}`,null,Or,{reason:e.reason})}},jr=class extends Br{constructor(e){super("KUI_E_DOM_RECORDER_UNAVAILABLE",`[keploy] capture ended before anything was sent: rrweb, the library the SDK records the page with, could not be loaded (KUI_E_DOM_RECORDER_UNAVAILABLE): ${e.reason}. What to do: ${Er.KUI_E_DOM_RECORDER_UNAVAILABLE.remedy.docs}`,null,Or,{reason:e.reason})}},Mr=class extends Br{constructor(e){super("KUI_E_PRIVACY_ROUTE_INVALID",`[keploy] capture did not start: privacy.${e.option} has ${e.received}, which is no route (KUI_E_PRIVACY_ROUTE_INVALID). ${tt}.`,null,Or,{option:e.option,received:e.received,rule:tt})}},Kr=class extends Br{constructor(e){super("KUI_E_CAPTURE_DECLINED",`[keploy] capture did not start: the browser sent ${"doNotTrack"===e?"Do Not Track":"Global Privacy Control"}, and honorPrivacySignals is on (KUI_E_CAPTURE_DECLINED). Nothing was recorded or sent.`,null,Or,{signal:e})}},Wr=class extends Br{constructor(){super("KUI_E_PRIVACY_CONFLICT",'[keploy] capture did not start: privacyMode "strict" records no request or response body, and privacy.maskNetworkBodies is false, which asks for them (KUI_E_PRIVACY_CONFLICT). Remove privacy.maskNetworkBodies, or use privacyMode "balanced".',null,Or,{privacyMode:"strict",option:"privacy.maskNetworkBodies"})}};function Fr(e){if("threw"in e)return`threw ${Lr(e.threw)}`;let t=e.returned;if("object"==typeof t&&null!==t){if("function"==typeof t.then)return"a Promise (sessionIdGenerator must return a string synchronously)";let e=t.constructor,n="string"==typeof e?.name?e.name:"";if(""!==n&&"Object"!==n)return`object ${n} ${Lr(t)}`}return`${typeof t} ${Lr(t)}`}var Hr,Zr,Vr,Jr=!1,Xr=!1,Gr=[],Qr=0,Yr=()=>Qr,ei=new WeakSet,ti=!1,ni=[],ri=!1,ii=[];function si(e=!0){if(!Jr)return;for(let t of ii)t(e);Jr=Xr=ti=!1,Hr=Zr=Vr=void 0;let t=ni;ni=[],ci(),setTimeout(()=>{for(let e of t)hi(e)||e()},0)}var oi=new Set,ai=(e,t)=>new Promise((n,r)=>{let i=()=>{if(Xr&&!t)return n(void 0);let i=()=>n(void 0);oi.add(i),e.then(e=>(oi.delete(i),n(e)),e=>(oi.delete(i),r(e)))};(t||!ui(i))&&i()});function li(){for(let e of oi)e();oi.clear()}function ui(e){let t=Jr&&!Xr;return t&&Gr.push(e),t}function ci(){let e=Gr;Gr=[];for(let t of e)t()}function di(){!Jr||Xr||(Xr=!0,ni.length&&li(),ci())}function hi(e){return Jr&&(ni.push(e),Xr&&li()),Jr}function fi(e){return new Promise((t,n)=>{let r=()=>{new Promise(t=>t(e())).then(t,e=>{hi(r)||n(e)})};hi(r)||r()})}var pi=()=>globalThis.navigation;function gi(e,t,n,r){let i=Qr;setTimeout(()=>{if(!r)return void(Hr===e&&t()&&si(n));if(ti||i!==Qr||!Jr)return;let s=r.defaultPrevented||ei.has(r);if(r===Vr&&Hr===r&&(s||t()))return si(n);r!==Vr&&s||(ti=!0,di())},0)}function yi(e){let t=e.type,n=e;if("currententrychange"===t)return void(Zr&&(n.from!==pi()?.currentEntry||n.navigationType)&&ei.add(Zr));if("pageshow"===t)return void(e.isTrusted&&e.persisted&&si());Jr||(Zr=void 0);let r=Jr;"navigate"===t&&(Zr=e),!n.destination?.sameDocument&&null==n.downloadRequest&&(r||Qr++,Jr=!0,Hr=e,"navigate"!==t?setTimeout(()=>{Hr===e&&(ti=!0,di())},0):(gi(e,()=>pi()?.transition,r&&Xr,Vr=n),n.signal?.addEventListener("abort",()=>gi(Hr,()=>Zr===e,!1))))}var vi=["beforeunload","pageshow"];function mi(e,t=e){if(t&&si(),ri===e||"function"!=typeof addEventListener)return;ri=e;let n={capture:!0,passive:!0},r=(t,r)=>{for(let i of r)e?t?.addEventListener(i,yi,n):t?.removeEventListener(i,yi,n)};r(globalThis,vi),r(pi(),["navigate","currententrychange"])}var wi="3.1.0-rc.2";function bi(e){return"default"in e?e.default:e}function ki(e,t){let n=e=>{let t=bi(e),n=t.version;if(n!==wi)throw new Error(`a chunk of version ${String(n)}, not the SDK's ${wi}`);return t};return fi(e).then(n).catch(e=>t?fi(t).then(n).catch(t=>Promise.reject(new Error(`${String(e)}; beside the SDK: ${String(t)}`,{cause:e}))):Promise.reject(e))}var Si,xi,Ei,Ii,Ai=!1,Ti=!1,Ri=!1,_i=new Set,Ci=new Map,Oi=0,$i=e=>e.mark===Yr();function Di(e){(typeof requestIdleCallback<"u"?requestIdleCallback:setTimeout)(e,{timeout:1e3,valueOf:()=>0})}var Ni,zi,Li="";function Bi(e,t){if(!Li.includes(e)){Li+=e;try{console.warn(function(e,t){return Rr({code:"KUI_E_BODY_WORKER_UNAVAILABLE",part:e,reason:t},"could not run the body worker or load the body chunk (evidence.part): without the worker, a body over 64 KiB is recorded cut; without the chunk, a body the main thread must redact is recorded with nothing kept; replay reports a test over a cut body unproven. Allow worker-src 'self' in the page's CSP, use a bundler that emits the worker (or copy dist/body-worker.js beside the bundle), serve it from the page's origin, or serve the SDK's dist/ as it is. Said once per page for each part.")}(e,typeof Event<"u"&&t instanceof Event?t.message||"the worker's script did not load or run (refused by the page's CSP, a 404, or a script that does not parse)":Lr(t)))}catch{}}}function Ui(e){if(typeof navigator>"u"||!1!==navigator.onLine||function(){try{return!!navigator.serviceWorker?.controller}catch{return!1}}()||"function"!=typeof addEventListener)return!1;if(!Ni){Ni=[];let e=()=>{if(!1===navigator.onLine)return;zi?.();let e=Ni??[];Ni=void 0;for(let t of e)t()};addEventListener("online",e);let t=setInterval(e,1e3);zi=()=>{removeEventListener("online",e),clearInterval(t),zi=void 0}}return Ni.push(e),!0}function Pi(){return xi??=new Promise(e=>{let t=()=>{Ai=!1,ki(()=>import("@keploy/capture-sdk/body-redact"),void 0).then(e=>{if("function"!=typeof e.redactBodies)throw new TypeError("the body chunk has no redactBodies export");return e}).then(t=>{Si=t,pr.redact=e=>t.redactBodies(e),e()},t=>{Ti=!0,Bi("code",t),e()})};(Ai=Ui(t))||t()})}function qi(){if(Ri||void 0!==Ei)return;Ri=!0;let e=()=>{ki(()=>import("@keploy/capture-sdk/body-worker-start"),void 0).then(e=>fi(()=>e.startBodyWorker())).then(e=>{e.onmessage=({data:t})=>{Ii=e;let n=Ci.get(t.id);n&&(Ci.delete(t.id),n.owner.answered(n,t.out))},e.onerror=t=>Zi(e,t),Ei=e,Ri=!1;let t=_i;_i=new Set;for(let e of t)Hi(e)}).catch(e=>Zi(null,e))};Ui(e)||e()}function ji(){Pi(),qi()}var Mi,Ki=!1,Wi=!1;function Fi(e=!1){xi&&void 0!==Ei||(e?Ki:Wi)||(e?Ki=!0:Wi=!0,(e?Di:e=>setTimeout(e,0))(()=>{e?Ki=!1:Wi=!1,ji()}))}function Hi(e){if(!e.owner.has(e))return;let t=Ei?Ei===Ii:null===Ei&&Si;if(t||!$i(e)||!ui(()=>Hi(e))){if(!t&&(e=>Xr&&$i(e))(e))return e.owner.answered(e,Gi(e.job)),void(e.job=null);if(Ei){Ci.set(++Oi,e);try{Ei.postMessage({id:Oi,job:e.job})}catch{Ci.delete(Oi),e.owner.alone(e)}}else null===Ei?e.owner.alone(e):(_i.add(e),ji())}}function Zi(e,t){if(e&&Ei!==e)return;try{e?.terminate()}catch{}let n=[...Ci.values(),..._i].filter(e=>e.owner.has(e));Ci.clear(),Ei=void 0,_i=new Set(n),Ri=!0;let r=()=>{Ri=!1,qi()};if(!Ui(r)&&!hi(r)){Ri=!1,Ei=null,_i=new Set,Bi("worker",t);for(let e of n)e.owner.alone(e)}}function Vi(){if(Mi=void 0,Ei&&!(Ci.size>0)){try{Ei.terminate()}catch{}Ei=void 0}}var Ji=()=>{Mi&&(Ci.clear(),Vi())};function Xi(e=!0,t=()=>!1){if(e&&Ni&&(zi?.(),Ni=void 0,Ai&&(xi=void 0),void 0===Ei&&(Ri=!1),_i=new Set),t()&&void 0!==Ii&&Ei===Ii&&Jr)return Mi=t,void addEventListener("pagehide",Ji);Vi()}function Gi(e){let t=e=>e&&function(e,t){return`${function(e,t){return`[Body cut: 0 of ${t} characters kept, unverified]\n`}(0,e)}[Body not captured: ${U[t]}]\n`}(e.length,Ti?"code-failed":"left");return{requestBody:t(e.requestBody),responseBody:t(e.responseBody)}}function Qi(e,t,n=t){try{return Si.redactBodies(e,t,n)}catch{return null}}function Yi(e){return(e?.requestBody?.length??0)+(e?.responseBody?.length??0)}ii.push(e=>{e&&Ei&&Ei!==Ii&&Zi(Ei,"left"),Mi&&!Mi()&&Vi()});var es=class{held=new Map;redact(e,t,n,r=Yr()){let i={job:e,owner:this,after:n,mark:r};this.held.set(i,t),e&&(e.requestBody||e.responseBody)?typeof requestIdleCallback>"u"&&(i.sent=!0,Hi(i)):i.out={requestBody:e?e.requestBody:null,responseBody:e?e.responseBody:null},Promise.resolve(n).then(()=>Di(()=>{this.held.has(i)&&(void 0!==i.out?this.answer(i,i.out):i.sent||Hi(i))}))}holds(){return this.held.size>0}has(e){return this.held.has(e)}answered(e,t){this.held.has(e)&&(e.out=t,Promise.resolve(e.after).then(()=>Di(()=>this.answer(e,t))))}answer(e,t){let n=this.held.get(e);n&&(this.held.delete(e),_i.delete(e),e.job=null,n(t))}alone(e){Promise.all([Pi(),e.after]).then(()=>Di(()=>{if(!this.held.has(e))return;let t=e.job;this.answer(e,Si?Qi(t,65536):Gi(t))}))}now(e){let t=65536;for(let n of e?[!0,!1]:[!0])for(let e of[...this.held.keys()]){if(void 0!==e.out){this.answer(e,e.out);continue}let r=e.job;if(!r){this.answer(e,{requestBody:null,responseBody:null});continue}let i=Yi(r);if(n&&!(Si&&i<=t))continue;let s=Math.min(r.requestBody?.length??0,t);this.answer(e,Si?Qi(r,s,t-s):Gi(r)),t-=n?i:t}}},ts=/^[\t\n\r ]*\{/,ns=/[^\t\n\r ]/;var rs,is=!1;function ss(e){try{let t=typeof document<"u"?document.baseURI:void 0;return new URL(e,t).href}catch{return e}}function os(e){let t={};if(!e)return t;if(e instanceof Headers)e.forEach((e,n)=>{t[n]=e});else if(Array.isArray(e))for(let[n,r]of e)t[n]=r;else Object.assign(t,e);return t}function as(e,t){return e.length>t?e.slice(0,t)+ge:e}function ls(e){let t=e=>encodeURIComponent(e).replace(/%20/g,"+"),n=[];return e.forEach((e,r)=>{n.push("string"==typeof e?`${t(r)}=${t(e)}`:`${t(r)}=${t(`[File: ${e.name}, ${e.size} bytes]`)}`)}),n.join("&")}function us(e,t){let n=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(n.byteLength>t)return`[Binary: ${n.byteLength} bytes]`;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{return`[Binary: ${n.byteLength} bytes]`}}function cs(e,t){if(null==e)return null;try{if("string"==typeof e)return""===e?null:gr;if(e instanceof URLSearchParams||e instanceof FormData)return e.keys().next().done?null:gr;if(e instanceof Blob)return t||e.size>0?gr:null;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength>0?gr:null;if(t&&typeof Document<"u"&&e instanceof Document)return e.hasChildNodes()?gr:null}catch{}return gr}function ds(e){return"object"==typeof e&&null!==e&&"Request"===e[Symbol.toStringTag]}var hs=/^\s*multipart\/form-data\s*(?:;|$)/i;var fs=()=>new TextDecoder("utf-8",{ignoreBOM:!0}),ps=(e,t)=>t<4194304&&"{"!==(ns.exec(e)?.[0]??"{"),gs=async e=>fs().decode(await e.arrayBuffer());function ys(e){return e+ge}var vs=Reflect.get(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag)??{},"get"),ms=["url","redirected","type","headers"];function ws(e,t){for(let n of ms)Object.defineProperty(e,n,{get:()=>t[n],configurable:!0});let n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),"clone")?.value;n&&Object.defineProperty(e,"clone",{value:function(){let e=n.call(this);return ws(e,t),e},writable:!0,configurable:!0})}function bs(e,t,n){let r=e.body;if(!r)return null;let i,s,o,a=Object.getPrototypeOf(r).constructor,l=Object.getPrototypeOf(e).constructor,u=new TextDecoder,c="",d=!1,h=!1,f=!1,p=!1,g=!1,y=[],v=0,m=null,w=null,b=new Promise(e=>i=e),k=e=>{p||(p=!0,n(e))},S=()=>{if(!m||!w)return;let e=y.shift();if(e)w.enqueue(new Uint8Array(e.chunk)),v=e.textEnd;else{if(!h)return;w.close(),w.byobRequest?.respond(0)}let t=m;m=null,t()},x=()=>{g||h||f||d&&!m||(g=!0,A.read().then(e=>{if(g=!1,!f)try{if(e.done)h=!0,i(),d||k(as(c+u.decode(),t));else{let n=function(e){if("Uint8Array"===function(e){return"function"==typeof vs?Reflect.apply(vs,e,[]):void 0}(e))return e;throw new TypeError("a response body chunk is not a Uint8Array")}(e.value);n.byteLength>0&&(d||(c+=u.decode(n,{stream:!0}),c.length>t&&(d=!0,setTimeout(i,1e3),k(as(c,t)),c="")),y.push({chunk:n,textEnd:c.length}))}S(),x()}catch(e){E(e),A.cancel(e).catch(()=>{})}},e=>{g=!1,!f&&E(e)}))},E=e=>{f=!0,i(),k(ys(c)),y.length=0;try{w?.error(e)}catch{}let t=m;m=null,t?.()},I={start(e){w=e},pull:()=>new Promise(e=>{m=e,S(),x()}),cancel:e=>(f=!0,i(),k(c.slice(0,v)),y.length=0,A.cancel(e))};try{s=new a({...I,type:"bytes"},{highWaterMark:0})}catch{s=new a(I,{highWaterMark:0})}try{o=new l(s,{status:e.status,statusText:e.statusText,headers:e.headers})}catch{return null}let A=r.getReader();return ws(o,e),x(),{page:o,cut:()=>{d||k(ys(c)),i()},done:b}}function ks(e){let t=typeof document<"u"&&document.baseURI?document.baseURI:typeof location<"u"?location.href:void 0;return new URL(e,t).href}var Ss=class{callback=null;privacyEngine;maxBodySize;ignored;active=!1;inflight=new Set;unloadCuts=new Set;bodies=new es;place;admit=null;run=0;originalFetch=null;originalXhrOpen=null;originalXhrSend=null;originalXhrSetHeader=null;constructor(e={},t=524288,n=[],r="balanced"){this.privacyEngine=new yr(e,r),this.maxBodySize=t,this.ignored=new Set(n.map(ss))}ignores(e){return this.ignored.size>0&&this.ignored.has(ss(e))}start(e,t,n){this.active||(this.active=!0,this.run++,this.callback=e,this.admit=t??null,this.place=n,this.termWarned=!1,this.privacyEngine.getConfig().maskNetworkBodies||Fi(!0),this.patchFetch(),this.patchXHR())}askForCode(){this.privacyEngine.getConfig().maskNetworkBodies||Pi()}stop(){this.active&&(this.active=!1,0===this.inflight.size&&(this.callback=null),this.restoreFetch(),this.restoreXHR())}settle(e){let t,n=Promise.allSettled([...this.inflight]),r=new Promise(n=>{t=setTimeout(n,e)});return Promise.race([n,r]).then(()=>{clearTimeout(t),!this.active&&(this.cutInflight(),this.callback=null)})}cutInflight(){this.cutBodies(),this.bodies.now(!0)}cutBodies(){for(let e of[...this.unloadCuts])e()}reportDue(){this.bodies.now(!1)}hasInflight(){return this.inflight.size>0}admits(){if(!this.active)return!1;try{let e=!this.admit||this.admit();return e&&!this.privacyEngine.getConfig().maskNetworkBodies&&Fi(),e}catch{return!1}}emitFor(e,t,n,r,i){e===this.run&&this.emit(t,n,r,i)}track(e){this.inflight.add(e),e.finally(()=>{this.inflight.delete(e),!this.active&&0===this.inflight.size&&(this.callback=null)})}recordResponse(e,t){let n=Number(e.headers.get("content-length")??0);if(n>this.maxBodySize)return t(`[Response body too large: ${n} bytes]`),{page:e,cut:null};if(null===e.body)return t(""),{page:e,cut:null};let r=null;if(void 0!==e.body)try{r=bs(e,this.maxBodySize,t)}catch{return t(null),{page:e,cut:null}}if(r)return r;try{e.clone().text().then(e=>t(as(e,this.maxBodySize)),()=>t(null))}catch{t(null)}return{page:e,cut:null}}patchFetch(){if("function"!=typeof globalThis.fetch)return;let e=globalThis.fetch;this.originalFetch=e,globalThis.fetch=(t,n)=>{if(!this.active||!this.admits())return e.call(globalThis,t,n);let r;try{r=ds(t)?t.url:t instanceof URL?t.href:String(t)}catch{return e.call(globalThis,t,n)}if(this.ignores(r))return e.call(globalThis,t,n);let i,s=t;if(ds(t)&&null==n?.body)try{s=t.clone()}catch{return e.call(globalThis,t,n)}try{i=new Request(s,n)}catch{return e.call(globalThis,t,n)}let o=this.run,a=performance.now(),l=i.method,u=ks(i.url),c=os(i.headers),d=this.privacyEngine.getConfig().maskNetworkBodies,h=e.call(globalThis,t,n),f=null==n?.body&&(i.body||ds(t)&&void 0===i.body&&!/^(?:GET|HEAD)$/.test(l))?function(e,t,n=!1){if(hs.test(e.headers.get("content-type")??""))return e.formData().then(ls);let r=e.body;if(r)return async function(e,t,n){let r=e.getReader(),i=fs(),s="",o="";try{for(;;){let e=await r.read();if(e.done)return s+i.decode();let a=i.decode(e.value,{stream:!0});if(o||(o=ns.exec(a)?.[0]??""),s+=a,n&&ps(o,t))return r.cancel().catch(()=>{}),s;if(s.length>t&&(s.length>4194304||""!==o&&"{"!==o))return r.cancel().catch(()=>{}),s}}catch{return null}}(r,t,n);let i=3*t+4;return e.blob().then(async e=>{if(0===e.size)return;if(n){let n=await gs(e.slice(0,1024));if(ps(n,t))return n}let r=await gs(e.slice(0,i));return e.size>i&&/^[\t\n\r ]*(?:\{|$)/.test(r)?gs(e.slice(0,12582916)):r}).catch(()=>null)}(i,this.maxBodySize,d):null,p=null!=n?.body?d?Promise.resolve(cs(n.body,!1)):async function(e,t){if(null==e)return null;try{return"string"==typeof e?as(e,t):e instanceof URLSearchParams?as(e.toString(),t):e instanceof FormData?as(ls(e),t):e instanceof Blob?e.size>t?`[Blob: ${e.size} bytes, truncated]`:await e.text():e instanceof ArrayBuffer||ArrayBuffer.isView(e)?us(e,t):"[ReadableStream]"}catch{return"[Unreadable body]"}}(n.body,this.maxBodySize):f?f.then(e=>null==e?null:as(e,this.maxBodySize),()=>"[Unreadable body]"):Promise.resolve(null),g=null!=n?.body?this.termFor(n.body,l):f?f.then(e=>null===e?"body:*":this.termFor(e,l),()=>"body:*"):this.termFor(null,l);return Promise.resolve(h).then(e=>{if(o!==this.run||!this.admits())return e;try{let t,n="HEAD"===l||[204,205,304].includes(e.status);return this.reportWhenKnown(o,Date.now(),{method:l,url:u,requestHeaders:c,requestBody:null,responseHeaders:os(e.headers),responseBody:null,statusCode:e.status,duration:performance.now()-a,type:"fetch"},p,g,r=>n?(r(""),t={page:e,cut:null}):d?(r(function(e){return null===e.body||e.body?.locked||/^\s*0+\s*$/.test(e.headers.get("content-length")??"")?null:gr}(e)),t={page:e,cut:null}):t=this.recordResponse(e,r)),t.page}catch{return e}},e=>{throw o!==this.run||!this.admits()||this.reportWhenKnown(o,Date.now(),{method:l,url:u,requestHeaders:c,requestBody:null,responseHeaders:{},responseBody:null,statusCode:0,duration:performance.now()-a,type:"fetch"},p,g),e})}}restoreFetch(){this.originalFetch&&(globalThis.fetch=this.originalFetch,this.originalFetch=null)}patchXHR(){if(typeof XMLHttpRequest>"u")return;let e=XMLHttpRequest.prototype.open,t=XMLHttpRequest.prototype.send;this.originalXhrOpen=e,this.originalXhrSend=t;let n=this.maxBodySize,r=()=>this.admits(),i=()=>this.run,s=(e,t)=>this.termFor(e,t),o=(...e)=>this.reportWhenKnown(...e),a=e=>this.ignores(e),l=()=>this.privacyEngine.getConfig().maskNetworkBodies,u=new WeakMap,c=XMLHttpRequest.prototype.setRequestHeader;this.originalXhrSetHeader=c,XMLHttpRequest.prototype.setRequestHeader=function(e,t){let n=u.get(this);return n&&(n.requestHeaders[e]=t),c.call(this,e,t)};let d=e;XMLHttpRequest.prototype.open=function(e,t,...n){let r="string"==typeof t?t:t.toString(),i=d.call(this,e,t,...n);return a(r)||u.set(this,{method:e,url:ks(r),requestHeaders:{},startTime:0}),i},XMLHttpRequest.prototype.send=function(e){let a=u.get(this);a&&(a.startTime=performance.now());let c,d=i(),h=r(),f=()=>{this.readyState<2||(c=Yr(),this.removeEventListener("readystatechange",f))};a&&h&&this.addEventListener("readystatechange",f);let p=l();return this.addEventListener("loadend",()=>{if(!a||!h||!r())return;let t=performance.now()-a.startTime,i=this.getAllResponseHeaders(),l={};if(i)for(let e of i.trim().split(/[\r\n]+/)){let t=e.indexOf(": ");t>0&&(l[e.slice(0,t)]=e.slice(t+2))}let u=null;if(p)u=function(e){if(""!==e.responseType&&"text"!==e.responseType)return gr;try{return e.responseText?gr:null}catch{return gr}}(this);else try{"string"==typeof this.responseText&&(u=as(this.responseText,n))}catch{u=`[${this.responseType} response]`}let f=p?cs(e,!0):function(e,t){if(null==e)return null;if("string"==typeof e)return as(e,t);if(e instanceof FormData)return as(ls(e),t);if(e instanceof URLSearchParams)return as(e.toString(),t);if(typeof Blob<"u"&&e instanceof Blob)return`[Blob: ${e.size} bytes]`;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return us(e,t);if(typeof Document<"u"&&e instanceof Document)try{return as((new XMLSerializer).serializeToString(e),t)}catch{return"[Unreadable body]"}return"[Unreadable body]"}(e,n);o(d,Date.now(),{method:a.method,url:a.url,requestHeaders:a.requestHeaders,requestBody:f,responseHeaders:l,responseBody:u,statusCode:this.status,duration:t,type:"xhr"},null,s(e,a.method),void 0,c)},{once:!0}),t.call(this,e)}}restoreXHR(){typeof XMLHttpRequest>"u"||(this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,this.originalXhrOpen=null),this.originalXhrSend&&(XMLHttpRequest.prototype.send=this.originalXhrSend,this.originalXhrSend=null),this.originalXhrSetHeader&&(XMLHttpRequest.prototype.setRequestHeader=this.originalXhrSetHeader,this.originalXhrSetHeader=null))}reportWhenKnown(e,t,n,r,i,s,o=Yr()){let a,l=r?null:{value:n.requestBody},u="object"==typeof i?null:{value:i},c=s?null:{value:n.responseBody},d=!1,h=()=>{},f=(r,i,s)=>{d||(d=!0,this.unloadCuts.delete(g),h(),this.emitFor(e,{...n,requestBody:r.value,responseBody:s.value,...void 0===i.value?{}:{requestTerm:i.value}},t,a?.done,o))},p=()=>{l&&u&&c&&f(l,u,c)},g=()=>{a?.cut?.(),f(l??{value:"[Unreadable body]"},u??{value:"body:*"},c??{value:null})};if(l&&u&&c)return p();this.unloadCuts.add(g),this.track(new Promise(e=>h=e)),r?.then(e=>{l={value:e},p()}),"object"==typeof i&&i.then(e=>{u={value:e},p()}),a=s?.(e=>{c={value:e},p()})}termWarned=!1;termFor(e,t){try{let n=function(e){return null==e||""===e?"":"string"==typeof e?e.length>4194304?"body:*":function(e){return ts.test(e)&&(e.includes('"query"')||e.includes("persistedQuery")||e.includes("\\u"))}(e)?null:"":e instanceof URLSearchParams||typeof FormData<"u"&&e instanceof FormData?"":"body:*"}(e);if(null!==n)return n;let r=globalThis.crypto?.subtle;return ai((rs||(rs=ki(()=>import("@keploy/capture-sdk/request-term"),void 0).then(e=>(is=!0,e)),rs.catch(()=>{})),rs),is).then(t=>t?t.recordTermFor(e,r):"body:*",e=>(this.termFailed(t,e),"body:*")).catch(e=>this.termFailed(t,e))}catch(e){return this.termFailed(t,e)}}termFailed(e,t){if(!this.termWarned){this.termWarned=!0;try{console.warn(function(e,t){return Rr({code:"KUI_E_REQUEST_TERM_FAILED",method:e,reason:t},"recorded a request without its term, or body:*: computing it failed; the request itself was not affected. The capture continues; any further such requests in this capture are recorded that way, silently.")}(e,Lr(t)))}catch{}}}emit(e,t,n,r){let i=this.callback;if(!i)return;let s,o,a=this.place?.();this.track(new Promise(e=>s=e));try{o=this.privacyEngine.bodyJob(e)}catch{return s()}this.bodies.redact(o,n=>{if(s(),n)try{i(this.privacyEngine.maskNetworkData(e,n),t,a)}catch{}},n,r)}},xs=wi,Es=32768;function Is(e){try{e()}catch(e){setTimeout(()=>{throw e})}}function As(e){return(new TextEncoder).encode(e).length}var Ts=10485760,Rs=16777216,_s=class{config;queue=[];retryQueue=[];batchCounter=0;flushTimer=null;current=null;sessionId=null;metadata=null;captureIdentity=null;get online(){return typeof navigator>"u"||!1!==navigator.onLine}started=!1;nextSeq=1;drainPending=!1;holding=!1;asked=0;rushDeferred=!1;wakeSender=null;inflightKeepaliveBytes=0;envelopeBytes=0;reportedUnserialisable=!1;reportedOversized=!1;reportedScrubOversized=!1;reportedNavigationUnwrapped=!1;jsonOf=new WeakMap;inFlight=null;held=0;queued=0;counted=!1;failures=0;notBefore=0;constructor(e){this.config={...e,batchSize:Math.min(e.batchSize,5e3)}}fail(e,t,n){this.discard();let r=new Ur({code:e,status:t,server:Dr(n),endpoint:this.config.endpoint,sessionId:this.sessionId??null});if(this.config.endsSessionOnly?.(e,function(e){if(null===e)return null;try{let t=JSON.parse(e)?.reason;return"string"==typeof t?t.slice(0,100):null}catch{return null}}(n))){this.stop();try{this.config.onSessionEnd?.()}catch{}}else{Is(()=>console.error(r.message)),this.stop();try{this.config.onCaptureEnd?.()}catch{}try{this.config.onError?.(r)}catch{}}}start(e,t,n=null){this.started||(this.started=!0,this.sessionId=e,this.metadata=t,this.captureIdentity=n,this.envelopeBytes=As(JSON.stringify(this.payload([],this.mintBatchId()))),this.flushTimer=setInterval(()=>{this.paced||this.flush(this.rushDeferred&&this.online)},this.config.batchInterval),typeof window<"u"&&(window.addEventListener("online",this.handleOnline),window.addEventListener("pagehide",this.handleUnload),window.addEventListener("beforeunload",this.handleUnload),document.addEventListener("visibilitychange",this.handleVisibility)))}hold(){this.holding=!0}release(){this.holding=!1,this.flush(!0)}discard(){this.queue=[],this.queued=0,this.retryQueue=[]}stop(){if(!this.started)return this.current??Promise.resolve();this.started=!1,this.holding&&this.discard(),this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null);let e=this.flush(!0);return typeof window<"u"&&(window.removeEventListener("online",this.handleOnline),e.finally(()=>this.disarmWhenDrained())),e}disarmWhenDrained(){this.started||this.pendingCount()>0||typeof window>"u"||(window.removeEventListener("pagehide",this.handleUnload),window.removeEventListener("beforeunload",this.handleUnload),document.removeEventListener("visibilitychange",this.handleVisibility))}enqueue(e){if(!this.started)return;let t;e.seq??=this.nextSeq++;try{let n=JSON.stringify(e),r=As(n);this.jsonOf.set(e,[n,r]),t=this.envelopeBytes+r}catch(t){return this.reportUnserialisable(e,t),void this.dropped([e])}if(t>Ts)return this.reportOversized(e,t),void this.dropped([e]);this.queue.push(e),this.held+=t,this.queued+=this.eventBytes(e);let n=[];for(;this.queue.length>this.config.maxQueueSize;){let e=this.queue.shift();this.queued-=this.eventBytes(e),n.push(e)}n.length>0&&this.dropped(n),this.fit(),!this.paced&&(t>Es?this.online?this.flush(!0):this.rushDeferred=!0:this.queue.length>=this.config.batchSize?(null!==this.current&&this.asked++,this.flush()):this.online&&this.pastShare()&&(this.counted=!0,this.flush()))}place(){return this.nextSeq++}get paced(){return performance.now()<this.notBefore}fit(){if(this.held<=Rs)return;let e=0;for(let t of this.retryQueue)e+=t.bytes;for(let t of this.queue)e+=this.eventBytes(t);let t=[];for(;e>Rs;){let n=this.retryQueue.shift();if(n)e-=n.bytes,t.push(...n.events);else{let n=this.queue.shift();e-=this.eventBytes(n),this.queued-=this.eventBytes(n),t.push(n)}}this.held=e,t.length>0&&this.dropped(t)}dropped(e){!this.online&&0===this.failures&&(this.failures=1,Is(()=>this.config.onFailing?.(!0)));let t=1/0;for(let n of e)"dom"===n.type&&(t=Math.min(t,n.seq??-1/0));let n=!1;if(t!==1/0){let r=[];for(let i of this.queue){let s=(i.seq??-1/0)>t,o="dom"===i.type?i.data?.type:void 0;s&&2===o&&(n=!0),s&&!n&&3===o?(e.push(i),this.queued-=this.eventBytes(i)):r.push(i)}this.queue=r}Is(()=>this.config.onDropped?.(e,n))}reportUnserialisable(e,t){if(this.reportedUnserialisable)return;this.reportedUnserialisable=!0;let n=t instanceof Error?t.message:String(t);console.warn(Tr({code:"KUI_E_EVENT_UNSERIALISABLE",eventId:e.id,eventType:e.type,reason:n},"it cannot be serialised to JSON."))}reportOversized(e,t){this.reportedOversized||(this.reportedOversized=!0,this.warnOversized({code:"KUI_E_EVENT_OVERSIZED",eventId:e.id,eventType:e.type,bytes:t,cap:Ts},`${t} bytes in a body, over the ingest server's ${Ts}-byte cap, so no batch could carry it.`))}reportScrubOversized(e,t,n){this.reportedScrubOversized||(this.reportedScrubOversized=!0,this.warnOversized({code:"KUI_E_EVENT_OVERSIZED_SCRUBBING",eventType:e,atLeast:t,cap:n},`scrubbing the page URL's credentials out of it was certain to write at least ${t} characters, over the ingest server's ${n}-byte cap, so no batch could carry it.`))}reportNavigationUnwrapped(e){this.reportedNavigationUnwrapped||(this.reportedNavigationUnwrapped=!0,this.warn(Rr({code:"KUI_E_NAVIGATION_UNWRAPPED",method:e},"the page made a History or Navigation API method impossible to replace and put back, so the SDK wrapped none of them. The capture continues: route changes are still recorded, with less detail, and none says that the page's script asked for it.")))}warnOversized(e,t){this.warn(Tr(e,t))}warn(e){console.warn(e)}payload(e,t){return{sessionId:this.sessionId,batchId:t,events:e,metadata:this.metadata,sdk:{name:"@keploy/capture-sdk",version:xs},captureIdentity:this.captureIdentity}}flush(e=!1){return this.holding?Promise.resolve():(e&&(this.drainPending=!0),this.current?this.current:0===this.pendingCount()||!this.online&&!this.drainPending?(this.drainPending=!1,this.failures>0&&0===this.pendingCount()&&this.online&&(this.failures=this.notBefore=0,Is(()=>this.config.onFailing?.(!1))),Promise.resolve()):(this.current=this.run(),this.current))}async run(){let e=!1;try{do{let t=this.reviveNext()??this.formFlight();if(null===t)return;this.inFlight=t;try{await this.sendWithRetry(t)}catch{return this.notBefore=performance.now()+Math.min(2e3*2**this.failures,6e4)*(1+Math.random()/2),0===this.failures++&&Is(()=>this.config.onFailing?.(!0)),this.held+=t.bytes,this.retryQueue.unshift(t),void this.trimToCapacity()}finally{this.inFlight===t&&(this.inFlight=null)}this.counted=!this.drainPending&&this.online&&this.pastShare(),e=this.asked>0&&!this.holding&&this.online&&this.queue.length>=this.config.batchSize,e&&this.asked--}while((this.drainPending||this.counted||e)&&this.pendingCount()>0)}finally{this.drainPending=!1,this.counted=!1,this.asked=0,0===this.pendingCount()&&(this.rushDeferred=!1),this.current=null,this.disarmWhenDrained()}}backoff(e){return new Promise(t=>{let n=()=>{clearTimeout(r),this.wakeSender===n&&(this.wakeSender=null),t()},r=setTimeout(n,e);this.wakeSender=n})}async sendWithRetry(e){let t=e.json,n=e.wire??=async function(e){if(typeof CompressionStream<"u"&&typeof Response<"u")try{let t=new Response(e).body.pipeThrough(new CompressionStream("gzip")),n=await new Response(t).arrayBuffer(),r=As(e);return n.byteLength<r?{body:n,bytes:n.byteLength,encoding:"gzip"}:{body:e,bytes:r,encoding:null}}catch{}return{body:e,bytes:As(e),encoding:null}}(t);for(let t=0;t<3;t++){if(e.abandoned)return;let r,i=null;try{let{body:t,bytes:s,encoding:o}=e.sent=await n;if(e.abandoned)return;let a={"Content-Type":"application/json","X-API-Key":this.config.apiKey};o&&(a["Content-Encoding"]=o);let l=!e.early&&s<=Es-this.inflightKeepaliveBytes;l&&(this.inflightKeepaliveBytes+=s),e.onWire=!0,e.dispatched=!0;try{r=await fetch(this.config.endpoint,{method:"POST",headers:a,body:t,keepalive:l});try{i=await r.text()}catch{i=null}}finally{e.onWire=!1,l&&(this.inflightKeepaliveBytes-=s)}}catch{}if(r){if(r.ok)return this.failures>0&&(this.failures=this.notBefore=0,this.drainPending=!0,Is(()=>this.config.onFailing?.(!1))),void Is(()=>this.config.onDelivered?.(e.events));let{status:t}=r,n=Cr(t);if(null!==n)return void Is(()=>this.fail(n,t,i))}if(this.failures>0||2===t)break;let s=1e3*Math.pow(2,t)*(.5+.5*Math.random());await this.backoff(s)}throw new Error("Transport: all retry attempts failed")}reclaimInFlight(){let e=this.inFlight;if(e&&!e.onWire&&!e.abandoned){if(e.abandoned=!0,this.inFlight=null,this.held+=e.bytes,e.dispatched)return this.retryQueue.unshift(e),void this.trimToCapacity();this.queue.unshift(...e.events),this.uncount(e.events,-1),this.trimToCapacity()}}reviveNext(){let e=this.retryQueue.shift();return e?{events:e.events,batchId:e.batchId,json:e.json,bytes:e.bytes,wire:e.wire,dispatched:e.dispatched,onWire:!1,abandoned:!1,early:e.early}:null}formFlight(){if(0===this.queue.length)return null;let e=this.pastShare(),t=this.counted&&!this.drainPending&&e?Es-this.inflightKeepaliveBytes:Ts;this.counted=!1;let n=0,r=this.envelopeBytes,i=0,s=Math.min(this.config.batchSize,this.queue.length);for(;i<s;){let e=this.eventBytes(this.queue[i])+(0===i?0:1);if(r+e>t)break;e>n&&(n=e),r+=e,i++}0===i&&(n=this.eventBytes(this.queue[0]),r+=n);let o=this.queue.splice(0,Math.max(i,1));this.uncount(o);let a=this.mintBatchId(),l=this.body(o,a);for(let e of o)this.jsonOf.delete(e);return{events:o,batchId:a,json:l,dispatched:!1,onWire:!1,abandoned:!1,bytes:r,early:e&&this.envelopeBytes+n<=Es}}body(e,t){return JSON.stringify(this.payload([],t)).replace('"events":[]',()=>`"events":[${e.map(e=>this.jsonOf.get(e)?.[0]??JSON.stringify(e)).join()}]`)}eventBytes(e){return this.jsonOf.get(e)?.[1]??As(JSON.stringify(e))}mintBatchId(){let e=typeof crypto<"u"?crypto:void 0;if(e&&"function"==typeof e.randomUUID)return e.randomUUID();this.batchCounter+=1;let t=Math.floor(4294967295*Math.random()).toString(16).padStart(8,"0");return`${Date.now().toString(16).padStart(12,"0")}-${(this.batchCounter%4294967296).toString(16).padStart(8,"0")}-`+t}uncount(e,t=1){for(let n of e)this.queued-=t*this.eventBytes(n)}pastShare(){return this.envelopeBytes+this.queued+this.queue.length>Es-this.inflightKeepaliveBytes}pendingCount(){let e=this.queue.length;for(let t of this.retryQueue)e+=t.events.length;return e}trimToCapacity(){let e=0;for(let t of this.retryQueue)e+=t.events.length;let t=[];for(;this.queue.length>0&&e+this.queue.length>this.config.maxQueueSize;){let e=this.queue.pop();this.queued-=this.eventBytes(e),t.push(e)}t.length>0&&this.dropped(t.reverse()),this.fit()}flushOnUnload(e=!1){if(this.holding||(this.reclaimInFlight(),this.queue.sort((e,t)=>e.seq-t.seq),"function"!=typeof fetch))return;for(;this.retryQueue.length>0;){let e=this.retryQueue[0],t=e.sent,n=t?t.bytes:As(e.json);if(n>Es-this.inflightKeepaliveBytes)return;this.retryQueue.shift(),e.dispatched=!0,this.postKeepalive(t?t.body:e.json,n,t?.encoding)}if(0===this.queue.length)return;let t=Es-this.inflightKeepaliveBytes-(e&&this.inFlight?.early&&this.inFlight.onWire?this.inFlight.sent?.bytes??this.inFlight.bytes:0),n=this.mintBatchId(),r=this.envelopeBytes,i=0;for(let e of this.queue){let n=this.eventBytes(e)+(0===i?0:1);if(r+n>t)break;r+=n,i++}if(0===i)return;let s=this.queue.splice(0,i);this.uncount(s);let o=this.body(s,n);this.postKeepalive(o,As(o))}postKeepalive(e,t,n){try{this.inflightKeepaliveBytes+=t,fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey,...n?{"Content-Encoding":n}:{}},body:e,keepalive:!0}).then(e=>e.arrayBuffer()).catch(()=>{}).finally(()=>{this.inflightKeepaliveBytes-=t})}catch{this.inflightKeepaliveBytes-=t}}handleOnline=()=>{try{this.config.beforeOnlineFlush?.()}catch{}this.wakeSender?.(),this.flush(this.rushDeferred)};handleUnload=e=>{if("pagehide"===e.type)try{this.config.beforeUnloadFlush?.()}catch{}this.flushOnUnload("beforeunload"===e.type),this.disarmWhenDrained()};handleVisibility=()=>{"hidden"===document.visibilityState&&(this.config.beforeHiddenFlush?.(),this.flush(!0))};get queueSize(){return this.pendingCount()}};function Cs(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}var Os=null,$s=!1;function Ds(){return Os||(Os=fi(()=>import("rrweb")).then(e=>($s=!0,{record:bi(e).record}),e=>(Os=null,{failed:Lr(e)}))),Os}var Ns=null,zs=!1;function Ls(e){return e?Promise.all([Ds(),Ns??=ki(()=>import("@keploy/capture-sdk/strict-attributes"),void 0).then(e=>{if("function"!=typeof e.kept)throw new TypeError("strict-attributes has no kept()");return function(e){In=e}(e.kept),zs=!0,null}).catch(e=>(Ns=null,Lr(e)))]).then(([e,t])=>null===t||"failed"in e?e:{failed:t,strict:!0}):Ds()}var Bs=[new Set,new Set],Us=[0,0],Ps=e=>e.strict?new qr({reason:e.failed}):new jr({reason:e.failed});function qs(){let e=document.documentElement;return{width:window.innerWidth||e?.clientWidth||document.body?.clientWidth||0,height:window.innerHeight||e?.clientHeight||document.body?.clientHeight||0}}function js(e){return e.split("#").map(e=>{let t=e.indexOf("?");return-1===t?e:e.slice(0,t)}).join("#")}var Ms=new Map,Ks="",Ws=-1,Fs=null;function Hs(e){return 2===e.kind?`2${e.before}/${e.value}`:`${e.kind}${e.value}`}function Zs(e){let t=!1;for(let n=e.length-1;n>=0;n--){let r=Hs(e[n]);Ms.delete(r)||(t=!0),Ms.set(r,e[n])}let n=new Set(e.map(Hs)),r=0;for(let e of Ms.keys())r+=e.length;for(let e of Ms.keys()){if(n.has(e)||Ms.size<=256&&r<=65536)break;Ms.delete(e),r-=e.length,t=!0}return t}var Vs=new Set;function Js(e){let t=st;if(e!==Ks||t!==Ws){let n=!1;if(""===Ks||t!==Ws){let e=globalThis.performance?.getEntriesByType?.("navigation");e?.[0]&&(n=Zs(yt(e[0].name)));for(let e of Vs)Zs(yt(e))&&(n=!0)}Ks=e,Ws=t,function(e){Vs.delete(e),Vs.add(e);let t=0;for(let e of Vs)t+=e.length;for(let n of Vs){if(n===e||Vs.size<=64&&t<=524288)break;Vs.delete(n),t-=n.length}}(e),(Zs(yt(e))||n)&&(Fs=en([...Ms.values()]))}return Fs}var Xs=new Set,Gs=null,Qs=null,Ys=null,eo=[],to=null,no=null,ro=new Map,io=!1;function so(e){let t=e,n=t.destination?.url;Ys="string"==typeof n&&"boolean"==typeof t.userInitiated?{href:n,userInitiated:t.userInitiated}:null;let r=t.destination?.key;if("replace"!==t.navigationType){if("traverse"===t.navigationType&&"string"==typeof r){let e=eo[0]===r&&!1===t.userInitiated;e||r===no?ro.set(r,(ro.get(r)??0)+1):ro.delete(r),eo=e?eo.slice(1):[],no=null}else{let n=[];if("push"===t.navigationType)try{let t=e.currentTarget;n=t.entries().slice(0,t.currentEntry.index).map(e=>e.key)}catch{}eo=eo.filter(e=>n.includes(e)),to=null,(!0!==t.userInitiated||!n.includes(no))&&(no=null),ro.clear()}io=!1}}function oo(e,t,n){if("object"==typeof t||"function"==typeof t)return null;let r=e;try{let e=0|Number(t),i=r?.entries()??[],s=null===n?Number(r?.currentEntry?.index):i.findIndex(e=>e.key===n);return s<0?null:i[s+e]?.key??null}catch{return null}}function ao(e,t){return function(...n){if(io)return Reflect.apply(e,this,n);let{next:r,now:i}=t(n);no=i,null!==i&&null!==r&&(to=r,r!==oo(Gs?.navigation??null,0,null)&&eo.push(r)),io=!0;try{return Reflect.apply(e,this,n)}catch(e){throw eo=[],no=null,e}finally{io=!1}}}function lo(e){let t=e,n=t.navigationType,r=function(){let e=Ys;return Ys=null,null!==e&&e.href===location.href?e.userInitiated:void 0}(),i=function(e){let t=e?.currentEntry?.key;if("string"!=typeof t)return;for(;eo[0]===t;)eo.shift();let n=ro.get(t)??0;return n>1?ro.set(t,n-1):ro.delete(t),n?"script":void 0}(Gs?.navigation??null);if("traverse"===n)co("traverse",r,i);else if("push"===n||"replace"===n){let e="string"==typeof t.from?.url?t.from.url:"";co(Qs??(function(e,t){return e!==t&&e.split("#")[0]===t.split("#")[0]}(e,location.href)?"hash":n),r)}}function uo(){let e=Reflect.get(window,"event")?.type;return"popstate"===e||"hashchange"===e?"traverse":"push"}function co(e,t,n){Js(location.href);for(let r of Xs)try{r(e,t,n)}catch{}}function ho([e,t,,n]){let r=Object.getOwnPropertyDescriptor(e,t);return void 0!==r&&r.value===n.value&&r.configurable===n.configurable&&(!0===r.configurable||!0===r.writable)}function fo([e,t,n]){n?Object.defineProperty(e,t,n):Reflect.deleteProperty(e,t)}function po(e){if(typeof window>"u"||!window.history)return()=>{};Xs.add(e),function(){if(Gs)return;let e=window.history,t=e.pushState,n=e.replaceState,r=Reflect.get(window,"navigation")??null;r?.addEventListener("currententrychange",lo,{capture:!0}),r?.addEventListener("navigate",so,{capture:!0});let i=e=>t=>{let n=e(t);return{next:oo(r,n,eo.length?to:null),now:oo(r,n,null)}},s=e=>t=>{let n=e(t);return{next:n,now:n}},o=[[e,"back",i(()=>-1)],[e,"forward",i(()=>1)],[e,"go",i(e=>e[0])],[r,"back",s(()=>oo(r,-1,null))],[r,"forward",s(()=>oo(r,1,null))],[r,"traverseTo",s(e=>"string"==typeof e[0]?oo(r,0,e[0]):null)]],a=[[e,"pushState",function(...e){let n=location.href,r=Qs;Qs="push";try{t.apply(this,e)}finally{Qs=r}co(location.href===n?uo():"push")}],[e,"replaceState",function(...e){let t=location.href,r=Qs;Qs="replace";try{n.apply(this,e)}finally{Qs=r}co(location.href===t?uo():"replace")}]];for(let[e,t,n]of o){let r=e&&Reflect.get(e,t);"function"==typeof r&&a.push([e,t,ao(r,n)])}let l=a.find(([e,t])=>!function(e,t){let n=Object.getOwnPropertyDescriptor(e,t);return void 0===n?Object.isExtensible(e):!0===n.configurable||!0===n.writable}(e,t));Gs={navigation:r,methods:l?[]:a.map(([e,t,n])=>function(e,t,n){let r=Object.getOwnPropertyDescriptor(e,t);return Object.defineProperty(e,t,!1===r?.configurable?{value:n}:{value:n,writable:!0,enumerable:r?.enumerable??!0,configurable:!0}),[e,t,r,Object.getOwnPropertyDescriptor(e,t)]}(e,t,n)),refused:l?`${l[0]===e?"history":"navigation"}.${l[1]}`:null}}();let t=()=>{Js(location.href),e("traverse")};return window.addEventListener("popstate",t,{capture:!0}),window.addEventListener("hashchange",t,{capture:!0}),()=>{Xs.delete(e),window.removeEventListener("popstate",t,{capture:!0}),window.removeEventListener("hashchange",t,{capture:!0}),function(){if(Gs&&!(Xs.size>0)&&Gs.methods.every(ho)){for(let e of Gs.methods)fo(e);Gs.navigation?.removeEventListener("currententrychange",lo,{capture:!0}),Gs.navigation?.removeEventListener("navigate",so,{capture:!0}),Ys=null,eo=[],no=null,ro.clear(),Gs=null}}()}}var go=class e{phase="idle";userPaused=!1;hidden=!1;droppedWhileShut=!1;baselineLost=!1;retakeTimer=null;retakeAtOnce=!1;retakeDelay=5e3;outage=!1;failing(e){this.outage=e,null!==this.retakeTimer&&clearTimeout(this.retakeTimer),this.retakeTimer=null,!e&&this.baselineLost&&this.rebaseline(!1)}lost(e,t){t||!e.some(e=>"dom"===e.type)||(this.baselineLost=!0,this.rebaseline(e.some(e=>"dom"===e.type&&2===e.data?.type)))}rebaseline(e){if(this.outage)return;if(null!==this.retakeTimer){if(!e||!this.retakeAtOnce)return;clearTimeout(this.retakeTimer)}this.retakeAtOnce=!e;let t=e?this.retakeDelay:0;e&&(this.retakeDelay=Math.min(2*this.retakeDelay,6e4)),this.retakeTimer=setTimeout(()=>{if(this.retakeTimer=null,!this.baselineLost||"recording"!==this.getState())return;let e=this.rrwebRecord?.takeFullSnapshot;if(e){this.droppedWhileShut=!1;try{e.call(this.rrwebRecord)}catch{this.droppedWhileShut=!0}}},t)}delivered(e){e.some(e=>"dom"===e.type&&2===e.data?.type)&&(this.retakeDelay=5e3)}styles=new nn({note:e=>{let t=this.rrwebRecord?.mirror?.getNode(e);t&&this.styleNodes.set(e,t)},present:e=>this.inPage(e),forget:e=>{this.styleNodes.delete(e)}});styleNodes=new Map;sessionId=null;metadata=null;config;onEvent=null;onSessionEnd=null;onScrubOversized=null;onRRWeb=null;landing=!1;onlineRetry=null;onlinePoll=null;rrwebStopFn=null;rrwebRecord=null;rrwebRequested=!1;generation=0;sessionTimer=null;visibilityHandler=null;stopNavigation=null;lastHref="";seenHref="";constructor(e){this.config=e}async start(e,t=null,n=!1,r=null,i=null,s=null){if("active"===this.phase)return this.sessionId;"stopping"===this.phase&&this.stop();let o={secretRoutes:[],keepRoutes:[]};for(let e of["secretRoutes","keepRoutes"]){let t=this.config.privacy?.[e]??[];if(!Array.isArray(t))throw this.phase="stopped",new Mr({option:e,received:Fr({returned:t})});for(let n of t){let t=nt(n,"keepRoutes"===e);if(null===t)throw this.phase="stopped",new Mr({option:e,received:Fr({returned:n})});o[e].push(t)}}!function(e,t){for(let[n,r]of[[rt.secret,e],[rt.keep,t]])for(let e of r){let t=`${n===rt.keep}${e.join("/")}`;it.has(t)||(it.add(t),n.push(e),st++,vt=["",[],!1,null])}}(o.secretRoutes,o.keepRoutes);let a,l=this.config.sampleRate??1;if(Math.random()>l)return this.phase="stopped","";this.onEvent=e,this.onSessionEnd=t,this.onScrubOversized=r,this.onRRWeb=i;try{a=this.config.sessionIdGenerator?this.config.sessionIdGenerator():Cs()}catch(e){throw this.phase="stopped",new Pr({sessionId:null,received:Fr({threw:e})})}if(!br(a))throw this.phase="stopped",new Pr({sessionId:"string"==typeof a?a:null,received:Fr({returned:a})});this.sessionId=a,this.metadata=function(e){let t=typeof window<"u"?window:void 0,n=t?.location?.href??"",r=""===n?null:Js(n);return{url:an(e(n),r),userAgent:typeof navigator<"u"?navigator.userAgent:"",viewport:{width:t?.innerWidth??0,height:t?.innerHeight??0},referrer:typeof document<"u"&&document.referrer?an(e(document.referrer),r):"",language:typeof navigator<"u"?navigator.language:"",devicePixelRatio:t?.devicePixelRatio??1,timestamp:Date.now()}}(this.scrubUrl),this.phase="active",this.userPaused=n,this.droppedWhileShut=!1,this.hidden=typeof document<"u"&&"hidden"===document.visibilityState,this.rrwebRequested=!1;let u=++this.generation;typeof document<"u"&&(this.visibilityHandler=()=>{this.hidden="hidden"===document.visibilityState,"recording"===this.getState()&&this.openDomGate()},document.addEventListener("visibilitychange",this.visibilityHandler)),this.seenHref=typeof location<"u"?location.href:"",this.lastHref=typeof location<"u"?this.scrubUrl(location.href):"",this.stopNavigation=po((e,t,n)=>this.navigated(e,t,n));let c=await this.startRRWeb();if(u!==this.generation||"active"!==this.phase)return"";if(null!==c&&typeof window<"u")throw this.stop(),Ps(c);let d=this.config.maxSessionDuration??6e5;return this.sessionTimer=setTimeout(()=>{try{this.onSessionEnd?.()}finally{"active"===this.phase&&this.stop()}},d),Gs?.refused&&s?.(Gs.refused),this.sessionId}stopDom(){"active"===this.phase&&(this.phase="stopping"),this.rrwebStopFn&&(this.rrwebStopFn(),this.rrwebStopFn=null),this.sessionTimer&&(clearTimeout(this.sessionTimer),this.sessionTimer=null)}stop(){if("active"===this.phase||"stopping"===this.phase){null!==this.onlineRetry&&(window.removeEventListener("online",this.onlineRetry),this.onlineRetry=null,this.stopOnlinePoll()),this.landing=!1;for(let e of Bs)e.delete(this);this.stopDom(),this.rrwebRecord=null,this.retakeTimer&&(clearTimeout(this.retakeTimer),this.retakeTimer=null),this.visibilityHandler&&typeof document<"u"&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null),this.stopNavigation?.(),this.stopNavigation=null,this.phase="stopped"}}navigated(e,t,n){if("active"!==this.phase)return;this.seenHref=location.href;let r=this.scrubUrl(location.href);js(r)!==js(this.lastHref)&&(this.lastHref=r,this.emitEvent("dom",{type:4,data:{href:r,...qs(),cause:e,...void 0===t?{}:{userInitiated:t},...void 0===n?{}:{initiator:n}},timestamp:Date.now()}))}recordedRRWebEvent(e){if("object"!=typeof e||null===e)return e;let t=e,n=t.data?.href;return 4!==t.type||"string"!=typeof n?e:(this.lastHref=this.scrubUrl(n),{...t,data:{...t.data,href:this.lastHref}})}isUserPaused(){return this.userPaused}pause(){"active"===this.phase&&(this.userPaused=!0)}resume(){"active"===this.phase&&(this.userPaused=!1,"recording"===this.getState()&&this.openDomGate())}openDomGate(){if(!this.rrwebStopFn){this.droppedWhileShut=!1;let e=this.generation;return void this.startRRWeb().then(t=>{null!==t?this.refuseLate(e,t):this.landedBeforeTheRetry(e)})}if(!this.droppedWhileShut&&!this.baselineLost)return;let e=this.rrwebRecord?.takeFullSnapshot;if(e){if(this.outage)return void(this.baselineLost=!0);this.droppedWhileShut=!1;try{e.call(this.rrwebRecord)}catch{this.droppedWhileShut=!0}}}getSessionId(){return"active"===this.phase?this.sessionId:null}get sessionOpen(){return"active"===this.phase&&!this.userPaused}getState(){return"idle"===this.phase?"idle":"stopped"===this.phase||"stopping"===this.phase?"stopped":this.userPaused||this.hidden?"paused":"recording"}getMetadata(){return this.metadata}async startRRWeb(){if(this.rrwebRequested)return null;this.rrwebRequested=!0;let t=this.generation;if(!this.loaded()&&typeof window<"u"&&!1===navigator.onLine&&!function(){try{return!!navigator.serviceWorker?.controller}catch{return!1}}())return this.rrwebRequested=!1,this.retryWhenOnline(t),null;let n=+("strict"===this.config.privacyMode);if(Us[n])return Bs[n].add(this),this.land();let r=Ls(n>0),i=await ai(r,this.loaded());if(!i)return t===this.generation&&"active"===this.phase&&(Bs[n].add(this),this.land(),Us[n]||e.whenLanded(n,r)),null;if(t!==this.generation)return null;if("failed"in i)return this.rrwebRequested=!1,i;let s=i.record;return"recording"!==this.getState()?(this.rrwebRequested=!1,null):(this.rrwebRecord=s,this.rrwebStopFn=s(this.rrwebOptions())??null,null)}retryWhenOnline(e){if(null!==this.onlineRetry)return;let t=()=>{if(window.removeEventListener("online",t),this.stopOnlinePoll(),this.onlineRetry=null,e===this.generation&&"active"===this.phase){if(!1===navigator.onLine)return void this.retryWhenOnline(e);Ls("strict"===this.config.privacyMode).then(t=>this.loadedLate(e,t))}};this.onlineRetry=t,window.addEventListener("online",t,{once:!0}),this.onlinePoll=setInterval(()=>{!1!==navigator.onLine&&t()},1e3)}static whenLanded(e,t){Us[e]++,t.then(t=>{Us[e]--;let n=[...Bs[e]];Bs[e].clear();for(let e of n)e.landing&&e.loadedLate(e.generation,t)})}land(){return this.rrwebRequested=!1,this.landing=!0,null}loadedLate(e,t){if(e===this.generation&&"active"===this.phase){if(this.landing=!1,"failed"in t)return void this.refuseLate(e,t);this.startRRWeb(),this.onRRWeb?.(null)}}stopOnlinePoll(){null!==this.onlinePoll&&(clearInterval(this.onlinePoll),this.onlinePoll=null)}refuseLate(e,t){e!==this.generation||"active"!==this.phase||(this.stop(),this.onRRWeb?.(Ps(t)))}landedBeforeTheRetry(e){e!==this.generation||"active"!==this.phase||!this.loaded()||null===this.onlineRetry||(window.removeEventListener("online",this.onlineRetry),this.onlineRetry=null,this.stopOnlinePoll(),this.onRRWeb?.(null))}loaded(){return $s&&(zs||"strict"!==this.config.privacyMode)}awaitingRRWeb(){return null!==this.onlineRetry||this.landing}rrwebOptions(){let e=this.config.privacyMode??"balanced",t=this.config.privacy??{},n=[...this.config.maskSelectors??[],...t.maskSelectors??[]],r=[...this.config.unmaskSelectors??[],...t.unmaskSelectors??[]],i="off"!==e,s={color:i,date:i,"datetime-local":i,email:i,file:i,month:i,number:i,range:i,search:i,tel:i,text:i,time:i,url:i,week:i,textarea:i,select:i,password:!0,hidden:!0},o='[contenteditable]:not([contenteditable="false"])',a=[...n,...i?[o]:[]].join(","),l=r.join(","),u=l?(e,t)=>{try{if(i&&t?.closest(o))return e.replace(/[\S]/g,"*");if(t?.closest(l))return e}catch{}return e.replace(/[\S]/g,"*")}:void 0;return{emit:e=>this.emitEvent("dom",e,e=>this.recordedRRWebEvent(e)),maskTextSelector:"strict"===e?"*":a||void 0,...u?{maskTextFn:u}:{},blockSelector:t.blockSelectors?.join(",")||void 0,maskInputOptions:s,userTriggeredOnInput:!0}}inPage(e){let t=this.rrwebRecord?.mirror;if(void 0===t)return!0;let n=this.styleNodes.get(e)??t.getNode(e);if(!n||!n.isConnected)return!1;for(let e=n.ownerDocument;null!==e&&e!==document;){let t=e.defaultView?.frameElement??null;if(null===t||!t.isConnected)return!1;e=t.ownerDocument}return!0}noticeUnheardMove(e){if(!(typeof location>"u"||location.href===this.seenHref)){if(4===e?.type)return void(this.seenHref=location.href);this.navigated(uo())}}scrubUrl=e=>function(e,t=!1){return e&&O(e,t?qn:Pn)}(function(e){let[,t,n]=mt(e);if(t)return`${gt(e)}/[REDACTED]`;let r=e.indexOf("#"),i=Ge(ht(e),Qe(Re(e))),s=Ce(-1===r?e:e.slice(0,r),i);if(-1!==r){let t=e.slice(r+1).split("#")[0];Oe.test(t)&&(s+=`#${Ce(t,i)}`)}return null===n?s:Mt(s,n)}(e),"strict"===(this.config.privacyMode??"balanced"));scrubDomUrls(e,t){let n=e;if(null===n||"object"!=typeof n)return e;let r=n.data;if(null===r||"object"!=typeof r)return e;let i="strict"===(this.config.privacyMode??"balanced"),s=null===t?[]:[...t.plain,...t.bounded];if(2===n.type&&ar(r.node,i,s),3===n.type&&0===r.source){if(Array.isArray(r.adds)){!function(e){let t=new Map;for(let n of e){let e=n?.node?.type;(3===e||5===e)&&t.set(n.node.id,n)}let n=new Set;for(let e of t.values())n.add(t.get(e.nextId));for(let e of t.values()){if(n.has(e))continue;let r=[];for(let n=e;n;n=t.get(n.nextId))sr(n.node)&&r.push(n.node);r.length>1&&ir(r)}}(r.adds);for(let e of r.adds)null!==e&&"object"==typeof e&&ar(e.node,i,s)}if(Array.isArray(r.attributes))for(let e of r.attributes){let t=e?.attributes;if(null!==t&&"object"==typeof t){let n=i?this.rrwebRecord?.mirror?.getNode(e.id??-1):null;Xn(t,i,s,n?.localName??"","http://www.w3.org/2000/svg"===n?.namespaceURI)}}if(Array.isArray(r.texts)){let e=this.styles.recordsIn(n);for(let t of r.texts)"string"==typeof t?.value&&(t.value=e.has(t)?rr(t.value,i,s):er(t.value))}}if(3===n.type&&(8===r.source||15===r.source)){let e=[...Array.isArray(r.adds)?r.adds:[],...Array.isArray(r.styles)?r.styles.flatMap(e=>Array.isArray(e?.rules)?e.rules:[]):[]];for(let t of e)null!==t&&"string"==typeof t?.rule&&(t.rule=rr(t.rule,i,s));"string"==typeof r.replace&&(r.replace=rr(r.replace,i,s)),"string"==typeof r.replaceSync&&(r.replaceSync=rr(r.replaceSync,i,s))}if(3===n.type&&5===r.source&&"string"==typeof r.text&&(r.text=i?r.text.replace(/\S/g,"*"):er(r.text)),3===n.type&&9===r.source&&"string"==typeof r.fontSource&&(r.fontSource=rr(r.fontSource,i,s)),3===n.type&&13===r.source){let e=r.set;null!==e&&"string"==typeof e?.value&&(e.value=rr(e.value,i,s))}return e}acceptsNetwork(){return this.sessionOpen}emitEvent(e,t,n,r=!1,i,s){if("dom"===e&&"active"===this.phase&&"recording"!==this.getState()&&(this.droppedWhileShut=!0),(r?"active"!==this.phase&&"stopping"!==this.phase:!this.sessionOpen)||"dom"===e&&this.hidden||!this.onEvent||!this.sessionId)return;this.noticeUnheardMove("dom"===e?t:null);let o=n?n(t):t,a="dom"===e&&null!==o&&"object"==typeof o?o.type:void 0;if(this.baselineLost&&3===a)return;let l=o;if(typeof location<"u")try{"dom"===e&&(l=this.scrubDomUrls(o,Js(location.href))),l=an(l,Js(location.href),e,this.styles,Ts)}catch(t){return"dom"===e&&(this.baselineLost=!0,this.rebaseline(2===a)),void(t instanceof rn&&this.onScrubOversized?.(e,t.atLeast,t.cap))}2===a&&(this.baselineLost=!1,null!==this.retakeTimer&&(clearTimeout(this.retakeTimer),this.retakeTimer=null));let u={id:Cs(),sessionId:this.sessionId,timestamp:i??Date.now(),type:e,data:l,seq:s};this.onEvent(u)}};function yo(){let e=typeof crypto<"u"?crypto:void 0;if(!e||"function"!=typeof e.getRandomValues)return null;let t=new Uint8Array(16);e.getRandomValues(t);let n="";for(let e of t)n+=e.toString(16).padStart(2,"0");return n}function vo(){if(typeof window>"u"||!window.location)return null;let e=window.location.origin;return"string"!=typeof e||""===e||"null"===e?null:e}var mo=class{captureId;nonce;t0WallMs;origins;constructor(e,t=Date.now()){this.captureId=e,this.nonce=yo(),this.t0WallMs=t;let n=vo();this.origins=null===n?[]:[n]}build(){return null===this.nonce?{refusal:"no-csprng"}:{identity:{captureId:this.captureId,sessionNonce:this.nonce,t0WallMs:this.t0WallMs,appOrigins:[...this.origins]}}}},wo=!1,bo=class e{static instance=null;recorder;network;transport;config;started=!1;identity=null;constructor(e){this.config=e,this.recorder=new go(e),this.network=new Ss(e.privacy??{},e.maxBodySize??524288,[e.endpoint],e.privacyMode);let t={endpoint:e.endpoint,apiKey:e.apiKey,batchSize:e.batchSize??50,batchInterval:e.batchInterval??5e3,maxQueueSize:e.maxQueueSize??5e3,...void 0!==e.onError?{onError:e.onError}:{},onCaptureEnd:()=>this.endCapture(),endsSessionOnly:(t,n)=>!0===e.continuous&&void 0===e.sessionIdGenerator&&("KUI_E_SESSION_CONFLICT"===t&&"session_completed"===n||"KUI_E_INGEST_REJECTED"===t&&"session_full"===n),onSessionEnd:()=>this.endSession(),onDropped:(e,t)=>this.recorder.lost(e,t),onDelivered:e=>this.recorder.delivered(e),onFailing:e=>this.recorder.failing(e),beforeUnloadFlush:()=>this.network.cutInflight(),beforeHiddenFlush:()=>this.network.reportDue(),beforeOnlineFlush:()=>this.network.reportDue()};this.transport=new _s(t)}static async init(t){if(e.instance)return e.instance;let n=e.nextSessionPaused;return e.cancelNextSession(),e.nextSessionPaused=!1,e.begin(t,n)}static async begin(t,n,r=!1){let i=new e(t);e.instance=i;try{await i.start(n,r)}catch(t){throw e.instance===i&&(e.instance=null),t}return i}static stop(){e.cancelNextSession(),e.nextSessionPaused=!1;let t=e.instance;e.instance=null;let n=Promise.all(e.ending),r=new Promise(e=>{let t=setTimeout(e,1e4);n.then(()=>{clearTimeout(t),e()})});return t||r.then(()=>{!e.instance&&!e.restartPending&&(mi(!1),Xi())}),Promise.all([t?t.stop():void 0,r]).then(()=>{})}static pause(){e.instance?.pause(),null===e.instance&&e.restartPending&&(e.nextSessionPaused=!0)}static resume(){e.instance?.resume(),e.nextSessionPaused=!1}static getSessionId(){return e.instance?.recorder.getSessionId()??""}static getInstance(){return e.instance}static getCaptureIdentity(){let t=e.instance?.identity;return t?t.build():null}async start(t,n=!1){if(this.started)return;if(this.started=!0,"strict"===this.config.privacyMode&&!1===this.config.privacy?.maskNetworkBodies)return void this.refuse(new Wr);let r=!1!==this.config.honorPrivacySignals?function(){try{if(typeof navigator>"u")return null;let e=navigator;if(!0===e.globalPrivacyControl)return"globalPrivacyControl";if("1"===e.doNotTrack||"yes"===e.doNotTrack||typeof window<"u"&&"1"===window.doNotTrack||"1"===e.msDoNotTrack)return"doNotTrack"}catch{}return null}():null;if(null!==r)return void this.decline(new Kr(r));let i,s=[],o=e=>{s?s.push(e):this.transport.enqueue(e)};try{mi(!0,!n);let e=this.recorder.start(o,()=>!0===this.config.continuous&&void 0===this.config.sessionIdGenerator?this.endSession():this.endCapture(),t,(e,t,n)=>this.transport.reportScrubOversized(e,t,n),e=>{null===e?this.transport.release():this.refuse(e)},e=>this.transport.reportNavigationUnwrapped(e));!1!==this.config.networkCapture&&null!==this.recorder.getSessionId()&&this.network.askForCode(),i=await e}catch(e){if(!(e instanceof Pr||e instanceof jr||e instanceof qr||e instanceof Mr))throw e;return void this.refuse(e)}if(!i)return this.started=!1,void((e.instance??this)===this&&mi(!1));let a=this.recorder.getMetadata();this.identity=new mo(i);let l=this.identity.build();this.recorder.awaitingRRWeb()&&this.transport.hold(),this.transport.start(i,a,"identity"in l?l.identity:null);let u=s;s=null;for(let e of u)this.transport.enqueue(e);!1!==this.config.networkCapture&&this.network.start((e,t,n)=>{this.recorder.emitEvent("network",e,void 0,!0,t,n)},()=>this.recorder.acceptsNetwork(),()=>this.transport.place())}stop(){return this.network.reportDue(),this.recorder.stopDom(),this.network.stop(),this.started=!1,this.network.settle(1e3).then(()=>{let t=null===e.instance;return Xi(t,()=>null!==e.instance||e.restartPending),t&&!e.restartPending&&mi(!1),this.recorder.stop(),this.transport.stop()})}decline(e){wo||console.info(e.message),wo=!0,this.endCapture();try{this.config.onError?.(e)}catch{}}refuse(e){console.error(e.message),this.endCapture();try{this.config.onError?.(e)}catch{}}endCapture(){let t=this.stop().catch(()=>{}).finally(()=>e.ending.delete(t));e.ending.add(t),e.instance===this&&(e.instance=null)}static cancelNextSession=()=>{};static nextSessionPaused=!1;static ending=new Set;static restartPending=!1;endSession(){let t=e.instance===this,n=this.recorder.isUserPaused();if(this.endCapture(),!t||typeof document>"u")return;e.cancelNextSession(),e.nextSessionPaused=n;let r={...this.config,sampleRate:1},i=()=>{let t=e.nextSessionPaused;e.cancelNextSession(),e.nextSessionPaused=!1,null===e.instance&&e.begin(r,t,!0).catch(e=>{console.warn("[keploy] the capture's next session could not start:",e)})},s={capture:!0,passive:!0};document.addEventListener("pointerdown",i,s),document.addEventListener("keydown",i,s);let o=po(()=>{});e.restartPending=!0,e.cancelNextSession=()=>{o(),document.removeEventListener("pointerdown",i,s),document.removeEventListener("keydown",i,s),e.restartPending=!1,e.cancelNextSession=()=>{}}}pause(){this.recorder.pause(),this.network.cutBodies()}resume(){this.recorder.resume()}};//# sourceMappingURL=index.js.map