@dtect/security-sdk-js 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -18,6 +18,14 @@ interface ISecurityResultResponse {
|
|
|
18
18
|
isAutomationDetected: boolean;
|
|
19
19
|
isUntrustedBrowserOrOS: boolean;
|
|
20
20
|
isBlockedIP: boolean;
|
|
21
|
+
isVpnDetected: boolean;
|
|
22
|
+
isDeviceTampered: boolean;
|
|
23
|
+
isVirtualMachine: boolean;
|
|
24
|
+
isDevToolsOpened: boolean;
|
|
25
|
+
isPrivacySettingsEnabled: boolean;
|
|
26
|
+
isTorDetected: boolean;
|
|
27
|
+
isHighActivityDevice: boolean;
|
|
28
|
+
isIncognito: boolean;
|
|
21
29
|
};
|
|
22
30
|
}
|
|
23
31
|
interface ISecurityTokenResponse {
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,14 @@ interface ISecurityResultResponse {
|
|
|
18
18
|
isAutomationDetected: boolean;
|
|
19
19
|
isUntrustedBrowserOrOS: boolean;
|
|
20
20
|
isBlockedIP: boolean;
|
|
21
|
+
isVpnDetected: boolean;
|
|
22
|
+
isDeviceTampered: boolean;
|
|
23
|
+
isVirtualMachine: boolean;
|
|
24
|
+
isDevToolsOpened: boolean;
|
|
25
|
+
isPrivacySettingsEnabled: boolean;
|
|
26
|
+
isTorDetected: boolean;
|
|
27
|
+
isHighActivityDevice: boolean;
|
|
28
|
+
isIncognito: boolean;
|
|
21
29
|
};
|
|
22
30
|
}
|
|
23
31
|
interface ISecurityTokenResponse {
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var J=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var it=(e,t)=>{for(var r in t)J(e,r,{get:t[r],enumerable:!0})},ot=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of rt(t))!nt.call(e,i)&&i!==r&&J(e,i,{get:()=>t[i],enumerable:!(n=tt(t,i))||n.enumerable});return e};var st=e=>ot(J({},"__esModule",{value:!0}),e);var tr={};it(tr,{SecurityAPIError:()=>ze,default:()=>er,getSecurityResult:()=>Ee,getSecurityToken:()=>me,init:()=>Je});module.exports=st(tr);var S=function(){return S=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},S.apply(this,arguments)};function Re(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function Te(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,s;n<i;n++)(s||!(n in t))&&(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return e.concat(s||Array.prototype.slice.call(t))}function at(e,t){return function(r,n){return Object.prototype.hasOwnProperty.call(r,n)}(e,t)?e[t]:void 0}function ut(e,t,r,n){var i,s=document,u="securitypolicyviolation",o=function(y){var l=new URL(e,location.href),h=y.blockedURI;h!==l.href&&h!==l.protocol.slice(0,-1)&&h!==l.origin||(i=y,a())};s.addEventListener(u,o);var a=function(){return s.removeEventListener(u,o)};return n?.then(a,a),Promise.resolve().then(t).then(function(y){return a(),y},function(y){return new Promise(function(l){var h=new MessageChannel;h.port1.onmessage=function(){return l()},h.port2.postMessage(null)}).then(function(){if(a(),i)return r(i);throw y})})}var ct={default:"endpoint"},lt={default:"tlsEndpoint"},ft="Client timeout",ht="Network connection error",dt="Network request aborted",pt="Response cannot be parsed",Z="Blocked by CSP",H="The endpoint parameter is not a valid URL";function A(e){for(var t="",r=0;r<e.length;++r)if(r>0){var n=e[r].toLowerCase();n!==e[r]?t+=" ".concat(n):t+=e[r]}else t+=e[r].toUpperCase();return t}var yt=A("WrongRegion"),Et=A("SubscriptionNotActive"),mt=A("UnsupportedVersion"),Rt=A("InstallationMethodRestricted"),Tt=A("HostnameRestricted"),Ot=A("IntegrationFailed"),ee="API key required",Oe="API key not found",Ie="API key expired",It="Request cannot be parsed",_t="Request failed",vt="Request failed to process",bt="Too many requests, rate limit exceeded",gt="Not available for this origin",wt="Not available with restricted header",At=ee,Pt=Oe,Nt=Ie,Dt="3.11.6",K="Failed to load the JS script of the agent",te="9319";function St(e,t){var r,n,i,s,u,o,a,y=[],l=(r=function(f){var c=Te([],f,!0);return{current:function(){return c[0]},postpone:function(){var d=c.shift();d!==void 0&&c.push(d)},exclude:function(){c.shift()}}}(e),s=100,u=3e3,o=0,n=function(){return Math.random()*Math.min(u,s*Math.pow(2,o++))},i=new Set,[r.current(),function(f,c){var d,p=c instanceof Error?c.message:"";if(p===Z||p===H)r.exclude(),d=0;else if(p===te)r.exclude();else if(p===K){var T=Date.now()-f.getTime()<50,O=r.current();O&&T&&!i.has(O)&&(i.add(O),d=0),r.postpone()}else r.postpone();var b=r.current();return b===void 0?void 0:[b,d??f.getTime()+n()-Date.now()]}]),h=l[0],_=l[1];if(h===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var v=function(f){var c=new Date,d=function(T){return y.push({url:f,startedAt:c,finishedAt:new Date,error:T})},p=t(f);return p.then(function(){return d()},d),p.catch(function(T){if(a!=null||(a=T),y.length>=5)throw a;var O=_(c,T);if(!O)throw a;var b,z=O[0],He=O[1];return(b=He,new Promise(function(et){return setTimeout(et,b)})).then(function(){return v(z)})})};return v(h).then(function(f){return[f,y]})}var _e="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Mt=_e;function xt(e){var t;e.scriptUrlPattern;var r=e.token,n=e.apiKey,i=n===void 0?r:n,s=Re(e,["scriptUrlPattern","token","apiKey"]),u=(t=at(e,"scriptUrlPattern"))!==null&&t!==void 0?t:_e,o=function(){var l=[],h=function(){l.push({time:new Date,state:document.visibilityState})},_=function(v,f,c,d){return v.addEventListener(f,c,d),function(){return v.removeEventListener(f,c,d)}}(document,"visibilitychange",h);return h(),[l,_]}(),a=o[0],y=o[1];return Promise.resolve().then(function(){if(!i||typeof i!="string")throw new Error(ee);var l=function(h,_){return(Array.isArray(h)?h:[h]).map(function(v){return function(f,c){var d=encodeURIComponent;return f.replace(/<[^<>]+>/g,function(p){return p==="<version>"?"3":p==="<apiKey>"?d(c):p==="<loaderVersion>"?d(Dt):p})}(String(v),_)})}(u,i);return St(l,Ft)}).catch(function(l){throw y(),function(h){return h instanceof Error&&h.message===te?new Error(K):h}(l)}).then(function(l){var h=l[0],_=l[1];return y(),h.load(S(S({},s),{ldi:{attempts:_,visibilityStates:a}}))})}function Ft(e){return ut(e,function(){return function(t){return new Promise(function(r,n){if(function(o){if(URL.prototype)try{return new URL(o,location.href),!1}catch(a){if(a instanceof Error&&a.name==="TypeError")return!0;throw a}}(t))throw new Error(H);var i=document.createElement("script"),s=function(){var o;return(o=i.parentNode)===null||o===void 0?void 0:o.removeChild(i)},u=document.head||document.getElementsByTagName("head")[0];i.onload=function(){s(),r()},i.onerror=function(){s(),n(new Error(K))},i.async=!0,i.src=t,u.appendChild(i)})}(e)},function(){throw new Error(Z)}).then(Lt)}function Lt(){var e=window,t="__fpjs_p_l_b",r=e[t];if(function(n,i){var s,u=(s=Object.getOwnPropertyDescriptor)===null||s===void 0?void 0:s.call(Object,n,i);u?.configurable?delete n[i]:u&&!u.writable||(n[i]=void 0)}(e,t),typeof r?.load!="function")throw new Error(te);return r}var k={load:xt,defaultScriptUrlPattern:Mt,ERROR_SCRIPT_LOAD_FAIL:K,ERROR_API_KEY_EXPIRED:Ie,ERROR_API_KEY_INVALID:Oe,ERROR_API_KEY_MISSING:ee,ERROR_BAD_REQUEST_FORMAT:It,ERROR_BAD_RESPONSE_FORMAT:pt,ERROR_CLIENT_TIMEOUT:ft,ERROR_CSP_BLOCK:Z,ERROR_FORBIDDEN_ENDPOINT:Tt,ERROR_FORBIDDEN_HEADER:wt,ERROR_FORBIDDEN_ORIGIN:gt,ERROR_GENERAL_SERVER_FAILURE:_t,ERROR_INSTALLATION_METHOD_RESTRICTED:Rt,ERROR_INTEGRATION_FAILURE:Ot,ERROR_INVALID_ENDPOINT:H,ERROR_NETWORK_ABORT:dt,ERROR_NETWORK_CONNECTION:ht,ERROR_RATE_LIMIT:bt,ERROR_SERVER_TIMEOUT:vt,ERROR_SUBSCRIPTION_NOT_ACTIVE:Et,ERROR_TOKEN_EXPIRED:Nt,ERROR_TOKEN_INVALID:Pt,ERROR_TOKEN_MISSING:At,ERROR_UNSUPPORTED_VERSION:mt,ERROR_WRONG_REGION:yt,defaultEndpoint:ct,defaultTlsEndpoint:lt};var R=[];for(let e=0;e<256;++e)R.push((e+256).toString(16).slice(1));function ve(e,t=0){return(R[e[t+0]]+R[e[t+1]]+R[e[t+2]]+R[e[t+3]]+"-"+R[e[t+4]]+R[e[t+5]]+"-"+R[e[t+6]]+R[e[t+7]]+"-"+R[e[t+8]]+R[e[t+9]]+"-"+R[e[t+10]]+R[e[t+11]]+R[e[t+12]]+R[e[t+13]]+R[e[t+14]]+R[e[t+15]]).toLowerCase()}var re,Ut=new Uint8Array(16);function ne(){if(!re){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");re=crypto.getRandomValues.bind(crypto)}return re(Ut)}var qt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ie={randomUUID:qt};function jt(e,t,r){if(ie.randomUUID&&!t&&!e)return ie.randomUUID();e=e||{};let n=e.random??e.rng?.()??ne();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[r+i]=n[i];return t}return ve(n)}var Q=jt;var Kt={UNAUTHORIZED:"Unauthorized"},kt={EXPIRED:"EXPIRED_TOKEN",INVALID_API_KEY:"INVALID_API_KEY",MISSING_AUTHENTICATION_TOKEN:"MISSING_AUTHENTICATION_TOKEN"},be={INTERNAL_SERVER_ERROR:"Internal Server Error during API Request",MISSING_CREDENTIALS:"Missing Public Client ID or Public API Key",MAINTENANCE_MODE:"API Under Maintenance"},ge={SDK_INIT_ERROR:"Internal Server Error during SDK Initialization",DUPLICATE_INITIALIZATION:"Multiple SDK Initializations Detected",NOT_INITIALIZED:"SDK Not Initialized"},we={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},Ae={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},Pe={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},E={...Kt,...kt,...be,...ge,...we,...Ae,...Pe},Ne={...be,...ge,...we,...Ae,...Pe};var g=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var w=typeof window>"u"||"Deno"in globalThis;function I(){}function Me(e,t){return typeof e=="function"?e(t):e}function xe(e){return typeof e=="number"&&e>=0&&e!==1/0}function Fe(e,t){return Math.max(e+(t||0)-Date.now(),0)}function se(e,t){return typeof e=="function"?e(t):e}function Le(e,t){return typeof e=="function"?e(t):e}function ae(e,t){let{type:r="all",exact:n,fetchStatus:i,predicate:s,queryKey:u,stale:o}=e;if(u){if(n){if(t.queryHash!==M(u,t.options))return!1}else if(!N(t.queryKey,u))return!1}if(r!=="all"){let a=t.isActive();if(r==="active"&&!a||r==="inactive"&&a)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||i&&i!==t.state.fetchStatus||s&&!s(t))}function ue(e,t){let{exact:r,status:n,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(r){if(P(t.options.mutationKey)!==P(s))return!1}else if(!N(t.options.mutationKey,s))return!1}return!(n&&t.state.status!==n||i&&!i(t))}function M(e,t){return(t?.queryKeyHashFn||P)(e)}function P(e){return JSON.stringify(e,(t,r)=>oe(r)?Object.keys(r).sort().reduce((n,i)=>(n[i]=r[i],n),{}):r)}function N(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!N(e[r],t[r])):!1}function Ue(e,t){if(e===t)return e;let r=De(e)&&De(t);if(r||oe(e)&&oe(t)){let n=r?e:Object.keys(e),i=n.length,s=r?t:Object.keys(t),u=s.length,o=r?[]:{},a=0;for(let y=0;y<u;y++){let l=r?y:s[y];(!r&&n.includes(l)||r)&&e[l]===void 0&&t[l]===void 0?(o[l]=void 0,a++):(o[l]=Ue(e[l],t[l]),o[l]===e[l]&&e[l]!==void 0&&a++)}return i===u&&a===i?e:o}return t}function De(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function oe(e){if(!Se(e))return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(!Se(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Se(e){return Object.prototype.toString.call(e)==="[object Object]"}function qe(e){return new Promise(t=>{setTimeout(t,e)})}function je(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?Ue(e,t):t}function Ke(e,t,r=0){let n=[...e,t];return r&&n.length>r?n.slice(1):n}function ke(e,t,r=0){let n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var x=Symbol();function G(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===x?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Qt=class extends g{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!w&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},B=new Qt;var Gt=class extends g{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!w&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},D=new Gt;function Qe(){let e,t,r=new Promise((i,s)=>{e=i,t=s});r.status="pending",r.catch(()=>{});function n(i){Object.assign(r,i),delete r.resolve,delete r.reject}return r.resolve=i=>{n({status:"fulfilled",value:i}),e(i)},r.reject=i=>{n({status:"rejected",reason:i}),t(i)},r}function Bt(e){return Math.min(1e3*2**e,3e4)}function ce(e){return(e??"online")==="online"?D.isOnline():!0}var Ge=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function V(e){return e instanceof Ge}function C(e){let t=!1,r=0,n=!1,i,s=Qe(),u=c=>{n||(_(new Ge(c)),e.abort?.())},o=()=>{t=!0},a=()=>{t=!1},y=()=>B.isFocused()&&(e.networkMode==="always"||D.isOnline())&&e.canRun(),l=()=>ce(e.networkMode)&&e.canRun(),h=c=>{n||(n=!0,e.onSuccess?.(c),i?.(),s.resolve(c))},_=c=>{n||(n=!0,e.onError?.(c),i?.(),s.reject(c))},v=()=>new Promise(c=>{i=d=>{(n||y())&&c(d)},e.onPause?.()}).then(()=>{i=void 0,n||e.onContinue?.()}),f=()=>{if(n)return;let c,d=r===0?e.initialPromise:void 0;try{c=d??e.fn()}catch(p){c=Promise.reject(p)}Promise.resolve(c).then(h).catch(p=>{if(n)return;let T=e.retry??(w?0:3),O=e.retryDelay??Bt,b=typeof O=="function"?O(r,p):O,z=T===!0||typeof T=="number"&&r<T||typeof T=="function"&&T(r,p);if(t||!z){_(p);return}r++,e.onFail?.(r,p),qe(b).then(()=>y()?void 0:v()).then(()=>{t?_(p):f()})})};return{promise:s,cancel:u,continue:()=>(i?.(),s),cancelRetry:o,continueRetry:a,canStart:l,start:()=>(l()?f():v().then(f),s)}}function Vt(){let e=[],t=0,r=o=>{o()},n=o=>{o()},i=o=>setTimeout(o,0),s=o=>{t?e.push(o):i(()=>{r(o)})},u=()=>{let o=e;e=[],o.length&&i(()=>{n(()=>{o.forEach(a=>{r(a)})})})};return{batch:o=>{let a;t++;try{a=o()}finally{t--,t||u()}return a},batchCalls:o=>(...a)=>{s(()=>{o(...a)})},schedule:s,setNotifyFunction:o=>{r=o},setBatchNotifyFunction:o=>{n=o},setScheduler:o=>{i=o}}}var m=Vt();var Y=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),xe(this.gcTime)&&(this.#e=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(w?1/0:5*60*1e3))}clearGcTimeout(){this.#e&&(clearTimeout(this.#e),this.#e=void 0)}};var Be=class extends Y{#e;#t;#r;#n;#s;#o;constructor(e){super(),this.#o=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Yt(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){this.options={...this.#s,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){let r=je(this.state.data,e,this.options);return this.#i({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(I).catch(I):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Le(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===x||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Fe(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#o?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){let o=this.observers.find(a=>a.options.queryFn);o&&this.setOptions(o.options)}let r=new AbortController,n=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,r.signal)})},i=()=>{let o=G(this.options,t),a={queryKey:this.queryKey,meta:this.meta};return n(a),this.#o=!1,this.options.persister?this.options.persister(o,a,this):o(a)},s={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};n(s),this.options.behavior?.onFetch(s,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#i({type:"fetch",meta:s.fetchOptions?.meta});let u=o=>{V(o)&&o.silent||this.#i({type:"error",error:o}),V(o)||(this.#r.config.onError?.(o,this),this.#r.config.onSettled?.(this.state.data,o,this)),this.scheduleGc()};return this.#n=C({initialPromise:t?.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:o=>{if(o===void 0){u(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(o)}catch(a){u(a);return}this.#r.config.onSuccess?.(o,this),this.#r.config.onSettled?.(o,this.state.error,this),this.scheduleGc()},onError:u,onFail:(o,a)=>{this.#i({type:"failed",failureCount:o,error:a})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0}),this.#n.start()}#i(e){let t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Ct(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":let n=e.error;return V(n)&&n.revert&&this.#t?{...this.#t,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),m.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function Ct(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ce(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Yt(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var F=class extends g{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){let n=t.queryKey,i=t.queryHash??M(n,t),s=this.get(i);return s||(s=new Be({cache:this,queryKey:n,queryHash:i,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(s)),s}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){m.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(r=>ae(t,r))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(r=>ae(e,r)):t}notify(e){m.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){m.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){m.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var Ve=class extends Y{#e;#t;#r;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||Wt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#t.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){this.#r=C({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(n,i)=>{this.#n({type:"failed",failureCount:n,error:i})},onPause:()=>{this.#n({type:"pause"})},onContinue:()=>{this.#n({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let t=this.state.status==="pending",r=!this.#r.canStart();try{if(!t){this.#n({type:"pending",variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let i=await this.options.onMutate?.(e);i!==this.state.context&&this.#n({type:"pending",context:i,variables:e,isPaused:r})}let n=await this.#r.start();return await this.#t.config.onSuccess?.(n,e,this.state.context,this),await this.options.onSuccess?.(n,e,this.state.context),await this.#t.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,e,this.state.context),this.#n({type:"success",data:n}),n}catch(n){try{throw await this.#t.config.onError?.(n,e,this.state.context,this),await this.options.onError?.(n,e,this.state.context),await this.#t.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,n,e,this.state.context),n}finally{this.#n({type:"error",error:n})}}finally{this.#t.runNext(this)}}#n(e){let t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),m.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function Wt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var L=class extends g{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,r){let n=new Ve({mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#e.add(e);let t=W(e);if(typeof t=="string"){let r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=W(e);if(typeof t=="string"){let r=this.#t.get(t);if(r)if(r.length>1){let n=r.indexOf(e);n!==-1&&r.splice(n,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=W(e);if(typeof t=="string"){let n=this.#t.get(t)?.find(i=>i.state.status==="pending");return!n||n===e}else return!0}runNext(e){let t=W(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){m.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(r=>ue(t,r))}findAll(e={}){return this.getAll().filter(t=>ue(e,t))}notify(e){m.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return m.batch(()=>Promise.all(e.map(t=>t.continue().catch(I))))}};function W(e){return e.options.scope?.id}function le(e){return{onFetch:(t,r)=>{let n=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,s=t.state.data?.pages||[],u=t.state.data?.pageParams||[],o={pages:[],pageParams:[]},a=0,y=async()=>{let l=!1,h=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(t.signal.aborted?l=!0:t.signal.addEventListener("abort",()=>{l=!0}),t.signal)})},_=G(t.options,t.fetchOptions),v=async(f,c,d)=>{if(l)return Promise.reject();if(c==null&&f.pages.length)return Promise.resolve(f);let p={queryKey:t.queryKey,pageParam:c,direction:d?"backward":"forward",meta:t.options.meta};h(p);let T=await _(p),{maxPages:O}=t.options,b=d?ke:Ke;return{pages:b(f.pages,T,O),pageParams:b(f.pageParams,c,O)}};if(i&&s.length){let f=i==="backward",c=f?Xt:Ce,d={pages:s,pageParams:u},p=c(n,d);o=await v(d,p,f)}else{let f=e??s.length;do{let c=a===0?u[0]??n.initialPageParam:Ce(n,o);if(a>0&&c==null)break;o=await v(o,c),a++}while(a<f)}return o};t.options.persister?t.fetchFn=()=>t.options.persister?.(y,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=y}}}function Ce(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function Xt(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var fe=class{#e;#t;#r;#n;#s;#o;#i;#a;constructor(e={}){this.#e=e.queryCache||new F,this.#t=e.mutationCache||new L,this.#r=e.defaultOptions||{},this.#n=new Map,this.#s=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=B.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=D.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#i?.(),this.#i=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(se(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{let n=r.data;return[t,n]})}setQueryData(e,t,r){let n=this.defaultQueryOptions({queryKey:e}),s=this.#e.get(n.queryHash)?.state.data,u=Me(t,s);if(u!==void 0)return this.#e.build(this,n).setData(u,{...r,manual:!0})}setQueriesData(e,t,r){return m.batch(()=>this.#e.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;m.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){let r=this.#e,n={type:"active",...e};return m.batch(()=>(r.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries(n,t)))}cancelQueries(e,t={}){let r={revert:!0,...t},n=m.batch(()=>this.#e.findAll(e).map(i=>i.cancel(r)));return Promise.all(n).then(I).catch(I)}invalidateQueries(e,t={}){return m.batch(()=>{if(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none")return Promise.resolve();let r={...e,type:e?.refetchType??e?.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??!0},n=m.batch(()=>this.#e.findAll(e).filter(i=>!i.isDisabled()).map(i=>{let s=i.fetch(void 0,r);return r.throwOnError||(s=s.catch(I)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(n).then(I)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(se(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(I).catch(I)}fetchInfiniteQuery(e){return e.behavior=le(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(I).catch(I)}ensureInfiniteQueryData(e){return e.behavior=le(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return D.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#n.set(P(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#n.values()],r={};return t.forEach(n=>{N(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){this.#s.set(P(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#s.values()],r={};return t.forEach(n=>{N(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=M(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===x&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var $t=new fe({defaultOptions:{queries:{staleTime:3e4}},queryCache:new F({onError:(e,t)=>{}}),mutationCache:new L}),Ye=$t;var zt=(e,t={})=>({"Content-Type":"application/json",...e?.accessToken&&{Authorization:`Bearer ${e?.accessToken}`},...t}),Jt=async(e,t)=>{if(!e.ok){let r=await e.text();throw new Error(r)}return t==="file"?e.blob():t==="json"?e.json():t==="text"?e.text():null},We=async({url:e,auth:t,body:r,method:n="GET",headers:i={},responseType:s="json"})=>{let u={method:n,headers:zt(t,i),...r?{body:r instanceof FormData?r:JSON.stringify(r)}:{}},o=await fetch(e,u);return Jt(o,s)},Xe=e=>We({...e,method:"GET"}),he=e=>We({...e,method:"POST"});var de,pe="https://api.dtect.io/security",q="",j="",$e="",Zt="20000000-aaaa-bbbb-cccc-000000000002",X,U={isLoading:!1},ze=Ne;function $(){return!!(document.querySelector("#dtect-h-captcha")&&de)}function ye(){return!!(q&&j)}async function Ht({behaviorKey:e}){let t=await k.load({apiKey:e,endpoint:["https://fp.dtect.io",k.defaultEndpoint],scriptUrlPattern:["https://fp.dtect.io/web/v<version>/<apiKey>/loader_v<loaderVersion>.js",k.defaultScriptUrlPattern]});if(t)de=t;else throw new Error(E.SDK_INIT_ERROR)}async function Je(e){if(!e?.clientId||!e?.apiKey)throw new Error(E.MISSING_CREDENTIALS);let{clientId:t,apiKey:r,endpoint:n="https://api.dtect.io/security"}=e;if(pe=n,U.isLoading){if($())return X;throw new Error(E.DUPLICATE_INITIALIZATION)}if(q=t,j=r,U={...U,isLoading:!0},!ye())throw new Error(E.MISSING_CREDENTIALS);if($())return X;let i=document.querySelector("head");document.querySelector("body")?.insertAdjacentHTML("beforeend",'<div id="dtect-h-captcha" ></div>');let u=document.createElement("script");u.setAttribute("src","https://js.hcaptcha.com/1/api.js"),u.setAttribute("async","true"),u.setAttribute("defer","true"),i?.append(u);try{let o=await Ye.fetchQuery({queryKey:["getKeys",t,r],queryFn:()=>Xe({url:`${n}/client/config`,headers:{"client-id":q,"x-api-key":j}})});if(o?.automationKey&&o?.behaviorKey)return $e=o.automationKey,Ht({...o}).then(()=>({getSecurityResult:Ee,getSecurityToken:me,SecurityAPIError:ze})).catch(a=>{throw new Error(a.message)});throw new Error}catch(o){if(o instanceof Error){if(o?.message?.includes("maintenance_mode"))throw new Error(E.MAINTENANCE_MODE);if([E.INVALID_API_KEY,E.UNAUTHORIZED].includes(o?.message))throw new Error(E.INVALID_CREDENTIALS)}throw new Error(E.SDK_INIT_ERROR)}finally{U={...U,isLoading:!1}}}async function Ze(){let e=await de?.get();if(window?.location?.href?.includes("localhost")){if(e?.sealedResult&&e?.requestId)return{behaviorRequestId:e.requestId,behaviorToken:e.sealedResult,automationToken:Zt}}else{await window?.hcaptcha?.render("dtect-h-captcha",{sitekey:$e,size:"invisible"});let t=await window?.hcaptcha?.execute({async:!0});if(t?.response&&e?.sealedResult&&e?.requestId)return{behaviorRequestId:e.requestId,behaviorToken:e.sealedResult,automationToken:t.response}}throw new Error(E.INTERNAL_SERVER_ERROR)}async function Ee(e){if(!$())throw new Error(E.NOT_INITIALIZED);if(!ye())throw new Error(E.MISSING_CREDENTIALS);if(!e||!e?.projectId?.trim())throw new Error(E.FAILED_TO_GET_SECURITY_RESULT);try{let t=await Ze();if(t?.behaviorToken&&t?.behaviorRequestId&&t?.behaviorToken){let r={...e,projectId:e?.projectId?.trim(),visitorId:e?.visitorId?.trim()||Q(),visitorData:{behaviorToken:t.behaviorToken,automationToken:t.automationToken,behaviorRequestId:t.behaviorRequestId,entryLink:window?.location?.href}},n=await he({url:`${pe}/client/check/results`,body:{...r},headers:{"client-id":q,"x-api-key":j}});if(n?.results?.dtectScore)return n}throw new Error}catch(t){throw t instanceof Error&&t?.message?.includes("maintenance_mode")?new Error(E.MAINTENANCE_MODE):new Error(E.FAILED_TO_GET_SECURITY_RESULT)}}async function me(e){if(!$())throw new Error(E.NOT_INITIALIZED);if(!ye())throw new Error(E.MISSING_CREDENTIALS);if(!e||!e?.projectId?.trim())throw new Error(E.FAILED_TO_GET_SECURITY_TOKEN);try{let t=await Ze();if(t?.behaviorToken&&t?.behaviorRequestId&&t?.behaviorToken){let r={...e,projectId:e.projectId?.trim(),visitorId:e.visitorId?.trim()||Q(),visitorData:{behaviorToken:t.behaviorToken,automationToken:t.automationToken,behaviorRequestId:t.behaviorRequestId,entryLink:window?.location?.href}},n=await he({url:`${pe}/client/check/token`,body:{...r},headers:{"client-id":q,"x-api-key":j}});if(n?.token)return n}throw new Error}catch(t){throw t instanceof Error&&t?.message?.includes("maintenance_mode")?new Error(E.MAINTENANCE_MODE):new Error(E.FAILED_TO_GET_SECURITY_TOKEN)}}X={init:Je,getSecurityResult:Ee,getSecurityToken:me};var er=X;
|
|
1
|
+
"use strict";var J=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var it=(e,t)=>{for(var r in t)J(e,r,{get:t[r],enumerable:!0})},ot=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of rt(t))!nt.call(e,i)&&i!==r&&J(e,i,{get:()=>t[i],enumerable:!(n=tt(t,i))||n.enumerable});return e};var st=e=>ot(J({},"__esModule",{value:!0}),e);var tr={};it(tr,{SecurityAPIError:()=>ze,default:()=>er,getSecurityResult:()=>Ee,getSecurityToken:()=>me,init:()=>Je});module.exports=st(tr);var S=function(){return S=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},S.apply(this,arguments)};function Re(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function Te(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,s;n<i;n++)(s||!(n in t))&&(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return e.concat(s||Array.prototype.slice.call(t))}function at(e,t){return function(r,n){return Object.prototype.hasOwnProperty.call(r,n)}(e,t)?e[t]:void 0}function ut(e,t,r,n){var i,s=document,u="securitypolicyviolation",o=function(y){var l=new URL(e,location.href),h=y.blockedURI;h!==l.href&&h!==l.protocol.slice(0,-1)&&h!==l.origin||(i=y,a())};s.addEventListener(u,o);var a=function(){return s.removeEventListener(u,o)};return n?.then(a,a),Promise.resolve().then(t).then(function(y){return a(),y},function(y){return new Promise(function(l){var h=new MessageChannel;h.port1.onmessage=function(){return l()},h.port2.postMessage(null)}).then(function(){if(a(),i)return r(i);throw y})})}var ct={default:"endpoint"},lt={default:"tlsEndpoint"},ft="Client timeout",ht="Network connection error",dt="Network request aborted",pt="Response cannot be parsed",Z="Blocked by CSP",H="The endpoint parameter is not a valid URL";function A(e){for(var t="",r=0;r<e.length;++r)if(r>0){var n=e[r].toLowerCase();n!==e[r]?t+=" ".concat(n):t+=e[r]}else t+=e[r].toUpperCase();return t}var yt=A("WrongRegion"),Et=A("SubscriptionNotActive"),mt=A("UnsupportedVersion"),Rt=A("InstallationMethodRestricted"),Tt=A("HostnameRestricted"),Ot=A("IntegrationFailed"),ee="API key required",Oe="API key not found",Ie="API key expired",It="Request cannot be parsed",_t="Request failed",vt="Request failed to process",wt="Too many requests, rate limit exceeded",bt="Not available for this origin",gt="Not available with restricted header",At=ee,Pt=Oe,Nt=Ie,Dt="3.11.6",j="Failed to load the JS script of the agent",te="9319";function St(e,t){var r,n,i,s,u,o,a,y=[],l=(r=function(f){var c=Te([],f,!0);return{current:function(){return c[0]},postpone:function(){var d=c.shift();d!==void 0&&c.push(d)},exclude:function(){c.shift()}}}(e),s=100,u=3e3,o=0,n=function(){return Math.random()*Math.min(u,s*Math.pow(2,o++))},i=new Set,[r.current(),function(f,c){var d,p=c instanceof Error?c.message:"";if(p===Z||p===H)r.exclude(),d=0;else if(p===te)r.exclude();else if(p===j){var T=Date.now()-f.getTime()<50,O=r.current();O&&T&&!i.has(O)&&(i.add(O),d=0),r.postpone()}else r.postpone();var w=r.current();return w===void 0?void 0:[w,d??f.getTime()+n()-Date.now()]}]),h=l[0],_=l[1];if(h===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var v=function(f){var c=new Date,d=function(T){return y.push({url:f,startedAt:c,finishedAt:new Date,error:T})},p=t(f);return p.then(function(){return d()},d),p.catch(function(T){if(a!=null||(a=T),y.length>=5)throw a;var O=_(c,T);if(!O)throw a;var w,z=O[0],He=O[1];return(w=He,new Promise(function(et){return setTimeout(et,w)})).then(function(){return v(z)})})};return v(h).then(function(f){return[f,y]})}var _e="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Mt=_e;function xt(e){var t;e.scriptUrlPattern;var r=e.token,n=e.apiKey,i=n===void 0?r:n,s=Re(e,["scriptUrlPattern","token","apiKey"]),u=(t=at(e,"scriptUrlPattern"))!==null&&t!==void 0?t:_e,o=function(){var l=[],h=function(){l.push({time:new Date,state:document.visibilityState})},_=function(v,f,c,d){return v.addEventListener(f,c,d),function(){return v.removeEventListener(f,c,d)}}(document,"visibilitychange",h);return h(),[l,_]}(),a=o[0],y=o[1];return Promise.resolve().then(function(){if(!i||typeof i!="string")throw new Error(ee);var l=function(h,_){return(Array.isArray(h)?h:[h]).map(function(v){return function(f,c){var d=encodeURIComponent;return f.replace(/<[^<>]+>/g,function(p){return p==="<version>"?"3":p==="<apiKey>"?d(c):p==="<loaderVersion>"?d(Dt):p})}(String(v),_)})}(u,i);return St(l,Ft)}).catch(function(l){throw y(),function(h){return h instanceof Error&&h.message===te?new Error(j):h}(l)}).then(function(l){var h=l[0],_=l[1];return y(),h.load(S(S({},s),{ldi:{attempts:_,visibilityStates:a}}))})}function Ft(e){return ut(e,function(){return function(t){return new Promise(function(r,n){if(function(o){if(URL.prototype)try{return new URL(o,location.href),!1}catch(a){if(a instanceof Error&&a.name==="TypeError")return!0;throw a}}(t))throw new Error(H);var i=document.createElement("script"),s=function(){var o;return(o=i.parentNode)===null||o===void 0?void 0:o.removeChild(i)},u=document.head||document.getElementsByTagName("head")[0];i.onload=function(){s(),r()},i.onerror=function(){s(),n(new Error(j))},i.async=!0,i.src=t,u.appendChild(i)})}(e)},function(){throw new Error(Z)}).then(Lt)}function Lt(){var e=window,t="__fpjs_p_l_b",r=e[t];if(function(n,i){var s,u=(s=Object.getOwnPropertyDescriptor)===null||s===void 0?void 0:s.call(Object,n,i);u?.configurable?delete n[i]:u&&!u.writable||(n[i]=void 0)}(e,t),typeof r?.load!="function")throw new Error(te);return r}var K={load:xt,defaultScriptUrlPattern:Mt,ERROR_SCRIPT_LOAD_FAIL:j,ERROR_API_KEY_EXPIRED:Ie,ERROR_API_KEY_INVALID:Oe,ERROR_API_KEY_MISSING:ee,ERROR_BAD_REQUEST_FORMAT:It,ERROR_BAD_RESPONSE_FORMAT:pt,ERROR_CLIENT_TIMEOUT:ft,ERROR_CSP_BLOCK:Z,ERROR_FORBIDDEN_ENDPOINT:Tt,ERROR_FORBIDDEN_HEADER:gt,ERROR_FORBIDDEN_ORIGIN:bt,ERROR_GENERAL_SERVER_FAILURE:_t,ERROR_INSTALLATION_METHOD_RESTRICTED:Rt,ERROR_INTEGRATION_FAILURE:Ot,ERROR_INVALID_ENDPOINT:H,ERROR_NETWORK_ABORT:dt,ERROR_NETWORK_CONNECTION:ht,ERROR_RATE_LIMIT:wt,ERROR_SERVER_TIMEOUT:vt,ERROR_SUBSCRIPTION_NOT_ACTIVE:Et,ERROR_TOKEN_EXPIRED:Nt,ERROR_TOKEN_INVALID:Pt,ERROR_TOKEN_MISSING:At,ERROR_UNSUPPORTED_VERSION:mt,ERROR_WRONG_REGION:yt,defaultEndpoint:ct,defaultTlsEndpoint:lt};var R=[];for(let e=0;e<256;++e)R.push((e+256).toString(16).slice(1));function ve(e,t=0){return(R[e[t+0]]+R[e[t+1]]+R[e[t+2]]+R[e[t+3]]+"-"+R[e[t+4]]+R[e[t+5]]+"-"+R[e[t+6]]+R[e[t+7]]+"-"+R[e[t+8]]+R[e[t+9]]+"-"+R[e[t+10]]+R[e[t+11]]+R[e[t+12]]+R[e[t+13]]+R[e[t+14]]+R[e[t+15]]).toLowerCase()}var re,Ut=new Uint8Array(16);function ne(){if(!re){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");re=crypto.getRandomValues.bind(crypto)}return re(Ut)}var qt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ie={randomUUID:qt};function kt(e,t,r){if(ie.randomUUID&&!t&&!e)return ie.randomUUID();e=e||{};let n=e.random??e.rng?.()??ne();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[r+i]=n[i];return t}return ve(n)}var Q=kt;var jt={UNAUTHORIZED:"Unauthorized"},Kt={EXPIRED:"EXPIRED_TOKEN",INVALID_API_KEY:"INVALID_API_KEY",MISSING_AUTHENTICATION_TOKEN:"MISSING_AUTHENTICATION_TOKEN"},we={INTERNAL_SERVER_ERROR:"Internal Server Error during API Request",MISSING_CREDENTIALS:"Missing Public Client ID or Public API Key",MAINTENANCE_MODE:"API Under Maintenance"},be={SDK_INIT_ERROR:"Internal Server Error during SDK Initialization",DUPLICATE_INITIALIZATION:"Multiple SDK Initializations Detected",NOT_INITIALIZED:"SDK Not Initialized"},ge={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},Ae={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},Pe={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},E={...jt,...Kt,...we,...be,...ge,...Ae,...Pe},Ne={...we,...be,...ge,...Ae,...Pe};var b=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var g=typeof window>"u"||"Deno"in globalThis;function I(){}function Me(e,t){return typeof e=="function"?e(t):e}function xe(e){return typeof e=="number"&&e>=0&&e!==1/0}function Fe(e,t){return Math.max(e+(t||0)-Date.now(),0)}function se(e,t){return typeof e=="function"?e(t):e}function Le(e,t){return typeof e=="function"?e(t):e}function ae(e,t){let{type:r="all",exact:n,fetchStatus:i,predicate:s,queryKey:u,stale:o}=e;if(u){if(n){if(t.queryHash!==M(u,t.options))return!1}else if(!N(t.queryKey,u))return!1}if(r!=="all"){let a=t.isActive();if(r==="active"&&!a||r==="inactive"&&a)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||i&&i!==t.state.fetchStatus||s&&!s(t))}function ue(e,t){let{exact:r,status:n,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(r){if(P(t.options.mutationKey)!==P(s))return!1}else if(!N(t.options.mutationKey,s))return!1}return!(n&&t.state.status!==n||i&&!i(t))}function M(e,t){return(t?.queryKeyHashFn||P)(e)}function P(e){return JSON.stringify(e,(t,r)=>oe(r)?Object.keys(r).sort().reduce((n,i)=>(n[i]=r[i],n),{}):r)}function N(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!N(e[r],t[r])):!1}function Ue(e,t){if(e===t)return e;let r=De(e)&&De(t);if(r||oe(e)&&oe(t)){let n=r?e:Object.keys(e),i=n.length,s=r?t:Object.keys(t),u=s.length,o=r?[]:{},a=0;for(let y=0;y<u;y++){let l=r?y:s[y];(!r&&n.includes(l)||r)&&e[l]===void 0&&t[l]===void 0?(o[l]=void 0,a++):(o[l]=Ue(e[l],t[l]),o[l]===e[l]&&e[l]!==void 0&&a++)}return i===u&&a===i?e:o}return t}function De(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function oe(e){if(!Se(e))return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(!Se(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Se(e){return Object.prototype.toString.call(e)==="[object Object]"}function qe(e){return new Promise(t=>{setTimeout(t,e)})}function ke(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?Ue(e,t):t}function je(e,t,r=0){let n=[...e,t];return r&&n.length>r?n.slice(1):n}function Ke(e,t,r=0){let n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var x=Symbol();function G(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===x?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Qt=class extends b{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!g&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},B=new Qt;var Gt=class extends b{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!g&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},D=new Gt;function Qe(){let e,t,r=new Promise((i,s)=>{e=i,t=s});r.status="pending",r.catch(()=>{});function n(i){Object.assign(r,i),delete r.resolve,delete r.reject}return r.resolve=i=>{n({status:"fulfilled",value:i}),e(i)},r.reject=i=>{n({status:"rejected",reason:i}),t(i)},r}function Bt(e){return Math.min(1e3*2**e,3e4)}function ce(e){return(e??"online")==="online"?D.isOnline():!0}var Ge=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function V(e){return e instanceof Ge}function C(e){let t=!1,r=0,n=!1,i,s=Qe(),u=c=>{n||(_(new Ge(c)),e.abort?.())},o=()=>{t=!0},a=()=>{t=!1},y=()=>B.isFocused()&&(e.networkMode==="always"||D.isOnline())&&e.canRun(),l=()=>ce(e.networkMode)&&e.canRun(),h=c=>{n||(n=!0,e.onSuccess?.(c),i?.(),s.resolve(c))},_=c=>{n||(n=!0,e.onError?.(c),i?.(),s.reject(c))},v=()=>new Promise(c=>{i=d=>{(n||y())&&c(d)},e.onPause?.()}).then(()=>{i=void 0,n||e.onContinue?.()}),f=()=>{if(n)return;let c,d=r===0?e.initialPromise:void 0;try{c=d??e.fn()}catch(p){c=Promise.reject(p)}Promise.resolve(c).then(h).catch(p=>{if(n)return;let T=e.retry??(g?0:3),O=e.retryDelay??Bt,w=typeof O=="function"?O(r,p):O,z=T===!0||typeof T=="number"&&r<T||typeof T=="function"&&T(r,p);if(t||!z){_(p);return}r++,e.onFail?.(r,p),qe(w).then(()=>y()?void 0:v()).then(()=>{t?_(p):f()})})};return{promise:s,cancel:u,continue:()=>(i?.(),s),cancelRetry:o,continueRetry:a,canStart:l,start:()=>(l()?f():v().then(f),s)}}function Vt(){let e=[],t=0,r=o=>{o()},n=o=>{o()},i=o=>setTimeout(o,0),s=o=>{t?e.push(o):i(()=>{r(o)})},u=()=>{let o=e;e=[],o.length&&i(()=>{n(()=>{o.forEach(a=>{r(a)})})})};return{batch:o=>{let a;t++;try{a=o()}finally{t--,t||u()}return a},batchCalls:o=>(...a)=>{s(()=>{o(...a)})},schedule:s,setNotifyFunction:o=>{r=o},setBatchNotifyFunction:o=>{n=o},setScheduler:o=>{i=o}}}var m=Vt();var Y=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),xe(this.gcTime)&&(this.#e=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(g?1/0:5*60*1e3))}clearGcTimeout(){this.#e&&(clearTimeout(this.#e),this.#e=void 0)}};var Be=class extends Y{#e;#t;#r;#n;#s;#o;constructor(e){super(),this.#o=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Yt(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){this.options={...this.#s,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){let r=ke(this.state.data,e,this.options);return this.#i({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(I).catch(I):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Le(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===x||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Fe(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#o?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){let o=this.observers.find(a=>a.options.queryFn);o&&this.setOptions(o.options)}let r=new AbortController,n=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,r.signal)})},i=()=>{let o=G(this.options,t),a={queryKey:this.queryKey,meta:this.meta};return n(a),this.#o=!1,this.options.persister?this.options.persister(o,a,this):o(a)},s={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};n(s),this.options.behavior?.onFetch(s,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#i({type:"fetch",meta:s.fetchOptions?.meta});let u=o=>{V(o)&&o.silent||this.#i({type:"error",error:o}),V(o)||(this.#r.config.onError?.(o,this),this.#r.config.onSettled?.(this.state.data,o,this)),this.scheduleGc()};return this.#n=C({initialPromise:t?.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:o=>{if(o===void 0){u(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(o)}catch(a){u(a);return}this.#r.config.onSuccess?.(o,this),this.#r.config.onSettled?.(o,this.state.error,this),this.scheduleGc()},onError:u,onFail:(o,a)=>{this.#i({type:"failed",failureCount:o,error:a})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0}),this.#n.start()}#i(e){let t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Ct(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":let n=e.error;return V(n)&&n.revert&&this.#t?{...this.#t,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),m.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function Ct(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ce(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Yt(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var F=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){let n=t.queryKey,i=t.queryHash??M(n,t),s=this.get(i);return s||(s=new Be({cache:this,queryKey:n,queryHash:i,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(s)),s}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){m.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(r=>ae(t,r))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(r=>ae(e,r)):t}notify(e){m.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){m.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){m.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var Ve=class extends Y{#e;#t;#r;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||Wt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#t.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){this.#r=C({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(n,i)=>{this.#n({type:"failed",failureCount:n,error:i})},onPause:()=>{this.#n({type:"pause"})},onContinue:()=>{this.#n({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let t=this.state.status==="pending",r=!this.#r.canStart();try{if(!t){this.#n({type:"pending",variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let i=await this.options.onMutate?.(e);i!==this.state.context&&this.#n({type:"pending",context:i,variables:e,isPaused:r})}let n=await this.#r.start();return await this.#t.config.onSuccess?.(n,e,this.state.context,this),await this.options.onSuccess?.(n,e,this.state.context),await this.#t.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,e,this.state.context),this.#n({type:"success",data:n}),n}catch(n){try{throw await this.#t.config.onError?.(n,e,this.state.context,this),await this.options.onError?.(n,e,this.state.context),await this.#t.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,n,e,this.state.context),n}finally{this.#n({type:"error",error:n})}}finally{this.#t.runNext(this)}}#n(e){let t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),m.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function Wt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var L=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,r){let n=new Ve({mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#e.add(e);let t=W(e);if(typeof t=="string"){let r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=W(e);if(typeof t=="string"){let r=this.#t.get(t);if(r)if(r.length>1){let n=r.indexOf(e);n!==-1&&r.splice(n,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=W(e);if(typeof t=="string"){let n=this.#t.get(t)?.find(i=>i.state.status==="pending");return!n||n===e}else return!0}runNext(e){let t=W(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){m.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(r=>ue(t,r))}findAll(e={}){return this.getAll().filter(t=>ue(e,t))}notify(e){m.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return m.batch(()=>Promise.all(e.map(t=>t.continue().catch(I))))}};function W(e){return e.options.scope?.id}function le(e){return{onFetch:(t,r)=>{let n=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,s=t.state.data?.pages||[],u=t.state.data?.pageParams||[],o={pages:[],pageParams:[]},a=0,y=async()=>{let l=!1,h=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(t.signal.aborted?l=!0:t.signal.addEventListener("abort",()=>{l=!0}),t.signal)})},_=G(t.options,t.fetchOptions),v=async(f,c,d)=>{if(l)return Promise.reject();if(c==null&&f.pages.length)return Promise.resolve(f);let p={queryKey:t.queryKey,pageParam:c,direction:d?"backward":"forward",meta:t.options.meta};h(p);let T=await _(p),{maxPages:O}=t.options,w=d?Ke:je;return{pages:w(f.pages,T,O),pageParams:w(f.pageParams,c,O)}};if(i&&s.length){let f=i==="backward",c=f?Xt:Ce,d={pages:s,pageParams:u},p=c(n,d);o=await v(d,p,f)}else{let f=e??s.length;do{let c=a===0?u[0]??n.initialPageParam:Ce(n,o);if(a>0&&c==null)break;o=await v(o,c),a++}while(a<f)}return o};t.options.persister?t.fetchFn=()=>t.options.persister?.(y,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=y}}}function Ce(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function Xt(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var fe=class{#e;#t;#r;#n;#s;#o;#i;#a;constructor(e={}){this.#e=e.queryCache||new F,this.#t=e.mutationCache||new L,this.#r=e.defaultOptions||{},this.#n=new Map,this.#s=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=B.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=D.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#i?.(),this.#i=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(se(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{let n=r.data;return[t,n]})}setQueryData(e,t,r){let n=this.defaultQueryOptions({queryKey:e}),s=this.#e.get(n.queryHash)?.state.data,u=Me(t,s);if(u!==void 0)return this.#e.build(this,n).setData(u,{...r,manual:!0})}setQueriesData(e,t,r){return m.batch(()=>this.#e.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;m.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){let r=this.#e,n={type:"active",...e};return m.batch(()=>(r.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries(n,t)))}cancelQueries(e,t={}){let r={revert:!0,...t},n=m.batch(()=>this.#e.findAll(e).map(i=>i.cancel(r)));return Promise.all(n).then(I).catch(I)}invalidateQueries(e,t={}){return m.batch(()=>{if(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none")return Promise.resolve();let r={...e,type:e?.refetchType??e?.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??!0},n=m.batch(()=>this.#e.findAll(e).filter(i=>!i.isDisabled()).map(i=>{let s=i.fetch(void 0,r);return r.throwOnError||(s=s.catch(I)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(n).then(I)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(se(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(I).catch(I)}fetchInfiniteQuery(e){return e.behavior=le(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(I).catch(I)}ensureInfiniteQueryData(e){return e.behavior=le(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return D.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#n.set(P(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#n.values()],r={};return t.forEach(n=>{N(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){this.#s.set(P(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#s.values()],r={};return t.forEach(n=>{N(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=M(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===x&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var $t=new fe({defaultOptions:{queries:{staleTime:3e4}},queryCache:new F({onError:(e,t)=>{}}),mutationCache:new L}),Ye=$t;var zt=(e,t={})=>({"Content-Type":"application/json",...e?.accessToken&&{Authorization:`Bearer ${e?.accessToken}`},...t}),Jt=async(e,t)=>{if(!e.ok){let r=await e.text();throw new Error(r)}return t==="file"?e.blob():t==="json"?e.json():t==="text"?e.text():null},We=async({url:e,auth:t,body:r,method:n="GET",headers:i={},responseType:s="json"})=>{let u={method:n,headers:zt(t,i),...r?{body:r instanceof FormData?r:JSON.stringify(r)}:{}},o=await fetch(e,u);return Jt(o,s)},Xe=e=>We({...e,method:"GET"}),he=e=>We({...e,method:"POST"});var de,pe="https://api.dtect.io/security",q="",k="",$e="",Zt="20000000-aaaa-bbbb-cccc-000000000002",X,U={isLoading:!1},ze=Ne;function $(){let e=window?.location?.href?.includes("localhost")||window?.location?.href?.includes("file:///"),t=document.querySelector("#dtect-h-captcha");return!!(de&&(t||e))}function ye(){return!!(q&&k)}async function Ht({behaviorKey:e}){let t=await K.load({apiKey:e,endpoint:["https://fp.dtect.io",K.defaultEndpoint],scriptUrlPattern:["https://fp.dtect.io/web/v<version>/<apiKey>/loader_v<loaderVersion>.js",K.defaultScriptUrlPattern]});if(t)de=t;else throw new Error(E.SDK_INIT_ERROR)}async function Je(e){if(!e?.clientId||!e?.apiKey)throw new Error(E.MISSING_CREDENTIALS);let{clientId:t,apiKey:r,endpoint:n="https://api.dtect.io/security"}=e;if(pe=n,U.isLoading){if($())return X;throw new Error(E.DUPLICATE_INITIALIZATION)}if(q=t,k=r,U={...U,isLoading:!0},!ye())throw new Error(E.MISSING_CREDENTIALS);if($())return X;let i=document.querySelector("head"),s=document.querySelector("body");if(!(window?.location?.href?.includes("localhost")||window?.location?.href?.includes("file:///"))){s?.insertAdjacentHTML("beforeend",'<div id="dtect-h-captcha" ></div>');let o=document.createElement("script");o.setAttribute("src","https://js.hcaptcha.com/1/api.js"),o.setAttribute("async","true"),o.setAttribute("defer","true"),i?.append(o)}try{let o=await Ye.fetchQuery({queryKey:["getKeys",t,r],queryFn:()=>Xe({url:`${n}/client/config`,headers:{"client-id":q,"x-api-key":k}})});if(o?.automationKey&&o?.behaviorKey)return $e=o.automationKey,Ht({...o}).then(()=>({getSecurityResult:Ee,getSecurityToken:me,SecurityAPIError:ze})).catch(a=>{throw new Error(a.message)});throw new Error}catch(o){if(o instanceof Error){if(o?.message?.includes("maintenance_mode"))throw new Error(E.MAINTENANCE_MODE);if([E.INVALID_API_KEY,E.UNAUTHORIZED].includes(o?.message))throw new Error(E.INVALID_CREDENTIALS)}throw new Error(E.SDK_INIT_ERROR)}finally{U={...U,isLoading:!1}}}async function Ze(){let e=await de?.get();if(window?.location?.href?.includes("localhost")||window?.location?.href?.includes("file:///")){if(e?.sealedResult&&e?.requestId)return{behaviorRequestId:e.requestId,behaviorToken:e.sealedResult,automationToken:Zt}}else{await window?.hcaptcha?.render("dtect-h-captcha",{sitekey:$e,size:"invisible"});let r=await window?.hcaptcha?.execute({async:!0});if(r?.response&&e?.sealedResult&&e?.requestId)return{behaviorRequestId:e.requestId,behaviorToken:e.sealedResult,automationToken:r.response}}throw new Error(E.INTERNAL_SERVER_ERROR)}async function Ee(e){if(!$())throw new Error(E.NOT_INITIALIZED);if(!ye())throw new Error(E.MISSING_CREDENTIALS);if(!e||!e?.projectId?.trim())throw new Error(E.FAILED_TO_GET_SECURITY_RESULT);try{let t=await Ze();if(t?.behaviorToken&&t?.behaviorRequestId&&t?.behaviorToken){let r={...e,projectId:e?.projectId?.trim(),visitorId:e?.visitorId?.trim()||Q(),visitorData:{behaviorToken:t.behaviorToken,automationToken:t.automationToken,behaviorRequestId:t.behaviorRequestId,entryLink:window?.location?.href}},n=await he({url:`${pe}/client/check/results`,body:{...r},headers:{"client-id":q,"x-api-key":k}});if(n?.results?.dtectScore)return n}throw new Error}catch(t){throw t instanceof Error&&t?.message?.includes("maintenance_mode")?new Error(E.MAINTENANCE_MODE):new Error(E.FAILED_TO_GET_SECURITY_RESULT)}}async function me(e){if(!$())throw new Error(E.NOT_INITIALIZED);if(!ye())throw new Error(E.MISSING_CREDENTIALS);if(!e||!e?.projectId?.trim())throw new Error(E.FAILED_TO_GET_SECURITY_TOKEN);try{let t=await Ze();if(t?.behaviorToken&&t?.behaviorRequestId&&t?.behaviorToken){let r={...e,projectId:e.projectId?.trim(),visitorId:e.visitorId?.trim()||Q(),visitorData:{behaviorToken:t.behaviorToken,automationToken:t.automationToken,behaviorRequestId:t.behaviorRequestId,entryLink:window?.location?.href}},n=await he({url:`${pe}/client/check/token`,body:{...r},headers:{"client-id":q,"x-api-key":k}});if(n?.token)return n}throw new Error}catch(t){throw t instanceof Error&&t?.message?.includes("maintenance_mode")?new Error(E.MAINTENANCE_MODE):new Error(E.FAILED_TO_GET_SECURITY_TOKEN)}}X={init:Je,getSecurityResult:Ee,getSecurityToken:me};var er=X;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var S=function(){return S=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},S.apply(this,arguments)};function ye(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function Ee(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,s;n<i;n++)(s||!(n in t))&&(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return e.concat(s||Array.prototype.slice.call(t))}function Ze(e,t){return function(r,n){return Object.prototype.hasOwnProperty.call(r,n)}(e,t)?e[t]:void 0}function He(e,t,r,n){var i,s=document,u="securitypolicyviolation",o=function(y){var l=new URL(e,location.href),h=y.blockedURI;h!==l.href&&h!==l.protocol.slice(0,-1)&&h!==l.origin||(i=y,a())};s.addEventListener(u,o);var a=function(){return s.removeEventListener(u,o)};return n?.then(a,a),Promise.resolve().then(t).then(function(y){return a(),y},function(y){return new Promise(function(l){var h=new MessageChannel;h.port1.onmessage=function(){return l()},h.port2.postMessage(null)}).then(function(){if(a(),i)return r(i);throw y})})}var et={default:"endpoint"},tt={default:"tlsEndpoint"},rt="Client timeout",nt="Network connection error",it="Network request aborted",ot="Response cannot be parsed",J="Blocked by CSP",Z="The endpoint parameter is not a valid URL";function A(e){for(var t="",r=0;r<e.length;++r)if(r>0){var n=e[r].toLowerCase();n!==e[r]?t+=" ".concat(n):t+=e[r]}else t+=e[r].toUpperCase();return t}var st=A("WrongRegion"),at=A("SubscriptionNotActive"),ut=A("UnsupportedVersion"),ct=A("InstallationMethodRestricted"),lt=A("HostnameRestricted"),ft=A("IntegrationFailed"),H="API key required",me="API key not found",Re="API key expired",ht="Request cannot be parsed",dt="Request failed",pt="Request failed to process",yt="Too many requests, rate limit exceeded",Et="Not available for this origin",mt="Not available with restricted header",Rt=H,Tt=me,Ot=Re,It="3.11.6",K="Failed to load the JS script of the agent",ee="9319";function _t(e,t){var r,n,i,s,u,o,a,y=[],l=(r=function(f){var c=Ee([],f,!0);return{current:function(){return c[0]},postpone:function(){var d=c.shift();d!==void 0&&c.push(d)},exclude:function(){c.shift()}}}(e),s=100,u=3e3,o=0,n=function(){return Math.random()*Math.min(u,s*Math.pow(2,o++))},i=new Set,[r.current(),function(f,c){var d,p=c instanceof Error?c.message:"";if(p===J||p===Z)r.exclude(),d=0;else if(p===ee)r.exclude();else if(p===K){var T=Date.now()-f.getTime()<50,O=r.current();O&&T&&!i.has(O)&&(i.add(O),d=0),r.postpone()}else r.postpone();var b=r.current();return b===void 0?void 0:[b,d??f.getTime()+n()-Date.now()]}]),h=l[0],_=l[1];if(h===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var v=function(f){var c=new Date,d=function(T){return y.push({url:f,startedAt:c,finishedAt:new Date,error:T})},p=t(f);return p.then(function(){return d()},d),p.catch(function(T){if(a!=null||(a=T),y.length>=5)throw a;var O=_(c,T);if(!O)throw a;var b,z=O[0],ze=O[1];return(b=ze,new Promise(function(Je){return setTimeout(Je,b)})).then(function(){return v(z)})})};return v(h).then(function(f){return[f,y]})}var Te="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",vt=Te;function bt(e){var t;e.scriptUrlPattern;var r=e.token,n=e.apiKey,i=n===void 0?r:n,s=ye(e,["scriptUrlPattern","token","apiKey"]),u=(t=Ze(e,"scriptUrlPattern"))!==null&&t!==void 0?t:Te,o=function(){var l=[],h=function(){l.push({time:new Date,state:document.visibilityState})},_=function(v,f,c,d){return v.addEventListener(f,c,d),function(){return v.removeEventListener(f,c,d)}}(document,"visibilitychange",h);return h(),[l,_]}(),a=o[0],y=o[1];return Promise.resolve().then(function(){if(!i||typeof i!="string")throw new Error(H);var l=function(h,_){return(Array.isArray(h)?h:[h]).map(function(v){return function(f,c){var d=encodeURIComponent;return f.replace(/<[^<>]+>/g,function(p){return p==="<version>"?"3":p==="<apiKey>"?d(c):p==="<loaderVersion>"?d(It):p})}(String(v),_)})}(u,i);return _t(l,gt)}).catch(function(l){throw y(),function(h){return h instanceof Error&&h.message===ee?new Error(K):h}(l)}).then(function(l){var h=l[0],_=l[1];return y(),h.load(S(S({},s),{ldi:{attempts:_,visibilityStates:a}}))})}function gt(e){return He(e,function(){return function(t){return new Promise(function(r,n){if(function(o){if(URL.prototype)try{return new URL(o,location.href),!1}catch(a){if(a instanceof Error&&a.name==="TypeError")return!0;throw a}}(t))throw new Error(Z);var i=document.createElement("script"),s=function(){var o;return(o=i.parentNode)===null||o===void 0?void 0:o.removeChild(i)},u=document.head||document.getElementsByTagName("head")[0];i.onload=function(){s(),r()},i.onerror=function(){s(),n(new Error(K))},i.async=!0,i.src=t,u.appendChild(i)})}(e)},function(){throw new Error(J)}).then(wt)}function wt(){var e=window,t="__fpjs_p_l_b",r=e[t];if(function(n,i){var s,u=(s=Object.getOwnPropertyDescriptor)===null||s===void 0?void 0:s.call(Object,n,i);u?.configurable?delete n[i]:u&&!u.writable||(n[i]=void 0)}(e,t),typeof r?.load!="function")throw new Error(ee);return r}var k={load:bt,defaultScriptUrlPattern:vt,ERROR_SCRIPT_LOAD_FAIL:K,ERROR_API_KEY_EXPIRED:Re,ERROR_API_KEY_INVALID:me,ERROR_API_KEY_MISSING:H,ERROR_BAD_REQUEST_FORMAT:ht,ERROR_BAD_RESPONSE_FORMAT:ot,ERROR_CLIENT_TIMEOUT:rt,ERROR_CSP_BLOCK:J,ERROR_FORBIDDEN_ENDPOINT:lt,ERROR_FORBIDDEN_HEADER:mt,ERROR_FORBIDDEN_ORIGIN:Et,ERROR_GENERAL_SERVER_FAILURE:dt,ERROR_INSTALLATION_METHOD_RESTRICTED:ct,ERROR_INTEGRATION_FAILURE:ft,ERROR_INVALID_ENDPOINT:Z,ERROR_NETWORK_ABORT:it,ERROR_NETWORK_CONNECTION:nt,ERROR_RATE_LIMIT:yt,ERROR_SERVER_TIMEOUT:pt,ERROR_SUBSCRIPTION_NOT_ACTIVE:at,ERROR_TOKEN_EXPIRED:Ot,ERROR_TOKEN_INVALID:Tt,ERROR_TOKEN_MISSING:Rt,ERROR_UNSUPPORTED_VERSION:ut,ERROR_WRONG_REGION:st,defaultEndpoint:et,defaultTlsEndpoint:tt};var R=[];for(let e=0;e<256;++e)R.push((e+256).toString(16).slice(1));function Oe(e,t=0){return(R[e[t+0]]+R[e[t+1]]+R[e[t+2]]+R[e[t+3]]+"-"+R[e[t+4]]+R[e[t+5]]+"-"+R[e[t+6]]+R[e[t+7]]+"-"+R[e[t+8]]+R[e[t+9]]+"-"+R[e[t+10]]+R[e[t+11]]+R[e[t+12]]+R[e[t+13]]+R[e[t+14]]+R[e[t+15]]).toLowerCase()}var te,At=new Uint8Array(16);function re(){if(!te){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");te=crypto.getRandomValues.bind(crypto)}return te(At)}var Pt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ne={randomUUID:Pt};function Nt(e,t,r){if(ne.randomUUID&&!t&&!e)return ne.randomUUID();e=e||{};let n=e.random??e.rng?.()??re();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Oe(n)}var Q=Nt;var Dt={UNAUTHORIZED:"Unauthorized"},St={EXPIRED:"EXPIRED_TOKEN",INVALID_API_KEY:"INVALID_API_KEY",MISSING_AUTHENTICATION_TOKEN:"MISSING_AUTHENTICATION_TOKEN"},Ie={INTERNAL_SERVER_ERROR:"Internal Server Error during API Request",MISSING_CREDENTIALS:"Missing Public Client ID or Public API Key",MAINTENANCE_MODE:"API Under Maintenance"},_e={SDK_INIT_ERROR:"Internal Server Error during SDK Initialization",DUPLICATE_INITIALIZATION:"Multiple SDK Initializations Detected",NOT_INITIALIZED:"SDK Not Initialized"},ve={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},be={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},ge={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},E={...Dt,...St,...Ie,..._e,...ve,...be,...ge},we={...Ie,..._e,...ve,...be,...ge};var g=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var w=typeof window>"u"||"Deno"in globalThis;function I(){}function Ne(e,t){return typeof e=="function"?e(t):e}function De(e){return typeof e=="number"&&e>=0&&e!==1/0}function Se(e,t){return Math.max(e+(t||0)-Date.now(),0)}function oe(e,t){return typeof e=="function"?e(t):e}function Me(e,t){return typeof e=="function"?e(t):e}function se(e,t){let{type:r="all",exact:n,fetchStatus:i,predicate:s,queryKey:u,stale:o}=e;if(u){if(n){if(t.queryHash!==M(u,t.options))return!1}else if(!N(t.queryKey,u))return!1}if(r!=="all"){let a=t.isActive();if(r==="active"&&!a||r==="inactive"&&a)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||i&&i!==t.state.fetchStatus||s&&!s(t))}function ae(e,t){let{exact:r,status:n,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(r){if(P(t.options.mutationKey)!==P(s))return!1}else if(!N(t.options.mutationKey,s))return!1}return!(n&&t.state.status!==n||i&&!i(t))}function M(e,t){return(t?.queryKeyHashFn||P)(e)}function P(e){return JSON.stringify(e,(t,r)=>ie(r)?Object.keys(r).sort().reduce((n,i)=>(n[i]=r[i],n),{}):r)}function N(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!N(e[r],t[r])):!1}function xe(e,t){if(e===t)return e;let r=Ae(e)&&Ae(t);if(r||ie(e)&&ie(t)){let n=r?e:Object.keys(e),i=n.length,s=r?t:Object.keys(t),u=s.length,o=r?[]:{},a=0;for(let y=0;y<u;y++){let l=r?y:s[y];(!r&&n.includes(l)||r)&&e[l]===void 0&&t[l]===void 0?(o[l]=void 0,a++):(o[l]=xe(e[l],t[l]),o[l]===e[l]&&e[l]!==void 0&&a++)}return i===u&&a===i?e:o}return t}function Ae(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ie(e){if(!Pe(e))return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(!Pe(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Pe(e){return Object.prototype.toString.call(e)==="[object Object]"}function Fe(e){return new Promise(t=>{setTimeout(t,e)})}function Le(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?xe(e,t):t}function Ue(e,t,r=0){let n=[...e,t];return r&&n.length>r?n.slice(1):n}function qe(e,t,r=0){let n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var x=Symbol();function G(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===x?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Mt=class extends g{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!w&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},B=new Mt;var xt=class extends g{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!w&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},D=new xt;function je(){let e,t,r=new Promise((i,s)=>{e=i,t=s});r.status="pending",r.catch(()=>{});function n(i){Object.assign(r,i),delete r.resolve,delete r.reject}return r.resolve=i=>{n({status:"fulfilled",value:i}),e(i)},r.reject=i=>{n({status:"rejected",reason:i}),t(i)},r}function Ft(e){return Math.min(1e3*2**e,3e4)}function ue(e){return(e??"online")==="online"?D.isOnline():!0}var Ke=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function V(e){return e instanceof Ke}function C(e){let t=!1,r=0,n=!1,i,s=je(),u=c=>{n||(_(new Ke(c)),e.abort?.())},o=()=>{t=!0},a=()=>{t=!1},y=()=>B.isFocused()&&(e.networkMode==="always"||D.isOnline())&&e.canRun(),l=()=>ue(e.networkMode)&&e.canRun(),h=c=>{n||(n=!0,e.onSuccess?.(c),i?.(),s.resolve(c))},_=c=>{n||(n=!0,e.onError?.(c),i?.(),s.reject(c))},v=()=>new Promise(c=>{i=d=>{(n||y())&&c(d)},e.onPause?.()}).then(()=>{i=void 0,n||e.onContinue?.()}),f=()=>{if(n)return;let c,d=r===0?e.initialPromise:void 0;try{c=d??e.fn()}catch(p){c=Promise.reject(p)}Promise.resolve(c).then(h).catch(p=>{if(n)return;let T=e.retry??(w?0:3),O=e.retryDelay??Ft,b=typeof O=="function"?O(r,p):O,z=T===!0||typeof T=="number"&&r<T||typeof T=="function"&&T(r,p);if(t||!z){_(p);return}r++,e.onFail?.(r,p),Fe(b).then(()=>y()?void 0:v()).then(()=>{t?_(p):f()})})};return{promise:s,cancel:u,continue:()=>(i?.(),s),cancelRetry:o,continueRetry:a,canStart:l,start:()=>(l()?f():v().then(f),s)}}function Lt(){let e=[],t=0,r=o=>{o()},n=o=>{o()},i=o=>setTimeout(o,0),s=o=>{t?e.push(o):i(()=>{r(o)})},u=()=>{let o=e;e=[],o.length&&i(()=>{n(()=>{o.forEach(a=>{r(a)})})})};return{batch:o=>{let a;t++;try{a=o()}finally{t--,t||u()}return a},batchCalls:o=>(...a)=>{s(()=>{o(...a)})},schedule:s,setNotifyFunction:o=>{r=o},setBatchNotifyFunction:o=>{n=o},setScheduler:o=>{i=o}}}var m=Lt();var Y=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),De(this.gcTime)&&(this.#e=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(w?1/0:5*60*1e3))}clearGcTimeout(){this.#e&&(clearTimeout(this.#e),this.#e=void 0)}};var ke=class extends Y{#e;#t;#r;#n;#s;#o;constructor(e){super(),this.#o=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=qt(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){this.options={...this.#s,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){let r=Le(this.state.data,e,this.options);return this.#i({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(I).catch(I):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Me(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===x||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Se(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#o?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){let o=this.observers.find(a=>a.options.queryFn);o&&this.setOptions(o.options)}let r=new AbortController,n=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,r.signal)})},i=()=>{let o=G(this.options,t),a={queryKey:this.queryKey,meta:this.meta};return n(a),this.#o=!1,this.options.persister?this.options.persister(o,a,this):o(a)},s={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};n(s),this.options.behavior?.onFetch(s,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#i({type:"fetch",meta:s.fetchOptions?.meta});let u=o=>{V(o)&&o.silent||this.#i({type:"error",error:o}),V(o)||(this.#r.config.onError?.(o,this),this.#r.config.onSettled?.(this.state.data,o,this)),this.scheduleGc()};return this.#n=C({initialPromise:t?.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:o=>{if(o===void 0){u(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(o)}catch(a){u(a);return}this.#r.config.onSuccess?.(o,this),this.#r.config.onSettled?.(o,this.state.error,this),this.scheduleGc()},onError:u,onFail:(o,a)=>{this.#i({type:"failed",failureCount:o,error:a})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0}),this.#n.start()}#i(e){let t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Ut(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":let n=e.error;return V(n)&&n.revert&&this.#t?{...this.#t,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),m.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function Ut(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ue(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function qt(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var F=class extends g{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){let n=t.queryKey,i=t.queryHash??M(n,t),s=this.get(i);return s||(s=new ke({cache:this,queryKey:n,queryHash:i,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(s)),s}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){m.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(r=>se(t,r))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(r=>se(e,r)):t}notify(e){m.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){m.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){m.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var Qe=class extends Y{#e;#t;#r;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||jt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#t.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){this.#r=C({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(n,i)=>{this.#n({type:"failed",failureCount:n,error:i})},onPause:()=>{this.#n({type:"pause"})},onContinue:()=>{this.#n({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let t=this.state.status==="pending",r=!this.#r.canStart();try{if(!t){this.#n({type:"pending",variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let i=await this.options.onMutate?.(e);i!==this.state.context&&this.#n({type:"pending",context:i,variables:e,isPaused:r})}let n=await this.#r.start();return await this.#t.config.onSuccess?.(n,e,this.state.context,this),await this.options.onSuccess?.(n,e,this.state.context),await this.#t.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,e,this.state.context),this.#n({type:"success",data:n}),n}catch(n){try{throw await this.#t.config.onError?.(n,e,this.state.context,this),await this.options.onError?.(n,e,this.state.context),await this.#t.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,n,e,this.state.context),n}finally{this.#n({type:"error",error:n})}}finally{this.#t.runNext(this)}}#n(e){let t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),m.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function jt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var L=class extends g{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,r){let n=new Qe({mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#e.add(e);let t=W(e);if(typeof t=="string"){let r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=W(e);if(typeof t=="string"){let r=this.#t.get(t);if(r)if(r.length>1){let n=r.indexOf(e);n!==-1&&r.splice(n,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=W(e);if(typeof t=="string"){let n=this.#t.get(t)?.find(i=>i.state.status==="pending");return!n||n===e}else return!0}runNext(e){let t=W(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){m.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(r=>ae(t,r))}findAll(e={}){return this.getAll().filter(t=>ae(e,t))}notify(e){m.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return m.batch(()=>Promise.all(e.map(t=>t.continue().catch(I))))}};function W(e){return e.options.scope?.id}function ce(e){return{onFetch:(t,r)=>{let n=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,s=t.state.data?.pages||[],u=t.state.data?.pageParams||[],o={pages:[],pageParams:[]},a=0,y=async()=>{let l=!1,h=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(t.signal.aborted?l=!0:t.signal.addEventListener("abort",()=>{l=!0}),t.signal)})},_=G(t.options,t.fetchOptions),v=async(f,c,d)=>{if(l)return Promise.reject();if(c==null&&f.pages.length)return Promise.resolve(f);let p={queryKey:t.queryKey,pageParam:c,direction:d?"backward":"forward",meta:t.options.meta};h(p);let T=await _(p),{maxPages:O}=t.options,b=d?qe:Ue;return{pages:b(f.pages,T,O),pageParams:b(f.pageParams,c,O)}};if(i&&s.length){let f=i==="backward",c=f?Kt:Ge,d={pages:s,pageParams:u},p=c(n,d);o=await v(d,p,f)}else{let f=e??s.length;do{let c=a===0?u[0]??n.initialPageParam:Ge(n,o);if(a>0&&c==null)break;o=await v(o,c),a++}while(a<f)}return o};t.options.persister?t.fetchFn=()=>t.options.persister?.(y,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=y}}}function Ge(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function Kt(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var le=class{#e;#t;#r;#n;#s;#o;#i;#a;constructor(e={}){this.#e=e.queryCache||new F,this.#t=e.mutationCache||new L,this.#r=e.defaultOptions||{},this.#n=new Map,this.#s=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=B.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=D.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#i?.(),this.#i=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(oe(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{let n=r.data;return[t,n]})}setQueryData(e,t,r){let n=this.defaultQueryOptions({queryKey:e}),s=this.#e.get(n.queryHash)?.state.data,u=Ne(t,s);if(u!==void 0)return this.#e.build(this,n).setData(u,{...r,manual:!0})}setQueriesData(e,t,r){return m.batch(()=>this.#e.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;m.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){let r=this.#e,n={type:"active",...e};return m.batch(()=>(r.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries(n,t)))}cancelQueries(e,t={}){let r={revert:!0,...t},n=m.batch(()=>this.#e.findAll(e).map(i=>i.cancel(r)));return Promise.all(n).then(I).catch(I)}invalidateQueries(e,t={}){return m.batch(()=>{if(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none")return Promise.resolve();let r={...e,type:e?.refetchType??e?.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??!0},n=m.batch(()=>this.#e.findAll(e).filter(i=>!i.isDisabled()).map(i=>{let s=i.fetch(void 0,r);return r.throwOnError||(s=s.catch(I)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(n).then(I)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(oe(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(I).catch(I)}fetchInfiniteQuery(e){return e.behavior=ce(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(I).catch(I)}ensureInfiniteQueryData(e){return e.behavior=ce(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return D.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#n.set(P(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#n.values()],r={};return t.forEach(n=>{N(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){this.#s.set(P(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#s.values()],r={};return t.forEach(n=>{N(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=M(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===x&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var kt=new le({defaultOptions:{queries:{staleTime:3e4}},queryCache:new F({onError:(e,t)=>{}}),mutationCache:new L}),Be=kt;var Qt=(e,t={})=>({"Content-Type":"application/json",...e?.accessToken&&{Authorization:`Bearer ${e?.accessToken}`},...t}),Gt=async(e,t)=>{if(!e.ok){let r=await e.text();throw new Error(r)}return t==="file"?e.blob():t==="json"?e.json():t==="text"?e.text():null},Ve=async({url:e,auth:t,body:r,method:n="GET",headers:i={},responseType:s="json"})=>{let u={method:n,headers:Qt(t,i),...r?{body:r instanceof FormData?r:JSON.stringify(r)}:{}},o=await fetch(e,u);return Gt(o,s)},Ce=e=>Ve({...e,method:"GET"}),fe=e=>Ve({...e,method:"POST"});var he,de="https://api.dtect.io/security",q="",j="",Ye="",Bt="20000000-aaaa-bbbb-cccc-000000000002",X,U={isLoading:!1},Vt=we;function $(){return!!(document.querySelector("#dtect-h-captcha")&&he)}function pe(){return!!(q&&j)}async function Ct({behaviorKey:e}){let t=await k.load({apiKey:e,endpoint:["https://fp.dtect.io",k.defaultEndpoint],scriptUrlPattern:["https://fp.dtect.io/web/v<version>/<apiKey>/loader_v<loaderVersion>.js",k.defaultScriptUrlPattern]});if(t)he=t;else throw new Error(E.SDK_INIT_ERROR)}async function Yt(e){if(!e?.clientId||!e?.apiKey)throw new Error(E.MISSING_CREDENTIALS);let{clientId:t,apiKey:r,endpoint:n="https://api.dtect.io/security"}=e;if(de=n,U.isLoading){if($())return X;throw new Error(E.DUPLICATE_INITIALIZATION)}if(q=t,j=r,U={...U,isLoading:!0},!pe())throw new Error(E.MISSING_CREDENTIALS);if($())return X;let i=document.querySelector("head");document.querySelector("body")?.insertAdjacentHTML("beforeend",'<div id="dtect-h-captcha" ></div>');let u=document.createElement("script");u.setAttribute("src","https://js.hcaptcha.com/1/api.js"),u.setAttribute("async","true"),u.setAttribute("defer","true"),i?.append(u);try{let o=await Be.fetchQuery({queryKey:["getKeys",t,r],queryFn:()=>Ce({url:`${n}/client/config`,headers:{"client-id":q,"x-api-key":j}})});if(o?.automationKey&&o?.behaviorKey)return Ye=o.automationKey,Ct({...o}).then(()=>({getSecurityResult:Xe,getSecurityToken:$e,SecurityAPIError:Vt})).catch(a=>{throw new Error(a.message)});throw new Error}catch(o){if(o instanceof Error){if(o?.message?.includes("maintenance_mode"))throw new Error(E.MAINTENANCE_MODE);if([E.INVALID_API_KEY,E.UNAUTHORIZED].includes(o?.message))throw new Error(E.INVALID_CREDENTIALS)}throw new Error(E.SDK_INIT_ERROR)}finally{U={...U,isLoading:!1}}}async function We(){let e=await he?.get();if(window?.location?.href?.includes("localhost")){if(e?.sealedResult&&e?.requestId)return{behaviorRequestId:e.requestId,behaviorToken:e.sealedResult,automationToken:Bt}}else{await window?.hcaptcha?.render("dtect-h-captcha",{sitekey:Ye,size:"invisible"});let t=await window?.hcaptcha?.execute({async:!0});if(t?.response&&e?.sealedResult&&e?.requestId)return{behaviorRequestId:e.requestId,behaviorToken:e.sealedResult,automationToken:t.response}}throw new Error(E.INTERNAL_SERVER_ERROR)}async function Xe(e){if(!$())throw new Error(E.NOT_INITIALIZED);if(!pe())throw new Error(E.MISSING_CREDENTIALS);if(!e||!e?.projectId?.trim())throw new Error(E.FAILED_TO_GET_SECURITY_RESULT);try{let t=await We();if(t?.behaviorToken&&t?.behaviorRequestId&&t?.behaviorToken){let r={...e,projectId:e?.projectId?.trim(),visitorId:e?.visitorId?.trim()||Q(),visitorData:{behaviorToken:t.behaviorToken,automationToken:t.automationToken,behaviorRequestId:t.behaviorRequestId,entryLink:window?.location?.href}},n=await fe({url:`${de}/client/check/results`,body:{...r},headers:{"client-id":q,"x-api-key":j}});if(n?.results?.dtectScore)return n}throw new Error}catch(t){throw t instanceof Error&&t?.message?.includes("maintenance_mode")?new Error(E.MAINTENANCE_MODE):new Error(E.FAILED_TO_GET_SECURITY_RESULT)}}async function $e(e){if(!$())throw new Error(E.NOT_INITIALIZED);if(!pe())throw new Error(E.MISSING_CREDENTIALS);if(!e||!e?.projectId?.trim())throw new Error(E.FAILED_TO_GET_SECURITY_TOKEN);try{let t=await We();if(t?.behaviorToken&&t?.behaviorRequestId&&t?.behaviorToken){let r={...e,projectId:e.projectId?.trim(),visitorId:e.visitorId?.trim()||Q(),visitorData:{behaviorToken:t.behaviorToken,automationToken:t.automationToken,behaviorRequestId:t.behaviorRequestId,entryLink:window?.location?.href}},n=await fe({url:`${de}/client/check/token`,body:{...r},headers:{"client-id":q,"x-api-key":j}});if(n?.token)return n}throw new Error}catch(t){throw t instanceof Error&&t?.message?.includes("maintenance_mode")?new Error(E.MAINTENANCE_MODE):new Error(E.FAILED_TO_GET_SECURITY_TOKEN)}}X={init:Yt,getSecurityResult:Xe,getSecurityToken:$e};var Vn=X;export{Vt as SecurityAPIError,Vn as default,Xe as getSecurityResult,$e as getSecurityToken,Yt as init};
|
|
1
|
+
var S=function(){return S=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},S.apply(this,arguments)};function ye(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function Ee(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,s;n<i;n++)(s||!(n in t))&&(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return e.concat(s||Array.prototype.slice.call(t))}function Ze(e,t){return function(r,n){return Object.prototype.hasOwnProperty.call(r,n)}(e,t)?e[t]:void 0}function He(e,t,r,n){var i,s=document,u="securitypolicyviolation",o=function(y){var l=new URL(e,location.href),h=y.blockedURI;h!==l.href&&h!==l.protocol.slice(0,-1)&&h!==l.origin||(i=y,a())};s.addEventListener(u,o);var a=function(){return s.removeEventListener(u,o)};return n?.then(a,a),Promise.resolve().then(t).then(function(y){return a(),y},function(y){return new Promise(function(l){var h=new MessageChannel;h.port1.onmessage=function(){return l()},h.port2.postMessage(null)}).then(function(){if(a(),i)return r(i);throw y})})}var et={default:"endpoint"},tt={default:"tlsEndpoint"},rt="Client timeout",nt="Network connection error",it="Network request aborted",ot="Response cannot be parsed",J="Blocked by CSP",Z="The endpoint parameter is not a valid URL";function A(e){for(var t="",r=0;r<e.length;++r)if(r>0){var n=e[r].toLowerCase();n!==e[r]?t+=" ".concat(n):t+=e[r]}else t+=e[r].toUpperCase();return t}var st=A("WrongRegion"),at=A("SubscriptionNotActive"),ut=A("UnsupportedVersion"),ct=A("InstallationMethodRestricted"),lt=A("HostnameRestricted"),ft=A("IntegrationFailed"),H="API key required",me="API key not found",Re="API key expired",ht="Request cannot be parsed",dt="Request failed",pt="Request failed to process",yt="Too many requests, rate limit exceeded",Et="Not available for this origin",mt="Not available with restricted header",Rt=H,Tt=me,Ot=Re,It="3.11.6",j="Failed to load the JS script of the agent",ee="9319";function _t(e,t){var r,n,i,s,u,o,a,y=[],l=(r=function(f){var c=Ee([],f,!0);return{current:function(){return c[0]},postpone:function(){var d=c.shift();d!==void 0&&c.push(d)},exclude:function(){c.shift()}}}(e),s=100,u=3e3,o=0,n=function(){return Math.random()*Math.min(u,s*Math.pow(2,o++))},i=new Set,[r.current(),function(f,c){var d,p=c instanceof Error?c.message:"";if(p===J||p===Z)r.exclude(),d=0;else if(p===ee)r.exclude();else if(p===j){var T=Date.now()-f.getTime()<50,O=r.current();O&&T&&!i.has(O)&&(i.add(O),d=0),r.postpone()}else r.postpone();var w=r.current();return w===void 0?void 0:[w,d??f.getTime()+n()-Date.now()]}]),h=l[0],_=l[1];if(h===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var v=function(f){var c=new Date,d=function(T){return y.push({url:f,startedAt:c,finishedAt:new Date,error:T})},p=t(f);return p.then(function(){return d()},d),p.catch(function(T){if(a!=null||(a=T),y.length>=5)throw a;var O=_(c,T);if(!O)throw a;var w,z=O[0],ze=O[1];return(w=ze,new Promise(function(Je){return setTimeout(Je,w)})).then(function(){return v(z)})})};return v(h).then(function(f){return[f,y]})}var Te="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",vt=Te;function wt(e){var t;e.scriptUrlPattern;var r=e.token,n=e.apiKey,i=n===void 0?r:n,s=ye(e,["scriptUrlPattern","token","apiKey"]),u=(t=Ze(e,"scriptUrlPattern"))!==null&&t!==void 0?t:Te,o=function(){var l=[],h=function(){l.push({time:new Date,state:document.visibilityState})},_=function(v,f,c,d){return v.addEventListener(f,c,d),function(){return v.removeEventListener(f,c,d)}}(document,"visibilitychange",h);return h(),[l,_]}(),a=o[0],y=o[1];return Promise.resolve().then(function(){if(!i||typeof i!="string")throw new Error(H);var l=function(h,_){return(Array.isArray(h)?h:[h]).map(function(v){return function(f,c){var d=encodeURIComponent;return f.replace(/<[^<>]+>/g,function(p){return p==="<version>"?"3":p==="<apiKey>"?d(c):p==="<loaderVersion>"?d(It):p})}(String(v),_)})}(u,i);return _t(l,bt)}).catch(function(l){throw y(),function(h){return h instanceof Error&&h.message===ee?new Error(j):h}(l)}).then(function(l){var h=l[0],_=l[1];return y(),h.load(S(S({},s),{ldi:{attempts:_,visibilityStates:a}}))})}function bt(e){return He(e,function(){return function(t){return new Promise(function(r,n){if(function(o){if(URL.prototype)try{return new URL(o,location.href),!1}catch(a){if(a instanceof Error&&a.name==="TypeError")return!0;throw a}}(t))throw new Error(Z);var i=document.createElement("script"),s=function(){var o;return(o=i.parentNode)===null||o===void 0?void 0:o.removeChild(i)},u=document.head||document.getElementsByTagName("head")[0];i.onload=function(){s(),r()},i.onerror=function(){s(),n(new Error(j))},i.async=!0,i.src=t,u.appendChild(i)})}(e)},function(){throw new Error(J)}).then(gt)}function gt(){var e=window,t="__fpjs_p_l_b",r=e[t];if(function(n,i){var s,u=(s=Object.getOwnPropertyDescriptor)===null||s===void 0?void 0:s.call(Object,n,i);u?.configurable?delete n[i]:u&&!u.writable||(n[i]=void 0)}(e,t),typeof r?.load!="function")throw new Error(ee);return r}var K={load:wt,defaultScriptUrlPattern:vt,ERROR_SCRIPT_LOAD_FAIL:j,ERROR_API_KEY_EXPIRED:Re,ERROR_API_KEY_INVALID:me,ERROR_API_KEY_MISSING:H,ERROR_BAD_REQUEST_FORMAT:ht,ERROR_BAD_RESPONSE_FORMAT:ot,ERROR_CLIENT_TIMEOUT:rt,ERROR_CSP_BLOCK:J,ERROR_FORBIDDEN_ENDPOINT:lt,ERROR_FORBIDDEN_HEADER:mt,ERROR_FORBIDDEN_ORIGIN:Et,ERROR_GENERAL_SERVER_FAILURE:dt,ERROR_INSTALLATION_METHOD_RESTRICTED:ct,ERROR_INTEGRATION_FAILURE:ft,ERROR_INVALID_ENDPOINT:Z,ERROR_NETWORK_ABORT:it,ERROR_NETWORK_CONNECTION:nt,ERROR_RATE_LIMIT:yt,ERROR_SERVER_TIMEOUT:pt,ERROR_SUBSCRIPTION_NOT_ACTIVE:at,ERROR_TOKEN_EXPIRED:Ot,ERROR_TOKEN_INVALID:Tt,ERROR_TOKEN_MISSING:Rt,ERROR_UNSUPPORTED_VERSION:ut,ERROR_WRONG_REGION:st,defaultEndpoint:et,defaultTlsEndpoint:tt};var R=[];for(let e=0;e<256;++e)R.push((e+256).toString(16).slice(1));function Oe(e,t=0){return(R[e[t+0]]+R[e[t+1]]+R[e[t+2]]+R[e[t+3]]+"-"+R[e[t+4]]+R[e[t+5]]+"-"+R[e[t+6]]+R[e[t+7]]+"-"+R[e[t+8]]+R[e[t+9]]+"-"+R[e[t+10]]+R[e[t+11]]+R[e[t+12]]+R[e[t+13]]+R[e[t+14]]+R[e[t+15]]).toLowerCase()}var te,At=new Uint8Array(16);function re(){if(!te){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");te=crypto.getRandomValues.bind(crypto)}return te(At)}var Pt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ne={randomUUID:Pt};function Nt(e,t,r){if(ne.randomUUID&&!t&&!e)return ne.randomUUID();e=e||{};let n=e.random??e.rng?.()??re();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Oe(n)}var Q=Nt;var Dt={UNAUTHORIZED:"Unauthorized"},St={EXPIRED:"EXPIRED_TOKEN",INVALID_API_KEY:"INVALID_API_KEY",MISSING_AUTHENTICATION_TOKEN:"MISSING_AUTHENTICATION_TOKEN"},Ie={INTERNAL_SERVER_ERROR:"Internal Server Error during API Request",MISSING_CREDENTIALS:"Missing Public Client ID or Public API Key",MAINTENANCE_MODE:"API Under Maintenance"},_e={SDK_INIT_ERROR:"Internal Server Error during SDK Initialization",DUPLICATE_INITIALIZATION:"Multiple SDK Initializations Detected",NOT_INITIALIZED:"SDK Not Initialized"},ve={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},we={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},be={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},E={...Dt,...St,...Ie,..._e,...ve,...we,...be},ge={...Ie,..._e,...ve,...we,...be};var b=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var g=typeof window>"u"||"Deno"in globalThis;function I(){}function Ne(e,t){return typeof e=="function"?e(t):e}function De(e){return typeof e=="number"&&e>=0&&e!==1/0}function Se(e,t){return Math.max(e+(t||0)-Date.now(),0)}function oe(e,t){return typeof e=="function"?e(t):e}function Me(e,t){return typeof e=="function"?e(t):e}function se(e,t){let{type:r="all",exact:n,fetchStatus:i,predicate:s,queryKey:u,stale:o}=e;if(u){if(n){if(t.queryHash!==M(u,t.options))return!1}else if(!N(t.queryKey,u))return!1}if(r!=="all"){let a=t.isActive();if(r==="active"&&!a||r==="inactive"&&a)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||i&&i!==t.state.fetchStatus||s&&!s(t))}function ae(e,t){let{exact:r,status:n,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(r){if(P(t.options.mutationKey)!==P(s))return!1}else if(!N(t.options.mutationKey,s))return!1}return!(n&&t.state.status!==n||i&&!i(t))}function M(e,t){return(t?.queryKeyHashFn||P)(e)}function P(e){return JSON.stringify(e,(t,r)=>ie(r)?Object.keys(r).sort().reduce((n,i)=>(n[i]=r[i],n),{}):r)}function N(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!N(e[r],t[r])):!1}function xe(e,t){if(e===t)return e;let r=Ae(e)&&Ae(t);if(r||ie(e)&&ie(t)){let n=r?e:Object.keys(e),i=n.length,s=r?t:Object.keys(t),u=s.length,o=r?[]:{},a=0;for(let y=0;y<u;y++){let l=r?y:s[y];(!r&&n.includes(l)||r)&&e[l]===void 0&&t[l]===void 0?(o[l]=void 0,a++):(o[l]=xe(e[l],t[l]),o[l]===e[l]&&e[l]!==void 0&&a++)}return i===u&&a===i?e:o}return t}function Ae(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ie(e){if(!Pe(e))return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(!Pe(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Pe(e){return Object.prototype.toString.call(e)==="[object Object]"}function Fe(e){return new Promise(t=>{setTimeout(t,e)})}function Le(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?xe(e,t):t}function Ue(e,t,r=0){let n=[...e,t];return r&&n.length>r?n.slice(1):n}function qe(e,t,r=0){let n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var x=Symbol();function G(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===x?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Mt=class extends b{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!g&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},B=new Mt;var xt=class extends b{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!g&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},D=new xt;function ke(){let e,t,r=new Promise((i,s)=>{e=i,t=s});r.status="pending",r.catch(()=>{});function n(i){Object.assign(r,i),delete r.resolve,delete r.reject}return r.resolve=i=>{n({status:"fulfilled",value:i}),e(i)},r.reject=i=>{n({status:"rejected",reason:i}),t(i)},r}function Ft(e){return Math.min(1e3*2**e,3e4)}function ue(e){return(e??"online")==="online"?D.isOnline():!0}var je=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function V(e){return e instanceof je}function C(e){let t=!1,r=0,n=!1,i,s=ke(),u=c=>{n||(_(new je(c)),e.abort?.())},o=()=>{t=!0},a=()=>{t=!1},y=()=>B.isFocused()&&(e.networkMode==="always"||D.isOnline())&&e.canRun(),l=()=>ue(e.networkMode)&&e.canRun(),h=c=>{n||(n=!0,e.onSuccess?.(c),i?.(),s.resolve(c))},_=c=>{n||(n=!0,e.onError?.(c),i?.(),s.reject(c))},v=()=>new Promise(c=>{i=d=>{(n||y())&&c(d)},e.onPause?.()}).then(()=>{i=void 0,n||e.onContinue?.()}),f=()=>{if(n)return;let c,d=r===0?e.initialPromise:void 0;try{c=d??e.fn()}catch(p){c=Promise.reject(p)}Promise.resolve(c).then(h).catch(p=>{if(n)return;let T=e.retry??(g?0:3),O=e.retryDelay??Ft,w=typeof O=="function"?O(r,p):O,z=T===!0||typeof T=="number"&&r<T||typeof T=="function"&&T(r,p);if(t||!z){_(p);return}r++,e.onFail?.(r,p),Fe(w).then(()=>y()?void 0:v()).then(()=>{t?_(p):f()})})};return{promise:s,cancel:u,continue:()=>(i?.(),s),cancelRetry:o,continueRetry:a,canStart:l,start:()=>(l()?f():v().then(f),s)}}function Lt(){let e=[],t=0,r=o=>{o()},n=o=>{o()},i=o=>setTimeout(o,0),s=o=>{t?e.push(o):i(()=>{r(o)})},u=()=>{let o=e;e=[],o.length&&i(()=>{n(()=>{o.forEach(a=>{r(a)})})})};return{batch:o=>{let a;t++;try{a=o()}finally{t--,t||u()}return a},batchCalls:o=>(...a)=>{s(()=>{o(...a)})},schedule:s,setNotifyFunction:o=>{r=o},setBatchNotifyFunction:o=>{n=o},setScheduler:o=>{i=o}}}var m=Lt();var Y=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),De(this.gcTime)&&(this.#e=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(g?1/0:5*60*1e3))}clearGcTimeout(){this.#e&&(clearTimeout(this.#e),this.#e=void 0)}};var Ke=class extends Y{#e;#t;#r;#n;#s;#o;constructor(e){super(),this.#o=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=qt(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){this.options={...this.#s,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){let r=Le(this.state.data,e,this.options);return this.#i({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(I).catch(I):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Me(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===x||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Se(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#o?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){let o=this.observers.find(a=>a.options.queryFn);o&&this.setOptions(o.options)}let r=new AbortController,n=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,r.signal)})},i=()=>{let o=G(this.options,t),a={queryKey:this.queryKey,meta:this.meta};return n(a),this.#o=!1,this.options.persister?this.options.persister(o,a,this):o(a)},s={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};n(s),this.options.behavior?.onFetch(s,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#i({type:"fetch",meta:s.fetchOptions?.meta});let u=o=>{V(o)&&o.silent||this.#i({type:"error",error:o}),V(o)||(this.#r.config.onError?.(o,this),this.#r.config.onSettled?.(this.state.data,o,this)),this.scheduleGc()};return this.#n=C({initialPromise:t?.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:o=>{if(o===void 0){u(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(o)}catch(a){u(a);return}this.#r.config.onSuccess?.(o,this),this.#r.config.onSettled?.(o,this.state.error,this),this.scheduleGc()},onError:u,onFail:(o,a)=>{this.#i({type:"failed",failureCount:o,error:a})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0}),this.#n.start()}#i(e){let t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Ut(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":let n=e.error;return V(n)&&n.revert&&this.#t?{...this.#t,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),m.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function Ut(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ue(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function qt(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var F=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){let n=t.queryKey,i=t.queryHash??M(n,t),s=this.get(i);return s||(s=new Ke({cache:this,queryKey:n,queryHash:i,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(s)),s}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){m.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(r=>se(t,r))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(r=>se(e,r)):t}notify(e){m.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){m.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){m.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var Qe=class extends Y{#e;#t;#r;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||kt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#t.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){this.#r=C({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(n,i)=>{this.#n({type:"failed",failureCount:n,error:i})},onPause:()=>{this.#n({type:"pause"})},onContinue:()=>{this.#n({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let t=this.state.status==="pending",r=!this.#r.canStart();try{if(!t){this.#n({type:"pending",variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let i=await this.options.onMutate?.(e);i!==this.state.context&&this.#n({type:"pending",context:i,variables:e,isPaused:r})}let n=await this.#r.start();return await this.#t.config.onSuccess?.(n,e,this.state.context,this),await this.options.onSuccess?.(n,e,this.state.context),await this.#t.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,e,this.state.context),this.#n({type:"success",data:n}),n}catch(n){try{throw await this.#t.config.onError?.(n,e,this.state.context,this),await this.options.onError?.(n,e,this.state.context),await this.#t.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,n,e,this.state.context),n}finally{this.#n({type:"error",error:n})}}finally{this.#t.runNext(this)}}#n(e){let t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),m.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function kt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var L=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,r){let n=new Qe({mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#e.add(e);let t=W(e);if(typeof t=="string"){let r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=W(e);if(typeof t=="string"){let r=this.#t.get(t);if(r)if(r.length>1){let n=r.indexOf(e);n!==-1&&r.splice(n,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=W(e);if(typeof t=="string"){let n=this.#t.get(t)?.find(i=>i.state.status==="pending");return!n||n===e}else return!0}runNext(e){let t=W(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){m.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(r=>ae(t,r))}findAll(e={}){return this.getAll().filter(t=>ae(e,t))}notify(e){m.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return m.batch(()=>Promise.all(e.map(t=>t.continue().catch(I))))}};function W(e){return e.options.scope?.id}function ce(e){return{onFetch:(t,r)=>{let n=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,s=t.state.data?.pages||[],u=t.state.data?.pageParams||[],o={pages:[],pageParams:[]},a=0,y=async()=>{let l=!1,h=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(t.signal.aborted?l=!0:t.signal.addEventListener("abort",()=>{l=!0}),t.signal)})},_=G(t.options,t.fetchOptions),v=async(f,c,d)=>{if(l)return Promise.reject();if(c==null&&f.pages.length)return Promise.resolve(f);let p={queryKey:t.queryKey,pageParam:c,direction:d?"backward":"forward",meta:t.options.meta};h(p);let T=await _(p),{maxPages:O}=t.options,w=d?qe:Ue;return{pages:w(f.pages,T,O),pageParams:w(f.pageParams,c,O)}};if(i&&s.length){let f=i==="backward",c=f?jt:Ge,d={pages:s,pageParams:u},p=c(n,d);o=await v(d,p,f)}else{let f=e??s.length;do{let c=a===0?u[0]??n.initialPageParam:Ge(n,o);if(a>0&&c==null)break;o=await v(o,c),a++}while(a<f)}return o};t.options.persister?t.fetchFn=()=>t.options.persister?.(y,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=y}}}function Ge(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function jt(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var le=class{#e;#t;#r;#n;#s;#o;#i;#a;constructor(e={}){this.#e=e.queryCache||new F,this.#t=e.mutationCache||new L,this.#r=e.defaultOptions||{},this.#n=new Map,this.#s=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=B.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=D.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#i?.(),this.#i=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(oe(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{let n=r.data;return[t,n]})}setQueryData(e,t,r){let n=this.defaultQueryOptions({queryKey:e}),s=this.#e.get(n.queryHash)?.state.data,u=Ne(t,s);if(u!==void 0)return this.#e.build(this,n).setData(u,{...r,manual:!0})}setQueriesData(e,t,r){return m.batch(()=>this.#e.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;m.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){let r=this.#e,n={type:"active",...e};return m.batch(()=>(r.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries(n,t)))}cancelQueries(e,t={}){let r={revert:!0,...t},n=m.batch(()=>this.#e.findAll(e).map(i=>i.cancel(r)));return Promise.all(n).then(I).catch(I)}invalidateQueries(e,t={}){return m.batch(()=>{if(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none")return Promise.resolve();let r={...e,type:e?.refetchType??e?.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??!0},n=m.batch(()=>this.#e.findAll(e).filter(i=>!i.isDisabled()).map(i=>{let s=i.fetch(void 0,r);return r.throwOnError||(s=s.catch(I)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(n).then(I)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(oe(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(I).catch(I)}fetchInfiniteQuery(e){return e.behavior=ce(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(I).catch(I)}ensureInfiniteQueryData(e){return e.behavior=ce(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return D.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#n.set(P(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#n.values()],r={};return t.forEach(n=>{N(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){this.#s.set(P(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#s.values()],r={};return t.forEach(n=>{N(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=M(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===x&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var Kt=new le({defaultOptions:{queries:{staleTime:3e4}},queryCache:new F({onError:(e,t)=>{}}),mutationCache:new L}),Be=Kt;var Qt=(e,t={})=>({"Content-Type":"application/json",...e?.accessToken&&{Authorization:`Bearer ${e?.accessToken}`},...t}),Gt=async(e,t)=>{if(!e.ok){let r=await e.text();throw new Error(r)}return t==="file"?e.blob():t==="json"?e.json():t==="text"?e.text():null},Ve=async({url:e,auth:t,body:r,method:n="GET",headers:i={},responseType:s="json"})=>{let u={method:n,headers:Qt(t,i),...r?{body:r instanceof FormData?r:JSON.stringify(r)}:{}},o=await fetch(e,u);return Gt(o,s)},Ce=e=>Ve({...e,method:"GET"}),fe=e=>Ve({...e,method:"POST"});var he,de="https://api.dtect.io/security",q="",k="",Ye="",Bt="20000000-aaaa-bbbb-cccc-000000000002",X,U={isLoading:!1},Vt=ge;function $(){let e=window?.location?.href?.includes("localhost")||window?.location?.href?.includes("file:///"),t=document.querySelector("#dtect-h-captcha");return!!(he&&(t||e))}function pe(){return!!(q&&k)}async function Ct({behaviorKey:e}){let t=await K.load({apiKey:e,endpoint:["https://fp.dtect.io",K.defaultEndpoint],scriptUrlPattern:["https://fp.dtect.io/web/v<version>/<apiKey>/loader_v<loaderVersion>.js",K.defaultScriptUrlPattern]});if(t)he=t;else throw new Error(E.SDK_INIT_ERROR)}async function Yt(e){if(!e?.clientId||!e?.apiKey)throw new Error(E.MISSING_CREDENTIALS);let{clientId:t,apiKey:r,endpoint:n="https://api.dtect.io/security"}=e;if(de=n,U.isLoading){if($())return X;throw new Error(E.DUPLICATE_INITIALIZATION)}if(q=t,k=r,U={...U,isLoading:!0},!pe())throw new Error(E.MISSING_CREDENTIALS);if($())return X;let i=document.querySelector("head"),s=document.querySelector("body");if(!(window?.location?.href?.includes("localhost")||window?.location?.href?.includes("file:///"))){s?.insertAdjacentHTML("beforeend",'<div id="dtect-h-captcha" ></div>');let o=document.createElement("script");o.setAttribute("src","https://js.hcaptcha.com/1/api.js"),o.setAttribute("async","true"),o.setAttribute("defer","true"),i?.append(o)}try{let o=await Be.fetchQuery({queryKey:["getKeys",t,r],queryFn:()=>Ce({url:`${n}/client/config`,headers:{"client-id":q,"x-api-key":k}})});if(o?.automationKey&&o?.behaviorKey)return Ye=o.automationKey,Ct({...o}).then(()=>({getSecurityResult:Xe,getSecurityToken:$e,SecurityAPIError:Vt})).catch(a=>{throw new Error(a.message)});throw new Error}catch(o){if(o instanceof Error){if(o?.message?.includes("maintenance_mode"))throw new Error(E.MAINTENANCE_MODE);if([E.INVALID_API_KEY,E.UNAUTHORIZED].includes(o?.message))throw new Error(E.INVALID_CREDENTIALS)}throw new Error(E.SDK_INIT_ERROR)}finally{U={...U,isLoading:!1}}}async function We(){let e=await he?.get();if(window?.location?.href?.includes("localhost")||window?.location?.href?.includes("file:///")){if(e?.sealedResult&&e?.requestId)return{behaviorRequestId:e.requestId,behaviorToken:e.sealedResult,automationToken:Bt}}else{await window?.hcaptcha?.render("dtect-h-captcha",{sitekey:Ye,size:"invisible"});let r=await window?.hcaptcha?.execute({async:!0});if(r?.response&&e?.sealedResult&&e?.requestId)return{behaviorRequestId:e.requestId,behaviorToken:e.sealedResult,automationToken:r.response}}throw new Error(E.INTERNAL_SERVER_ERROR)}async function Xe(e){if(!$())throw new Error(E.NOT_INITIALIZED);if(!pe())throw new Error(E.MISSING_CREDENTIALS);if(!e||!e?.projectId?.trim())throw new Error(E.FAILED_TO_GET_SECURITY_RESULT);try{let t=await We();if(t?.behaviorToken&&t?.behaviorRequestId&&t?.behaviorToken){let r={...e,projectId:e?.projectId?.trim(),visitorId:e?.visitorId?.trim()||Q(),visitorData:{behaviorToken:t.behaviorToken,automationToken:t.automationToken,behaviorRequestId:t.behaviorRequestId,entryLink:window?.location?.href}},n=await fe({url:`${de}/client/check/results`,body:{...r},headers:{"client-id":q,"x-api-key":k}});if(n?.results?.dtectScore)return n}throw new Error}catch(t){throw t instanceof Error&&t?.message?.includes("maintenance_mode")?new Error(E.MAINTENANCE_MODE):new Error(E.FAILED_TO_GET_SECURITY_RESULT)}}async function $e(e){if(!$())throw new Error(E.NOT_INITIALIZED);if(!pe())throw new Error(E.MISSING_CREDENTIALS);if(!e||!e?.projectId?.trim())throw new Error(E.FAILED_TO_GET_SECURITY_TOKEN);try{let t=await We();if(t?.behaviorToken&&t?.behaviorRequestId&&t?.behaviorToken){let r={...e,projectId:e.projectId?.trim(),visitorId:e.visitorId?.trim()||Q(),visitorData:{behaviorToken:t.behaviorToken,automationToken:t.automationToken,behaviorRequestId:t.behaviorRequestId,entryLink:window?.location?.href}},n=await fe({url:`${de}/client/check/token`,body:{...r},headers:{"client-id":q,"x-api-key":k}});if(n?.token)return n}throw new Error}catch(t){throw t instanceof Error&&t?.message?.includes("maintenance_mode")?new Error(E.MAINTENANCE_MODE):new Error(E.FAILED_TO_GET_SECURITY_TOKEN)}}X={init:Yt,getSecurityResult:Xe,getSecurityToken:$e};var Vn=X;export{Vt as SecurityAPIError,Vn as default,Xe as getSecurityResult,$e as getSecurityToken,Yt as init};
|