"use strict";
(() => {
var exports = {};
exports.id = 829;
exports.ids = [829];
exports.modules = {

/***/ 32104:
/***/ ((module) => {

module.exports = require("@next-auth/prisma-adapter");

/***/ }),

/***/ 53524:
/***/ ((module) => {

module.exports = require("@prisma/client");

/***/ }),

/***/ 73227:
/***/ ((module) => {

module.exports = require("next-auth");

/***/ }),

/***/ 47449:
/***/ ((module) => {

module.exports = require("next-auth/providers/credentials");

/***/ }),

/***/ 41649:
/***/ ((module) => {

module.exports = require("next-auth/react");

/***/ }),

/***/ 96703:
/***/ ((module) => {

module.exports = require("siwe");

/***/ }),

/***/ 48534:
/***/ ((module) => {

module.exports = require("viem");

/***/ }),

/***/ 50852:
/***/ ((module) => {

module.exports = require("async_hooks");

/***/ }),

/***/ 14300:
/***/ ((module) => {

module.exports = require("buffer");

/***/ }),

/***/ 82361:
/***/ ((module) => {

module.exports = require("events");

/***/ }),

/***/ 57147:
/***/ ((module) => {

module.exports = require("fs");

/***/ }),

/***/ 13685:
/***/ ((module) => {

module.exports = require("http");

/***/ }),

/***/ 41808:
/***/ ((module) => {

module.exports = require("net");

/***/ }),

/***/ 6005:
/***/ ((module) => {

module.exports = require("node:crypto");

/***/ }),

/***/ 71017:
/***/ ((module) => {

module.exports = require("path");

/***/ }),

/***/ 63477:
/***/ ((module) => {

module.exports = require("querystring");

/***/ }),

/***/ 12781:
/***/ ((module) => {

module.exports = require("stream");

/***/ }),

/***/ 71576:
/***/ ((module) => {

module.exports = require("string_decoder");

/***/ }),

/***/ 57310:
/***/ ((module) => {

module.exports = require("url");

/***/ }),

/***/ 73837:
/***/ ((module) => {

module.exports = require("util");

/***/ }),

/***/ 59796:
/***/ ((module) => {

module.exports = require("zlib");

/***/ }),

/***/ 32346:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// EXPORTS
__webpack_require__.d(__webpack_exports__, {
  "default": () => (/* binding */ _trpc_)
});

// EXTERNAL MODULE: ../../node_modules/.pnpm/@trpc+server@10.36.0/node_modules/@trpc/server/dist/index.mjs
var dist = __webpack_require__(52456);
// EXTERNAL MODULE: ../../node_modules/.pnpm/superjson@1.13.1/node_modules/superjson/dist/index.js
var superjson_dist = __webpack_require__(63887);
var dist_default = /*#__PURE__*/__webpack_require__.n(superjson_dist);
;// CONCATENATED MODULE: ../../packages/trpc/src/utils/transformer.ts
// Copyright (C) 2023 Light, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
/**
 * If you need to add transformers for special data types like `Temporal.Instant` or `Temporal.Date`, `Decimal.js`, etc you can do so here.
 * Make sure to import this file rather than `superjson` directly.
 * @see https://github.com/blitz-js/superjson#recipes
 */ 
const transformer = (dist_default());

// EXTERNAL MODULE: ../../node_modules/.pnpm/@trpc-limiter+core@0.0.8_@trpc+client@10.36.0_@trpc+server@10.36.0/node_modules/@trpc-limiter/core/dist/index.js
var core_dist = __webpack_require__(98211);
// EXTERNAL MODULE: ../../node_modules/.pnpm/@upstash+ratelimit@0.4.3/node_modules/@upstash/ratelimit/dist/index.js
var ratelimit_dist = __webpack_require__(28047);
// EXTERNAL MODULE: ../../node_modules/.pnpm/@upstash+redis@1.22.0/node_modules/@upstash/redis/esm/platforms/nodejs.js + 154 modules
var nodejs = __webpack_require__(25898);
;// CONCATENATED MODULE: ../../packages/trpc/src/utils/rate-limit.ts
// Copyright (C) 2023 Light, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
// From: https://github.com/OrJDev/trpc-limiter/blob/a4b6c38c9a3a04f042dd5a7b7b20af710ec4801f/packages/upstash/src/index.ts



const createTRPCUpstashLimiter = (0,core_dist/* defineTRPCLimiter */.b)({
    store: (opts)=>new ratelimit_dist.Ratelimit({
            redis: nodejs/* Redis */.s.fromEnv(),
            limiter: ratelimit_dist.Ratelimit.fixedWindow(opts.max, `${opts.windowMs} ms`)
        }),
    async isBlocked (store, fingerprint) {
        const { success, pending, ...rest } = await store.limit(fingerprint);
        await pending;
        return success ? null : rest;
    }
});

// EXTERNAL MODULE: ../../node_modules/.pnpm/zod@3.21.4/node_modules/zod/lib/index.mjs
var lib = __webpack_require__(45948);
;// CONCATENATED MODULE: ../../packages/trpc/src/server/trpc.ts
// Copyright (C) 2023 Light, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
/**
 * This is your entry point to setup the root configuration for tRPC on the server.
 * - `initTRPC` should only be used once per app.
 * - We export only the functionality that we use so we can enforce which base procedures should be used
 *
 * Learn how to create protected base procedures and other things below:
 * @see https://trpc.io/docs/v10/router
 * @see https://trpc.io/docs/v10/procedures
 */ 



const root = dist/* initTRPC */.rN.meta().context().create({
    /**
     * @see https://trpc.io/docs/v10/data-transformers
     */ transformer: transformer,
    // From: https://trpc.io/docs/server/error-formatting
    errorFormatter ({ shape, error }) {
        return {
            ...shape,
            data: {
                ...shape.data,
                zodError: error.code === "BAD_REQUEST" && error.cause instanceof lib/* ZodError */.jm ? error.cause.flatten() : null
            }
        };
    }
});
/**
 * Create a router
 * @see https://trpc.io/docs/v10/router
 */ const router = root.router;
/**
 * Create an unprotected procedure
 * @see https://trpc.io/docs/v10/procedures
 **/ const publicProcedure = root.procedure;
/**
 * @see https://trpc.io/docs/v10/middlewares
 */ const middleware = root.middleware;
/**
 * @see https://trpc.io/docs/v10/merging-routers
 */ const mergeRouters = root.mergeRouters;
const getFingerprint = (req)=>{
    const forwarded = req.headers["x-forwarded-for"];
    const ip = forwarded ? (typeof forwarded === "string" ? forwarded : forwarded[0])?.split(/, /)[0] : req.socket.remoteAddress;
    return ip || "127.0.0.1";
};
const rateLimiter = createTRPCUpstashLimiter({
    root,
    fingerprint: (ctx)=>getFingerprint(ctx.req),
    windowMs: 20000,
    message: (hitInfo)=>`Too many requests, please try again later. ${Math.ceil((hitInfo.reset - Date.now()) / 1000)}`,
    onLimit: (hitInfo)=>{
        console.log(hitInfo);
    },
    max: 5
});
const rateLimitedProcedure = publicProcedure.use(rateLimiter);

// EXTERNAL MODULE: external "@prisma/client"
var client_ = __webpack_require__(53524);
// EXTERNAL MODULE: ../../configurations/prisma/index.ts + 5 modules
var prisma = __webpack_require__(4812);
;// CONCATENATED MODULE: ../../packages/trpc/src/routers/user.ts
// Copyright (C) 2023 Light, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
/**
 *
 * This is an example router, you can delete this file and then update `../pages/api/trpc/[trpc].tsx`
 */ 




/**
 * Default selector for User.
 * It's important to always explicitly say which fields you want to return in order to not leak extra information
 * @see https://github.com/prisma/prisma/issues/9353
 */ const defaultUserSelect = client_.Prisma.validator()({
    id: true,
    createdAt: true,
    updatedAt: true
});
const userRouter = router({
    list: publicProcedure.input(lib.z.object({
        limit: lib.z.number().min(1).max(100).nullish(),
        cursor: lib.z.string().nullish()
    })).query(async ({ input })=>{
        /**
       * For pagination docs you can have a look here
       * @see https://trpc.io/docs/useInfiniteQuery
       * @see https://www.prisma.io/docs/concepts/components/prisma-client/pagination
       */ const limit = input.limit ?? 50;
        const { cursor } = input;
        const items = await prisma.prisma.user.findMany({
            select: defaultUserSelect,
            // get an extra item at the end which we'll use as next cursor
            take: limit + 1,
            where: {},
            cursor: cursor ? {
                id: cursor
            } : undefined,
            orderBy: {
                createdAt: "desc"
            }
        });
        let nextCursor = undefined;
        if (items.length > limit) {
            // Remove the last item and use it as next cursor
            // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
            const nextItem = items.pop();
            nextCursor = nextItem.id;
        }
        return {
            items: items.reverse(),
            nextCursor
        };
    }),
    byId: rateLimitedProcedure.input(lib.z.object({
        id: lib.z.string()
    })).query(async ({ input })=>{
        const { id } = input;
        const user = await prisma.prisma.user.findUnique({
            where: {
                id
            },
            select: defaultUserSelect
        });
        if (!user) {
            throw new dist/* TRPCError */.bR({
                code: "NOT_FOUND",
                message: `No user with id '${id}'`
            });
        }
        return user;
    }),
    add: publicProcedure.input(lib.z.object({
        id: lib.z.string().uuid().optional(),
        title: lib.z.string().min(1).max(32),
        text: lib.z.string().min(1)
    })).mutation(async ({ input })=>{
        const user = await prisma.prisma.user.create({
            data: input,
            select: defaultUserSelect
        });
        return user;
    })
});

;// CONCATENATED MODULE: ../../packages/trpc/src/routers/app.ts
// Copyright (C) 2023 Light, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.


const appRouter = router({
    healthcheck: publicProcedure.query(()=>"yay!"),
    user: userRouter
});

;// CONCATENATED MODULE: ../../packages/trpc/src/routers/index.ts
// Copyright (C) 2023 Light, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.



// EXTERNAL MODULE: ../../packages/auth/index.ts
var auth = __webpack_require__(15559);
;// CONCATENATED MODULE: ../../packages/trpc/src/server/context.ts
// Copyright (C) 2023 Light, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.


/** Use this helper for:
 * - testing, so we dont have to mock Next.js' req/res
 * - trpc's `createSSGHelpers` where we don't have req/res
 * @see https://create.t3.gg/en/usage/trpc#-servertrpccontextts
 **/ // eslint-disable-next-line no-unused-vars
const createInnerTRPCContext = async (opts)=>{
    return {
        req: opts.req,
        res: opts.res,
        session: opts.session,
        prisma: prisma.prisma
    };
};
/**
 * This is the actual context you'll use in your router
 * @link https://trpc.io/docs/context
 **/ const createContext = async ({ req, res })=>{
    // Get the session from the server using the getServerSession wrapper function
    const session = await (0,auth/* getNextAuthServerSession */.nu)({
        req,
        res
    });
    return createInnerTRPCContext({
        req,
        res,
        session
    });
};

// EXTERNAL MODULE: ../../node_modules/.pnpm/@trpc+server@10.36.0/node_modules/@trpc/server/dist/adapters/next.mjs + 7 modules
var next = __webpack_require__(75080);
;// CONCATENATED MODULE: ../../packages/trpc/src/server/handler.ts
// Copyright (C) 2023 Light, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.


// From: https://trpc.io/docs/server/caching
const nextHandler = (handler)=>next/* createNextApiHandler */.K({
        router: handler,
        createContext: createContext,
        responseMeta (opts) {
            const { ctx, paths, errors, type } = opts;
            // assuming you have all your public routes with the keyword `public` in them
            const allPublic = paths && paths.every((path)=>path.includes("public"));
            // checking that no procedures errored
            const allOk = errors.length === 0;
            // checking we're doing a query request
            const isQuery = type === "query";
            if (ctx?.res && allPublic && allOk && isQuery) {
                // cache request for 1 day + revalidate once every second
                const ONE_DAY_IN_SECONDS = 60 * 60 * 24;
                return {
                    headers: {
                        "cache-control": `s-maxage=1, stale-while-revalidate=${ONE_DAY_IN_SECONDS}`
                    }
                };
            }
            return {};
        },
        onError (opts) {
            // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
            const { error, type, path, input, ctx, req } = opts;
            console.error("Error:", error);
            // console.error("Type:", type);
            // console.error("Path:", path);
            // console.error("Input:", input);
            // console.error("Context:", ctx);
            // console.error("Request:", req);
            if (error.code === "INTERNAL_SERVER_ERROR") {
            // send to bug reporting
            }
        }
    });

// EXTERNAL MODULE: ../../node_modules/.pnpm/trpc-openapi@1.2.0_@trpc+server@10.36.0_zod@3.21.4/node_modules/trpc-openapi/dist/index.js
var trpc_openapi_dist = __webpack_require__(93283);
;// CONCATENATED MODULE: ../../packages/trpc/src/server/open-api.ts
// Copyright (C) 2023 Light, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.


const openApiDocument = (0,trpc_openapi_dist/* generateOpenApiDocument */.wj)(appRouter, {
    title: "Example CRUD API",
    description: "OpenAPI compliant REST API built using tRPC with Next.js",
    version: "1.0.0",
    baseUrl: "http://localhost:3000/api"
});

;// CONCATENATED MODULE: ../../packages/trpc/src/server/index.ts
// Copyright (C) 2023 Light, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.





;// CONCATENATED MODULE: ../../packages/trpc/src/utils/index.ts
// Copyright (C) 2023 Light, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.



;// CONCATENATED MODULE: ../../packages/trpc/index.ts
// Copyright (C) 2023 Light, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.




;// CONCATENATED MODULE: ./pages/api/trpc/[trpc].ts
// Copyright (C) 2023 Light, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

/* harmony default export */ const _trpc_ = (nextHandler(appRouter));


/***/ })

};
;

// load runtime
var __webpack_require__ = require("../../../webpack-api-runtime.js");
__webpack_require__.C(exports);
var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
var __webpack_exports__ = __webpack_require__.X(0, [948,746,559], () => (__webpack_exec__(32346)));
module.exports = __webpack_exports__;

})();