module.exports = [
"[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-YBVFDYDR.mjs [app-rsc] (ecmascript) <locals>", ((__turbopack_context__) => {
"use strict";

// src/util/shared.ts
__turbopack_context__.s([
    "errorThrower",
    ()=>errorThrower
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$deprecated$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/deprecated.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$deprecated$2d$BqlFbLHj$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/deprecated-BqlFbLHj.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$keys$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/keys.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$keys$2d$YNv6yjKk$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/keys-YNv6yjKk.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$retry$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/retry.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$retry$2d$DAlTROH9$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/retry-DAlTROH9.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$url$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/url.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$error$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/error.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$error$2d$CC05ENkI$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/error-CC05ENkI.mjs [app-rsc] (ecmascript)");
;
;
;
;
;
;
var errorThrower = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$error$2d$CC05ENkI$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["buildErrorThrower"])({
    packageName: "@clerk/backend"
});
var { isDevOrStagingUrl } = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$keys$2d$YNv6yjKk$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["createDevOrStagingUrlCache"])();
;
 //# sourceMappingURL=chunk-YBVFDYDR.mjs.map
}),
"[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-TCIXZLLW.mjs [app-rsc] (ecmascript)", ((__turbopack_context__) => {
"use strict";

// src/errors.ts
__turbopack_context__.s([
    "MachineTokenVerificationError",
    ()=>MachineTokenVerificationError,
    "MachineTokenVerificationErrorCode",
    ()=>MachineTokenVerificationErrorCode,
    "SignJWTError",
    ()=>SignJWTError,
    "TokenVerificationError",
    ()=>TokenVerificationError,
    "TokenVerificationErrorAction",
    ()=>TokenVerificationErrorAction,
    "TokenVerificationErrorCode",
    ()=>TokenVerificationErrorCode,
    "TokenVerificationErrorReason",
    ()=>TokenVerificationErrorReason
]);
var TokenVerificationErrorCode = {
    InvalidSecretKey: "clerk_key_invalid"
};
var TokenVerificationErrorReason = {
    TokenExpired: "token-expired",
    TokenInvalid: "token-invalid",
    TokenInvalidAlgorithm: "token-invalid-algorithm",
    TokenInvalidAuthorizedParties: "token-invalid-authorized-parties",
    TokenInvalidSignature: "token-invalid-signature",
    TokenNotActiveYet: "token-not-active-yet",
    TokenIatInTheFuture: "token-iat-in-the-future",
    TokenVerificationFailed: "token-verification-failed",
    InvalidSecretKey: "secret-key-invalid",
    LocalJWKMissing: "jwk-local-missing",
    RemoteJWKFailedToLoad: "jwk-remote-failed-to-load",
    RemoteJWKInvalid: "jwk-remote-invalid",
    RemoteJWKMissing: "jwk-remote-missing",
    JWKFailedToResolve: "jwk-failed-to-resolve",
    JWKKidMismatch: "jwk-kid-mismatch"
};
var TokenVerificationErrorAction = {
    ContactSupport: "Contact support@clerk.com",
    EnsureClerkJWT: "Make sure that this is a valid Clerk-generated JWT.",
    SetClerkJWTKey: "Set the CLERK_JWT_KEY environment variable.",
    SetClerkSecretKey: "Set the CLERK_SECRET_KEY environment variable.",
    EnsureClockSync: "Make sure your system clock is in sync (e.g. turn off and on automatic time synchronization)."
};
var TokenVerificationError = class _TokenVerificationError extends Error {
    constructor({ action, message, reason }){
        super(message);
        Object.setPrototypeOf(this, _TokenVerificationError.prototype);
        this.reason = reason;
        this.message = message;
        this.action = action;
    }
    getFullMessage() {
        return `${[
            this.message,
            this.action
        ].filter((m)=>m).join(" ")} (reason=${this.reason}, token-carrier=${this.tokenCarrier})`;
    }
};
var SignJWTError = class extends Error {
};
var MachineTokenVerificationErrorCode = {
    TokenInvalid: "token-invalid",
    InvalidSecretKey: "secret-key-invalid",
    UnexpectedError: "unexpected-error",
    TokenVerificationFailed: "token-verification-failed"
};
var MachineTokenVerificationError = class _MachineTokenVerificationError extends Error {
    constructor({ message, code, status, action }){
        super(message);
        Object.setPrototypeOf(this, _MachineTokenVerificationError.prototype);
        this.code = code;
        this.status = status;
        this.action = action;
    }
    getFullMessage() {
        return `${this.message} (code=${this.code}, status=${this.status || "n/a"})`;
    }
};
;
 //# sourceMappingURL=chunk-TCIXZLLW.mjs.map
}),
"[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/runtime/node/crypto.mjs [app-rsc] (ecmascript) <locals>", ((__turbopack_context__) => {
"use strict";

__turbopack_context__.s([]);
var __TURBOPACK__imported__module__$5b$externals$5d2f$node$3a$crypto__$5b$external$5d$__$28$node$3a$crypto$2c$__cjs$29$__ = __turbopack_context__.i("[externals]/node:crypto [external] (node:crypto, cjs)");
;
}),
"[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-7X3P2E3X.mjs [app-rsc] (ecmascript)", ((__turbopack_context__) => {
"use strict";

__turbopack_context__.s([
    "assertHeaderAlgorithm",
    ()=>assertHeaderAlgorithm,
    "assertHeaderType",
    ()=>assertHeaderType,
    "base64url",
    ()=>base64url,
    "decodeJwt",
    ()=>decodeJwt,
    "getCryptoAlgorithm",
    ()=>getCryptoAlgorithm,
    "hasValidSignature",
    ()=>hasValidSignature,
    "importKey",
    ()=>importKey,
    "runtime",
    ()=>runtime,
    "verifyJwt",
    ()=>verifyJwt
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-TCIXZLLW.mjs [app-rsc] (ecmascript)");
// src/runtime.ts
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$runtime$2f$node$2f$crypto$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/runtime/node/crypto.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$externals$5d2f$node$3a$crypto__$5b$external$5d$__$28$node$3a$crypto$2c$__cjs$29$__ = __turbopack_context__.i("[externals]/node:crypto [external] (node:crypto, cjs)");
// src/jwt/cryptoKeys.ts
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$isomorphicAtob$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/isomorphicAtob.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$isomorphicAtob$2d$DybBXGFR$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/isomorphicAtob-DybBXGFR.mjs [app-rsc] (ecmascript)");
;
;
var globalFetch = fetch.bind(globalThis);
var runtime = {
    crypto: __TURBOPACK__imported__module__$5b$externals$5d2f$node$3a$crypto__$5b$external$5d$__$28$node$3a$crypto$2c$__cjs$29$__["webcrypto"],
    get fetch () {
        return ("TURBOPACK compile-time falsy", 0) ? "TURBOPACK unreachable" : globalFetch;
    },
    AbortController: globalThis.AbortController,
    Blob: globalThis.Blob,
    FormData: globalThis.FormData,
    Headers: globalThis.Headers,
    Request: globalThis.Request,
    Response: globalThis.Response
};
// src/util/rfc4648.ts
var base64url = {
    parse (string, opts) {
        return parse(string, base64UrlEncoding, opts);
    },
    stringify (data, opts) {
        return stringify(data, base64UrlEncoding, opts);
    }
};
var base64UrlEncoding = {
    chars: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
    bits: 6
};
function parse(string, encoding, opts = {}) {
    if (!encoding.codes) {
        encoding.codes = {};
        for(let i = 0; i < encoding.chars.length; ++i){
            encoding.codes[encoding.chars[i]] = i;
        }
    }
    if (!opts.loose && string.length * encoding.bits & 7) {
        throw new SyntaxError("Invalid padding");
    }
    let end = string.length;
    while(string[end - 1] === "="){
        --end;
        if (!opts.loose && !((string.length - end) * encoding.bits & 7)) {
            throw new SyntaxError("Invalid padding");
        }
    }
    const out = new (opts.out ?? Uint8Array)(end * encoding.bits / 8 | 0);
    let bits = 0;
    let buffer = 0;
    let written = 0;
    for(let i = 0; i < end; ++i){
        const value = encoding.codes[string[i]];
        if (value === void 0) {
            throw new SyntaxError("Invalid character " + string[i]);
        }
        buffer = buffer << encoding.bits | value;
        bits += encoding.bits;
        if (bits >= 8) {
            bits -= 8;
            out[written++] = 255 & buffer >> bits;
        }
    }
    if (bits >= encoding.bits || 255 & buffer << 8 - bits) {
        throw new SyntaxError("Unexpected end of data");
    }
    return out;
}
function stringify(data, encoding, opts = {}) {
    const { pad = true } = opts;
    const mask = (1 << encoding.bits) - 1;
    let out = "";
    let bits = 0;
    let buffer = 0;
    for(let i = 0; i < data.length; ++i){
        buffer = buffer << 8 | 255 & data[i];
        bits += 8;
        while(bits > encoding.bits){
            bits -= encoding.bits;
            out += encoding.chars[mask & buffer >> bits];
        }
    }
    if (bits) {
        out += encoding.chars[mask & buffer << encoding.bits - bits];
    }
    if (pad) {
        while(out.length * encoding.bits & 7){
            out += "=";
        }
    }
    return out;
}
// src/jwt/algorithms.ts
var algToHash = {
    RS256: "SHA-256",
    RS384: "SHA-384",
    RS512: "SHA-512"
};
var RSA_ALGORITHM_NAME = "RSASSA-PKCS1-v1_5";
var jwksAlgToCryptoAlg = {
    RS256: RSA_ALGORITHM_NAME,
    RS384: RSA_ALGORITHM_NAME,
    RS512: RSA_ALGORITHM_NAME
};
var algs = Object.keys(algToHash);
function getCryptoAlgorithm(algorithmName) {
    const hash = algToHash[algorithmName];
    const name = jwksAlgToCryptoAlg[algorithmName];
    if (!hash || !name) {
        throw new Error(`Unsupported algorithm ${algorithmName}, expected one of ${algs.join(",")}.`);
    }
    return {
        hash: {
            name: algToHash[algorithmName]
        },
        name: jwksAlgToCryptoAlg[algorithmName]
    };
}
// src/jwt/assertions.ts
var isArrayString = (s)=>{
    return Array.isArray(s) && s.length > 0 && s.every((a)=>typeof a === "string");
};
var assertAudienceClaim = (aud, audience)=>{
    const audienceList = [
        audience
    ].flat().filter((a)=>!!a);
    const audList = [
        aud
    ].flat().filter((a)=>!!a);
    const shouldVerifyAudience = audienceList.length > 0 && audList.length > 0;
    if (!shouldVerifyAudience) {
        return;
    }
    if (typeof aud === "string") {
        if (!audienceList.includes(aud)) {
            throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
                action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].EnsureClerkJWT,
                reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenVerificationFailed,
                message: `Invalid JWT audience claim (aud) ${JSON.stringify(aud)}. Is not included in "${JSON.stringify(audienceList)}".`
            });
        }
    } else if (isArrayString(aud)) {
        if (!aud.some((a)=>audienceList.includes(a))) {
            throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
                action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].EnsureClerkJWT,
                reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenVerificationFailed,
                message: `Invalid JWT audience claim array (aud) ${JSON.stringify(aud)}. Is not included in "${JSON.stringify(audienceList)}".`
            });
        }
    }
};
var assertHeaderType = (typ, allowedTypes = "JWT")=>{
    if (typeof typ === "undefined") {
        return;
    }
    const allowed = Array.isArray(allowedTypes) ? allowedTypes : [
        allowedTypes
    ];
    if (!allowed.includes(typ)) {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].EnsureClerkJWT,
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenInvalid,
            message: `Invalid JWT type ${JSON.stringify(typ)}. Expected "${allowed.join(", ")}".`
        });
    }
};
var assertHeaderAlgorithm = (alg)=>{
    if (!algs.includes(alg)) {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].EnsureClerkJWT,
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenInvalidAlgorithm,
            message: `Invalid JWT algorithm ${JSON.stringify(alg)}. Supported: ${algs}.`
        });
    }
};
var assertSubClaim = (sub)=>{
    if (typeof sub !== "string") {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].EnsureClerkJWT,
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenVerificationFailed,
            message: `Subject claim (sub) is required and must be a string. Received ${JSON.stringify(sub)}.`
        });
    }
};
var assertAuthorizedPartiesClaim = (azp, authorizedParties)=>{
    if (!azp || !authorizedParties || authorizedParties.length === 0) {
        return;
    }
    if (!authorizedParties.includes(azp)) {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenInvalidAuthorizedParties,
            message: `Invalid JWT Authorized party claim (azp) ${JSON.stringify(azp)}. Expected "${authorizedParties}".`
        });
    }
};
var assertExpirationClaim = (exp, clockSkewInMs)=>{
    if (typeof exp !== "number") {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].EnsureClerkJWT,
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenVerificationFailed,
            message: `Invalid JWT expiry date claim (exp) ${JSON.stringify(exp)}. Expected number.`
        });
    }
    const currentDate = new Date(Date.now());
    const expiryDate = /* @__PURE__ */ new Date(0);
    expiryDate.setUTCSeconds(exp);
    const expired = expiryDate.getTime() <= currentDate.getTime() - clockSkewInMs;
    if (expired) {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenExpired,
            message: `JWT is expired. Expiry date: ${expiryDate.toUTCString()}, Current date: ${currentDate.toUTCString()}.`
        });
    }
};
var assertActivationClaim = (nbf, clockSkewInMs)=>{
    if (typeof nbf === "undefined") {
        return;
    }
    if (typeof nbf !== "number") {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].EnsureClerkJWT,
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenVerificationFailed,
            message: `Invalid JWT not before date claim (nbf) ${JSON.stringify(nbf)}. Expected number.`
        });
    }
    const currentDate = new Date(Date.now());
    const notBeforeDate = /* @__PURE__ */ new Date(0);
    notBeforeDate.setUTCSeconds(nbf);
    const early = notBeforeDate.getTime() > currentDate.getTime() + clockSkewInMs;
    if (early) {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenNotActiveYet,
            message: `JWT cannot be used prior to not before date claim (nbf). Not before date: ${notBeforeDate.toUTCString()}; Current date: ${currentDate.toUTCString()};`
        });
    }
};
var assertIssuedAtClaim = (iat, clockSkewInMs)=>{
    if (typeof iat === "undefined") {
        return;
    }
    if (typeof iat !== "number") {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].EnsureClerkJWT,
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenVerificationFailed,
            message: `Invalid JWT issued at date claim (iat) ${JSON.stringify(iat)}. Expected number.`
        });
    }
    const currentDate = new Date(Date.now());
    const issuedAtDate = /* @__PURE__ */ new Date(0);
    issuedAtDate.setUTCSeconds(iat);
    const postIssued = issuedAtDate.getTime() > currentDate.getTime() + clockSkewInMs;
    if (postIssued) {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenIatInTheFuture,
            message: `JWT issued at date claim (iat) is in the future. Issued at date: ${issuedAtDate.toUTCString()}; Current date: ${currentDate.toUTCString()};`
        });
    }
};
;
function pemToBuffer(secret) {
    const trimmed = secret.replace(/-----BEGIN.*?-----/g, "").replace(/-----END.*?-----/g, "").replace(/\s/g, "");
    const decoded = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$isomorphicAtob$2d$DybBXGFR$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["isomorphicAtob"])(trimmed);
    const buffer = new ArrayBuffer(decoded.length);
    const bufView = new Uint8Array(buffer);
    for(let i = 0, strLen = decoded.length; i < strLen; i++){
        bufView[i] = decoded.charCodeAt(i);
    }
    return bufView;
}
function importKey(key, algorithm, keyUsage) {
    if (typeof key === "object") {
        return runtime.crypto.subtle.importKey("jwk", key, algorithm, false, [
            keyUsage
        ]);
    }
    const keyData = pemToBuffer(key);
    const format = keyUsage === "sign" ? "pkcs8" : "spki";
    return runtime.crypto.subtle.importKey(format, keyData, algorithm, false, [
        keyUsage
    ]);
}
// src/jwt/verifyJwt.ts
var DEFAULT_CLOCK_SKEW_IN_MS = 5 * 1e3;
async function hasValidSignature(jwt, key) {
    const { header, signature, raw } = jwt;
    const encoder = new TextEncoder();
    const data = encoder.encode([
        raw.header,
        raw.payload
    ].join("."));
    const algorithm = getCryptoAlgorithm(header.alg);
    try {
        const cryptoKey = await importKey(key, algorithm, "verify");
        const verified = await runtime.crypto.subtle.verify(algorithm.name, cryptoKey, signature, data);
        return {
            data: verified
        };
    } catch (error) {
        return {
            errors: [
                new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
                    reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenInvalidSignature,
                    message: error?.message
                })
            ]
        };
    }
}
function decodeJwt(token) {
    const tokenParts = (token || "").toString().split(".");
    if (tokenParts.length !== 3) {
        return {
            errors: [
                new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
                    reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenInvalid,
                    message: `Invalid JWT form. A JWT consists of three parts separated by dots.`
                })
            ]
        };
    }
    const [rawHeader, rawPayload, rawSignature] = tokenParts;
    const decoder = new TextDecoder();
    const header = JSON.parse(decoder.decode(base64url.parse(rawHeader, {
        loose: true
    })));
    const payload = JSON.parse(decoder.decode(base64url.parse(rawPayload, {
        loose: true
    })));
    const signature = base64url.parse(rawSignature, {
        loose: true
    });
    const data = {
        header,
        payload,
        signature,
        raw: {
            header: rawHeader,
            payload: rawPayload,
            signature: rawSignature,
            text: token
        }
    };
    return {
        data
    };
}
async function verifyJwt(token, options) {
    const { audience, authorizedParties, clockSkewInMs, key, headerType } = options;
    const clockSkew = clockSkewInMs || DEFAULT_CLOCK_SKEW_IN_MS;
    const { data: decoded, errors } = decodeJwt(token);
    if (errors) {
        return {
            errors
        };
    }
    const { header, payload } = decoded;
    try {
        const { typ, alg } = header;
        assertHeaderType(typ, headerType);
        assertHeaderAlgorithm(alg);
        const { azp, sub, aud, iat, exp, nbf } = payload;
        assertSubClaim(sub);
        assertAudienceClaim([
            aud
        ], [
            audience
        ]);
        assertAuthorizedPartiesClaim(azp, authorizedParties);
        assertExpirationClaim(exp, clockSkew);
        assertActivationClaim(nbf, clockSkew);
        assertIssuedAtClaim(iat, clockSkew);
    } catch (err) {
        return {
            errors: [
                err
            ]
        };
    }
    const { data: signatureValid, errors: signatureErrors } = await hasValidSignature(decoded, key);
    if (signatureErrors) {
        return {
            errors: [
                new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
                    action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].EnsureClerkJWT,
                    reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenVerificationFailed,
                    message: `Error verifying JWT signature. ${signatureErrors[0]}`
                })
            ]
        };
    }
    if (!signatureValid) {
        return {
            errors: [
                new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
                    reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenInvalidSignature,
                    message: "JWT signature is invalid."
                })
            ]
        };
    }
    return {
        data: payload
    };
}
;
 //# sourceMappingURL=chunk-7X3P2E3X.mjs.map
}),
"[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-RPS7XK5K.mjs [app-rsc] (ecmascript)", ((__turbopack_context__) => {
"use strict";

__turbopack_context__.s([
    "__privateAdd",
    ()=>__privateAdd,
    "__privateMethod",
    ()=>__privateMethod
]);
var __typeError = (msg)=>{
    throw TypeError(msg);
};
var __accessCheck = (obj, member, msg)=>member.has(obj) || __typeError("Cannot " + msg);
var __privateAdd = (obj, member, value)=>member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateMethod = (obj, member, method)=>(__accessCheck(obj, member, "access private method"), method);
;
 //# sourceMappingURL=chunk-RPS7XK5K.mjs.map
}),
"[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-4EVRZKGK.mjs [app-rsc] (ecmascript) <locals>", ((__turbopack_context__) => {
"use strict";

__turbopack_context__.s([
    "AuthStatus",
    ()=>AuthStatus,
    "TokenType",
    ()=>TokenType,
    "authenticatedMachineObject",
    ()=>authenticatedMachineObject,
    "constants",
    ()=>constants,
    "createAuthenticateRequest",
    ()=>createAuthenticateRequest,
    "createBackendApiClient",
    ()=>createBackendApiClient,
    "createClerkRequest",
    ()=>createClerkRequest,
    "createRedirect",
    ()=>createRedirect,
    "debugRequestState",
    ()=>debugRequestState,
    "decorateObjectWithResources",
    ()=>decorateObjectWithResources,
    "getAuthObjectForAcceptedToken",
    ()=>getAuthObjectForAcceptedToken,
    "getAuthObjectFromJwt",
    ()=>getAuthObjectFromJwt,
    "getMachineTokenType",
    ()=>getMachineTokenType,
    "invalidTokenAuthObject",
    ()=>invalidTokenAuthObject,
    "isMachineTokenByPrefix",
    ()=>isMachineTokenByPrefix,
    "isMachineTokenType",
    ()=>isMachineTokenType,
    "isTokenTypeAccepted",
    ()=>isTokenTypeAccepted,
    "makeAuthObjectSerializable",
    ()=>makeAuthObjectSerializable,
    "signedInAuthObject",
    ()=>signedInAuthObject,
    "signedOutAuthObject",
    ()=>signedOutAuthObject,
    "stripPrivateDataFromObject",
    ()=>stripPrivateDataFromObject,
    "unauthenticatedMachineObject",
    ()=>unauthenticatedMachineObject,
    "verifyMachineAuthToken",
    ()=>verifyMachineAuthToken,
    "verifyToken",
    ()=>verifyToken
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$YBVFDYDR$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-YBVFDYDR.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$deprecated$2d$BqlFbLHj$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/deprecated-BqlFbLHj.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$keys$2d$YNv6yjKk$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/keys-YNv6yjKk.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$retry$2d$DAlTROH9$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/retry-DAlTROH9.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-7X3P2E3X.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-TCIXZLLW.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$RPS7XK5K$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-RPS7XK5K.mjs [app-rsc] (ecmascript)");
// src/createRedirect.ts
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$buildAccountsBaseUrl$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/buildAccountsBaseUrl.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$url$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/url.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$url$2d$Cdy8w8vK$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/url-Cdy8w8vK.mjs [app-rsc] (ecmascript)");
// src/tokens/authObjects.ts
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$authorization$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/authorization.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$authorization$2d$D2ans7vW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/authorization-D2ans7vW.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$jwtPayloadParser$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/jwtPayloadParser.mjs [app-rsc] (ecmascript)");
// src/api/request.ts
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$error$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/error.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$error$2d$CC05ENkI$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/error-CC05ENkI.mjs [app-rsc] (ecmascript)");
// src/tokens/clerkRequest.ts
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f$cookie$2f$dist$2f$index$2e$js__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/cookie/dist/index.js [app-rsc] (ecmascript)");
// src/tokens/organizationMatcher.ts
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$pathToRegexp$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/pathToRegexp.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$pathToRegexp$2d$Bu45OrlU$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/pathToRegexp-Bu45OrlU.mjs [app-rsc] (ecmascript)");
// src/internal.ts
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$authorization$2d$errors$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/authorization-errors.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$authorization$2d$errors$2d$CS1pNy8i$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/authorization-errors-CS1pNy8i.mjs [app-rsc] (ecmascript)");
;
;
;
;
// src/constants.ts
var API_URL = "https://api.clerk.com";
var API_VERSION = "v1";
var USER_AGENT = `${"@clerk/backend"}@${"2.26.0"}`;
var MAX_CACHE_LAST_UPDATED_AT_SECONDS = 5 * 60;
var SUPPORTED_BAPI_VERSION = "2025-11-10";
var Attributes = {
    AuthToken: "__clerkAuthToken",
    AuthSignature: "__clerkAuthSignature",
    AuthStatus: "__clerkAuthStatus",
    AuthReason: "__clerkAuthReason",
    AuthMessage: "__clerkAuthMessage",
    ClerkUrl: "__clerkUrl"
};
var Cookies = {
    Session: "__session",
    Refresh: "__refresh",
    ClientUat: "__client_uat",
    Handshake: "__clerk_handshake",
    DevBrowser: "__clerk_db_jwt",
    RedirectCount: "__clerk_redirect_count",
    HandshakeNonce: "__clerk_handshake_nonce"
};
var QueryParameters = {
    ClerkSynced: "__clerk_synced",
    SuffixedCookies: "suffixed_cookies",
    ClerkRedirectUrl: "__clerk_redirect_url",
    // use the reference to Cookies to indicate that it's the same value
    DevBrowser: Cookies.DevBrowser,
    Handshake: Cookies.Handshake,
    HandshakeHelp: "__clerk_help",
    LegacyDevBrowser: "__dev_session",
    HandshakeReason: "__clerk_hs_reason",
    HandshakeNonce: Cookies.HandshakeNonce,
    HandshakeFormat: "format"
};
var Headers2 = {
    Accept: "accept",
    AuthMessage: "x-clerk-auth-message",
    Authorization: "authorization",
    AuthReason: "x-clerk-auth-reason",
    AuthSignature: "x-clerk-auth-signature",
    AuthStatus: "x-clerk-auth-status",
    AuthToken: "x-clerk-auth-token",
    CacheControl: "cache-control",
    ClerkRedirectTo: "x-clerk-redirect-to",
    ClerkRequestData: "x-clerk-request-data",
    ClerkUrl: "x-clerk-clerk-url",
    CloudFrontForwardedProto: "cloudfront-forwarded-proto",
    ContentType: "content-type",
    ContentSecurityPolicy: "content-security-policy",
    ContentSecurityPolicyReportOnly: "content-security-policy-report-only",
    EnableDebug: "x-clerk-debug",
    ForwardedHost: "x-forwarded-host",
    ForwardedPort: "x-forwarded-port",
    ForwardedProto: "x-forwarded-proto",
    Host: "host",
    Location: "location",
    Nonce: "x-nonce",
    Origin: "origin",
    Referrer: "referer",
    SecFetchDest: "sec-fetch-dest",
    SecFetchSite: "sec-fetch-site",
    UserAgent: "user-agent",
    ReportingEndpoints: "reporting-endpoints"
};
var ContentTypes = {
    Json: "application/json"
};
var constants = {
    Attributes,
    Cookies,
    Headers: Headers2,
    ContentTypes,
    QueryParameters
};
;
var buildUrl = (_baseUrl, _targetUrl, _returnBackUrl, _devBrowserToken)=>{
    if (_baseUrl === "") {
        return legacyBuildUrl(_targetUrl.toString(), _returnBackUrl?.toString());
    }
    const baseUrl = new URL(_baseUrl);
    const returnBackUrl = _returnBackUrl ? new URL(_returnBackUrl, baseUrl) : void 0;
    const res = new URL(_targetUrl, baseUrl);
    const isCrossOriginRedirect = `${baseUrl.hostname}:${baseUrl.port}` !== `${res.hostname}:${res.port}`;
    if (returnBackUrl) {
        if (isCrossOriginRedirect) {
            returnBackUrl.searchParams.delete(constants.QueryParameters.ClerkSynced);
        }
        res.searchParams.set("redirect_url", returnBackUrl.toString());
    }
    if (isCrossOriginRedirect && _devBrowserToken) {
        res.searchParams.set(constants.QueryParameters.DevBrowser, _devBrowserToken);
    }
    return res.toString();
};
var legacyBuildUrl = (targetUrl, redirectUrl)=>{
    let url;
    if (!targetUrl.startsWith("http")) {
        if (!redirectUrl || !redirectUrl.startsWith("http")) {
            throw new Error("destination url or return back url should be an absolute path url!");
        }
        const baseURL = new URL(redirectUrl);
        url = new URL(targetUrl, baseURL.origin);
    } else {
        url = new URL(targetUrl);
    }
    if (redirectUrl) {
        url.searchParams.set("redirect_url", redirectUrl);
    }
    return url.toString();
};
var createRedirect = (params)=>{
    const { publishableKey, redirectAdapter, signInUrl, signUpUrl, baseUrl, sessionStatus } = params;
    const parsedPublishableKey = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$keys$2d$YNv6yjKk$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["parsePublishableKey"])(publishableKey);
    const frontendApi = parsedPublishableKey?.frontendApi;
    const isDevelopment = parsedPublishableKey?.instanceType === "development";
    const accountsBaseUrl = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$buildAccountsBaseUrl$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["buildAccountsBaseUrl"])(frontendApi);
    const hasPendingStatus = sessionStatus === "pending";
    const redirectToTasks = (url, { returnBackUrl })=>{
        return redirectAdapter(buildUrl(baseUrl, `${url}/tasks`, returnBackUrl, isDevelopment ? params.devBrowserToken : null));
    };
    const redirectToSignUp = ({ returnBackUrl } = {})=>{
        if (!signUpUrl && !accountsBaseUrl) {
            __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$YBVFDYDR$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__["errorThrower"].throwMissingPublishableKeyError();
        }
        const accountsSignUpUrl = `${accountsBaseUrl}/sign-up`;
        function buildSignUpUrl(signIn) {
            if (!signIn) {
                return;
            }
            const url = new URL(signIn, baseUrl);
            url.pathname = `${url.pathname}/create`;
            return url.toString();
        }
        const targetUrl = signUpUrl || buildSignUpUrl(signInUrl) || accountsSignUpUrl;
        if (hasPendingStatus) {
            return redirectToTasks(targetUrl, {
                returnBackUrl
            });
        }
        return redirectAdapter(buildUrl(baseUrl, targetUrl, returnBackUrl, isDevelopment ? params.devBrowserToken : null));
    };
    const redirectToSignIn = ({ returnBackUrl } = {})=>{
        if (!signInUrl && !accountsBaseUrl) {
            __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$YBVFDYDR$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__["errorThrower"].throwMissingPublishableKeyError();
        }
        const accountsSignInUrl = `${accountsBaseUrl}/sign-in`;
        const targetUrl = signInUrl || accountsSignInUrl;
        if (hasPendingStatus) {
            return redirectToTasks(targetUrl, {
                returnBackUrl
            });
        }
        return redirectAdapter(buildUrl(baseUrl, targetUrl, returnBackUrl, isDevelopment ? params.devBrowserToken : null));
    };
    return {
        redirectToSignUp,
        redirectToSignIn
    };
};
// src/util/mergePreDefinedOptions.ts
function mergePreDefinedOptions(preDefinedOptions, options) {
    return Object.keys(preDefinedOptions).reduce((obj, key)=>{
        return {
            ...obj,
            [key]: options[key] || obj[key]
        };
    }, {
        ...preDefinedOptions
    });
}
// src/util/optionsAssertions.ts
function assertValidSecretKey(val) {
    if (!val || typeof val !== "string") {
        throw Error("Missing Clerk Secret Key. Go to https://dashboard.clerk.com and get your key for your instance.");
    }
}
function assertValidPublishableKey(val) {
    (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$keys$2d$YNv6yjKk$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["parsePublishableKey"])(val, {
        fatal: true
    });
}
;
;
// src/tokens/tokenTypes.ts
var TokenType = {
    SessionToken: "session_token",
    ApiKey: "api_key",
    M2MToken: "m2m_token",
    OAuthToken: "oauth_token"
};
// src/tokens/authenticateContext.ts
var AuthenticateContext = class {
    constructor(cookieSuffix, clerkRequest, options){
        this.cookieSuffix = cookieSuffix;
        this.clerkRequest = clerkRequest;
        /**
     * The original Clerk frontend API URL, extracted from publishable key before proxy URL override.
     * Used for backend operations like token validation and issuer checking.
     */ this.originalFrontendApi = "";
        if (options.acceptsToken === TokenType.M2MToken || options.acceptsToken === TokenType.ApiKey) {
            this.initHeaderValues();
        } else {
            this.initPublishableKeyValues(options);
            this.initHeaderValues();
            this.initCookieValues();
            this.initHandshakeValues();
        }
        Object.assign(this, options);
        this.clerkUrl = this.clerkRequest.clerkUrl;
    }
    /**
   * Retrieves the session token from either the cookie or the header.
   *
   * @returns {string | undefined} The session token if available, otherwise undefined.
   */ get sessionToken() {
        return this.sessionTokenInCookie || this.tokenInHeader;
    }
    usesSuffixedCookies() {
        const suffixedClientUat = this.getSuffixedCookie(constants.Cookies.ClientUat);
        const clientUat = this.getCookie(constants.Cookies.ClientUat);
        const suffixedSession = this.getSuffixedCookie(constants.Cookies.Session) || "";
        const session = this.getCookie(constants.Cookies.Session) || "";
        if (session && !this.tokenHasIssuer(session)) {
            return false;
        }
        if (session && !this.tokenBelongsToInstance(session)) {
            return true;
        }
        if (!suffixedClientUat && !suffixedSession) {
            return false;
        }
        const { data: sessionData } = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["decodeJwt"])(session);
        const sessionIat = sessionData?.payload.iat || 0;
        const { data: suffixedSessionData } = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["decodeJwt"])(suffixedSession);
        const suffixedSessionIat = suffixedSessionData?.payload.iat || 0;
        if (suffixedClientUat !== "0" && clientUat !== "0" && sessionIat > suffixedSessionIat) {
            return false;
        }
        if (suffixedClientUat === "0" && clientUat !== "0") {
            return false;
        }
        if (this.instanceType !== "production") {
            const isSuffixedSessionExpired = this.sessionExpired(suffixedSessionData);
            if (suffixedClientUat !== "0" && clientUat === "0" && isSuffixedSessionExpired) {
                return false;
            }
        }
        if (!suffixedClientUat && suffixedSession) {
            return false;
        }
        return true;
    }
    /**
   * Determines if the request came from a different origin based on the referrer header.
   * Used for cross-origin detection in multi-domain authentication flows.
   *
   * @returns {boolean} True if referrer exists and is from a different origin, false otherwise.
   */ isCrossOriginReferrer() {
        if (!this.referrer || !this.clerkUrl.origin) {
            return false;
        }
        try {
            const referrerOrigin = new URL(this.referrer).origin;
            return referrerOrigin !== this.clerkUrl.origin;
        } catch  {
            return false;
        }
    }
    /**
   * Determines if the referrer URL is from a Clerk domain (accounts portal or FAPI).
   * This includes both development and production account portal domains, as well as FAPI domains
   * used for redirect-based authentication flows.
   *
   * @returns {boolean} True if the referrer is from a Clerk accounts portal or FAPI domain, false otherwise
   */ isKnownClerkReferrer() {
        if (!this.referrer) {
            return false;
        }
        try {
            const referrerOrigin = new URL(this.referrer);
            const referrerHost = referrerOrigin.hostname;
            if (this.frontendApi) {
                const fapiHost = this.frontendApi.startsWith("http") ? new URL(this.frontendApi).hostname : this.frontendApi;
                if (referrerHost === fapiHost) {
                    return true;
                }
            }
            if ((0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$url$2d$Cdy8w8vK$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["isLegacyDevAccountPortalOrigin"])(referrerHost) || (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$url$2d$Cdy8w8vK$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["isCurrentDevAccountPortalOrigin"])(referrerHost)) {
                return true;
            }
            const expectedAccountsUrl = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$buildAccountsBaseUrl$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["buildAccountsBaseUrl"])(this.frontendApi);
            if (expectedAccountsUrl) {
                const expectedAccountsOrigin = new URL(expectedAccountsUrl).origin;
                if (referrerOrigin.origin === expectedAccountsOrigin) {
                    return true;
                }
            }
            if (referrerHost.startsWith("accounts.")) {
                return true;
            }
            return false;
        } catch  {
            return false;
        }
    }
    initPublishableKeyValues(options) {
        assertValidPublishableKey(options.publishableKey);
        this.publishableKey = options.publishableKey;
        const originalPk = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$keys$2d$YNv6yjKk$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["parsePublishableKey"])(this.publishableKey, {
            fatal: true,
            domain: options.domain,
            isSatellite: options.isSatellite
        });
        this.originalFrontendApi = originalPk.frontendApi;
        const pk = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$keys$2d$YNv6yjKk$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["parsePublishableKey"])(this.publishableKey, {
            fatal: true,
            proxyUrl: options.proxyUrl,
            domain: options.domain,
            isSatellite: options.isSatellite
        });
        this.instanceType = pk.instanceType;
        this.frontendApi = pk.frontendApi;
    }
    initHeaderValues() {
        this.tokenInHeader = this.parseAuthorizationHeader(this.getHeader(constants.Headers.Authorization));
        this.origin = this.getHeader(constants.Headers.Origin);
        this.host = this.getHeader(constants.Headers.Host);
        this.forwardedHost = this.getHeader(constants.Headers.ForwardedHost);
        this.forwardedProto = this.getHeader(constants.Headers.CloudFrontForwardedProto) || this.getHeader(constants.Headers.ForwardedProto);
        this.referrer = this.getHeader(constants.Headers.Referrer);
        this.userAgent = this.getHeader(constants.Headers.UserAgent);
        this.secFetchDest = this.getHeader(constants.Headers.SecFetchDest);
        this.accept = this.getHeader(constants.Headers.Accept);
    }
    initCookieValues() {
        this.sessionTokenInCookie = this.getSuffixedOrUnSuffixedCookie(constants.Cookies.Session);
        this.refreshTokenInCookie = this.getSuffixedCookie(constants.Cookies.Refresh);
        this.clientUat = Number.parseInt(this.getSuffixedOrUnSuffixedCookie(constants.Cookies.ClientUat) || "") || 0;
    }
    initHandshakeValues() {
        this.devBrowserToken = this.getQueryParam(constants.QueryParameters.DevBrowser) || this.getSuffixedOrUnSuffixedCookie(constants.Cookies.DevBrowser);
        this.handshakeToken = this.getQueryParam(constants.QueryParameters.Handshake) || this.getCookie(constants.Cookies.Handshake);
        this.handshakeRedirectLoopCounter = Number(this.getCookie(constants.Cookies.RedirectCount)) || 0;
        this.handshakeNonce = this.getQueryParam(constants.QueryParameters.HandshakeNonce) || this.getCookie(constants.Cookies.HandshakeNonce);
    }
    getQueryParam(name) {
        return this.clerkRequest.clerkUrl.searchParams.get(name);
    }
    getHeader(name) {
        return this.clerkRequest.headers.get(name) || void 0;
    }
    getCookie(name) {
        return this.clerkRequest.cookies.get(name) || void 0;
    }
    getSuffixedCookie(name) {
        return this.getCookie((0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$keys$2d$YNv6yjKk$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["getSuffixedCookieName"])(name, this.cookieSuffix)) || void 0;
    }
    getSuffixedOrUnSuffixedCookie(cookieName) {
        if (this.usesSuffixedCookies()) {
            return this.getSuffixedCookie(cookieName);
        }
        return this.getCookie(cookieName);
    }
    parseAuthorizationHeader(authorizationHeader) {
        if (!authorizationHeader) {
            return void 0;
        }
        const [scheme, token] = authorizationHeader.split(" ", 2);
        if (!token) {
            return scheme;
        }
        if (scheme === "Bearer") {
            return token;
        }
        return void 0;
    }
    tokenHasIssuer(token) {
        const { data, errors } = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["decodeJwt"])(token);
        if (errors) {
            return false;
        }
        return !!data.payload.iss;
    }
    tokenBelongsToInstance(token) {
        if (!token) {
            return false;
        }
        const { data, errors } = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["decodeJwt"])(token);
        if (errors) {
            return false;
        }
        const tokenIssuer = data.payload.iss.replace(/https?:\/\//gi, "");
        return this.originalFrontendApi === tokenIssuer;
    }
    sessionExpired(jwt) {
        return !!jwt && jwt?.payload.exp <= Date.now() / 1e3 >> 0;
    }
};
var createAuthenticateContext = async (clerkRequest, options)=>{
    const cookieSuffix = options.publishableKey ? await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$keys$2d$YNv6yjKk$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["getCookieSuffix"])(options.publishableKey, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["runtime"].crypto.subtle) : "";
    return new AuthenticateContext(cookieSuffix, clerkRequest, options);
};
;
;
// src/util/path.ts
var SEPARATOR = "/";
var MULTIPLE_SEPARATOR_REGEX = new RegExp("(?<!:)" + SEPARATOR + "{1,}", "g");
function joinPaths(...args) {
    return args.filter((p)=>p).join(SEPARATOR).replace(MULTIPLE_SEPARATOR_REGEX, SEPARATOR);
}
// src/api/endpoints/AbstractApi.ts
var AbstractAPI = class {
    constructor(request){
        this.request = request;
    }
    requireId(id) {
        if (!id) {
            throw new Error("A valid resource ID is required.");
        }
    }
};
// src/api/endpoints/ActorTokenApi.ts
var basePath = "/actor_tokens";
var ActorTokenAPI = class extends AbstractAPI {
    async create(params) {
        return this.request({
            method: "POST",
            path: basePath,
            bodyParams: params
        });
    }
    async revoke(actorTokenId) {
        this.requireId(actorTokenId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath, actorTokenId, "revoke")
        });
    }
};
// src/api/endpoints/AccountlessApplicationsAPI.ts
var basePath2 = "/accountless_applications";
var AccountlessApplicationAPI = class extends AbstractAPI {
    async createAccountlessApplication(params) {
        const headerParams = params?.requestHeaders ? Object.fromEntries(params.requestHeaders.entries()) : void 0;
        return this.request({
            method: "POST",
            path: basePath2,
            headerParams
        });
    }
    async completeAccountlessApplicationOnboarding(params) {
        const headerParams = params?.requestHeaders ? Object.fromEntries(params.requestHeaders.entries()) : void 0;
        return this.request({
            method: "POST",
            path: joinPaths(basePath2, "complete"),
            headerParams
        });
    }
};
// src/api/endpoints/AllowlistIdentifierApi.ts
var basePath3 = "/allowlist_identifiers";
var AllowlistIdentifierAPI = class extends AbstractAPI {
    async getAllowlistIdentifierList(params = {}) {
        return this.request({
            method: "GET",
            path: basePath3,
            queryParams: {
                ...params,
                paginated: true
            }
        });
    }
    async createAllowlistIdentifier(params) {
        return this.request({
            method: "POST",
            path: basePath3,
            bodyParams: params
        });
    }
    async deleteAllowlistIdentifier(allowlistIdentifierId) {
        this.requireId(allowlistIdentifierId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath3, allowlistIdentifierId)
        });
    }
};
// src/api/endpoints/APIKeysApi.ts
var basePath4 = "/api_keys";
var APIKeysAPI = class extends AbstractAPI {
    async list(queryParams) {
        return this.request({
            method: "GET",
            path: basePath4,
            queryParams
        });
    }
    async create(params) {
        return this.request({
            method: "POST",
            path: basePath4,
            bodyParams: params
        });
    }
    async revoke(params) {
        const { apiKeyId, ...bodyParams } = params;
        this.requireId(apiKeyId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath4, apiKeyId, "revoke"),
            bodyParams
        });
    }
    async getSecret(apiKeyId) {
        this.requireId(apiKeyId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath4, apiKeyId, "secret")
        });
    }
    async verify(secret) {
        return this.request({
            method: "POST",
            path: joinPaths(basePath4, "verify"),
            bodyParams: {
                secret
            }
        });
    }
    /**
   * @deprecated Use `verify()` instead. This method will be removed in the next major release.
   */ async verifySecret(secret) {
        (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$deprecated$2d$BqlFbLHj$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["deprecated"])("apiKeys.verifySecret()", "Use `apiKeys.verify()` instead.");
        return this.verify(secret);
    }
};
// src/api/endpoints/BetaFeaturesApi.ts
var basePath5 = "/beta_features";
var BetaFeaturesAPI = class extends AbstractAPI {
    /**
   * Change the domain of a production instance.
   *
   * Changing the domain requires updating the DNS records accordingly, deploying new SSL certificates,
   * updating your Social Connection's redirect URLs and setting the new keys in your code.
   *
   * @remarks
   * WARNING: Changing your domain will invalidate all current user sessions (i.e. users will be logged out).
   *          Also, while your application is being deployed, a small downtime is expected to occur.
   */ async changeDomain(params) {
        return this.request({
            method: "POST",
            path: joinPaths(basePath5, "change_domain"),
            bodyParams: params
        });
    }
};
// src/api/endpoints/BlocklistIdentifierApi.ts
var basePath6 = "/blocklist_identifiers";
var BlocklistIdentifierAPI = class extends AbstractAPI {
    async getBlocklistIdentifierList(params = {}) {
        return this.request({
            method: "GET",
            path: basePath6,
            queryParams: params
        });
    }
    async createBlocklistIdentifier(params) {
        return this.request({
            method: "POST",
            path: basePath6,
            bodyParams: params
        });
    }
    async deleteBlocklistIdentifier(blocklistIdentifierId) {
        this.requireId(blocklistIdentifierId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath6, blocklistIdentifierId)
        });
    }
};
// src/api/endpoints/ClientApi.ts
var basePath7 = "/clients";
var ClientAPI = class extends AbstractAPI {
    async getClientList(params = {}) {
        return this.request({
            method: "GET",
            path: basePath7,
            queryParams: {
                ...params,
                paginated: true
            }
        });
    }
    async getClient(clientId) {
        this.requireId(clientId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath7, clientId)
        });
    }
    verifyClient(token) {
        return this.request({
            method: "POST",
            path: joinPaths(basePath7, "verify"),
            bodyParams: {
                token
            }
        });
    }
    async getHandshakePayload(queryParams) {
        return this.request({
            method: "GET",
            path: joinPaths(basePath7, "handshake_payload"),
            queryParams
        });
    }
};
// src/api/endpoints/DomainApi.ts
var basePath8 = "/domains";
var DomainAPI = class extends AbstractAPI {
    async list() {
        return this.request({
            method: "GET",
            path: basePath8
        });
    }
    async add(params) {
        return this.request({
            method: "POST",
            path: basePath8,
            bodyParams: params
        });
    }
    async update(params) {
        const { domainId, ...bodyParams } = params;
        this.requireId(domainId);
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath8, domainId),
            bodyParams
        });
    }
    /**
   * Deletes a satellite domain for the instance.
   * It is currently not possible to delete the instance's primary domain.
   */ async delete(satelliteDomainId) {
        return this.deleteDomain(satelliteDomainId);
    }
    /**
   * @deprecated Use `delete` instead
   */ async deleteDomain(satelliteDomainId) {
        this.requireId(satelliteDomainId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath8, satelliteDomainId)
        });
    }
};
// src/api/endpoints/EmailAddressApi.ts
var basePath9 = "/email_addresses";
var EmailAddressAPI = class extends AbstractAPI {
    async getEmailAddress(emailAddressId) {
        this.requireId(emailAddressId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath9, emailAddressId)
        });
    }
    async createEmailAddress(params) {
        return this.request({
            method: "POST",
            path: basePath9,
            bodyParams: params
        });
    }
    async updateEmailAddress(emailAddressId, params = {}) {
        this.requireId(emailAddressId);
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath9, emailAddressId),
            bodyParams: params
        });
    }
    async deleteEmailAddress(emailAddressId) {
        this.requireId(emailAddressId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath9, emailAddressId)
        });
    }
};
// src/api/endpoints/IdPOAuthAccessTokenApi.ts
var basePath10 = "/oauth_applications/access_tokens";
var IdPOAuthAccessTokenApi = class extends AbstractAPI {
    async verify(accessToken) {
        return this.request({
            method: "POST",
            path: joinPaths(basePath10, "verify"),
            bodyParams: {
                access_token: accessToken
            }
        });
    }
    /**
   * @deprecated Use `verify()` instead. This method will be removed in the next major release.
   */ async verifyAccessToken(accessToken) {
        (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$deprecated$2d$BqlFbLHj$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["deprecated"])("idPOAuthAccessToken.verifyAccessToken()", "Use `idPOAuthAccessToken.verify()` instead.");
        return this.verify(accessToken);
    }
};
// src/api/endpoints/InstanceApi.ts
var basePath11 = "/instance";
var InstanceAPI = class extends AbstractAPI {
    async get() {
        return this.request({
            method: "GET",
            path: basePath11
        });
    }
    async update(params) {
        return this.request({
            method: "PATCH",
            path: basePath11,
            bodyParams: params
        });
    }
    async updateRestrictions(params) {
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath11, "restrictions"),
            bodyParams: params
        });
    }
    async updateOrganizationSettings(params) {
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath11, "organization_settings"),
            bodyParams: params
        });
    }
};
// src/api/endpoints/InvitationApi.ts
var basePath12 = "/invitations";
var InvitationAPI = class extends AbstractAPI {
    async getInvitationList(params = {}) {
        return this.request({
            method: "GET",
            path: basePath12,
            queryParams: {
                ...params,
                paginated: true
            }
        });
    }
    async createInvitation(params) {
        return this.request({
            method: "POST",
            path: basePath12,
            bodyParams: params
        });
    }
    async createInvitationBulk(params) {
        return this.request({
            method: "POST",
            path: joinPaths(basePath12, "bulk"),
            bodyParams: params
        });
    }
    async revokeInvitation(invitationId) {
        this.requireId(invitationId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath12, invitationId, "revoke")
        });
    }
};
// src/api/endpoints/MachineApi.ts
var basePath13 = "/machines";
var MachineApi = class extends AbstractAPI {
    async get(machineId) {
        this.requireId(machineId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath13, machineId)
        });
    }
    async list(queryParams = {}) {
        return this.request({
            method: "GET",
            path: basePath13,
            queryParams
        });
    }
    async create(bodyParams) {
        return this.request({
            method: "POST",
            path: basePath13,
            bodyParams
        });
    }
    async update(params) {
        const { machineId, ...bodyParams } = params;
        this.requireId(machineId);
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath13, machineId),
            bodyParams
        });
    }
    async delete(machineId) {
        this.requireId(machineId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath13, machineId)
        });
    }
    async getSecretKey(machineId) {
        this.requireId(machineId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath13, machineId, "secret_key")
        });
    }
    async rotateSecretKey(params) {
        const { machineId, previousTokenTtl } = params;
        this.requireId(machineId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath13, machineId, "secret_key", "rotate"),
            bodyParams: {
                previousTokenTtl
            }
        });
    }
    /**
   * Creates a new machine scope, allowing the specified machine to access another machine.
   *
   * @param machineId - The ID of the machine that will have access to another machine.
   * @param toMachineId - The ID of the machine that will be scoped to the current machine.
   */ async createScope(machineId, toMachineId) {
        this.requireId(machineId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath13, machineId, "scopes"),
            bodyParams: {
                toMachineId
            }
        });
    }
    /**
   * Deletes a machine scope, removing access from one machine to another.
   *
   * @param machineId - The ID of the machine that has access to another machine.
   * @param otherMachineId - The ID of the machine that is being accessed.
   */ async deleteScope(machineId, otherMachineId) {
        this.requireId(machineId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath13, machineId, "scopes", otherMachineId)
        });
    }
};
// src/api/endpoints/M2MTokenApi.ts
var basePath14 = "/m2m_tokens";
var _M2MTokenApi_instances, createRequestOptions_fn;
var M2MTokenApi = class extends AbstractAPI {
    constructor(){
        super(...arguments);
        (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$RPS7XK5K$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["__privateAdd"])(this, _M2MTokenApi_instances);
    }
    async createToken(params) {
        const { claims = null, machineSecretKey, secondsUntilExpiration = null } = params || {};
        const requestOptions = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$RPS7XK5K$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["__privateMethod"])(this, _M2MTokenApi_instances, createRequestOptions_fn).call(this, {
            method: "POST",
            path: basePath14,
            bodyParams: {
                secondsUntilExpiration,
                claims
            }
        }, machineSecretKey);
        return this.request(requestOptions);
    }
    async revokeToken(params) {
        const { m2mTokenId, revocationReason = null, machineSecretKey } = params;
        this.requireId(m2mTokenId);
        const requestOptions = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$RPS7XK5K$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["__privateMethod"])(this, _M2MTokenApi_instances, createRequestOptions_fn).call(this, {
            method: "POST",
            path: joinPaths(basePath14, m2mTokenId, "revoke"),
            bodyParams: {
                revocationReason
            }
        }, machineSecretKey);
        return this.request(requestOptions);
    }
    async verify(params) {
        const { token, machineSecretKey } = params;
        const requestOptions = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$RPS7XK5K$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["__privateMethod"])(this, _M2MTokenApi_instances, createRequestOptions_fn).call(this, {
            method: "POST",
            path: joinPaths(basePath14, "verify"),
            bodyParams: {
                token
            }
        }, machineSecretKey);
        return this.request(requestOptions);
    }
    /**
   * @deprecated Use `verify()` instead. This method will be removed in the next major release.
   */ async verifyToken(params) {
        (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$deprecated$2d$BqlFbLHj$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["deprecated"])("m2m.verifyToken()", "Use `m2m.verify()` instead.");
        return this.verify(params);
    }
};
_M2MTokenApi_instances = new WeakSet();
createRequestOptions_fn = function(options, machineSecretKey) {
    if (machineSecretKey) {
        return {
            ...options,
            headerParams: {
                ...options.headerParams,
                Authorization: `Bearer ${machineSecretKey}`
            }
        };
    }
    return options;
};
// src/api/endpoints/JwksApi.ts
var basePath15 = "/jwks";
var JwksAPI = class extends AbstractAPI {
    async getJwks() {
        return this.request({
            method: "GET",
            path: basePath15
        });
    }
};
// src/api/endpoints/JwtTemplatesApi.ts
var basePath16 = "/jwt_templates";
var JwtTemplatesApi = class extends AbstractAPI {
    async list(params = {}) {
        return this.request({
            method: "GET",
            path: basePath16,
            queryParams: {
                ...params,
                paginated: true
            }
        });
    }
    async get(templateId) {
        this.requireId(templateId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath16, templateId)
        });
    }
    async create(params) {
        return this.request({
            method: "POST",
            path: basePath16,
            bodyParams: params
        });
    }
    async update(params) {
        const { templateId, ...bodyParams } = params;
        this.requireId(templateId);
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath16, templateId),
            bodyParams
        });
    }
    async delete(templateId) {
        this.requireId(templateId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath16, templateId)
        });
    }
};
// src/api/endpoints/OrganizationApi.ts
var basePath17 = "/organizations";
var OrganizationAPI = class extends AbstractAPI {
    async getOrganizationList(params) {
        return this.request({
            method: "GET",
            path: basePath17,
            queryParams: params
        });
    }
    async createOrganization(params) {
        return this.request({
            method: "POST",
            path: basePath17,
            bodyParams: params
        });
    }
    async getOrganization(params) {
        const { includeMembersCount } = params;
        const organizationIdOrSlug = "organizationId" in params ? params.organizationId : params.slug;
        this.requireId(organizationIdOrSlug);
        return this.request({
            method: "GET",
            path: joinPaths(basePath17, organizationIdOrSlug),
            queryParams: {
                includeMembersCount
            }
        });
    }
    async updateOrganization(organizationId, params) {
        this.requireId(organizationId);
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath17, organizationId),
            bodyParams: params
        });
    }
    async updateOrganizationLogo(organizationId, params) {
        this.requireId(organizationId);
        const formData = new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["runtime"].FormData();
        formData.append("file", params?.file);
        if (params?.uploaderUserId) {
            formData.append("uploader_user_id", params?.uploaderUserId);
        }
        return this.request({
            method: "PUT",
            path: joinPaths(basePath17, organizationId, "logo"),
            formData
        });
    }
    async deleteOrganizationLogo(organizationId) {
        this.requireId(organizationId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath17, organizationId, "logo")
        });
    }
    async updateOrganizationMetadata(organizationId, params) {
        this.requireId(organizationId);
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath17, organizationId, "metadata"),
            bodyParams: params
        });
    }
    async deleteOrganization(organizationId) {
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath17, organizationId)
        });
    }
    async getOrganizationMembershipList(params) {
        const { organizationId, ...queryParams } = params;
        this.requireId(organizationId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath17, organizationId, "memberships"),
            queryParams
        });
    }
    async getInstanceOrganizationMembershipList(params) {
        return this.request({
            method: "GET",
            path: "/organization_memberships",
            queryParams: params
        });
    }
    async createOrganizationMembership(params) {
        const { organizationId, ...bodyParams } = params;
        this.requireId(organizationId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath17, organizationId, "memberships"),
            bodyParams
        });
    }
    async updateOrganizationMembership(params) {
        const { organizationId, userId, ...bodyParams } = params;
        this.requireId(organizationId);
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath17, organizationId, "memberships", userId),
            bodyParams
        });
    }
    async updateOrganizationMembershipMetadata(params) {
        const { organizationId, userId, ...bodyParams } = params;
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath17, organizationId, "memberships", userId, "metadata"),
            bodyParams
        });
    }
    async deleteOrganizationMembership(params) {
        const { organizationId, userId } = params;
        this.requireId(organizationId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath17, organizationId, "memberships", userId)
        });
    }
    async getOrganizationInvitationList(params) {
        const { organizationId, ...queryParams } = params;
        this.requireId(organizationId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath17, organizationId, "invitations"),
            queryParams
        });
    }
    async createOrganizationInvitation(params) {
        const { organizationId, ...bodyParams } = params;
        this.requireId(organizationId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath17, organizationId, "invitations"),
            bodyParams
        });
    }
    async createOrganizationInvitationBulk(organizationId, params) {
        this.requireId(organizationId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath17, organizationId, "invitations", "bulk"),
            bodyParams: params
        });
    }
    async getOrganizationInvitation(params) {
        const { organizationId, invitationId } = params;
        this.requireId(organizationId);
        this.requireId(invitationId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath17, organizationId, "invitations", invitationId)
        });
    }
    async revokeOrganizationInvitation(params) {
        const { organizationId, invitationId, ...bodyParams } = params;
        this.requireId(organizationId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath17, organizationId, "invitations", invitationId, "revoke"),
            bodyParams
        });
    }
    async getOrganizationDomainList(params) {
        const { organizationId, ...queryParams } = params;
        this.requireId(organizationId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath17, organizationId, "domains"),
            queryParams
        });
    }
    async createOrganizationDomain(params) {
        const { organizationId, ...bodyParams } = params;
        this.requireId(organizationId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath17, organizationId, "domains"),
            bodyParams: {
                ...bodyParams,
                verified: bodyParams.verified ?? true
            }
        });
    }
    async updateOrganizationDomain(params) {
        const { organizationId, domainId, ...bodyParams } = params;
        this.requireId(organizationId);
        this.requireId(domainId);
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath17, organizationId, "domains", domainId),
            bodyParams
        });
    }
    async deleteOrganizationDomain(params) {
        const { organizationId, domainId } = params;
        this.requireId(organizationId);
        this.requireId(domainId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath17, organizationId, "domains", domainId)
        });
    }
};
// src/api/endpoints/OAuthApplicationsApi.ts
var basePath18 = "/oauth_applications";
var OAuthApplicationsApi = class extends AbstractAPI {
    async list(params = {}) {
        return this.request({
            method: "GET",
            path: basePath18,
            queryParams: params
        });
    }
    async get(oauthApplicationId) {
        this.requireId(oauthApplicationId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath18, oauthApplicationId)
        });
    }
    async create(params) {
        return this.request({
            method: "POST",
            path: basePath18,
            bodyParams: params
        });
    }
    async update(params) {
        const { oauthApplicationId, ...bodyParams } = params;
        this.requireId(oauthApplicationId);
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath18, oauthApplicationId),
            bodyParams
        });
    }
    async delete(oauthApplicationId) {
        this.requireId(oauthApplicationId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath18, oauthApplicationId)
        });
    }
    async rotateSecret(oauthApplicationId) {
        this.requireId(oauthApplicationId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath18, oauthApplicationId, "rotate_secret")
        });
    }
};
// src/api/endpoints/PhoneNumberApi.ts
var basePath19 = "/phone_numbers";
var PhoneNumberAPI = class extends AbstractAPI {
    async getPhoneNumber(phoneNumberId) {
        this.requireId(phoneNumberId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath19, phoneNumberId)
        });
    }
    async createPhoneNumber(params) {
        return this.request({
            method: "POST",
            path: basePath19,
            bodyParams: params
        });
    }
    async updatePhoneNumber(phoneNumberId, params = {}) {
        this.requireId(phoneNumberId);
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath19, phoneNumberId),
            bodyParams: params
        });
    }
    async deletePhoneNumber(phoneNumberId) {
        this.requireId(phoneNumberId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath19, phoneNumberId)
        });
    }
};
// src/api/endpoints/ProxyCheckApi.ts
var basePath20 = "/proxy_checks";
var ProxyCheckAPI = class extends AbstractAPI {
    async verify(params) {
        return this.request({
            method: "POST",
            path: basePath20,
            bodyParams: params
        });
    }
};
// src/api/endpoints/RedirectUrlApi.ts
var basePath21 = "/redirect_urls";
var RedirectUrlAPI = class extends AbstractAPI {
    async getRedirectUrlList() {
        return this.request({
            method: "GET",
            path: basePath21,
            queryParams: {
                paginated: true
            }
        });
    }
    async getRedirectUrl(redirectUrlId) {
        this.requireId(redirectUrlId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath21, redirectUrlId)
        });
    }
    async createRedirectUrl(params) {
        return this.request({
            method: "POST",
            path: basePath21,
            bodyParams: params
        });
    }
    async deleteRedirectUrl(redirectUrlId) {
        this.requireId(redirectUrlId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath21, redirectUrlId)
        });
    }
};
// src/api/endpoints/SamlConnectionApi.ts
var basePath22 = "/saml_connections";
var SamlConnectionAPI = class extends AbstractAPI {
    async getSamlConnectionList(params = {}) {
        return this.request({
            method: "GET",
            path: basePath22,
            queryParams: params
        });
    }
    async createSamlConnection(params) {
        return this.request({
            method: "POST",
            path: basePath22,
            bodyParams: params,
            options: {
                deepSnakecaseBodyParamKeys: true
            }
        });
    }
    async getSamlConnection(samlConnectionId) {
        this.requireId(samlConnectionId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath22, samlConnectionId)
        });
    }
    async updateSamlConnection(samlConnectionId, params = {}) {
        this.requireId(samlConnectionId);
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath22, samlConnectionId),
            bodyParams: params,
            options: {
                deepSnakecaseBodyParamKeys: true
            }
        });
    }
    async deleteSamlConnection(samlConnectionId) {
        this.requireId(samlConnectionId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath22, samlConnectionId)
        });
    }
};
// src/api/endpoints/SessionApi.ts
var basePath23 = "/sessions";
var SessionAPI = class extends AbstractAPI {
    async getSessionList(params = {}) {
        return this.request({
            method: "GET",
            path: basePath23,
            queryParams: {
                ...params,
                paginated: true
            }
        });
    }
    async getSession(sessionId) {
        this.requireId(sessionId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath23, sessionId)
        });
    }
    async createSession(params) {
        return this.request({
            method: "POST",
            path: basePath23,
            bodyParams: params
        });
    }
    async revokeSession(sessionId) {
        this.requireId(sessionId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath23, sessionId, "revoke")
        });
    }
    async verifySession(sessionId, token) {
        this.requireId(sessionId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath23, sessionId, "verify"),
            bodyParams: {
                token
            }
        });
    }
    /**
   * Retrieves a session token or generates a JWT using a specified template.
   *
   * @param sessionId - The ID of the session for which to generate the token
   * @param template - Optional name of the JWT template configured in the Clerk Dashboard.
   * @param expiresInSeconds - Optional expiration time for the token in seconds.
   *   If not provided, uses the default expiration.
   *
   * @returns A promise that resolves to the generated token
   *
   * @throws {Error} When sessionId is invalid or empty
   */ async getToken(sessionId, template, expiresInSeconds) {
        this.requireId(sessionId);
        const path = template ? joinPaths(basePath23, sessionId, "tokens", template) : joinPaths(basePath23, sessionId, "tokens");
        const requestOptions = {
            method: "POST",
            path
        };
        if (expiresInSeconds !== void 0) {
            requestOptions.bodyParams = {
                expires_in_seconds: expiresInSeconds
            };
        }
        return this.request(requestOptions);
    }
    async refreshSession(sessionId, params) {
        this.requireId(sessionId);
        const { suffixed_cookies, ...restParams } = params;
        return this.request({
            method: "POST",
            path: joinPaths(basePath23, sessionId, "refresh"),
            bodyParams: restParams,
            queryParams: {
                suffixed_cookies
            }
        });
    }
};
// src/api/endpoints/SignInTokenApi.ts
var basePath24 = "/sign_in_tokens";
var SignInTokenAPI = class extends AbstractAPI {
    async createSignInToken(params) {
        return this.request({
            method: "POST",
            path: basePath24,
            bodyParams: params
        });
    }
    async revokeSignInToken(signInTokenId) {
        this.requireId(signInTokenId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath24, signInTokenId, "revoke")
        });
    }
};
// src/api/endpoints/SignUpApi.ts
var basePath25 = "/sign_ups";
var SignUpAPI = class extends AbstractAPI {
    async get(signUpAttemptId) {
        this.requireId(signUpAttemptId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath25, signUpAttemptId)
        });
    }
    async update(params) {
        const { signUpAttemptId, ...bodyParams } = params;
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath25, signUpAttemptId),
            bodyParams
        });
    }
};
// src/api/endpoints/TestingTokenApi.ts
var basePath26 = "/testing_tokens";
var TestingTokenAPI = class extends AbstractAPI {
    async createTestingToken() {
        return this.request({
            method: "POST",
            path: basePath26
        });
    }
};
// src/api/endpoints/UserApi.ts
var basePath27 = "/users";
var UserAPI = class extends AbstractAPI {
    async getUserList(params = {}) {
        const { limit, offset, orderBy, ...userCountParams } = params;
        const [data, totalCount] = await Promise.all([
            this.request({
                method: "GET",
                path: basePath27,
                queryParams: params
            }),
            this.getCount(userCountParams)
        ]);
        return {
            data,
            totalCount
        };
    }
    async getUser(userId) {
        this.requireId(userId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath27, userId)
        });
    }
    async createUser(params) {
        return this.request({
            method: "POST",
            path: basePath27,
            bodyParams: params
        });
    }
    async updateUser(userId, params = {}) {
        this.requireId(userId);
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath27, userId),
            bodyParams: params
        });
    }
    async updateUserProfileImage(userId, params) {
        this.requireId(userId);
        const formData = new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["runtime"].FormData();
        formData.append("file", params?.file);
        return this.request({
            method: "POST",
            path: joinPaths(basePath27, userId, "profile_image"),
            formData
        });
    }
    async updateUserMetadata(userId, params) {
        this.requireId(userId);
        return this.request({
            method: "PATCH",
            path: joinPaths(basePath27, userId, "metadata"),
            bodyParams: params
        });
    }
    async deleteUser(userId) {
        this.requireId(userId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath27, userId)
        });
    }
    async getCount(params = {}) {
        return this.request({
            method: "GET",
            path: joinPaths(basePath27, "count"),
            queryParams: params
        });
    }
    async getUserOauthAccessToken(userId, provider) {
        this.requireId(userId);
        const hasPrefix = provider.startsWith("oauth_");
        const _provider = hasPrefix ? provider : `oauth_${provider}`;
        if (hasPrefix) {
            (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$deprecated$2d$BqlFbLHj$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["deprecated"])("getUserOauthAccessToken(userId, provider)", "Remove the `oauth_` prefix from the `provider` argument.");
        }
        return this.request({
            method: "GET",
            path: joinPaths(basePath27, userId, "oauth_access_tokens", _provider),
            queryParams: {
                paginated: true
            }
        });
    }
    async disableUserMFA(userId) {
        this.requireId(userId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath27, userId, "mfa")
        });
    }
    async getOrganizationMembershipList(params) {
        const { userId, limit, offset } = params;
        this.requireId(userId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath27, userId, "organization_memberships"),
            queryParams: {
                limit,
                offset
            }
        });
    }
    async getOrganizationInvitationList(params) {
        const { userId, ...queryParams } = params;
        this.requireId(userId);
        return this.request({
            method: "GET",
            path: joinPaths(basePath27, userId, "organization_invitations"),
            queryParams
        });
    }
    async verifyPassword(params) {
        const { userId, password } = params;
        this.requireId(userId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath27, userId, "verify_password"),
            bodyParams: {
                password
            }
        });
    }
    async verifyTOTP(params) {
        const { userId, code } = params;
        this.requireId(userId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath27, userId, "verify_totp"),
            bodyParams: {
                code
            }
        });
    }
    async banUser(userId) {
        this.requireId(userId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath27, userId, "ban")
        });
    }
    async unbanUser(userId) {
        this.requireId(userId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath27, userId, "unban")
        });
    }
    async lockUser(userId) {
        this.requireId(userId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath27, userId, "lock")
        });
    }
    async unlockUser(userId) {
        this.requireId(userId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath27, userId, "unlock")
        });
    }
    async deleteUserProfileImage(userId) {
        this.requireId(userId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath27, userId, "profile_image")
        });
    }
    async deleteUserPasskey(params) {
        this.requireId(params.userId);
        this.requireId(params.passkeyIdentificationId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath27, params.userId, "passkeys", params.passkeyIdentificationId)
        });
    }
    async deleteUserWeb3Wallet(params) {
        this.requireId(params.userId);
        this.requireId(params.web3WalletIdentificationId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath27, params.userId, "web3_wallets", params.web3WalletIdentificationId)
        });
    }
    async deleteUserExternalAccount(params) {
        this.requireId(params.userId);
        this.requireId(params.externalAccountId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath27, params.userId, "external_accounts", params.externalAccountId)
        });
    }
    async deleteUserBackupCodes(userId) {
        this.requireId(userId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath27, userId, "backup_code")
        });
    }
    async deleteUserTOTP(userId) {
        this.requireId(userId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath27, userId, "totp")
        });
    }
    async __experimental_passwordCompromised(userId) {
        this.requireId(userId);
        return this.request({
            method: "POST",
            path: joinPaths(basePath27, userId, "password_compromised"),
            bodyParams: {
                revokeAllSessions: false
            }
        });
    }
};
// src/api/endpoints/WaitlistEntryApi.ts
var basePath28 = "/waitlist_entries";
var WaitlistEntryAPI = class extends AbstractAPI {
    /**
   * List waitlist entries.
   * @param params Optional parameters (e.g., `query`, `status`, `orderBy`).
   */ async list(params = {}) {
        return this.request({
            method: "GET",
            path: basePath28,
            queryParams: params
        });
    }
    /**
   * Create a waitlist entry.
   * @param params The parameters for creating a waitlist entry.
   */ async create(params) {
        return this.request({
            method: "POST",
            path: basePath28,
            bodyParams: params
        });
    }
    /**
   * Invite a waitlist entry.
   * @param id The waitlist entry ID.
   * @param params Optional parameters (e.g., `ignoreExisting`).
   */ async invite(id, params = {}) {
        this.requireId(id);
        return this.request({
            method: "POST",
            path: joinPaths(basePath28, id, "invite"),
            bodyParams: params
        });
    }
    /**
   * Reject a waitlist entry.
   * @param id The waitlist entry ID.
   */ async reject(id) {
        this.requireId(id);
        return this.request({
            method: "POST",
            path: joinPaths(basePath28, id, "reject")
        });
    }
    /**
   * Delete a waitlist entry.
   * @param id The waitlist entry ID.
   */ async delete(id) {
        this.requireId(id);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath28, id)
        });
    }
};
// src/api/endpoints/WebhookApi.ts
var basePath29 = "/webhooks";
var WebhookAPI = class extends AbstractAPI {
    async createSvixApp() {
        return this.request({
            method: "POST",
            path: joinPaths(basePath29, "svix")
        });
    }
    async generateSvixAuthURL() {
        return this.request({
            method: "POST",
            path: joinPaths(basePath29, "svix_url")
        });
    }
    async deleteSvixApp() {
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath29, "svix")
        });
    }
};
// src/api/endpoints/BillingApi.ts
var basePath30 = "/billing";
var organizationBasePath = "/organizations";
var userBasePath = "/users";
var BillingAPI = class extends AbstractAPI {
    /**
   * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
   */ async getPlanList(params) {
        return this.request({
            method: "GET",
            path: joinPaths(basePath30, "plans"),
            queryParams: params
        });
    }
    /**
   * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
   */ async cancelSubscriptionItem(subscriptionItemId, params) {
        this.requireId(subscriptionItemId);
        return this.request({
            method: "DELETE",
            path: joinPaths(basePath30, "subscription_items", subscriptionItemId),
            queryParams: params
        });
    }
    /**
   * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
   */ async extendSubscriptionItemFreeTrial(subscriptionItemId, params) {
        this.requireId(subscriptionItemId);
        return this.request({
            method: "POST",
            path: joinPaths("/billing", "subscription_items", subscriptionItemId, "extend_free_trial"),
            bodyParams: params
        });
    }
    /**
   * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
   */ async getOrganizationBillingSubscription(organizationId) {
        this.requireId(organizationId);
        return this.request({
            method: "GET",
            path: joinPaths(organizationBasePath, organizationId, "billing", "subscription")
        });
    }
    /**
   * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
   */ async getUserBillingSubscription(userId) {
        this.requireId(userId);
        return this.request({
            method: "GET",
            path: joinPaths(userBasePath, userId, "billing", "subscription")
        });
    }
};
;
// ../../node_modules/.pnpm/map-obj@5.0.2/node_modules/map-obj/index.js
var isObject = (value)=>typeof value === "object" && value !== null;
var isObjectCustom = (value)=>isObject(value) && !(value instanceof RegExp) && !(value instanceof Error) && !(value instanceof Date) && !(globalThis.Blob && value instanceof globalThis.Blob);
var mapObjectSkip = Symbol("mapObjectSkip");
var _mapObject = (object, mapper, options, isSeen = /* @__PURE__ */ new WeakMap())=>{
    options = {
        deep: false,
        target: {},
        ...options
    };
    if (isSeen.has(object)) {
        return isSeen.get(object);
    }
    isSeen.set(object, options.target);
    const { target } = options;
    delete options.target;
    const mapArray = (array)=>array.map((element)=>isObjectCustom(element) ? _mapObject(element, mapper, options, isSeen) : element);
    if (Array.isArray(object)) {
        return mapArray(object);
    }
    for (const [key, value] of Object.entries(object)){
        const mapResult = mapper(key, value, object);
        if (mapResult === mapObjectSkip) {
            continue;
        }
        let [newKey, newValue, { shouldRecurse = true } = {}] = mapResult;
        if (newKey === "__proto__") {
            continue;
        }
        if (options.deep && shouldRecurse && isObjectCustom(newValue)) {
            newValue = Array.isArray(newValue) ? mapArray(newValue) : _mapObject(newValue, mapper, options, isSeen);
        }
        target[newKey] = newValue;
    }
    return target;
};
function mapObject(object, mapper, options) {
    if (!isObject(object)) {
        throw new TypeError(`Expected an object, got \`${object}\` (${typeof object})`);
    }
    if (Array.isArray(object)) {
        throw new TypeError("Expected an object, got an array");
    }
    return _mapObject(object, mapper, options);
}
// ../../node_modules/.pnpm/change-case@5.4.4/node_modules/change-case/dist/index.js
var SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
var SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
var SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
var DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
var SPLIT_REPLACE_VALUE = "$1\0$2";
var DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
function split(value) {
    let result = value.trim();
    result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
    result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
    let start = 0;
    let end = result.length;
    while(result.charAt(start) === "\0")start++;
    if (start === end) return [];
    while(result.charAt(end - 1) === "\0")end--;
    return result.slice(start, end).split(/\0/g);
}
function splitSeparateNumbers(value) {
    const words = split(value);
    for(let i = 0; i < words.length; i++){
        const word = words[i];
        const match2 = SPLIT_SEPARATE_NUMBER_RE.exec(word);
        if (match2) {
            const offset = match2.index + (match2[1] ?? match2[2]).length;
            words.splice(i, 1, word.slice(0, offset), word.slice(offset));
        }
    }
    return words;
}
function noCase(input, options) {
    const [prefix, words, suffix] = splitPrefixSuffix(input, options);
    return prefix + words.map(lowerFactory(options?.locale)).join(options?.delimiter ?? " ") + suffix;
}
function snakeCase(input, options) {
    return noCase(input, {
        delimiter: "_",
        ...options
    });
}
function lowerFactory(locale) {
    return locale === false ? (input)=>input.toLowerCase() : (input)=>input.toLocaleLowerCase(locale);
}
function splitPrefixSuffix(input, options = {}) {
    const splitFn = options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);
    const prefixCharacters = options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
    const suffixCharacters = options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
    let prefixIndex = 0;
    let suffixIndex = input.length;
    while(prefixIndex < input.length){
        const char = input.charAt(prefixIndex);
        if (!prefixCharacters.includes(char)) break;
        prefixIndex++;
    }
    while(suffixIndex > prefixIndex){
        const index = suffixIndex - 1;
        const char = input.charAt(index);
        if (!suffixCharacters.includes(char)) break;
        suffixIndex = index;
    }
    return [
        input.slice(0, prefixIndex),
        splitFn(input.slice(prefixIndex, suffixIndex)),
        input.slice(suffixIndex)
    ];
}
// ../../node_modules/.pnpm/snakecase-keys@9.0.2/node_modules/snakecase-keys/index.js
var PlainObjectConstructor = {}.constructor;
function snakecaseKeys(obj, options) {
    if (Array.isArray(obj)) {
        if (obj.some((item)=>item.constructor !== PlainObjectConstructor)) {
            throw new Error("obj must be array of plain objects");
        }
        options = {
            deep: true,
            exclude: [],
            parsingOptions: {},
            ...options
        };
        const convertCase2 = options.snakeCase || ((key)=>snakeCase(key, options.parsingOptions));
        return obj.map((item)=>{
            return mapObject(item, (key, val)=>{
                return [
                    matches(options.exclude, key) ? key : convertCase2(key),
                    val,
                    mapperOptions(key, val, options)
                ];
            }, options);
        });
    } else {
        if (obj.constructor !== PlainObjectConstructor) {
            throw new Error("obj must be an plain object");
        }
    }
    options = {
        deep: true,
        exclude: [],
        parsingOptions: {},
        ...options
    };
    const convertCase = options.snakeCase || ((key)=>snakeCase(key, options.parsingOptions));
    return mapObject(obj, (key, val)=>{
        return [
            matches(options.exclude, key) ? key : convertCase(key),
            val,
            mapperOptions(key, val, options)
        ];
    }, options);
}
function matches(patterns, value) {
    return patterns.some((pattern)=>{
        return typeof pattern === "string" ? pattern === value : pattern.test(value);
    });
}
function mapperOptions(key, val, options) {
    return options.shouldRecurse ? {
        shouldRecurse: options.shouldRecurse(key, val)
    } : void 0;
}
var snakecase_keys_default = snakecaseKeys;
// src/api/resources/AccountlessApplication.ts
var AccountlessApplication = class _AccountlessApplication {
    constructor(publishableKey, secretKey, claimUrl, apiKeysUrl){
        this.publishableKey = publishableKey;
        this.secretKey = secretKey;
        this.claimUrl = claimUrl;
        this.apiKeysUrl = apiKeysUrl;
    }
    static fromJSON(data) {
        return new _AccountlessApplication(data.publishable_key, data.secret_key, data.claim_url, data.api_keys_url);
    }
};
// src/api/resources/ActorToken.ts
var ActorToken = class _ActorToken {
    constructor(id, status, userId, actor, token, url, createdAt, updatedAt){
        this.id = id;
        this.status = status;
        this.userId = userId;
        this.actor = actor;
        this.token = token;
        this.url = url;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
    }
    static fromJSON(data) {
        return new _ActorToken(data.id, data.status, data.user_id, data.actor, data.token, data.url, data.created_at, data.updated_at);
    }
};
// src/api/resources/AllowlistIdentifier.ts
var AllowlistIdentifier = class _AllowlistIdentifier {
    constructor(id, identifier, identifierType, createdAt, updatedAt, instanceId, invitationId){
        this.id = id;
        this.identifier = identifier;
        this.identifierType = identifierType;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.instanceId = instanceId;
        this.invitationId = invitationId;
    }
    static fromJSON(data) {
        return new _AllowlistIdentifier(data.id, data.identifier, data.identifier_type, data.created_at, data.updated_at, data.instance_id, data.invitation_id);
    }
};
// src/api/resources/APIKey.ts
var APIKey = class _APIKey {
    constructor(id, type, name, subject, scopes, claims, revoked, revocationReason, expired, expiration, createdBy, description, lastUsedAt, createdAt, updatedAt, secret){
        this.id = id;
        this.type = type;
        this.name = name;
        this.subject = subject;
        this.scopes = scopes;
        this.claims = claims;
        this.revoked = revoked;
        this.revocationReason = revocationReason;
        this.expired = expired;
        this.expiration = expiration;
        this.createdBy = createdBy;
        this.description = description;
        this.lastUsedAt = lastUsedAt;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.secret = secret;
    }
    static fromJSON(data) {
        return new _APIKey(data.id, data.type, data.name, data.subject, data.scopes, data.claims, data.revoked, data.revocation_reason, data.expired, data.expiration, data.created_by, data.description, data.last_used_at, data.created_at, data.updated_at, data.secret);
    }
};
// src/api/resources/BlocklistIdentifier.ts
var BlocklistIdentifier = class _BlocklistIdentifier {
    constructor(id, identifier, identifierType, createdAt, updatedAt, instanceId){
        this.id = id;
        this.identifier = identifier;
        this.identifierType = identifierType;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.instanceId = instanceId;
    }
    static fromJSON(data) {
        return new _BlocklistIdentifier(data.id, data.identifier, data.identifier_type, data.created_at, data.updated_at, data.instance_id);
    }
};
// src/api/resources/Session.ts
var SessionActivity = class _SessionActivity {
    constructor(id, isMobile, ipAddress, city, country, browserVersion, browserName, deviceType){
        this.id = id;
        this.isMobile = isMobile;
        this.ipAddress = ipAddress;
        this.city = city;
        this.country = country;
        this.browserVersion = browserVersion;
        this.browserName = browserName;
        this.deviceType = deviceType;
    }
    static fromJSON(data) {
        return new _SessionActivity(data.id, data.is_mobile, data.ip_address, data.city, data.country, data.browser_version, data.browser_name, data.device_type);
    }
};
var Session = class _Session {
    constructor(id, clientId, userId, status, lastActiveAt, expireAt, abandonAt, createdAt, updatedAt, lastActiveOrganizationId, latestActivity, actor = null){
        this.id = id;
        this.clientId = clientId;
        this.userId = userId;
        this.status = status;
        this.lastActiveAt = lastActiveAt;
        this.expireAt = expireAt;
        this.abandonAt = abandonAt;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.lastActiveOrganizationId = lastActiveOrganizationId;
        this.latestActivity = latestActivity;
        this.actor = actor;
    }
    static fromJSON(data) {
        return new _Session(data.id, data.client_id, data.user_id, data.status, data.last_active_at, data.expire_at, data.abandon_at, data.created_at, data.updated_at, data.last_active_organization_id, data.latest_activity && SessionActivity.fromJSON(data.latest_activity), data.actor);
    }
};
// src/api/resources/Client.ts
var Client = class _Client {
    constructor(id, sessionIds, sessions, signInId, signUpId, lastActiveSessionId, lastAuthenticationStrategy, createdAt, updatedAt){
        this.id = id;
        this.sessionIds = sessionIds;
        this.sessions = sessions;
        this.signInId = signInId;
        this.signUpId = signUpId;
        this.lastActiveSessionId = lastActiveSessionId;
        this.lastAuthenticationStrategy = lastAuthenticationStrategy;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
    }
    static fromJSON(data) {
        return new _Client(data.id, data.session_ids, data.sessions.map((x)=>Session.fromJSON(x)), data.sign_in_id, data.sign_up_id, data.last_active_session_id, data.last_authentication_strategy, data.created_at, data.updated_at);
    }
};
// src/api/resources/CnameTarget.ts
var CnameTarget = class _CnameTarget {
    constructor(host, value, required){
        this.host = host;
        this.value = value;
        this.required = required;
    }
    static fromJSON(data) {
        return new _CnameTarget(data.host, data.value, data.required);
    }
};
// src/api/resources/Cookies.ts
var Cookies2 = class _Cookies {
    constructor(cookies){
        this.cookies = cookies;
    }
    static fromJSON(data) {
        return new _Cookies(data.cookies);
    }
};
// src/api/resources/DeletedObject.ts
var DeletedObject = class _DeletedObject {
    constructor(object, id, slug, deleted){
        this.object = object;
        this.id = id;
        this.slug = slug;
        this.deleted = deleted;
    }
    static fromJSON(data) {
        return new _DeletedObject(data.object, data.id || null, data.slug || null, data.deleted);
    }
};
// src/api/resources/Domain.ts
var Domain = class _Domain {
    constructor(id, name, isSatellite, frontendApiUrl, developmentOrigin, cnameTargets, accountsPortalUrl, proxyUrl){
        this.id = id;
        this.name = name;
        this.isSatellite = isSatellite;
        this.frontendApiUrl = frontendApiUrl;
        this.developmentOrigin = developmentOrigin;
        this.cnameTargets = cnameTargets;
        this.accountsPortalUrl = accountsPortalUrl;
        this.proxyUrl = proxyUrl;
    }
    static fromJSON(data) {
        return new _Domain(data.id, data.name, data.is_satellite, data.frontend_api_url, data.development_origin, data.cname_targets && data.cname_targets.map((x)=>CnameTarget.fromJSON(x)), data.accounts_portal_url, data.proxy_url);
    }
};
// src/api/resources/Email.ts
var Email = class _Email {
    constructor(id, fromEmailName, emailAddressId, toEmailAddress, subject, body, bodyPlain, status, slug, data, deliveredByClerk){
        this.id = id;
        this.fromEmailName = fromEmailName;
        this.emailAddressId = emailAddressId;
        this.toEmailAddress = toEmailAddress;
        this.subject = subject;
        this.body = body;
        this.bodyPlain = bodyPlain;
        this.status = status;
        this.slug = slug;
        this.data = data;
        this.deliveredByClerk = deliveredByClerk;
    }
    static fromJSON(data) {
        return new _Email(data.id, data.from_email_name, data.email_address_id, data.to_email_address, data.subject, data.body, data.body_plain, data.status, data.slug, data.data, data.delivered_by_clerk);
    }
};
// src/api/resources/IdentificationLink.ts
var IdentificationLink = class _IdentificationLink {
    constructor(id, type){
        this.id = id;
        this.type = type;
    }
    static fromJSON(data) {
        return new _IdentificationLink(data.id, data.type);
    }
};
// src/api/resources/Verification.ts
var Verification = class _Verification {
    constructor(status, strategy, externalVerificationRedirectURL = null, attempts = null, expireAt = null, nonce = null, message = null){
        this.status = status;
        this.strategy = strategy;
        this.externalVerificationRedirectURL = externalVerificationRedirectURL;
        this.attempts = attempts;
        this.expireAt = expireAt;
        this.nonce = nonce;
        this.message = message;
    }
    static fromJSON(data) {
        return new _Verification(data.status, data.strategy, data.external_verification_redirect_url ? new URL(data.external_verification_redirect_url) : null, data.attempts, data.expire_at, data.nonce);
    }
};
// src/api/resources/EmailAddress.ts
var EmailAddress = class _EmailAddress {
    constructor(id, emailAddress, verification, linkedTo){
        this.id = id;
        this.emailAddress = emailAddress;
        this.verification = verification;
        this.linkedTo = linkedTo;
    }
    static fromJSON(data) {
        return new _EmailAddress(data.id, data.email_address, data.verification && Verification.fromJSON(data.verification), data.linked_to.map((link)=>IdentificationLink.fromJSON(link)));
    }
};
// src/api/resources/ExternalAccount.ts
var ExternalAccount = class _ExternalAccount {
    constructor(id, provider, identificationId, externalId, approvedScopes, emailAddress, firstName, lastName, imageUrl, username, phoneNumber, publicMetadata = {}, label, verification){
        this.id = id;
        this.provider = provider;
        this.identificationId = identificationId;
        this.externalId = externalId;
        this.approvedScopes = approvedScopes;
        this.emailAddress = emailAddress;
        this.firstName = firstName;
        this.lastName = lastName;
        this.imageUrl = imageUrl;
        this.username = username;
        this.phoneNumber = phoneNumber;
        this.publicMetadata = publicMetadata;
        this.label = label;
        this.verification = verification;
    }
    static fromJSON(data) {
        return new _ExternalAccount(data.id, data.provider, data.identification_id, data.provider_user_id, data.approved_scopes, data.email_address, data.first_name, data.last_name, data.image_url || "", data.username, data.phone_number, data.public_metadata, data.label, data.verification && Verification.fromJSON(data.verification));
    }
};
// src/api/resources/IdPOAuthAccessToken.ts
var IdPOAuthAccessToken = class _IdPOAuthAccessToken {
    constructor(id, clientId, type, subject, scopes, revoked, revocationReason, expired, expiration, createdAt, updatedAt){
        this.id = id;
        this.clientId = clientId;
        this.type = type;
        this.subject = subject;
        this.scopes = scopes;
        this.revoked = revoked;
        this.revocationReason = revocationReason;
        this.expired = expired;
        this.expiration = expiration;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
    }
    static fromJSON(data) {
        return new _IdPOAuthAccessToken(data.id, data.client_id, data.type, data.subject, data.scopes, data.revoked, data.revocation_reason, data.expired, data.expiration, data.created_at, data.updated_at);
    }
    /**
   * Creates an IdPOAuthAccessToken from a JWT payload.
   * Maps standard JWT claims and OAuth-specific fields to token properties.
   */ static fromJwtPayload(payload, clockSkewInMs = 5e3) {
        const oauthPayload = payload;
        return new _IdPOAuthAccessToken(oauthPayload.jti ?? "", oauthPayload.client_id ?? "", "oauth_token", payload.sub, oauthPayload.scp ?? oauthPayload.scope?.split(" ") ?? [], false, null, payload.exp * 1e3 <= Date.now() - clockSkewInMs, payload.exp, payload.iat, payload.iat);
    }
};
// src/api/resources/Instance.ts
var Instance = class _Instance {
    constructor(id, environmentType, allowedOrigins){
        this.id = id;
        this.environmentType = environmentType;
        this.allowedOrigins = allowedOrigins;
    }
    static fromJSON(data) {
        return new _Instance(data.id, data.environment_type, data.allowed_origins);
    }
};
// src/api/resources/InstanceRestrictions.ts
var InstanceRestrictions = class _InstanceRestrictions {
    constructor(allowlist, blocklist, blockEmailSubaddresses, blockDisposableEmailDomains, ignoreDotsForGmailAddresses){
        this.allowlist = allowlist;
        this.blocklist = blocklist;
        this.blockEmailSubaddresses = blockEmailSubaddresses;
        this.blockDisposableEmailDomains = blockDisposableEmailDomains;
        this.ignoreDotsForGmailAddresses = ignoreDotsForGmailAddresses;
    }
    static fromJSON(data) {
        return new _InstanceRestrictions(data.allowlist, data.blocklist, data.block_email_subaddresses, data.block_disposable_email_domains, data.ignore_dots_for_gmail_addresses);
    }
};
// src/api/resources/InstanceSettings.ts
var InstanceSettings = class _InstanceSettings {
    constructor(id, restrictedToAllowlist, fromEmailAddress, progressiveSignUp, enhancedEmailDeliverability){
        this.id = id;
        this.restrictedToAllowlist = restrictedToAllowlist;
        this.fromEmailAddress = fromEmailAddress;
        this.progressiveSignUp = progressiveSignUp;
        this.enhancedEmailDeliverability = enhancedEmailDeliverability;
    }
    static fromJSON(data) {
        return new _InstanceSettings(data.id, data.restricted_to_allowlist, data.from_email_address, data.progressive_sign_up, data.enhanced_email_deliverability);
    }
};
// src/api/resources/Invitation.ts
var Invitation = class _Invitation {
    constructor(id, emailAddress, publicMetadata, createdAt, updatedAt, status, url, revoked){
        this.id = id;
        this.emailAddress = emailAddress;
        this.publicMetadata = publicMetadata;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.status = status;
        this.url = url;
        this.revoked = revoked;
        this._raw = null;
    }
    get raw() {
        return this._raw;
    }
    static fromJSON(data) {
        const res = new _Invitation(data.id, data.email_address, data.public_metadata, data.created_at, data.updated_at, data.status, data.url, data.revoked);
        res._raw = data;
        return res;
    }
};
// src/api/resources/JSON.ts
var ObjectType = {
    AccountlessApplication: "accountless_application",
    ActorToken: "actor_token",
    AllowlistIdentifier: "allowlist_identifier",
    ApiKey: "api_key",
    BlocklistIdentifier: "blocklist_identifier",
    Client: "client",
    Cookies: "cookies",
    Domain: "domain",
    Email: "email",
    EmailAddress: "email_address",
    ExternalAccount: "external_account",
    FacebookAccount: "facebook_account",
    GoogleAccount: "google_account",
    Instance: "instance",
    InstanceRestrictions: "instance_restrictions",
    InstanceSettings: "instance_settings",
    Invitation: "invitation",
    Machine: "machine",
    MachineScope: "machine_scope",
    MachineSecretKey: "machine_secret_key",
    M2MToken: "machine_to_machine_token",
    JwtTemplate: "jwt_template",
    OauthAccessToken: "oauth_access_token",
    IdpOAuthAccessToken: "clerk_idp_oauth_access_token",
    OAuthApplication: "oauth_application",
    Organization: "organization",
    OrganizationDomain: "organization_domain",
    OrganizationInvitation: "organization_invitation",
    OrganizationMembership: "organization_membership",
    OrganizationSettings: "organization_settings",
    PhoneNumber: "phone_number",
    ProxyCheck: "proxy_check",
    RedirectUrl: "redirect_url",
    SamlAccount: "saml_account",
    SamlConnection: "saml_connection",
    Session: "session",
    SignInAttempt: "sign_in_attempt",
    SignInToken: "sign_in_token",
    SignUpAttempt: "sign_up_attempt",
    SmsMessage: "sms_message",
    User: "user",
    WaitlistEntry: "waitlist_entry",
    Web3Wallet: "web3_wallet",
    Token: "token",
    TotalCount: "total_count",
    TestingToken: "testing_token",
    Role: "role",
    Permission: "permission",
    BillingPayer: "commerce_payer",
    BillingPaymentAttempt: "commerce_payment_attempt",
    BillingSubscription: "commerce_subscription",
    BillingSubscriptionItem: "commerce_subscription_item",
    BillingPlan: "commerce_plan",
    Feature: "feature"
};
// src/api/resources/Machine.ts
var Machine = class _Machine {
    constructor(id, name, instanceId, createdAt, updatedAt, scopedMachines, defaultTokenTtl, secretKey){
        this.id = id;
        this.name = name;
        this.instanceId = instanceId;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.scopedMachines = scopedMachines;
        this.defaultTokenTtl = defaultTokenTtl;
        this.secretKey = secretKey;
    }
    static fromJSON(data) {
        return new _Machine(data.id, data.name, data.instance_id, data.created_at, data.updated_at, data.scoped_machines.map((m)=>new _Machine(m.id, m.name, m.instance_id, m.created_at, m.updated_at, [], // Nested machines don't have scoped_machines
            m.default_token_ttl)), data.default_token_ttl, data.secret_key);
    }
};
// src/api/resources/MachineScope.ts
var MachineScope = class _MachineScope {
    constructor(fromMachineId, toMachineId, createdAt, deleted){
        this.fromMachineId = fromMachineId;
        this.toMachineId = toMachineId;
        this.createdAt = createdAt;
        this.deleted = deleted;
    }
    static fromJSON(data) {
        return new _MachineScope(data.from_machine_id, data.to_machine_id, data.created_at, data.deleted);
    }
};
// src/api/resources/MachineSecretKey.ts
var MachineSecretKey = class _MachineSecretKey {
    constructor(secret){
        this.secret = secret;
    }
    static fromJSON(data) {
        return new _MachineSecretKey(data.secret);
    }
};
// src/api/resources/M2MToken.ts
var M2MToken = class _M2MToken {
    constructor(id, subject, scopes, claims, revoked, revocationReason, expired, expiration, createdAt, updatedAt, token){
        this.id = id;
        this.subject = subject;
        this.scopes = scopes;
        this.claims = claims;
        this.revoked = revoked;
        this.revocationReason = revocationReason;
        this.expired = expired;
        this.expiration = expiration;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.token = token;
    }
    static fromJSON(data) {
        return new _M2MToken(data.id, data.subject, data.scopes, data.claims, data.revoked, data.revocation_reason, data.expired, data.expiration, data.created_at, data.updated_at, data.token);
    }
};
// src/api/resources/JwtTemplate.ts
var JwtTemplate = class _JwtTemplate {
    constructor(id, name, claims, lifetime, allowedClockSkew, customSigningKey, signingAlgorithm, createdAt, updatedAt){
        this.id = id;
        this.name = name;
        this.claims = claims;
        this.lifetime = lifetime;
        this.allowedClockSkew = allowedClockSkew;
        this.customSigningKey = customSigningKey;
        this.signingAlgorithm = signingAlgorithm;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
    }
    static fromJSON(data) {
        return new _JwtTemplate(data.id, data.name, data.claims, data.lifetime, data.allowed_clock_skew, data.custom_signing_key, data.signing_algorithm, data.created_at, data.updated_at);
    }
};
// src/api/resources/OauthAccessToken.ts
var OauthAccessToken = class _OauthAccessToken {
    constructor(externalAccountId, provider, token, publicMetadata = {}, label, scopes, tokenSecret, expiresAt){
        this.externalAccountId = externalAccountId;
        this.provider = provider;
        this.token = token;
        this.publicMetadata = publicMetadata;
        this.label = label;
        this.scopes = scopes;
        this.tokenSecret = tokenSecret;
        this.expiresAt = expiresAt;
    }
    static fromJSON(data) {
        return new _OauthAccessToken(data.external_account_id, data.provider, data.token, data.public_metadata, data.label || "", data.scopes, data.token_secret, data.expires_at);
    }
};
// src/api/resources/OAuthApplication.ts
var OAuthApplication = class _OAuthApplication {
    constructor(id, instanceId, name, clientId, clientUri, clientImageUrl, dynamicallyRegistered, consentScreenEnabled, pkceRequired, isPublic, scopes, redirectUris, authorizeUrl, tokenFetchUrl, userInfoUrl, discoveryUrl, tokenIntrospectionUrl, createdAt, updatedAt, clientSecret){
        this.id = id;
        this.instanceId = instanceId;
        this.name = name;
        this.clientId = clientId;
        this.clientUri = clientUri;
        this.clientImageUrl = clientImageUrl;
        this.dynamicallyRegistered = dynamicallyRegistered;
        this.consentScreenEnabled = consentScreenEnabled;
        this.pkceRequired = pkceRequired;
        this.isPublic = isPublic;
        this.scopes = scopes;
        this.redirectUris = redirectUris;
        this.authorizeUrl = authorizeUrl;
        this.tokenFetchUrl = tokenFetchUrl;
        this.userInfoUrl = userInfoUrl;
        this.discoveryUrl = discoveryUrl;
        this.tokenIntrospectionUrl = tokenIntrospectionUrl;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.clientSecret = clientSecret;
    }
    static fromJSON(data) {
        return new _OAuthApplication(data.id, data.instance_id, data.name, data.client_id, data.client_uri, data.client_image_url, data.dynamically_registered, data.consent_screen_enabled, data.pkce_required, data.public, data.scopes, data.redirect_uris, data.authorize_url, data.token_fetch_url, data.user_info_url, data.discovery_url, data.token_introspection_url, data.created_at, data.updated_at, data.client_secret);
    }
};
// src/api/resources/Organization.ts
var Organization = class _Organization {
    constructor(id, name, slug, imageUrl, hasImage, createdAt, updatedAt, publicMetadata = {}, privateMetadata = {}, maxAllowedMemberships, adminDeleteEnabled, membersCount, createdBy){
        this.id = id;
        this.name = name;
        this.slug = slug;
        this.imageUrl = imageUrl;
        this.hasImage = hasImage;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.publicMetadata = publicMetadata;
        this.privateMetadata = privateMetadata;
        this.maxAllowedMemberships = maxAllowedMemberships;
        this.adminDeleteEnabled = adminDeleteEnabled;
        this.membersCount = membersCount;
        this.createdBy = createdBy;
        this._raw = null;
    }
    get raw() {
        return this._raw;
    }
    static fromJSON(data) {
        const res = new _Organization(data.id, data.name, data.slug, data.image_url || "", data.has_image, data.created_at, data.updated_at, data.public_metadata, data.private_metadata, data.max_allowed_memberships, data.admin_delete_enabled, data.members_count, data.created_by);
        res._raw = data;
        return res;
    }
};
// src/api/resources/OrganizationInvitation.ts
var OrganizationInvitation = class _OrganizationInvitation {
    constructor(id, emailAddress, role, roleName, organizationId, createdAt, updatedAt, expiresAt, url, status, publicMetadata = {}, privateMetadata = {}, publicOrganizationData){
        this.id = id;
        this.emailAddress = emailAddress;
        this.role = role;
        this.roleName = roleName;
        this.organizationId = organizationId;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.expiresAt = expiresAt;
        this.url = url;
        this.status = status;
        this.publicMetadata = publicMetadata;
        this.privateMetadata = privateMetadata;
        this.publicOrganizationData = publicOrganizationData;
        this._raw = null;
    }
    get raw() {
        return this._raw;
    }
    static fromJSON(data) {
        const res = new _OrganizationInvitation(data.id, data.email_address, data.role, data.role_name, data.organization_id, data.created_at, data.updated_at, data.expires_at, data.url, data.status, data.public_metadata, data.private_metadata, data.public_organization_data);
        res._raw = data;
        return res;
    }
};
// src/api/resources/OrganizationMembership.ts
var OrganizationMembership = class _OrganizationMembership {
    constructor(id, role, permissions, publicMetadata = {}, privateMetadata = {}, createdAt, updatedAt, organization, publicUserData){
        this.id = id;
        this.role = role;
        this.permissions = permissions;
        this.publicMetadata = publicMetadata;
        this.privateMetadata = privateMetadata;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.organization = organization;
        this.publicUserData = publicUserData;
        this._raw = null;
    }
    get raw() {
        return this._raw;
    }
    static fromJSON(data) {
        const res = new _OrganizationMembership(data.id, data.role, data.permissions, data.public_metadata, data.private_metadata, data.created_at, data.updated_at, Organization.fromJSON(data.organization), OrganizationMembershipPublicUserData.fromJSON(data.public_user_data));
        res._raw = data;
        return res;
    }
};
var OrganizationMembershipPublicUserData = class _OrganizationMembershipPublicUserData {
    constructor(identifier, firstName, lastName, imageUrl, hasImage, userId){
        this.identifier = identifier;
        this.firstName = firstName;
        this.lastName = lastName;
        this.imageUrl = imageUrl;
        this.hasImage = hasImage;
        this.userId = userId;
    }
    static fromJSON(data) {
        return new _OrganizationMembershipPublicUserData(data.identifier, data.first_name, data.last_name, data.image_url, data.has_image, data.user_id);
    }
};
// src/api/resources/OrganizationSettings.ts
var OrganizationSettings = class _OrganizationSettings {
    constructor(enabled, maxAllowedMemberships, maxAllowedRoles, maxAllowedPermissions, creatorRole, adminDeleteEnabled, domainsEnabled, slugDisabled, domainsEnrollmentModes, domainsDefaultRole){
        this.enabled = enabled;
        this.maxAllowedMemberships = maxAllowedMemberships;
        this.maxAllowedRoles = maxAllowedRoles;
        this.maxAllowedPermissions = maxAllowedPermissions;
        this.creatorRole = creatorRole;
        this.adminDeleteEnabled = adminDeleteEnabled;
        this.domainsEnabled = domainsEnabled;
        this.slugDisabled = slugDisabled;
        this.domainsEnrollmentModes = domainsEnrollmentModes;
        this.domainsDefaultRole = domainsDefaultRole;
    }
    static fromJSON(data) {
        return new _OrganizationSettings(data.enabled, data.max_allowed_memberships, data.max_allowed_roles, data.max_allowed_permissions, data.creator_role, data.admin_delete_enabled, data.domains_enabled, data.slug_disabled, data.domains_enrollment_modes, data.domains_default_role);
    }
};
// src/api/resources/PhoneNumber.ts
var PhoneNumber = class _PhoneNumber {
    constructor(id, phoneNumber, reservedForSecondFactor, defaultSecondFactor, verification, linkedTo){
        this.id = id;
        this.phoneNumber = phoneNumber;
        this.reservedForSecondFactor = reservedForSecondFactor;
        this.defaultSecondFactor = defaultSecondFactor;
        this.verification = verification;
        this.linkedTo = linkedTo;
    }
    static fromJSON(data) {
        return new _PhoneNumber(data.id, data.phone_number, data.reserved_for_second_factor, data.default_second_factor, data.verification && Verification.fromJSON(data.verification), data.linked_to.map((link)=>IdentificationLink.fromJSON(link)));
    }
};
// src/api/resources/ProxyCheck.ts
var ProxyCheck = class _ProxyCheck {
    constructor(id, domainId, lastRunAt, proxyUrl, successful, createdAt, updatedAt){
        this.id = id;
        this.domainId = domainId;
        this.lastRunAt = lastRunAt;
        this.proxyUrl = proxyUrl;
        this.successful = successful;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
    }
    static fromJSON(data) {
        return new _ProxyCheck(data.id, data.domain_id, data.last_run_at, data.proxy_url, data.successful, data.created_at, data.updated_at);
    }
};
// src/api/resources/RedirectUrl.ts
var RedirectUrl = class _RedirectUrl {
    constructor(id, url, createdAt, updatedAt){
        this.id = id;
        this.url = url;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
    }
    static fromJSON(data) {
        return new _RedirectUrl(data.id, data.url, data.created_at, data.updated_at);
    }
};
// src/api/resources/SamlConnection.ts
var SamlConnection = class _SamlConnection {
    constructor(id, name, domain, organizationId, idpEntityId, idpSsoUrl, idpCertificate, idpMetadataUrl, idpMetadata, acsUrl, spEntityId, spMetadataUrl, active, provider, userCount, syncUserAttributes, allowSubdomains, allowIdpInitiated, createdAt, updatedAt, attributeMapping){
        this.id = id;
        this.name = name;
        this.domain = domain;
        this.organizationId = organizationId;
        this.idpEntityId = idpEntityId;
        this.idpSsoUrl = idpSsoUrl;
        this.idpCertificate = idpCertificate;
        this.idpMetadataUrl = idpMetadataUrl;
        this.idpMetadata = idpMetadata;
        this.acsUrl = acsUrl;
        this.spEntityId = spEntityId;
        this.spMetadataUrl = spMetadataUrl;
        this.active = active;
        this.provider = provider;
        this.userCount = userCount;
        this.syncUserAttributes = syncUserAttributes;
        this.allowSubdomains = allowSubdomains;
        this.allowIdpInitiated = allowIdpInitiated;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.attributeMapping = attributeMapping;
    }
    static fromJSON(data) {
        return new _SamlConnection(data.id, data.name, data.domain, data.organization_id, data.idp_entity_id, data.idp_sso_url, data.idp_certificate, data.idp_metadata_url, data.idp_metadata, data.acs_url, data.sp_entity_id, data.sp_metadata_url, data.active, data.provider, data.user_count, data.sync_user_attributes, data.allow_subdomains, data.allow_idp_initiated, data.created_at, data.updated_at, data.attribute_mapping && AttributeMapping.fromJSON(data.attribute_mapping));
    }
};
var SamlAccountConnection = class _SamlAccountConnection {
    constructor(id, name, domain, active, provider, syncUserAttributes, allowSubdomains, allowIdpInitiated, createdAt, updatedAt){
        this.id = id;
        this.name = name;
        this.domain = domain;
        this.active = active;
        this.provider = provider;
        this.syncUserAttributes = syncUserAttributes;
        this.allowSubdomains = allowSubdomains;
        this.allowIdpInitiated = allowIdpInitiated;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
    }
    static fromJSON(data) {
        return new _SamlAccountConnection(data.id, data.name, data.domain, data.active, data.provider, data.sync_user_attributes, data.allow_subdomains, data.allow_idp_initiated, data.created_at, data.updated_at);
    }
};
var AttributeMapping = class _AttributeMapping {
    constructor(userId, emailAddress, firstName, lastName){
        this.userId = userId;
        this.emailAddress = emailAddress;
        this.firstName = firstName;
        this.lastName = lastName;
    }
    static fromJSON(data) {
        return new _AttributeMapping(data.user_id, data.email_address, data.first_name, data.last_name);
    }
};
// src/api/resources/SamlAccount.ts
var SamlAccount = class _SamlAccount {
    constructor(id, provider, providerUserId, active, emailAddress, firstName, lastName, verification, samlConnection, lastAuthenticatedAt, enterpriseConnectionId){
        this.id = id;
        this.provider = provider;
        this.providerUserId = providerUserId;
        this.active = active;
        this.emailAddress = emailAddress;
        this.firstName = firstName;
        this.lastName = lastName;
        this.verification = verification;
        this.samlConnection = samlConnection;
        this.lastAuthenticatedAt = lastAuthenticatedAt;
        this.enterpriseConnectionId = enterpriseConnectionId;
    }
    static fromJSON(data) {
        return new _SamlAccount(data.id, data.provider, data.provider_user_id, data.active, data.email_address, data.first_name, data.last_name, data.verification && Verification.fromJSON(data.verification), data.saml_connection && SamlAccountConnection.fromJSON(data.saml_connection), data.last_authenticated_at ?? null, data.enterprise_connection_id);
    }
};
// src/api/resources/SignInTokens.ts
var SignInToken = class _SignInToken {
    constructor(id, userId, token, status, url, createdAt, updatedAt){
        this.id = id;
        this.userId = userId;
        this.token = token;
        this.status = status;
        this.url = url;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
    }
    static fromJSON(data) {
        return new _SignInToken(data.id, data.user_id, data.token, data.status, data.url, data.created_at, data.updated_at);
    }
};
// src/api/resources/SignUpAttempt.ts
var SignUpAttemptVerification = class _SignUpAttemptVerification {
    constructor(nextAction, supportedStrategies){
        this.nextAction = nextAction;
        this.supportedStrategies = supportedStrategies;
    }
    static fromJSON(data) {
        return new _SignUpAttemptVerification(data.next_action, data.supported_strategies);
    }
};
var SignUpAttemptVerifications = class _SignUpAttemptVerifications {
    constructor(emailAddress, phoneNumber, web3Wallet, externalAccount){
        this.emailAddress = emailAddress;
        this.phoneNumber = phoneNumber;
        this.web3Wallet = web3Wallet;
        this.externalAccount = externalAccount;
    }
    static fromJSON(data) {
        return new _SignUpAttemptVerifications(data.email_address && SignUpAttemptVerification.fromJSON(data.email_address), data.phone_number && SignUpAttemptVerification.fromJSON(data.phone_number), data.web3_wallet && SignUpAttemptVerification.fromJSON(data.web3_wallet), data.external_account);
    }
};
var SignUpAttempt = class _SignUpAttempt {
    constructor(id, status, requiredFields, optionalFields, missingFields, unverifiedFields, verifications, username, emailAddress, phoneNumber, web3Wallet, passwordEnabled, firstName, lastName, customAction, externalId, createdSessionId, createdUserId, abandonAt, legalAcceptedAt, publicMetadata, unsafeMetadata){
        this.id = id;
        this.status = status;
        this.requiredFields = requiredFields;
        this.optionalFields = optionalFields;
        this.missingFields = missingFields;
        this.unverifiedFields = unverifiedFields;
        this.verifications = verifications;
        this.username = username;
        this.emailAddress = emailAddress;
        this.phoneNumber = phoneNumber;
        this.web3Wallet = web3Wallet;
        this.passwordEnabled = passwordEnabled;
        this.firstName = firstName;
        this.lastName = lastName;
        this.customAction = customAction;
        this.externalId = externalId;
        this.createdSessionId = createdSessionId;
        this.createdUserId = createdUserId;
        this.abandonAt = abandonAt;
        this.legalAcceptedAt = legalAcceptedAt;
        this.publicMetadata = publicMetadata;
        this.unsafeMetadata = unsafeMetadata;
    }
    static fromJSON(data) {
        return new _SignUpAttempt(data.id, data.status, data.required_fields, data.optional_fields, data.missing_fields, data.unverified_fields, data.verifications ? SignUpAttemptVerifications.fromJSON(data.verifications) : null, data.username, data.email_address, data.phone_number, data.web3_wallet, data.password_enabled, data.first_name, data.last_name, data.custom_action, data.external_id, data.created_session_id, data.created_user_id, data.abandon_at, data.legal_accepted_at, data.public_metadata, data.unsafe_metadata);
    }
};
// src/api/resources/SMSMessage.ts
var SMSMessage = class _SMSMessage {
    constructor(id, fromPhoneNumber, toPhoneNumber, message, status, phoneNumberId, data){
        this.id = id;
        this.fromPhoneNumber = fromPhoneNumber;
        this.toPhoneNumber = toPhoneNumber;
        this.message = message;
        this.status = status;
        this.phoneNumberId = phoneNumberId;
        this.data = data;
    }
    static fromJSON(data) {
        return new _SMSMessage(data.id, data.from_phone_number, data.to_phone_number, data.message, data.status, data.phone_number_id, data.data);
    }
};
// src/api/resources/Token.ts
var Token = class _Token {
    constructor(jwt){
        this.jwt = jwt;
    }
    static fromJSON(data) {
        return new _Token(data.jwt);
    }
};
// src/api/resources/Web3Wallet.ts
var Web3Wallet = class _Web3Wallet {
    constructor(id, web3Wallet, verification){
        this.id = id;
        this.web3Wallet = web3Wallet;
        this.verification = verification;
    }
    static fromJSON(data) {
        return new _Web3Wallet(data.id, data.web3_wallet, data.verification && Verification.fromJSON(data.verification));
    }
};
// src/api/resources/User.ts
var User = class _User {
    constructor(id, passwordEnabled, totpEnabled, backupCodeEnabled, twoFactorEnabled, banned, locked, createdAt, updatedAt, imageUrl, hasImage, primaryEmailAddressId, primaryPhoneNumberId, primaryWeb3WalletId, lastSignInAt, externalId, username, firstName, lastName, publicMetadata = {}, privateMetadata = {}, unsafeMetadata = {}, emailAddresses = [], phoneNumbers = [], web3Wallets = [], externalAccounts = [], samlAccounts = [], lastActiveAt, createOrganizationEnabled, createOrganizationsLimit = null, deleteSelfEnabled, legalAcceptedAt, locale){
        this.id = id;
        this.passwordEnabled = passwordEnabled;
        this.totpEnabled = totpEnabled;
        this.backupCodeEnabled = backupCodeEnabled;
        this.twoFactorEnabled = twoFactorEnabled;
        this.banned = banned;
        this.locked = locked;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.imageUrl = imageUrl;
        this.hasImage = hasImage;
        this.primaryEmailAddressId = primaryEmailAddressId;
        this.primaryPhoneNumberId = primaryPhoneNumberId;
        this.primaryWeb3WalletId = primaryWeb3WalletId;
        this.lastSignInAt = lastSignInAt;
        this.externalId = externalId;
        this.username = username;
        this.firstName = firstName;
        this.lastName = lastName;
        this.publicMetadata = publicMetadata;
        this.privateMetadata = privateMetadata;
        this.unsafeMetadata = unsafeMetadata;
        this.emailAddresses = emailAddresses;
        this.phoneNumbers = phoneNumbers;
        this.web3Wallets = web3Wallets;
        this.externalAccounts = externalAccounts;
        this.samlAccounts = samlAccounts;
        this.lastActiveAt = lastActiveAt;
        this.createOrganizationEnabled = createOrganizationEnabled;
        this.createOrganizationsLimit = createOrganizationsLimit;
        this.deleteSelfEnabled = deleteSelfEnabled;
        this.legalAcceptedAt = legalAcceptedAt;
        this.locale = locale;
        this._raw = null;
    }
    get raw() {
        return this._raw;
    }
    static fromJSON(data) {
        const res = new _User(data.id, data.password_enabled, data.totp_enabled, data.backup_code_enabled, data.two_factor_enabled, data.banned, data.locked, data.created_at, data.updated_at, data.image_url, data.has_image, data.primary_email_address_id, data.primary_phone_number_id, data.primary_web3_wallet_id, data.last_sign_in_at, data.external_id, data.username, data.first_name, data.last_name, data.public_metadata, data.private_metadata, data.unsafe_metadata, (data.email_addresses || []).map((x)=>EmailAddress.fromJSON(x)), (data.phone_numbers || []).map((x)=>PhoneNumber.fromJSON(x)), (data.web3_wallets || []).map((x)=>Web3Wallet.fromJSON(x)), (data.external_accounts || []).map((x)=>ExternalAccount.fromJSON(x)), (data.saml_accounts || []).map((x)=>SamlAccount.fromJSON(x)), data.last_active_at, data.create_organization_enabled, data.create_organizations_limit, data.delete_self_enabled, data.legal_accepted_at, data.locale);
        res._raw = data;
        return res;
    }
    /**
   * The primary email address of the user.
   */ get primaryEmailAddress() {
        return this.emailAddresses.find(({ id })=>id === this.primaryEmailAddressId) ?? null;
    }
    /**
   * The primary phone number of the user.
   */ get primaryPhoneNumber() {
        return this.phoneNumbers.find(({ id })=>id === this.primaryPhoneNumberId) ?? null;
    }
    /**
   * The primary web3 wallet of the user.
   */ get primaryWeb3Wallet() {
        return this.web3Wallets.find(({ id })=>id === this.primaryWeb3WalletId) ?? null;
    }
    /**
   * The full name of the user.
   */ get fullName() {
        return [
            this.firstName,
            this.lastName
        ].join(" ").trim() || null;
    }
};
// src/api/resources/WaitlistEntry.ts
var WaitlistEntry = class _WaitlistEntry {
    constructor(id, emailAddress, status, invitation, createdAt, updatedAt, isLocked){
        this.id = id;
        this.emailAddress = emailAddress;
        this.status = status;
        this.invitation = invitation;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.isLocked = isLocked;
    }
    static fromJSON(data) {
        return new _WaitlistEntry(data.id, data.email_address, data.status, data.invitation && Invitation.fromJSON(data.invitation), data.created_at, data.updated_at, data.is_locked);
    }
};
// src/api/resources/Feature.ts
var Feature = class _Feature {
    constructor(id, name, description, slug, avatarUrl){
        this.id = id;
        this.name = name;
        this.description = description;
        this.slug = slug;
        this.avatarUrl = avatarUrl;
    }
    static fromJSON(data) {
        return new _Feature(data.id, data.name, data.description ?? null, data.slug, data.avatar_url ?? null);
    }
};
// src/api/resources/CommercePlan.ts
var BillingPlan = class _BillingPlan {
    constructor(id, name, slug, description, isDefault, isRecurring, hasBaseFee, publiclyVisible, fee, annualFee, annualMonthlyFee, forPayerType, features){
        this.id = id;
        this.name = name;
        this.slug = slug;
        this.description = description;
        this.isDefault = isDefault;
        this.isRecurring = isRecurring;
        this.hasBaseFee = hasBaseFee;
        this.publiclyVisible = publiclyVisible;
        this.fee = fee;
        this.annualFee = annualFee;
        this.annualMonthlyFee = annualMonthlyFee;
        this.forPayerType = forPayerType;
        this.features = features;
    }
    static fromJSON(data) {
        const formatAmountJSON = (fee)=>{
            return fee ? {
                amount: fee.amount,
                amountFormatted: fee.amount_formatted,
                currency: fee.currency,
                currencySymbol: fee.currency_symbol
            } : null;
        };
        return new _BillingPlan(data.id, data.name, data.slug, data.description ?? null, data.is_default, data.is_recurring, data.has_base_fee, data.publicly_visible, formatAmountJSON(data.fee), formatAmountJSON(data.annual_fee), formatAmountJSON(data.annual_monthly_fee), data.for_payer_type, (data.features ?? []).map((feature)=>Feature.fromJSON(feature)));
    }
};
// src/api/resources/CommerceSubscriptionItem.ts
var BillingSubscriptionItem = class _BillingSubscriptionItem {
    constructor(id, status, planPeriod, periodStart, nextPayment, amount, plan, planId, createdAt, updatedAt, periodEnd, canceledAt, pastDueAt, endedAt, payerId, isFreeTrial, lifetimePaid){
        this.id = id;
        this.status = status;
        this.planPeriod = planPeriod;
        this.periodStart = periodStart;
        this.nextPayment = nextPayment;
        this.amount = amount;
        this.plan = plan;
        this.planId = planId;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.periodEnd = periodEnd;
        this.canceledAt = canceledAt;
        this.pastDueAt = pastDueAt;
        this.endedAt = endedAt;
        this.payerId = payerId;
        this.isFreeTrial = isFreeTrial;
        this.lifetimePaid = lifetimePaid;
    }
    static fromJSON(data) {
        function formatAmountJSON(amount) {
            if (!amount) {
                return amount;
            }
            return {
                amount: amount.amount,
                amountFormatted: amount.amount_formatted,
                currency: amount.currency,
                currencySymbol: amount.currency_symbol
            };
        }
        return new _BillingSubscriptionItem(data.id, data.status, data.plan_period, data.period_start, data.next_payment, formatAmountJSON(data.amount) ?? void 0, data.plan ? BillingPlan.fromJSON(data.plan) : null, data.plan_id ?? null, data.created_at, data.updated_at, data.period_end, data.canceled_at, data.past_due_at, data.ended_at, data.payer_id, data.is_free_trial, formatAmountJSON(data.lifetime_paid) ?? void 0);
    }
};
// src/api/resources/CommerceSubscription.ts
var BillingSubscription = class _BillingSubscription {
    constructor(id, status, payerId, createdAt, updatedAt, activeAt, pastDueAt, subscriptionItems, nextPayment, eligibleForFreeTrial){
        this.id = id;
        this.status = status;
        this.payerId = payerId;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.activeAt = activeAt;
        this.pastDueAt = pastDueAt;
        this.subscriptionItems = subscriptionItems;
        this.nextPayment = nextPayment;
        this.eligibleForFreeTrial = eligibleForFreeTrial;
    }
    static fromJSON(data) {
        const nextPayment = data.next_payment ? {
            date: data.next_payment.date,
            amount: {
                amount: data.next_payment.amount.amount,
                amountFormatted: data.next_payment.amount.amount_formatted,
                currency: data.next_payment.amount.currency,
                currencySymbol: data.next_payment.amount.currency_symbol
            }
        } : null;
        return new _BillingSubscription(data.id, data.status, data.payer_id, data.created_at, data.updated_at, data.active_at ?? null, data.past_due_at ?? null, (data.subscription_items ?? []).map((item)=>BillingSubscriptionItem.fromJSON(item)), nextPayment, data.eligible_for_free_trial ?? false);
    }
};
// src/api/resources/Deserializer.ts
function deserialize(payload) {
    let data, totalCount;
    if (Array.isArray(payload)) {
        const data2 = payload.map((item)=>jsonToObject(item));
        return {
            data: data2
        };
    } else if (isPaginated(payload)) {
        data = payload.data.map((item)=>jsonToObject(item));
        totalCount = payload.total_count;
        return {
            data,
            totalCount
        };
    } else {
        return {
            data: jsonToObject(payload)
        };
    }
}
function isPaginated(payload) {
    if (!payload || typeof payload !== "object" || !("data" in payload)) {
        return false;
    }
    return Array.isArray(payload.data) && payload.data !== void 0;
}
function getCount(item) {
    return item.total_count;
}
function jsonToObject(item) {
    if (typeof item !== "string" && "object" in item && "deleted" in item) {
        return DeletedObject.fromJSON(item);
    }
    switch(item.object){
        case ObjectType.AccountlessApplication:
            return AccountlessApplication.fromJSON(item);
        case ObjectType.ActorToken:
            return ActorToken.fromJSON(item);
        case ObjectType.AllowlistIdentifier:
            return AllowlistIdentifier.fromJSON(item);
        case ObjectType.ApiKey:
            return APIKey.fromJSON(item);
        case ObjectType.BlocklistIdentifier:
            return BlocklistIdentifier.fromJSON(item);
        case ObjectType.Client:
            return Client.fromJSON(item);
        case ObjectType.Cookies:
            return Cookies2.fromJSON(item);
        case ObjectType.Domain:
            return Domain.fromJSON(item);
        case ObjectType.EmailAddress:
            return EmailAddress.fromJSON(item);
        case ObjectType.Email:
            return Email.fromJSON(item);
        case ObjectType.IdpOAuthAccessToken:
            return IdPOAuthAccessToken.fromJSON(item);
        case ObjectType.Instance:
            return Instance.fromJSON(item);
        case ObjectType.InstanceRestrictions:
            return InstanceRestrictions.fromJSON(item);
        case ObjectType.InstanceSettings:
            return InstanceSettings.fromJSON(item);
        case ObjectType.Invitation:
            return Invitation.fromJSON(item);
        case ObjectType.JwtTemplate:
            return JwtTemplate.fromJSON(item);
        case ObjectType.Machine:
            return Machine.fromJSON(item);
        case ObjectType.MachineScope:
            return MachineScope.fromJSON(item);
        case ObjectType.MachineSecretKey:
            return MachineSecretKey.fromJSON(item);
        case ObjectType.M2MToken:
            return M2MToken.fromJSON(item);
        case ObjectType.OauthAccessToken:
            return OauthAccessToken.fromJSON(item);
        case ObjectType.OAuthApplication:
            return OAuthApplication.fromJSON(item);
        case ObjectType.Organization:
            return Organization.fromJSON(item);
        case ObjectType.OrganizationInvitation:
            return OrganizationInvitation.fromJSON(item);
        case ObjectType.OrganizationMembership:
            return OrganizationMembership.fromJSON(item);
        case ObjectType.OrganizationSettings:
            return OrganizationSettings.fromJSON(item);
        case ObjectType.PhoneNumber:
            return PhoneNumber.fromJSON(item);
        case ObjectType.ProxyCheck:
            return ProxyCheck.fromJSON(item);
        case ObjectType.RedirectUrl:
            return RedirectUrl.fromJSON(item);
        case ObjectType.SamlConnection:
            return SamlConnection.fromJSON(item);
        case ObjectType.SignInToken:
            return SignInToken.fromJSON(item);
        case ObjectType.SignUpAttempt:
            return SignUpAttempt.fromJSON(item);
        case ObjectType.Session:
            return Session.fromJSON(item);
        case ObjectType.SmsMessage:
            return SMSMessage.fromJSON(item);
        case ObjectType.Token:
            return Token.fromJSON(item);
        case ObjectType.TotalCount:
            return getCount(item);
        case ObjectType.User:
            return User.fromJSON(item);
        case ObjectType.WaitlistEntry:
            return WaitlistEntry.fromJSON(item);
        case ObjectType.BillingPlan:
            return BillingPlan.fromJSON(item);
        case ObjectType.BillingSubscription:
            return BillingSubscription.fromJSON(item);
        case ObjectType.BillingSubscriptionItem:
            return BillingSubscriptionItem.fromJSON(item);
        case ObjectType.Feature:
            return Feature.fromJSON(item);
        default:
            return item;
    }
}
// src/api/request.ts
function buildRequest(options) {
    const requestFn = async (requestOptions)=>{
        const { secretKey, machineSecretKey, useMachineSecretKey = false, requireSecretKey = true, apiUrl = API_URL, apiVersion = API_VERSION, userAgent = USER_AGENT, skipApiVersionInUrl = false } = options;
        const { path, method, queryParams, headerParams, bodyParams, formData, options: opts } = requestOptions;
        const { deepSnakecaseBodyParamKeys = false } = opts || {};
        if (requireSecretKey) {
            assertValidSecretKey(secretKey);
        }
        const url = skipApiVersionInUrl ? joinPaths(apiUrl, path) : joinPaths(apiUrl, apiVersion, path);
        const finalUrl = new URL(url);
        if (queryParams) {
            const snakecasedQueryParams = snakecase_keys_default({
                ...queryParams
            });
            for (const [key, val] of Object.entries(snakecasedQueryParams)){
                if (val) {
                    [
                        val
                    ].flat().forEach((v)=>finalUrl.searchParams.append(key, v));
                }
            }
        }
        const headers = new Headers({
            "Clerk-API-Version": SUPPORTED_BAPI_VERSION,
            [constants.Headers.UserAgent]: userAgent,
            ...headerParams
        });
        const authorizationHeader = constants.Headers.Authorization;
        if (!headers.has(authorizationHeader)) {
            if (useMachineSecretKey && machineSecretKey) {
                headers.set(authorizationHeader, `Bearer ${machineSecretKey}`);
            } else if (secretKey) {
                headers.set(authorizationHeader, `Bearer ${secretKey}`);
            }
        }
        let res;
        try {
            if (formData) {
                res = await __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["runtime"].fetch(finalUrl.href, {
                    method,
                    headers,
                    body: formData
                });
            } else {
                headers.set("Content-Type", "application/json");
                const buildBody = ()=>{
                    const hasBody = method !== "GET" && bodyParams && Object.keys(bodyParams).length > 0;
                    if (!hasBody) {
                        return null;
                    }
                    const formatKeys = (object)=>snakecase_keys_default(object, {
                            deep: deepSnakecaseBodyParamKeys
                        });
                    return {
                        body: JSON.stringify(Array.isArray(bodyParams) ? bodyParams.map(formatKeys) : formatKeys(bodyParams))
                    };
                };
                res = await __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["runtime"].fetch(finalUrl.href, {
                    method,
                    headers,
                    ...buildBody()
                });
            }
            const isJSONResponse = res?.headers && res.headers?.get(constants.Headers.ContentType) === constants.ContentTypes.Json;
            const responseBody = await (isJSONResponse ? res.json() : res.text());
            if (!res.ok) {
                return {
                    data: null,
                    errors: parseErrors(responseBody),
                    status: res?.status,
                    statusText: res?.statusText,
                    clerkTraceId: getTraceId(responseBody, res?.headers),
                    retryAfter: getRetryAfter(res?.headers)
                };
            }
            return {
                ...deserialize(responseBody),
                errors: null
            };
        } catch (err) {
            if (err instanceof Error) {
                return {
                    data: null,
                    errors: [
                        {
                            code: "unexpected_error",
                            message: err.message || "Unexpected error"
                        }
                    ],
                    clerkTraceId: getTraceId(err, res?.headers)
                };
            }
            return {
                data: null,
                errors: parseErrors(err),
                status: res?.status,
                statusText: res?.statusText,
                clerkTraceId: getTraceId(err, res?.headers),
                retryAfter: getRetryAfter(res?.headers)
            };
        }
    };
    return withLegacyRequestReturn(requestFn);
}
function getTraceId(data, headers) {
    if (data && typeof data === "object" && "clerk_trace_id" in data && typeof data.clerk_trace_id === "string") {
        return data.clerk_trace_id;
    }
    const cfRay = headers?.get("cf-ray");
    return cfRay || "";
}
function getRetryAfter(headers) {
    const retryAfter = headers?.get("Retry-After");
    if (!retryAfter) {
        return;
    }
    const value = parseInt(retryAfter, 10);
    if (isNaN(value)) {
        return;
    }
    return value;
}
function parseErrors(data) {
    if (!!data && typeof data === "object" && "errors" in data) {
        const errors = data.errors;
        return errors.length > 0 ? errors.map(__TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$error$2d$CC05ENkI$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["parseError"]) : [];
    }
    return [];
}
function withLegacyRequestReturn(cb) {
    return async (...args)=>{
        const { data, errors, totalCount, status, statusText, clerkTraceId, retryAfter } = await cb(...args);
        if (errors) {
            const error = new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$error$2d$CC05ENkI$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["ClerkAPIResponseError"](statusText || "", {
                data: [],
                status,
                clerkTraceId,
                retryAfter
            });
            error.errors = errors;
            throw error;
        }
        if (typeof totalCount !== "undefined") {
            return {
                data,
                totalCount
            };
        }
        return data;
    };
}
// src/api/factory.ts
function createBackendApiClient(options) {
    const request = buildRequest(options);
    return {
        __experimental_accountlessApplications: new AccountlessApplicationAPI(buildRequest({
            ...options,
            requireSecretKey: false
        })),
        actorTokens: new ActorTokenAPI(request),
        allowlistIdentifiers: new AllowlistIdentifierAPI(request),
        apiKeys: new APIKeysAPI(buildRequest({
            ...options,
            skipApiVersionInUrl: true
        })),
        betaFeatures: new BetaFeaturesAPI(request),
        blocklistIdentifiers: new BlocklistIdentifierAPI(request),
        /**
     * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
     */ billing: new BillingAPI(request),
        clients: new ClientAPI(request),
        domains: new DomainAPI(request),
        emailAddresses: new EmailAddressAPI(request),
        idPOAuthAccessToken: new IdPOAuthAccessTokenApi(buildRequest({
            ...options,
            skipApiVersionInUrl: true
        })),
        instance: new InstanceAPI(request),
        invitations: new InvitationAPI(request),
        jwks: new JwksAPI(request),
        jwtTemplates: new JwtTemplatesApi(request),
        machines: new MachineApi(request),
        m2m: new M2MTokenApi(buildRequest({
            ...options,
            skipApiVersionInUrl: true,
            requireSecretKey: false,
            useMachineSecretKey: true
        })),
        oauthApplications: new OAuthApplicationsApi(request),
        organizations: new OrganizationAPI(request),
        phoneNumbers: new PhoneNumberAPI(request),
        proxyChecks: new ProxyCheckAPI(request),
        redirectUrls: new RedirectUrlAPI(request),
        samlConnections: new SamlConnectionAPI(request),
        sessions: new SessionAPI(request),
        signInTokens: new SignInTokenAPI(request),
        signUps: new SignUpAPI(request),
        testingTokens: new TestingTokenAPI(request),
        users: new UserAPI(request),
        waitlistEntries: new WaitlistEntryAPI(request),
        webhooks: new WebhookAPI(request)
    };
}
// src/tokens/machine.ts
var M2M_TOKEN_PREFIX = "mt_";
var OAUTH_TOKEN_PREFIX = "oat_";
var API_KEY_PREFIX = "ak_";
var MACHINE_TOKEN_PREFIXES = [
    M2M_TOKEN_PREFIX,
    OAUTH_TOKEN_PREFIX,
    API_KEY_PREFIX
];
var JwtFormatRegExp = /^[a-zA-Z0-9\-_]+\.[a-zA-Z0-9\-_]+\.[a-zA-Z0-9\-_]+$/;
function isJwtFormat(token) {
    return JwtFormatRegExp.test(token);
}
var OAUTH_ACCESS_TOKEN_TYPES = [
    "at+jwt",
    "application/at+jwt"
];
function isOAuthJwt(token) {
    if (!isJwtFormat(token)) {
        return false;
    }
    try {
        const { data, errors } = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["decodeJwt"])(token);
        return !errors && !!data && OAUTH_ACCESS_TOKEN_TYPES.includes(data.header.typ);
    } catch  {
        return false;
    }
}
function isMachineTokenByPrefix(token) {
    return MACHINE_TOKEN_PREFIXES.some((prefix)=>token.startsWith(prefix));
}
function isMachineToken(token) {
    return isMachineTokenByPrefix(token) || isOAuthJwt(token);
}
function getMachineTokenType(token) {
    if (token.startsWith(M2M_TOKEN_PREFIX)) {
        return TokenType.M2MToken;
    }
    if (token.startsWith(OAUTH_TOKEN_PREFIX) || isOAuthJwt(token)) {
        return TokenType.OAuthToken;
    }
    if (token.startsWith(API_KEY_PREFIX)) {
        return TokenType.ApiKey;
    }
    throw new Error("Unknown machine token type");
}
var isTokenTypeAccepted = (tokenType, acceptsToken)=>{
    if (!tokenType) {
        return false;
    }
    if (acceptsToken === "any") {
        return true;
    }
    const tokenTypes = Array.isArray(acceptsToken) ? acceptsToken : [
        acceptsToken
    ];
    return tokenTypes.includes(tokenType);
};
function isMachineTokenType(type) {
    return type === TokenType.ApiKey || type === TokenType.M2MToken || type === TokenType.OAuthToken;
}
// src/tokens/authObjects.ts
var createDebug = (data)=>{
    return ()=>{
        const res = {
            ...data
        };
        res.secretKey = (res.secretKey || "").substring(0, 7);
        res.jwtKey = (res.jwtKey || "").substring(0, 7);
        return {
            ...res
        };
    };
};
function signedInAuthObject(authenticateContext, sessionToken, sessionClaims) {
    const { actor, sessionId, sessionStatus, userId, orgId, orgRole, orgSlug, orgPermissions, factorVerificationAge } = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$jwtPayloadParser$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["__experimental_JWTPayloadToAuthObjectProperties"])(sessionClaims);
    const apiClient = createBackendApiClient(authenticateContext);
    const getToken = createGetToken({
        sessionId,
        sessionToken,
        fetcher: async (sessionId2, template, expiresInSeconds)=>(await apiClient.sessions.getToken(sessionId2, template || "", expiresInSeconds)).jwt
    });
    return {
        tokenType: TokenType.SessionToken,
        actor,
        sessionClaims,
        sessionId,
        sessionStatus,
        userId,
        orgId,
        orgRole,
        orgSlug,
        orgPermissions,
        factorVerificationAge,
        getToken,
        has: (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$authorization$2d$D2ans7vW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["createCheckAuthorization"])({
            orgId,
            orgRole,
            orgPermissions,
            userId,
            factorVerificationAge,
            features: sessionClaims.fea || "",
            plans: sessionClaims.pla || ""
        }),
        debug: createDebug({
            ...authenticateContext,
            sessionToken
        }),
        isAuthenticated: true
    };
}
function signedOutAuthObject(debugData, initialSessionStatus) {
    return {
        tokenType: TokenType.SessionToken,
        sessionClaims: null,
        sessionId: null,
        sessionStatus: initialSessionStatus ?? null,
        userId: null,
        actor: null,
        orgId: null,
        orgRole: null,
        orgSlug: null,
        orgPermissions: null,
        factorVerificationAge: null,
        getToken: ()=>Promise.resolve(null),
        has: ()=>false,
        debug: createDebug(debugData),
        isAuthenticated: false
    };
}
function authenticatedMachineObject(tokenType, token, verificationResult, debugData) {
    const baseObject = {
        id: verificationResult.id,
        subject: verificationResult.subject,
        getToken: ()=>Promise.resolve(token),
        has: ()=>false,
        debug: createDebug(debugData),
        isAuthenticated: true
    };
    switch(tokenType){
        case TokenType.ApiKey:
            {
                const result = verificationResult;
                return {
                    ...baseObject,
                    tokenType,
                    name: result.name,
                    claims: result.claims,
                    scopes: result.scopes,
                    userId: result.subject.startsWith("user_") ? result.subject : null,
                    orgId: result.subject.startsWith("org_") ? result.subject : null
                };
            }
        case TokenType.M2MToken:
            {
                const result = verificationResult;
                return {
                    ...baseObject,
                    tokenType,
                    claims: result.claims,
                    scopes: result.scopes,
                    machineId: result.subject
                };
            }
        case TokenType.OAuthToken:
            {
                const result = verificationResult;
                return {
                    ...baseObject,
                    tokenType,
                    scopes: result.scopes,
                    userId: result.subject,
                    clientId: result.clientId
                };
            }
        default:
            throw new Error(`Invalid token type: ${tokenType}`);
    }
}
function unauthenticatedMachineObject(tokenType, debugData) {
    const baseObject = {
        id: null,
        subject: null,
        scopes: null,
        has: ()=>false,
        getToken: ()=>Promise.resolve(null),
        debug: createDebug(debugData),
        isAuthenticated: false
    };
    switch(tokenType){
        case TokenType.ApiKey:
            {
                return {
                    ...baseObject,
                    tokenType,
                    name: null,
                    claims: null,
                    scopes: null,
                    userId: null,
                    orgId: null
                };
            }
        case TokenType.M2MToken:
            {
                return {
                    ...baseObject,
                    tokenType,
                    claims: null,
                    scopes: null,
                    machineId: null
                };
            }
        case TokenType.OAuthToken:
            {
                return {
                    ...baseObject,
                    tokenType,
                    scopes: null,
                    userId: null,
                    clientId: null
                };
            }
        default:
            throw new Error(`Invalid token type: ${tokenType}`);
    }
}
function invalidTokenAuthObject() {
    return {
        isAuthenticated: false,
        tokenType: null,
        getToken: ()=>Promise.resolve(null),
        has: ()=>false,
        debug: ()=>({})
    };
}
var makeAuthObjectSerializable = (obj)=>{
    const { debug, getToken, has, ...rest } = obj;
    return rest;
};
var createGetToken = (params)=>{
    const { fetcher, sessionToken, sessionId } = params || {};
    return async (options = {})=>{
        if (!sessionId) {
            return null;
        }
        if (options.template || options.expiresInSeconds !== void 0) {
            return fetcher(sessionId, options.template, options.expiresInSeconds);
        }
        return sessionToken;
    };
};
var getAuthObjectFromJwt = (jwt, { treatPendingAsSignedOut = true, ...options })=>{
    const authObject = signedInAuthObject(options, jwt.raw.text, jwt.payload);
    if (treatPendingAsSignedOut && authObject.sessionStatus === "pending") {
        return signedOutAuthObject(options, authObject.sessionStatus);
    }
    return authObject;
};
var getAuthObjectForAcceptedToken = ({ authObject, acceptsToken = TokenType.SessionToken })=>{
    if (acceptsToken === "any") {
        return authObject;
    }
    if (Array.isArray(acceptsToken)) {
        if (!isTokenTypeAccepted(authObject.tokenType, acceptsToken)) {
            return invalidTokenAuthObject();
        }
        return authObject;
    }
    if (!isTokenTypeAccepted(authObject.tokenType, acceptsToken)) {
        if (isMachineTokenType(acceptsToken)) {
            return unauthenticatedMachineObject(acceptsToken, authObject.debug);
        }
        return signedOutAuthObject(authObject.debug);
    }
    return authObject;
};
// src/tokens/authStatus.ts
var AuthStatus = {
    SignedIn: "signed-in",
    SignedOut: "signed-out",
    Handshake: "handshake"
};
var AuthErrorReason = {
    ClientUATWithoutSessionToken: "client-uat-but-no-session-token",
    DevBrowserMissing: "dev-browser-missing",
    DevBrowserSync: "dev-browser-sync",
    PrimaryRespondsToSyncing: "primary-responds-to-syncing",
    PrimaryDomainCrossOriginSync: "primary-domain-cross-origin-sync",
    SatelliteCookieNeedsSyncing: "satellite-needs-syncing",
    SessionTokenAndUATMissing: "session-token-and-uat-missing",
    SessionTokenMissing: "session-token-missing",
    SessionTokenExpired: "session-token-expired",
    SessionTokenIATBeforeClientUAT: "session-token-iat-before-client-uat",
    SessionTokenNBF: "session-token-nbf",
    SessionTokenIatInTheFuture: "session-token-iat-in-the-future",
    SessionTokenWithoutClientUAT: "session-token-but-no-client-uat",
    ActiveOrganizationMismatch: "active-organization-mismatch",
    TokenTypeMismatch: "token-type-mismatch",
    UnexpectedError: "unexpected-error"
};
function signedIn(params) {
    const { authenticateContext, headers = new Headers(), token } = params;
    const toAuth = ({ treatPendingAsSignedOut = true } = {})=>{
        if (params.tokenType === TokenType.SessionToken) {
            const { sessionClaims } = params;
            const authObject = signedInAuthObject(authenticateContext, token, sessionClaims);
            if (treatPendingAsSignedOut && authObject.sessionStatus === "pending") {
                return signedOutAuthObject(void 0, authObject.sessionStatus);
            }
            return authObject;
        }
        const { machineData } = params;
        return authenticatedMachineObject(params.tokenType, token, machineData, authenticateContext);
    };
    return {
        status: AuthStatus.SignedIn,
        reason: null,
        message: null,
        proxyUrl: authenticateContext.proxyUrl || "",
        publishableKey: authenticateContext.publishableKey || "",
        isSatellite: authenticateContext.isSatellite || false,
        domain: authenticateContext.domain || "",
        signInUrl: authenticateContext.signInUrl || "",
        signUpUrl: authenticateContext.signUpUrl || "",
        afterSignInUrl: authenticateContext.afterSignInUrl || "",
        afterSignUpUrl: authenticateContext.afterSignUpUrl || "",
        isSignedIn: true,
        isAuthenticated: true,
        tokenType: params.tokenType,
        toAuth,
        headers,
        token
    };
}
function signedOut(params) {
    const { authenticateContext, headers = new Headers(), reason, message = "", tokenType } = params;
    const toAuth = ()=>{
        if (tokenType === TokenType.SessionToken) {
            return signedOutAuthObject({
                ...authenticateContext,
                status: AuthStatus.SignedOut,
                reason,
                message
            });
        }
        return unauthenticatedMachineObject(tokenType, {
            reason,
            message,
            headers
        });
    };
    return withDebugHeaders({
        status: AuthStatus.SignedOut,
        reason,
        message,
        proxyUrl: authenticateContext.proxyUrl || "",
        publishableKey: authenticateContext.publishableKey || "",
        isSatellite: authenticateContext.isSatellite || false,
        domain: authenticateContext.domain || "",
        signInUrl: authenticateContext.signInUrl || "",
        signUpUrl: authenticateContext.signUpUrl || "",
        afterSignInUrl: authenticateContext.afterSignInUrl || "",
        afterSignUpUrl: authenticateContext.afterSignUpUrl || "",
        isSignedIn: false,
        isAuthenticated: false,
        tokenType,
        toAuth,
        headers,
        token: null
    });
}
function handshake(authenticateContext, reason, message = "", headers) {
    return withDebugHeaders({
        status: AuthStatus.Handshake,
        reason,
        message,
        publishableKey: authenticateContext.publishableKey || "",
        isSatellite: authenticateContext.isSatellite || false,
        domain: authenticateContext.domain || "",
        proxyUrl: authenticateContext.proxyUrl || "",
        signInUrl: authenticateContext.signInUrl || "",
        signUpUrl: authenticateContext.signUpUrl || "",
        afterSignInUrl: authenticateContext.afterSignInUrl || "",
        afterSignUpUrl: authenticateContext.afterSignUpUrl || "",
        isSignedIn: false,
        isAuthenticated: false,
        tokenType: TokenType.SessionToken,
        toAuth: ()=>null,
        headers,
        token: null
    });
}
function signedOutInvalidToken() {
    const authObject = invalidTokenAuthObject();
    return withDebugHeaders({
        status: AuthStatus.SignedOut,
        reason: AuthErrorReason.TokenTypeMismatch,
        message: "",
        proxyUrl: "",
        publishableKey: "",
        isSatellite: false,
        domain: "",
        signInUrl: "",
        signUpUrl: "",
        afterSignInUrl: "",
        afterSignUpUrl: "",
        isSignedIn: false,
        isAuthenticated: false,
        tokenType: null,
        toAuth: ()=>authObject,
        headers: new Headers(),
        token: null
    });
}
var withDebugHeaders = (requestState)=>{
    const headers = new Headers(requestState.headers || {});
    if (requestState.message) {
        try {
            headers.set(constants.Headers.AuthMessage, requestState.message);
        } catch  {}
    }
    if (requestState.reason) {
        try {
            headers.set(constants.Headers.AuthReason, requestState.reason);
        } catch  {}
    }
    if (requestState.status) {
        try {
            headers.set(constants.Headers.AuthStatus, requestState.status);
        } catch  {}
    }
    requestState.headers = headers;
    return requestState;
};
;
// src/tokens/clerkUrl.ts
var ClerkUrl = class extends URL {
    isCrossOrigin(other) {
        return this.origin !== new URL(other.toString()).origin;
    }
};
var createClerkUrl = (...args)=>{
    return new ClerkUrl(...args);
};
// src/tokens/clerkRequest.ts
var ClerkRequest = class extends Request {
    constructor(input, init){
        const url = typeof input !== "string" && "url" in input ? input.url : String(input);
        super(url, init || typeof input === "string" ? void 0 : input);
        this.clerkUrl = this.deriveUrlFromHeaders(this);
        this.cookies = this.parseCookies(this);
    }
    toJSON() {
        return {
            url: this.clerkUrl.href,
            method: this.method,
            headers: JSON.stringify(Object.fromEntries(this.headers)),
            clerkUrl: this.clerkUrl.toString(),
            cookies: JSON.stringify(Object.fromEntries(this.cookies))
        };
    }
    /**
   * Used to fix request.url using the x-forwarded-* headers
   * TODO add detailed description of the issues this solves
   */ deriveUrlFromHeaders(req) {
        const initialUrl = new URL(req.url);
        const forwardedProto = req.headers.get(constants.Headers.ForwardedProto);
        const forwardedHost = req.headers.get(constants.Headers.ForwardedHost);
        const host = req.headers.get(constants.Headers.Host);
        const protocol = initialUrl.protocol;
        const resolvedHost = this.getFirstValueFromHeader(forwardedHost) ?? host;
        const resolvedProtocol = this.getFirstValueFromHeader(forwardedProto) ?? protocol?.replace(/[:/]/, "");
        const origin = resolvedHost && resolvedProtocol ? `${resolvedProtocol}://${resolvedHost}` : initialUrl.origin;
        if (origin === initialUrl.origin) {
            return createClerkUrl(initialUrl);
        }
        return createClerkUrl(initialUrl.pathname + initialUrl.search, origin);
    }
    getFirstValueFromHeader(value) {
        return value?.split(",")[0];
    }
    parseCookies(req) {
        const cookiesRecord = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f$cookie$2f$dist$2f$index$2e$js__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["parse"])(this.decodeCookieValue(req.headers.get("cookie") || ""));
        return new Map(Object.entries(cookiesRecord));
    }
    decodeCookieValue(str) {
        return str ? str.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent) : str;
    }
};
var createClerkRequest = (...args)=>{
    return args[0] instanceof ClerkRequest ? args[0] : new ClerkRequest(...args);
};
// src/tokens/cookie.ts
var getCookieName = (cookieDirective)=>{
    return cookieDirective.split(";")[0]?.split("=")[0];
};
var getCookieValue = (cookieDirective)=>{
    return cookieDirective.split(";")[0]?.split("=")[1];
};
// src/tokens/keys.ts
var cache = {};
var lastUpdatedAt = 0;
function getFromCache(kid) {
    return cache[kid];
}
function getCacheValues() {
    return Object.values(cache);
}
function setInCache(cacheKey, jwk, shouldExpire = true) {
    cache[cacheKey] = jwk;
    lastUpdatedAt = shouldExpire ? Date.now() : -1;
}
var PEM_HEADER = "-----BEGIN PUBLIC KEY-----";
var PEM_TRAILER = "-----END PUBLIC KEY-----";
var RSA_PREFIX = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA";
var RSA_SUFFIX = "IDAQAB";
function loadClerkJwkFromPem(params) {
    const { kid, pem } = params;
    const prefixedKid = `local-${kid}`;
    const cachedJwk = getFromCache(prefixedKid);
    if (cachedJwk) {
        return cachedJwk;
    }
    if (!pem) {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].SetClerkJWTKey,
            message: "Missing local JWK.",
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].LocalJWKMissing
        });
    }
    const modulus = pem.replace(/\r\n|\n|\r/g, "").replace(PEM_HEADER, "").replace(PEM_TRAILER, "").replace(RSA_PREFIX, "").replace(RSA_SUFFIX, "").replace(/\+/g, "-").replace(/\//g, "_");
    const jwk = {
        kid: prefixedKid,
        kty: "RSA",
        alg: "RS256",
        n: modulus,
        e: "AQAB"
    };
    setInCache(prefixedKid, jwk, false);
    return jwk;
}
async function loadClerkJWKFromRemote(params) {
    const { secretKey, apiUrl = API_URL, apiVersion = API_VERSION, kid, skipJwksCache } = params;
    if (skipJwksCache || cacheHasExpired() || !getFromCache(kid)) {
        if (!secretKey) {
            throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
                action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].ContactSupport,
                message: "Failed to load JWKS from Clerk Backend or Frontend API.",
                reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].RemoteJWKFailedToLoad
            });
        }
        const fetcher = ()=>fetchJWKSFromBAPI(apiUrl, secretKey, apiVersion);
        const { keys } = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$retry$2d$DAlTROH9$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["retry"])(fetcher);
        if (!keys || !keys.length) {
            throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
                action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].ContactSupport,
                message: "The JWKS endpoint did not contain any signing keys. Contact support@clerk.com.",
                reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].RemoteJWKFailedToLoad
            });
        }
        keys.forEach((key)=>setInCache(key.kid, key));
    }
    const jwk = getFromCache(kid);
    if (!jwk) {
        const cacheValues = getCacheValues();
        const jwkKeys = cacheValues.map((jwk2)=>jwk2.kid).sort().join(", ");
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            action: `Go to your Dashboard and validate your secret and public keys are correct. ${__TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].ContactSupport} if the issue persists.`,
            message: `Unable to find a signing key in JWKS that matches the kid='${kid}' of the provided session token. Please make sure that the __session cookie or the HTTP authorization header contain a Clerk-generated session JWT. The following kid is available: ${jwkKeys}`,
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].JWKKidMismatch
        });
    }
    return jwk;
}
async function fetchJWKSFromBAPI(apiUrl, key, apiVersion) {
    if (!key) {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].SetClerkSecretKey,
            message: "Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance.",
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].RemoteJWKFailedToLoad
        });
    }
    const url = new URL(apiUrl);
    url.pathname = joinPaths(url.pathname, apiVersion, "/jwks");
    const response = await __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["runtime"].fetch(url.href, {
        headers: {
            Authorization: `Bearer ${key}`,
            "Clerk-API-Version": SUPPORTED_BAPI_VERSION,
            "Content-Type": "application/json",
            "User-Agent": USER_AGENT
        }
    });
    if (!response.ok) {
        const json = await response.json();
        const invalidSecretKeyError = getErrorObjectByCode(json?.errors, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorCode"].InvalidSecretKey);
        if (invalidSecretKeyError) {
            const reason = __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].InvalidSecretKey;
            throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
                action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].ContactSupport,
                message: invalidSecretKeyError.message,
                reason
            });
        }
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].ContactSupport,
            message: `Error loading Clerk JWKS from ${url.href} with code=${response.status}`,
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].RemoteJWKFailedToLoad
        });
    }
    return response.json();
}
function cacheHasExpired() {
    if (lastUpdatedAt === -1) {
        return false;
    }
    const isExpired = Date.now() - lastUpdatedAt >= MAX_CACHE_LAST_UPDATED_AT_SECONDS * 1e3;
    if (isExpired) {
        cache = {};
    }
    return isExpired;
}
var getErrorObjectByCode = (errors, code)=>{
    if (!errors) {
        return null;
    }
    return errors.find((err)=>err.code === code);
};
;
async function verifyToken(token, options) {
    const { data: decodedResult, errors } = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["decodeJwt"])(token);
    if (errors) {
        return {
            errors
        };
    }
    const { header } = decodedResult;
    const { kid } = header;
    try {
        let key;
        if (options.jwtKey) {
            key = loadClerkJwkFromPem({
                kid,
                pem: options.jwtKey
            });
        } else if (options.secretKey) {
            key = await loadClerkJWKFromRemote({
                ...options,
                kid
            });
        } else {
            return {
                errors: [
                    new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
                        action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].SetClerkJWTKey,
                        message: "Failed to resolve JWK during verification.",
                        reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].JWKFailedToResolve
                    })
                ]
            };
        }
        return await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["verifyJwt"])(token, {
            ...options,
            key
        });
    } catch (error) {
        return {
            errors: [
                error
            ]
        };
    }
}
function handleClerkAPIError(tokenType, err, notFoundMessage) {
    if ((0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$error$2d$CC05ENkI$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["isClerkAPIResponseError"])(err)) {
        let code;
        let message;
        switch(err.status){
            case 401:
                code = __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationErrorCode"].InvalidSecretKey;
                message = err.errors[0]?.message || "Invalid secret key";
                break;
            case 404:
                code = __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationErrorCode"].TokenInvalid;
                message = notFoundMessage;
                break;
            default:
                code = __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationErrorCode"].UnexpectedError;
                message = "Unexpected error";
        }
        return {
            data: void 0,
            tokenType,
            errors: [
                new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationError"]({
                    message,
                    code,
                    status: err.status
                })
            ]
        };
    }
    return {
        data: void 0,
        tokenType,
        errors: [
            new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationError"]({
                message: "Unexpected error",
                code: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationErrorCode"].UnexpectedError,
                status: err.status
            })
        ]
    };
}
async function verifyM2MToken(token, options) {
    try {
        const client = createBackendApiClient(options);
        const verifiedToken = await client.m2m.verify({
            token
        });
        return {
            data: verifiedToken,
            tokenType: TokenType.M2MToken,
            errors: void 0
        };
    } catch (err) {
        return handleClerkAPIError(TokenType.M2MToken, err, "Machine token not found");
    }
}
async function verifyJwtOAuthToken(accessToken, options) {
    let decoded;
    try {
        decoded = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["decodeJwt"])(accessToken);
    } catch (e) {
        return {
            data: void 0,
            tokenType: TokenType.OAuthToken,
            errors: [
                new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationError"]({
                    code: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationErrorCode"].TokenInvalid,
                    message: e.message
                })
            ]
        };
    }
    const { data: decodedResult, errors } = decoded;
    if (errors) {
        return {
            data: void 0,
            tokenType: TokenType.OAuthToken,
            errors: [
                new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationError"]({
                    code: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationErrorCode"].TokenInvalid,
                    message: errors[0].message
                })
            ]
        };
    }
    const { header } = decodedResult;
    const { kid } = header;
    let key;
    try {
        if (options.jwtKey) {
            key = loadClerkJwkFromPem({
                kid,
                pem: options.jwtKey
            });
        } else if (options.secretKey) {
            key = await loadClerkJWKFromRemote({
                ...options,
                kid
            });
        } else {
            return {
                data: void 0,
                tokenType: TokenType.OAuthToken,
                errors: [
                    new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationError"]({
                        action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].SetClerkJWTKey,
                        message: "Failed to resolve JWK during verification.",
                        code: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationErrorCode"].TokenVerificationFailed
                    })
                ]
            };
        }
        const { data: payload, errors: verifyErrors } = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["verifyJwt"])(accessToken, {
            ...options,
            key,
            headerType: OAUTH_ACCESS_TOKEN_TYPES
        });
        if (verifyErrors) {
            return {
                data: void 0,
                tokenType: TokenType.OAuthToken,
                errors: [
                    new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationError"]({
                        code: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationErrorCode"].TokenVerificationFailed,
                        message: verifyErrors[0].message
                    })
                ]
            };
        }
        const token = IdPOAuthAccessToken.fromJwtPayload(payload, options.clockSkewInMs);
        return {
            data: token,
            tokenType: TokenType.OAuthToken,
            errors: void 0
        };
    } catch (error) {
        return {
            tokenType: TokenType.OAuthToken,
            errors: [
                new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationError"]({
                    code: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationErrorCode"].TokenVerificationFailed,
                    message: error.message
                })
            ]
        };
    }
}
async function verifyOAuthToken(accessToken, options) {
    if (isJwtFormat(accessToken)) {
        return verifyJwtOAuthToken(accessToken, options);
    }
    try {
        const client = createBackendApiClient(options);
        const verifiedToken = await client.idPOAuthAccessToken.verify(accessToken);
        return {
            data: verifiedToken,
            tokenType: TokenType.OAuthToken,
            errors: void 0
        };
    } catch (err) {
        return handleClerkAPIError(TokenType.OAuthToken, err, "OAuth token not found");
    }
}
async function verifyAPIKey(secret, options) {
    try {
        const client = createBackendApiClient(options);
        const verifiedToken = await client.apiKeys.verify(secret);
        return {
            data: verifiedToken,
            tokenType: TokenType.ApiKey,
            errors: void 0
        };
    } catch (err) {
        return handleClerkAPIError(TokenType.ApiKey, err, "API key not found");
    }
}
async function verifyMachineAuthToken(token, options) {
    if (token.startsWith(M2M_TOKEN_PREFIX)) {
        return verifyM2MToken(token, options);
    }
    if (token.startsWith(OAUTH_TOKEN_PREFIX) || isJwtFormat(token)) {
        return verifyOAuthToken(token, options);
    }
    if (token.startsWith(API_KEY_PREFIX)) {
        return verifyAPIKey(token, options);
    }
    throw new Error("Unknown machine token type");
}
// src/tokens/handshake.ts
async function verifyHandshakeJwt(token, { key }) {
    const { data: decoded, errors } = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["decodeJwt"])(token);
    if (errors) {
        throw errors[0];
    }
    const { header, payload } = decoded;
    const { typ, alg } = header;
    (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["assertHeaderType"])(typ);
    (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["assertHeaderAlgorithm"])(alg);
    const { data: signatureValid, errors: signatureErrors } = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["hasValidSignature"])(decoded, key);
    if (signatureErrors) {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenVerificationFailed,
            message: `Error verifying handshake token. ${signatureErrors[0]}`
        });
    }
    if (!signatureValid) {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenInvalidSignature,
            message: "Handshake signature is invalid."
        });
    }
    return payload;
}
async function verifyHandshakeToken(token, options) {
    const { secretKey, apiUrl, apiVersion, jwksCacheTtlInMs, jwtKey, skipJwksCache } = options;
    const { data, errors } = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["decodeJwt"])(token);
    if (errors) {
        throw errors[0];
    }
    const { kid } = data.header;
    let key;
    if (jwtKey) {
        key = loadClerkJwkFromPem({
            kid,
            pem: jwtKey
        });
    } else if (secretKey) {
        key = await loadClerkJWKFromRemote({
            secretKey,
            apiUrl,
            apiVersion,
            kid,
            jwksCacheTtlInMs,
            skipJwksCache
        });
    } else {
        throw new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
            action: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorAction"].SetClerkJWTKey,
            message: "Failed to resolve JWK during handshake verification.",
            reason: __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].JWKFailedToResolve
        });
    }
    return verifyHandshakeJwt(token, {
        key
    });
}
var HandshakeService = class {
    constructor(authenticateContext, options, organizationMatcher){
        this.authenticateContext = authenticateContext;
        this.options = options;
        this.organizationMatcher = organizationMatcher;
    }
    /**
   * Determines if a request is eligible for handshake based on its headers
   *
   * Currently, a request is only eligible for a handshake if we can say it's *probably* a request for a document, not a fetch or some other exotic request.
   * This heuristic should give us a reliable enough signal for browsers that support `Sec-Fetch-Dest` and for those that don't.
   *
   * @returns boolean indicating if the request is eligible for handshake
   */ isRequestEligibleForHandshake() {
        const { accept, secFetchDest } = this.authenticateContext;
        if (secFetchDest === "document" || secFetchDest === "iframe") {
            return true;
        }
        if (!secFetchDest && accept?.startsWith("text/html")) {
            return true;
        }
        return false;
    }
    /**
   * Builds the redirect headers for a handshake request
   * @param reason - The reason for the handshake (e.g. 'session-token-expired')
   * @returns Headers object containing the Location header for redirect
   * @throws Error if clerkUrl is missing in authenticateContext
   */ buildRedirectToHandshake(reason) {
        if (!this.authenticateContext?.clerkUrl) {
            throw new Error("Missing clerkUrl in authenticateContext");
        }
        const redirectUrl = this.removeDevBrowserFromURL(this.authenticateContext.clerkUrl);
        let baseUrl = this.authenticateContext.frontendApi.startsWith("http") ? this.authenticateContext.frontendApi : `https://${this.authenticateContext.frontendApi}`;
        baseUrl = baseUrl.replace(/\/+$/, "") + "/";
        const url = new URL("v1/client/handshake", baseUrl);
        url.searchParams.append("redirect_url", redirectUrl?.href || "");
        url.searchParams.append("__clerk_api_version", SUPPORTED_BAPI_VERSION);
        url.searchParams.append(constants.QueryParameters.SuffixedCookies, this.authenticateContext.usesSuffixedCookies().toString());
        url.searchParams.append(constants.QueryParameters.HandshakeReason, reason);
        url.searchParams.append(constants.QueryParameters.HandshakeFormat, "nonce");
        if (this.authenticateContext.instanceType === "development" && this.authenticateContext.devBrowserToken) {
            url.searchParams.append(constants.QueryParameters.DevBrowser, this.authenticateContext.devBrowserToken);
        }
        const toActivate = this.getOrganizationSyncTarget(this.authenticateContext.clerkUrl, this.organizationMatcher);
        if (toActivate) {
            const params = this.getOrganizationSyncQueryParams(toActivate);
            params.forEach((value, key)=>{
                url.searchParams.append(key, value);
            });
        }
        return new Headers({
            [constants.Headers.Location]: url.href
        });
    }
    /**
   * Gets cookies from either a handshake nonce or a handshake token
   * @returns Promise resolving to string array of cookie directives
   */ async getCookiesFromHandshake() {
        const cookiesToSet = [];
        if (this.authenticateContext.handshakeNonce) {
            try {
                const handshakePayload = await this.authenticateContext.apiClient?.clients.getHandshakePayload({
                    nonce: this.authenticateContext.handshakeNonce
                });
                if (handshakePayload) {
                    cookiesToSet.push(...handshakePayload.directives);
                }
            } catch (error) {
                console.error("Clerk: HandshakeService: error getting handshake payload:", error);
            }
        } else if (this.authenticateContext.handshakeToken) {
            const handshakePayload = await verifyHandshakeToken(this.authenticateContext.handshakeToken, this.authenticateContext);
            if (handshakePayload && Array.isArray(handshakePayload.handshake)) {
                cookiesToSet.push(...handshakePayload.handshake);
            }
        }
        return cookiesToSet;
    }
    /**
   * Resolves a handshake request by verifying the handshake token and setting appropriate cookies
   * @returns Promise resolving to either a SignedInState or SignedOutState
   * @throws Error if handshake verification fails or if there are issues with the session token
   */ async resolveHandshake() {
        const headers = new Headers({
            "Access-Control-Allow-Origin": "null",
            "Access-Control-Allow-Credentials": "true"
        });
        const cookiesToSet = await this.getCookiesFromHandshake();
        let sessionToken = "";
        cookiesToSet.forEach((x)=>{
            headers.append("Set-Cookie", x);
            if (getCookieName(x).startsWith(constants.Cookies.Session)) {
                sessionToken = getCookieValue(x);
            }
        });
        if (this.authenticateContext.instanceType === "development") {
            const newUrl = new URL(this.authenticateContext.clerkUrl);
            newUrl.searchParams.delete(constants.QueryParameters.Handshake);
            newUrl.searchParams.delete(constants.QueryParameters.HandshakeHelp);
            newUrl.searchParams.delete(constants.QueryParameters.DevBrowser);
            newUrl.searchParams.delete(constants.QueryParameters.HandshakeNonce);
            headers.append(constants.Headers.Location, newUrl.toString());
            headers.set(constants.Headers.CacheControl, "no-store");
        }
        if (sessionToken === "") {
            return signedOut({
                tokenType: TokenType.SessionToken,
                authenticateContext: this.authenticateContext,
                reason: AuthErrorReason.SessionTokenMissing,
                message: "",
                headers
            });
        }
        const { data, errors: [error] = [] } = await verifyToken(sessionToken, this.authenticateContext);
        if (data) {
            return signedIn({
                tokenType: TokenType.SessionToken,
                authenticateContext: this.authenticateContext,
                sessionClaims: data,
                headers,
                token: sessionToken
            });
        }
        if (this.authenticateContext.instanceType === "development" && (error?.reason === __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenExpired || error?.reason === __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenNotActiveYet || error?.reason === __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenIatInTheFuture)) {
            const developmentError = new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"]({
                action: error.action,
                message: error.message,
                reason: error.reason
            });
            developmentError.tokenCarrier = "cookie";
            console.error(`Clerk: Clock skew detected. This usually means that your system clock is inaccurate. Clerk will attempt to account for the clock skew in development.

To resolve this issue, make sure your system's clock is set to the correct time (e.g. turn off and on automatic time synchronization).

---

${developmentError.getFullMessage()}`);
            const { data: retryResult, errors: [retryError] = [] } = await verifyToken(sessionToken, {
                ...this.authenticateContext,
                clockSkewInMs: 864e5
            });
            if (retryResult) {
                return signedIn({
                    tokenType: TokenType.SessionToken,
                    authenticateContext: this.authenticateContext,
                    sessionClaims: retryResult,
                    headers,
                    token: sessionToken
                });
            }
            throw new Error(retryError?.message || "Clerk: Handshake retry failed.");
        }
        throw new Error(error?.message || "Clerk: Handshake failed.");
    }
    /**
   * Handles handshake token verification errors in development mode
   * @param error - The TokenVerificationError that occurred
   * @throws Error with a descriptive message about the verification failure
   */ handleTokenVerificationErrorInDevelopment(error) {
        if (error.reason === __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenInvalidSignature) {
            const msg = `Clerk: Handshake token verification failed due to an invalid signature. If you have switched Clerk keys locally, clear your cookies and try again.`;
            throw new Error(msg);
        }
        throw new Error(`Clerk: Handshake token verification failed: ${error.getFullMessage()}.`);
    }
    /**
   * Checks if a redirect loop is detected and sets headers to track redirect count
   * @param headers - The Headers object to modify
   * @returns boolean indicating if a redirect loop was detected (true) or if the request can proceed (false)
   */ checkAndTrackRedirectLoop(headers) {
        if (this.authenticateContext.handshakeRedirectLoopCounter === 3) {
            return true;
        }
        const newCounterValue = this.authenticateContext.handshakeRedirectLoopCounter + 1;
        const cookieName = constants.Cookies.RedirectCount;
        headers.append("Set-Cookie", `${cookieName}=${newCounterValue}; SameSite=Lax; HttpOnly; Max-Age=2`);
        return false;
    }
    removeDevBrowserFromURL(url) {
        const updatedURL = new URL(url);
        updatedURL.searchParams.delete(constants.QueryParameters.DevBrowser);
        updatedURL.searchParams.delete(constants.QueryParameters.LegacyDevBrowser);
        return updatedURL;
    }
    getOrganizationSyncTarget(url, matchers) {
        return matchers.findTarget(url);
    }
    getOrganizationSyncQueryParams(toActivate) {
        const ret = /* @__PURE__ */ new Map();
        if (toActivate.type === "personalAccount") {
            ret.set("organization_id", "");
        }
        if (toActivate.type === "organization") {
            if (toActivate.organizationId) {
                ret.set("organization_id", toActivate.organizationId);
            }
            if (toActivate.organizationSlug) {
                ret.set("organization_id", toActivate.organizationSlug);
            }
        }
        return ret;
    }
};
;
var OrganizationMatcher = class {
    constructor(options){
        this.organizationPattern = this.createMatcher(options?.organizationPatterns);
        this.personalAccountPattern = this.createMatcher(options?.personalAccountPatterns);
    }
    createMatcher(pattern) {
        if (!pattern) {
            return null;
        }
        try {
            return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$pathToRegexp$2d$Bu45OrlU$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["match"])(pattern);
        } catch (e) {
            throw new Error(`Invalid pattern "${pattern}": ${e}`);
        }
    }
    findTarget(url) {
        const orgTarget = this.findOrganizationTarget(url);
        if (orgTarget) {
            return orgTarget;
        }
        return this.findPersonalAccountTarget(url);
    }
    findOrganizationTarget(url) {
        if (!this.organizationPattern) {
            return null;
        }
        try {
            const result = this.organizationPattern(url.pathname);
            if (!result || !("params" in result)) {
                return null;
            }
            const params = result.params;
            if (params.id) {
                return {
                    type: "organization",
                    organizationId: params.id
                };
            }
            if (params.slug) {
                return {
                    type: "organization",
                    organizationSlug: params.slug
                };
            }
            return null;
        } catch (e) {
            console.error("Failed to match organization pattern:", e);
            return null;
        }
    }
    findPersonalAccountTarget(url) {
        if (!this.personalAccountPattern) {
            return null;
        }
        try {
            const result = this.personalAccountPattern(url.pathname);
            return result ? {
                type: "personalAccount"
            } : null;
        } catch (e) {
            console.error("Failed to match personal account pattern:", e);
            return null;
        }
    }
};
// src/tokens/request.ts
var RefreshTokenErrorReason = {
    NonEligibleNoCookie: "non-eligible-no-refresh-cookie",
    NonEligibleNonGet: "non-eligible-non-get",
    InvalidSessionToken: "invalid-session-token",
    MissingApiClient: "missing-api-client",
    MissingSessionToken: "missing-session-token",
    MissingRefreshToken: "missing-refresh-token",
    ExpiredSessionTokenDecodeFailed: "expired-session-token-decode-failed",
    ExpiredSessionTokenMissingSidClaim: "expired-session-token-missing-sid-claim",
    FetchError: "fetch-error",
    UnexpectedSDKError: "unexpected-sdk-error",
    UnexpectedBAPIError: "unexpected-bapi-error"
};
function assertSignInUrlExists(signInUrl, key) {
    if (!signInUrl && (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$keys$2d$YNv6yjKk$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["isDevelopmentFromSecretKey"])(key)) {
        throw new Error(`Missing signInUrl. Pass a signInUrl for dev instances if an app is satellite`);
    }
}
function assertProxyUrlOrDomain(proxyUrlOrDomain) {
    if (!proxyUrlOrDomain) {
        throw new Error(`Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl`);
    }
}
function assertSignInUrlFormatAndOrigin(_signInUrl, origin) {
    let signInUrl;
    try {
        signInUrl = new URL(_signInUrl);
    } catch  {
        throw new Error(`The signInUrl needs to have a absolute url format.`);
    }
    if (signInUrl.origin === origin) {
        throw new Error(`The signInUrl needs to be on a different origin than your satellite application.`);
    }
}
function assertMachineSecretOrSecretKey(authenticateContext) {
    if (!authenticateContext.machineSecretKey && !authenticateContext.secretKey) {
        throw new Error("Machine token authentication requires either a Machine secret key or a Clerk secret key. Ensure a Clerk secret key or Machine secret key is set.");
    }
}
function isRequestEligibleForRefresh(err, authenticateContext, request) {
    return err.reason === __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenExpired && !!authenticateContext.refreshTokenInCookie && request.method === "GET";
}
function checkTokenTypeMismatch(parsedTokenType, acceptsToken, authenticateContext) {
    const mismatch = !isTokenTypeAccepted(parsedTokenType, acceptsToken);
    if (mismatch) {
        const tokenTypeToReturn = typeof acceptsToken === "string" ? acceptsToken : parsedTokenType;
        return signedOut({
            tokenType: tokenTypeToReturn,
            authenticateContext,
            reason: AuthErrorReason.TokenTypeMismatch
        });
    }
    return null;
}
function isTokenTypeInAcceptedArray(acceptsToken, authenticateContext) {
    let parsedTokenType = null;
    const { tokenInHeader } = authenticateContext;
    if (tokenInHeader) {
        if (isMachineToken(tokenInHeader)) {
            parsedTokenType = getMachineTokenType(tokenInHeader);
        } else {
            parsedTokenType = TokenType.SessionToken;
        }
    }
    const typeToCheck = parsedTokenType ?? TokenType.SessionToken;
    return isTokenTypeAccepted(typeToCheck, acceptsToken);
}
var authenticateRequest = async (request, options)=>{
    const authenticateContext = await createAuthenticateContext(createClerkRequest(request), options);
    const acceptsToken = options.acceptsToken ?? TokenType.SessionToken;
    if (acceptsToken !== TokenType.M2MToken) {
        assertValidSecretKey(authenticateContext.secretKey);
        if (authenticateContext.isSatellite) {
            assertSignInUrlExists(authenticateContext.signInUrl, authenticateContext.secretKey);
            if (authenticateContext.signInUrl && authenticateContext.origin) {
                assertSignInUrlFormatAndOrigin(authenticateContext.signInUrl, authenticateContext.origin);
            }
            assertProxyUrlOrDomain(authenticateContext.proxyUrl || authenticateContext.domain);
        }
    }
    if (acceptsToken === TokenType.M2MToken) {
        assertMachineSecretOrSecretKey(authenticateContext);
    }
    const organizationMatcher = new OrganizationMatcher(options.organizationSyncOptions);
    const handshakeService = new HandshakeService(authenticateContext, {
        organizationSyncOptions: options.organizationSyncOptions
    }, organizationMatcher);
    async function refreshToken(authenticateContext2) {
        if (!options.apiClient) {
            return {
                data: null,
                error: {
                    message: "An apiClient is needed to perform token refresh.",
                    cause: {
                        reason: RefreshTokenErrorReason.MissingApiClient
                    }
                }
            };
        }
        const { sessionToken: expiredSessionToken, refreshTokenInCookie: refreshToken2 } = authenticateContext2;
        if (!expiredSessionToken) {
            return {
                data: null,
                error: {
                    message: "Session token must be provided.",
                    cause: {
                        reason: RefreshTokenErrorReason.MissingSessionToken
                    }
                }
            };
        }
        if (!refreshToken2) {
            return {
                data: null,
                error: {
                    message: "Refresh token must be provided.",
                    cause: {
                        reason: RefreshTokenErrorReason.MissingRefreshToken
                    }
                }
            };
        }
        const { data: decodeResult, errors: decodedErrors } = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["decodeJwt"])(expiredSessionToken);
        if (!decodeResult || decodedErrors) {
            return {
                data: null,
                error: {
                    message: "Unable to decode the expired session token.",
                    cause: {
                        reason: RefreshTokenErrorReason.ExpiredSessionTokenDecodeFailed,
                        errors: decodedErrors
                    }
                }
            };
        }
        if (!decodeResult?.payload?.sid) {
            return {
                data: null,
                error: {
                    message: "Expired session token is missing the `sid` claim.",
                    cause: {
                        reason: RefreshTokenErrorReason.ExpiredSessionTokenMissingSidClaim
                    }
                }
            };
        }
        try {
            const response = await options.apiClient.sessions.refreshSession(decodeResult.payload.sid, {
                format: "cookie",
                suffixed_cookies: authenticateContext2.usesSuffixedCookies(),
                expired_token: expiredSessionToken || "",
                refresh_token: refreshToken2 || "",
                request_origin: authenticateContext2.clerkUrl.origin,
                // The refresh endpoint expects headers as Record<string, string[]>, so we need to transform it.
                request_headers: Object.fromEntries(Array.from(request.headers.entries()).map(([k, v])=>[
                        k,
                        [
                            v
                        ]
                    ]))
            });
            return {
                data: response.cookies,
                error: null
            };
        } catch (err) {
            if (err?.errors?.length) {
                if (err.errors[0].code === "unexpected_error") {
                    return {
                        data: null,
                        error: {
                            message: `Fetch unexpected error`,
                            cause: {
                                reason: RefreshTokenErrorReason.FetchError,
                                errors: err.errors
                            }
                        }
                    };
                }
                return {
                    data: null,
                    error: {
                        message: err.errors[0].code,
                        cause: {
                            reason: err.errors[0].code,
                            errors: err.errors
                        }
                    }
                };
            } else {
                return {
                    data: null,
                    error: {
                        message: `Unexpected Server/BAPI error`,
                        cause: {
                            reason: RefreshTokenErrorReason.UnexpectedBAPIError,
                            errors: [
                                err
                            ]
                        }
                    }
                };
            }
        }
    }
    async function attemptRefresh(authenticateContext2) {
        const { data: cookiesToSet, error } = await refreshToken(authenticateContext2);
        if (!cookiesToSet || cookiesToSet.length === 0) {
            return {
                data: null,
                error
            };
        }
        const headers = new Headers();
        let sessionToken = "";
        cookiesToSet.forEach((x)=>{
            headers.append("Set-Cookie", x);
            if (getCookieName(x).startsWith(constants.Cookies.Session)) {
                sessionToken = getCookieValue(x);
            }
        });
        const { data: jwtPayload, errors } = await verifyToken(sessionToken, authenticateContext2);
        if (errors) {
            return {
                data: null,
                error: {
                    message: `Clerk: unable to verify refreshed session token.`,
                    cause: {
                        reason: RefreshTokenErrorReason.InvalidSessionToken,
                        errors
                    }
                }
            };
        }
        return {
            data: {
                jwtPayload,
                sessionToken,
                headers
            },
            error: null
        };
    }
    function handleMaybeHandshakeStatus(authenticateContext2, reason, message, headers) {
        if (!handshakeService.isRequestEligibleForHandshake()) {
            return signedOut({
                tokenType: TokenType.SessionToken,
                authenticateContext: authenticateContext2,
                reason,
                message
            });
        }
        const handshakeHeaders = headers ?? handshakeService.buildRedirectToHandshake(reason);
        if (handshakeHeaders.get(constants.Headers.Location)) {
            handshakeHeaders.set(constants.Headers.CacheControl, "no-store");
        }
        const isRedirectLoop = handshakeService.checkAndTrackRedirectLoop(handshakeHeaders);
        if (isRedirectLoop) {
            const msg = `Clerk: Refreshing the session token resulted in an infinite redirect loop. This usually means that your Clerk instance keys do not match - make sure to copy the correct publishable and secret keys from the Clerk dashboard.`;
            console.log(msg);
            return signedOut({
                tokenType: TokenType.SessionToken,
                authenticateContext: authenticateContext2,
                reason,
                message
            });
        }
        return handshake(authenticateContext2, reason, message, handshakeHeaders);
    }
    function handleMaybeOrganizationSyncHandshake(authenticateContext2, auth) {
        const organizationSyncTarget = organizationMatcher.findTarget(authenticateContext2.clerkUrl);
        if (!organizationSyncTarget) {
            return null;
        }
        let mustActivate = false;
        if (organizationSyncTarget.type === "organization") {
            if (organizationSyncTarget.organizationSlug && organizationSyncTarget.organizationSlug !== auth.orgSlug) {
                mustActivate = true;
            }
            if (organizationSyncTarget.organizationId && organizationSyncTarget.organizationId !== auth.orgId) {
                mustActivate = true;
            }
        }
        if (organizationSyncTarget.type === "personalAccount" && auth.orgId) {
            mustActivate = true;
        }
        if (!mustActivate) {
            return null;
        }
        if (authenticateContext2.handshakeRedirectLoopCounter >= 3) {
            console.warn("Clerk: Organization activation handshake loop detected. This is likely due to an invalid organization ID or slug. Skipping organization activation.");
            return null;
        }
        const handshakeState = handleMaybeHandshakeStatus(authenticateContext2, AuthErrorReason.ActiveOrganizationMismatch, "");
        if (handshakeState.status !== "handshake") {
            return null;
        }
        return handshakeState;
    }
    async function authenticateRequestWithTokenInHeader() {
        const { tokenInHeader } = authenticateContext;
        try {
            const { data, errors } = await verifyToken(tokenInHeader, authenticateContext);
            if (errors) {
                throw errors[0];
            }
            return signedIn({
                tokenType: TokenType.SessionToken,
                authenticateContext,
                sessionClaims: data,
                headers: new Headers(),
                // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
                token: tokenInHeader
            });
        } catch (err) {
            return handleSessionTokenError(err, "header");
        }
    }
    async function authenticateRequestWithTokenInCookie() {
        const hasActiveClient = authenticateContext.clientUat;
        const hasSessionToken = !!authenticateContext.sessionTokenInCookie;
        const hasDevBrowserToken = !!authenticateContext.devBrowserToken;
        if (authenticateContext.handshakeNonce || authenticateContext.handshakeToken) {
            try {
                return await handshakeService.resolveHandshake();
            } catch (error) {
                if (error instanceof __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"] && authenticateContext.instanceType === "development") {
                    handshakeService.handleTokenVerificationErrorInDevelopment(error);
                } else {
                    console.error("Clerk: unable to resolve handshake:", error);
                }
            }
        }
        const isRequestEligibleForMultiDomainSync = authenticateContext.isSatellite && authenticateContext.secFetchDest === "document";
        if (authenticateContext.instanceType === "production" && isRequestEligibleForMultiDomainSync) {
            return handleMaybeHandshakeStatus(authenticateContext, AuthErrorReason.SatelliteCookieNeedsSyncing, "");
        }
        if (authenticateContext.instanceType === "development" && isRequestEligibleForMultiDomainSync && !authenticateContext.clerkUrl.searchParams.has(constants.QueryParameters.ClerkSynced)) {
            const redirectURL = new URL(authenticateContext.signInUrl);
            redirectURL.searchParams.append(constants.QueryParameters.ClerkRedirectUrl, authenticateContext.clerkUrl.toString());
            const headers = new Headers({
                [constants.Headers.Location]: redirectURL.toString()
            });
            return handleMaybeHandshakeStatus(authenticateContext, AuthErrorReason.SatelliteCookieNeedsSyncing, "", headers);
        }
        const redirectUrl = new URL(authenticateContext.clerkUrl).searchParams.get(constants.QueryParameters.ClerkRedirectUrl);
        if (authenticateContext.instanceType === "development" && !authenticateContext.isSatellite && redirectUrl) {
            const redirectBackToSatelliteUrl = new URL(redirectUrl);
            if (authenticateContext.devBrowserToken) {
                redirectBackToSatelliteUrl.searchParams.append(constants.QueryParameters.DevBrowser, authenticateContext.devBrowserToken);
            }
            redirectBackToSatelliteUrl.searchParams.append(constants.QueryParameters.ClerkSynced, "true");
            const headers = new Headers({
                [constants.Headers.Location]: redirectBackToSatelliteUrl.toString()
            });
            return handleMaybeHandshakeStatus(authenticateContext, AuthErrorReason.PrimaryRespondsToSyncing, "", headers);
        }
        if (authenticateContext.instanceType === "development" && authenticateContext.clerkUrl.searchParams.has(constants.QueryParameters.DevBrowser)) {
            return handleMaybeHandshakeStatus(authenticateContext, AuthErrorReason.DevBrowserSync, "");
        }
        if (authenticateContext.instanceType === "development" && !hasDevBrowserToken) {
            return handleMaybeHandshakeStatus(authenticateContext, AuthErrorReason.DevBrowserMissing, "");
        }
        if (!hasActiveClient && !hasSessionToken) {
            return signedOut({
                tokenType: TokenType.SessionToken,
                authenticateContext,
                reason: AuthErrorReason.SessionTokenAndUATMissing
            });
        }
        if (!hasActiveClient && hasSessionToken) {
            return handleMaybeHandshakeStatus(authenticateContext, AuthErrorReason.SessionTokenWithoutClientUAT, "");
        }
        if (hasActiveClient && !hasSessionToken) {
            return handleMaybeHandshakeStatus(authenticateContext, AuthErrorReason.ClientUATWithoutSessionToken, "");
        }
        const { data: decodeResult, errors: decodedErrors } = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["decodeJwt"])(authenticateContext.sessionTokenInCookie);
        if (decodedErrors) {
            return handleSessionTokenError(decodedErrors[0], "cookie");
        }
        if (decodeResult.payload.iat < authenticateContext.clientUat) {
            return handleMaybeHandshakeStatus(authenticateContext, AuthErrorReason.SessionTokenIATBeforeClientUAT, "");
        }
        try {
            const { data, errors } = await verifyToken(authenticateContext.sessionTokenInCookie, authenticateContext);
            if (errors) {
                throw errors[0];
            }
            const signedInRequestState = signedIn({
                tokenType: TokenType.SessionToken,
                authenticateContext,
                sessionClaims: data,
                headers: new Headers(),
                // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
                token: authenticateContext.sessionTokenInCookie
            });
            const shouldForceHandshakeForCrossDomain = !authenticateContext.isSatellite && // We're on primary
            authenticateContext.secFetchDest === "document" && // Document navigation
            authenticateContext.isCrossOriginReferrer() && // Came from different domain
            !authenticateContext.isKnownClerkReferrer() && // Not from Clerk accounts portal or FAPI
            authenticateContext.handshakeRedirectLoopCounter === 0;
            if (shouldForceHandshakeForCrossDomain) {
                return handleMaybeHandshakeStatus(authenticateContext, AuthErrorReason.PrimaryDomainCrossOriginSync, "Cross-origin request from satellite domain requires handshake");
            }
            const authObject = signedInRequestState.toAuth();
            if (authObject.userId) {
                const handshakeRequestState = handleMaybeOrganizationSyncHandshake(authenticateContext, authObject);
                if (handshakeRequestState) {
                    return handshakeRequestState;
                }
            }
            return signedInRequestState;
        } catch (err) {
            return handleSessionTokenError(err, "cookie");
        }
        return signedOut({
            tokenType: TokenType.SessionToken,
            authenticateContext,
            reason: AuthErrorReason.UnexpectedError
        });
    }
    async function handleSessionTokenError(err, tokenCarrier) {
        if (!(err instanceof __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationError"])) {
            return signedOut({
                tokenType: TokenType.SessionToken,
                authenticateContext,
                reason: AuthErrorReason.UnexpectedError
            });
        }
        let refreshError;
        if (isRequestEligibleForRefresh(err, authenticateContext, request)) {
            const { data, error } = await attemptRefresh(authenticateContext);
            if (data) {
                return signedIn({
                    tokenType: TokenType.SessionToken,
                    authenticateContext,
                    sessionClaims: data.jwtPayload,
                    headers: data.headers,
                    token: data.sessionToken
                });
            }
            if (error?.cause?.reason) {
                refreshError = error.cause.reason;
            } else {
                refreshError = RefreshTokenErrorReason.UnexpectedSDKError;
            }
        } else {
            if (request.method !== "GET") {
                refreshError = RefreshTokenErrorReason.NonEligibleNonGet;
            } else if (!authenticateContext.refreshTokenInCookie) {
                refreshError = RefreshTokenErrorReason.NonEligibleNoCookie;
            } else {
                refreshError = null;
            }
        }
        err.tokenCarrier = tokenCarrier;
        const reasonToHandshake = [
            __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenExpired,
            __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenNotActiveYet,
            __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenIatInTheFuture
        ].includes(err.reason);
        if (reasonToHandshake) {
            return handleMaybeHandshakeStatus(authenticateContext, convertTokenVerificationErrorReasonToAuthErrorReason({
                tokenError: err.reason,
                refreshError
            }), err.getFullMessage());
        }
        return signedOut({
            tokenType: TokenType.SessionToken,
            authenticateContext,
            reason: err.reason,
            message: err.getFullMessage()
        });
    }
    function handleMachineError(tokenType, err) {
        if (!(err instanceof __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["MachineTokenVerificationError"])) {
            return signedOut({
                tokenType,
                authenticateContext,
                reason: AuthErrorReason.UnexpectedError
            });
        }
        return signedOut({
            tokenType,
            authenticateContext,
            reason: err.code,
            message: err.getFullMessage()
        });
    }
    async function authenticateMachineRequestWithTokenInHeader() {
        const { tokenInHeader } = authenticateContext;
        if (!tokenInHeader) {
            return handleSessionTokenError(new Error("Missing token in header"), "header");
        }
        if (!isMachineToken(tokenInHeader)) {
            return signedOut({
                tokenType: acceptsToken,
                authenticateContext,
                reason: AuthErrorReason.TokenTypeMismatch,
                message: ""
            });
        }
        const parsedTokenType = getMachineTokenType(tokenInHeader);
        const mismatchState = checkTokenTypeMismatch(parsedTokenType, acceptsToken, authenticateContext);
        if (mismatchState) {
            return mismatchState;
        }
        const { data, tokenType, errors } = await verifyMachineAuthToken(tokenInHeader, authenticateContext);
        if (errors) {
            return handleMachineError(tokenType, errors[0]);
        }
        return signedIn({
            tokenType,
            authenticateContext,
            machineData: data,
            token: tokenInHeader
        });
    }
    async function authenticateAnyRequestWithTokenInHeader() {
        const { tokenInHeader } = authenticateContext;
        if (!tokenInHeader) {
            return handleSessionTokenError(new Error("Missing token in header"), "header");
        }
        if (isMachineToken(tokenInHeader)) {
            const parsedTokenType = getMachineTokenType(tokenInHeader);
            const mismatchState = checkTokenTypeMismatch(parsedTokenType, acceptsToken, authenticateContext);
            if (mismatchState) {
                return mismatchState;
            }
            const { data: data2, tokenType, errors: errors2 } = await verifyMachineAuthToken(tokenInHeader, authenticateContext);
            if (errors2) {
                return handleMachineError(tokenType, errors2[0]);
            }
            return signedIn({
                tokenType,
                authenticateContext,
                machineData: data2,
                token: tokenInHeader
            });
        }
        const { data, errors } = await verifyToken(tokenInHeader, authenticateContext);
        if (errors) {
            return handleSessionTokenError(errors[0], "header");
        }
        return signedIn({
            tokenType: TokenType.SessionToken,
            authenticateContext,
            sessionClaims: data,
            token: tokenInHeader
        });
    }
    if (Array.isArray(acceptsToken)) {
        if (!isTokenTypeInAcceptedArray(acceptsToken, authenticateContext)) {
            return signedOutInvalidToken();
        }
    }
    if (authenticateContext.tokenInHeader) {
        if (acceptsToken === "any") {
            return authenticateAnyRequestWithTokenInHeader();
        }
        if (acceptsToken === TokenType.SessionToken) {
            return authenticateRequestWithTokenInHeader();
        }
        return authenticateMachineRequestWithTokenInHeader();
    }
    if (acceptsToken === TokenType.OAuthToken || acceptsToken === TokenType.ApiKey || acceptsToken === TokenType.M2MToken) {
        return signedOut({
            tokenType: acceptsToken,
            authenticateContext,
            reason: "No token in header"
        });
    }
    return authenticateRequestWithTokenInCookie();
};
var debugRequestState = (params)=>{
    const { isSignedIn, isAuthenticated, proxyUrl, reason, message, publishableKey, isSatellite, domain } = params;
    return {
        isSignedIn,
        isAuthenticated,
        proxyUrl,
        reason,
        message,
        publishableKey,
        isSatellite,
        domain
    };
};
var convertTokenVerificationErrorReasonToAuthErrorReason = ({ tokenError, refreshError })=>{
    switch(tokenError){
        case __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenExpired:
            return `${AuthErrorReason.SessionTokenExpired}-refresh-${refreshError}`;
        case __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenNotActiveYet:
            return AuthErrorReason.SessionTokenNBF;
        case __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TokenVerificationErrorReason"].TokenIatInTheFuture:
            return AuthErrorReason.SessionTokenIatInTheFuture;
        default:
            return AuthErrorReason.UnexpectedError;
    }
};
// src/tokens/factory.ts
var defaultOptions = {
    secretKey: "",
    machineSecretKey: "",
    jwtKey: "",
    apiUrl: void 0,
    apiVersion: void 0,
    proxyUrl: "",
    publishableKey: "",
    isSatellite: false,
    domain: "",
    audience: ""
};
function createAuthenticateRequest(params) {
    const buildTimeOptions = mergePreDefinedOptions(defaultOptions, params.options);
    const apiClient = params.apiClient;
    const authenticateRequest2 = (request, options = {})=>{
        const { apiUrl, apiVersion } = buildTimeOptions;
        const runTimeOptions = mergePreDefinedOptions(buildTimeOptions, options);
        return authenticateRequest(request, {
            ...options,
            ...runTimeOptions,
            // We should add all the omitted props from options here (eg apiUrl / apiVersion)
            // to avoid runtime options override them.
            apiUrl,
            apiVersion,
            apiClient
        });
    };
    return {
        authenticateRequest: authenticateRequest2,
        debugRequestState
    };
}
// src/util/decorateObjectWithResources.ts
var decorateObjectWithResources = async (obj, authObj, opts)=>{
    const { loadSession, loadUser, loadOrganization } = opts || {};
    const { userId, sessionId, orgId } = authObj;
    const { sessions, users, organizations } = createBackendApiClient({
        ...opts
    });
    const [sessionResp, userResp, organizationResp] = await Promise.all([
        loadSession && sessionId ? sessions.getSession(sessionId) : Promise.resolve(void 0),
        loadUser && userId ? users.getUser(userId) : Promise.resolve(void 0),
        loadOrganization && orgId ? organizations.getOrganization({
            organizationId: orgId
        }) : Promise.resolve(void 0)
    ]);
    const resources = stripPrivateDataFromObject({
        session: sessionResp,
        user: userResp,
        organization: organizationResp
    });
    return Object.assign(obj, resources);
};
function stripPrivateDataFromObject(authObject) {
    const user = authObject.user ? {
        ...authObject.user
    } : authObject.user;
    const organization = authObject.organization ? {
        ...authObject.organization
    } : authObject.organization;
    prunePrivateMetadata(user);
    prunePrivateMetadata(organization);
    return {
        ...authObject,
        user,
        organization
    };
}
function prunePrivateMetadata(resource) {
    if (resource) {
        if ("privateMetadata" in resource) {
            delete resource["privateMetadata"];
        }
        if ("private_metadata" in resource) {
            delete resource["private_metadata"];
        }
    }
    return resource;
}
;
;
 //# sourceMappingURL=chunk-4EVRZKGK.mjs.map
}),
"[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/internal.mjs [app-rsc] (ecmascript) <locals>", ((__turbopack_context__) => {
"use strict";

__turbopack_context__.s([]);
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$4EVRZKGK$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-4EVRZKGK.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$authorization$2d$errors$2d$CS1pNy8i$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/authorization-errors-CS1pNy8i.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$YBVFDYDR$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-YBVFDYDR.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-7X3P2E3X.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-TCIXZLLW.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$RPS7XK5K$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-RPS7XK5K.mjs [app-rsc] (ecmascript)");
;
;
;
;
;
;
 //# sourceMappingURL=internal.mjs.map
}),
"[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-P263NW7Z.mjs [app-rsc] (ecmascript)", ((__turbopack_context__) => {
"use strict";

// src/jwt/legacyReturn.ts
__turbopack_context__.s([
    "withLegacyReturn",
    ()=>withLegacyReturn,
    "withLegacySyncReturn",
    ()=>withLegacySyncReturn
]);
function withLegacyReturn(cb) {
    return async (...args)=>{
        const { data, errors } = await cb(...args);
        if (errors) {
            throw errors[0];
        }
        return data;
    };
}
function withLegacySyncReturn(cb) {
    return (...args)=>{
        const { data, errors } = cb(...args);
        if (errors) {
            throw errors[0];
        }
        return data;
    };
}
;
 //# sourceMappingURL=chunk-P263NW7Z.mjs.map
}),
"[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/jwt/index.mjs [app-rsc] (ecmascript)", ((__turbopack_context__) => {
"use strict";

__turbopack_context__.s([
    "decodeJwt",
    ()=>decodeJwt2,
    "hasValidSignature",
    ()=>hasValidSignature2,
    "signJwt",
    ()=>signJwt2,
    "verifyJwt",
    ()=>verifyJwt2
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$P263NW7Z$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-P263NW7Z.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-7X3P2E3X.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-TCIXZLLW.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$RPS7XK5K$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-RPS7XK5K.mjs [app-rsc] (ecmascript)");
;
;
;
;
// src/jwt/signJwt.ts
function encodeJwtData(value) {
    const stringified = JSON.stringify(value);
    const encoder = new TextEncoder();
    const encoded = encoder.encode(stringified);
    return __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["base64url"].stringify(encoded, {
        pad: false
    });
}
async function signJwt(payload, key, options) {
    if (!options.algorithm) {
        throw new Error("No algorithm specified");
    }
    const encoder = new TextEncoder();
    const algorithm = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["getCryptoAlgorithm"])(options.algorithm);
    if (!algorithm) {
        return {
            errors: [
                new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["SignJWTError"](`Unsupported algorithm ${options.algorithm}`)
            ]
        };
    }
    const cryptoKey = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["importKey"])(key, algorithm, "sign");
    const header = options.header || {
        typ: "JWT"
    };
    header.alg = options.algorithm;
    payload.iat = Math.floor(Date.now() / 1e3);
    const encodedHeader = encodeJwtData(header);
    const encodedPayload = encodeJwtData(payload);
    const firstPart = `${encodedHeader}.${encodedPayload}`;
    try {
        const signature = await __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["runtime"].crypto.subtle.sign(algorithm, cryptoKey, encoder.encode(firstPart));
        const encodedSignature = `${firstPart}.${__TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["base64url"].stringify(new Uint8Array(signature), {
            pad: false
        })}`;
        return {
            data: encodedSignature
        };
    } catch (error) {
        return {
            errors: [
                new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["SignJWTError"](error?.message)
            ]
        };
    }
}
// src/jwt/index.ts
var verifyJwt2 = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$P263NW7Z$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["withLegacyReturn"])(__TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["verifyJwt"]);
var decodeJwt2 = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$P263NW7Z$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["withLegacySyncReturn"])(__TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["decodeJwt"]);
var signJwt2 = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$P263NW7Z$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["withLegacyReturn"])(signJwt);
var hasValidSignature2 = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$P263NW7Z$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["withLegacyReturn"])(__TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["hasValidSignature"]);
;
 //# sourceMappingURL=index.mjs.map
}),
"[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/index.mjs [app-rsc] (ecmascript)", ((__turbopack_context__) => {
"use strict";

__turbopack_context__.s([
    "createClerkClient",
    ()=>createClerkClient,
    "verifyToken",
    ()=>verifyToken2
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$4EVRZKGK$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-4EVRZKGK.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$YBVFDYDR$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-YBVFDYDR.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$P263NW7Z$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-P263NW7Z.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$7X3P2E3X$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-7X3P2E3X.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$TCIXZLLW$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-TCIXZLLW.mjs [app-rsc] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$RPS7XK5K$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/backend/dist/chunk-RPS7XK5K.mjs [app-rsc] (ecmascript)");
// src/index.ts
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$telemetry$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/telemetry.mjs [app-rsc] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$telemetry$2d$wqMDWlvR$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Desktop/Aynnaka/DiffaTours-main 2/node_modules/@clerk/shared/dist/runtime/telemetry-wqMDWlvR.mjs [app-rsc] (ecmascript)");
;
;
;
;
;
;
;
var verifyToken2 = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$P263NW7Z$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["withLegacyReturn"])(__TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$4EVRZKGK$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__["verifyToken"]);
function createClerkClient(options) {
    const opts = {
        ...options
    };
    const apiClient = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$4EVRZKGK$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__["createBackendApiClient"])(opts);
    const requestState = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$backend$2f$dist$2f$chunk$2d$4EVRZKGK$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$3c$locals$3e$__["createAuthenticateRequest"])({
        options: opts,
        apiClient
    });
    const telemetry = new __TURBOPACK__imported__module__$5b$project$5d2f$Desktop$2f$Aynnaka$2f$DiffaTours$2d$main__2$2f$node_modules$2f40$clerk$2f$shared$2f$dist$2f$runtime$2f$telemetry$2d$wqMDWlvR$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["TelemetryCollector"]({
        publishableKey: opts.publishableKey,
        secretKey: opts.secretKey,
        samplingRate: 0.1,
        ...opts.sdkMetadata ? {
            sdk: opts.sdkMetadata.name,
            sdkVersion: opts.sdkMetadata.version
        } : {},
        ...opts.telemetry || {}
    });
    return {
        ...apiClient,
        ...requestState,
        telemetry
    };
}
;
 //# sourceMappingURL=index.mjs.map
}),
];

//# sourceMappingURL=e99c8_%40clerk_backend_dist_96543c6f._.js.map