@velastack/patterns 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/_layout-D0OmzCu1.js +47 -0
- package/dist/chunks/_layout-D0OmzCu1.js.map +1 -0
- package/dist/chunks/{collections-B-yQ1qt6.js → collections-B3lAtPlQ.js} +2 -2
- package/dist/chunks/{collections-B-yQ1qt6.js.map → collections-B3lAtPlQ.js.map} +1 -1
- package/dist/chunks/{generate-BoEG6Rb-.js → generate-Va1sxVPG.js} +2 -2
- package/dist/chunks/{generate-BoEG6Rb-.js.map → generate-Va1sxVPG.js.map} +1 -1
- package/dist/chunks/{generate-BCBS08AS.js → generate-tOkjJFUf.js} +2 -2
- package/dist/chunks/{generate-BCBS08AS.js.map → generate-tOkjJFUf.js.map} +1 -1
- package/dist/chunks/{generate.runtime-_VsM0zBS.js → generate.runtime-4Iplvp8f.js} +6 -6
- package/dist/chunks/{generate.runtime-_VsM0zBS.js.map → generate.runtime-4Iplvp8f.js.map} +1 -1
- package/dist/chunks/{generate.runtime-ByASCDoo.js → generate.runtime-B9gdCz4t.js} +3 -3
- package/dist/chunks/{generate.runtime-ByASCDoo.js.map → generate.runtime-B9gdCz4t.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CIuSkWtY.js → generate.runtime-BKb9thdE.js} +91 -131
- package/dist/chunks/generate.runtime-BKb9thdE.js.map +1 -0
- package/dist/chunks/generate.runtime-BdTCMGGB.js +65 -0
- package/dist/chunks/generate.runtime-BdTCMGGB.js.map +1 -0
- package/dist/chunks/{generate.runtime-CRgw-aja.js → generate.runtime-BjULAL3h.js} +47 -46
- package/dist/chunks/generate.runtime-BjULAL3h.js.map +1 -0
- package/dist/chunks/{generate.runtime-C6qZUlN-.js → generate.runtime-BlQ1vx8j.js} +6 -6
- package/dist/chunks/{generate.runtime-C6qZUlN-.js.map → generate.runtime-BlQ1vx8j.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CghBFVEf.js → generate.runtime-BltGUllM.js} +6 -6
- package/dist/chunks/{generate.runtime-CghBFVEf.js.map → generate.runtime-BltGUllM.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CwaPHcYP.js → generate.runtime-BsuyMwoj.js} +6 -6
- package/dist/chunks/{generate.runtime-CwaPHcYP.js.map → generate.runtime-BsuyMwoj.js.map} +1 -1
- package/dist/chunks/{generate.runtime-PjMBpjkG.js → generate.runtime-C-Val7lP.js} +5 -5
- package/dist/chunks/{generate.runtime-PjMBpjkG.js.map → generate.runtime-C-Val7lP.js.map} +1 -1
- package/dist/chunks/generate.runtime-CGkVUKvz.js +106 -0
- package/dist/chunks/generate.runtime-CGkVUKvz.js.map +1 -0
- package/dist/chunks/{generate.runtime-BBOWWrZv.js → generate.runtime-CXXwLatT.js} +5 -5
- package/dist/chunks/{generate.runtime-BBOWWrZv.js.map → generate.runtime-CXXwLatT.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CrrAzNZS.js → generate.runtime-DCvLLO7w.js} +5 -5
- package/dist/chunks/{generate.runtime-CrrAzNZS.js.map → generate.runtime-DCvLLO7w.js.map} +1 -1
- package/dist/chunks/{generate.runtime-WwZt9Mu5.js → generate.runtime-DKJaYtVZ.js} +7 -7
- package/dist/chunks/{generate.runtime-WwZt9Mu5.js.map → generate.runtime-DKJaYtVZ.js.map} +1 -1
- package/dist/chunks/generate.runtime-DWeiewRj.js +145 -0
- package/dist/chunks/generate.runtime-DWeiewRj.js.map +1 -0
- package/dist/chunks/{generate.runtime-CUtOhlNA.js → generate.runtime-DaPNrIyg.js} +3 -3
- package/dist/chunks/{generate.runtime-CUtOhlNA.js.map → generate.runtime-DaPNrIyg.js.map} +1 -1
- package/dist/chunks/generate.runtime-Dc98DCsh.js +256 -0
- package/dist/chunks/generate.runtime-Dc98DCsh.js.map +1 -0
- package/dist/chunks/{generate.runtime-DercL_qN.js → generate.runtime-FMYR64DL.js} +5 -5
- package/dist/chunks/{generate.runtime-DercL_qN.js.map → generate.runtime-FMYR64DL.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Biy8wuHU.js → generate.runtime-QmFJI7G1.js} +13 -13
- package/dist/chunks/{generate.runtime-Biy8wuHU.js.map → generate.runtime-QmFJI7G1.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dlokr7A0.js → generate.runtime-SQhCLSah.js} +2 -2
- package/dist/chunks/{generate.runtime-Dlokr7A0.js.map → generate.runtime-SQhCLSah.js.map} +1 -1
- package/dist/chunks/{generate.runtime-UIN_TkYo.js → generate.runtime-Wssys8A0.js} +6 -6
- package/dist/chunks/{generate.runtime-UIN_TkYo.js.map → generate.runtime-Wssys8A0.js.map} +1 -1
- package/dist/chunks/{generate.runtime-nyMB57Tf.js → generate.runtime-fSDNxfGG.js} +2 -2
- package/dist/chunks/{generate.runtime-nyMB57Tf.js.map → generate.runtime-fSDNxfGG.js.map} +1 -1
- package/dist/chunks/{generate.runtime-XpQGIrOx.js → generate.runtime-kH6XaWQz.js} +6 -6
- package/dist/chunks/{generate.runtime-XpQGIrOx.js.map → generate.runtime-kH6XaWQz.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C6RhVu5K.js → generate.runtime-lqPPXQyS.js} +6 -6
- package/dist/chunks/{generate.runtime-C6RhVu5K.js.map → generate.runtime-lqPPXQyS.js.map} +1 -1
- package/dist/chunks/{generate.runtime-JWURZXj-.js → generate.runtime-tAbxWeq-.js} +7 -7
- package/dist/chunks/{generate.runtime-JWURZXj-.js.map → generate.runtime-tAbxWeq-.js.map} +1 -1
- package/dist/chunks/{modify-file-Dgd_PzRG.js → modify-file-Cgu_WeFk.js} +2 -2
- package/dist/chunks/{modify-file-Dgd_PzRG.js.map → modify-file-Cgu_WeFk.js.map} +1 -1
- package/dist/chunks/{shared-cFKFtcgw.js → shared--_BWnGsc.js} +3 -3
- package/dist/chunks/{shared-cFKFtcgw.js.map → shared--_BWnGsc.js.map} +1 -1
- package/dist/chunks/{test-setup-BBb4kcoO.js → test-setup-DjbhQYZC.js} +49 -58
- package/dist/chunks/test-setup-DjbhQYZC.js.map +1 -0
- package/dist/chunks/{ts-morph-helpers-7qF9S2k7.js → ts-morph-helpers-Bf5iuQW8.js} +28 -12
- package/dist/chunks/ts-morph-helpers-Bf5iuQW8.js.map +1 -0
- package/dist/chunks/{ui-X12f0xKA.js → ui-BsG60gQg.js} +2 -2
- package/dist/chunks/{ui-X12f0xKA.js.map → ui-BsG60gQg.js.map} +1 -1
- package/dist/chunks/unmodify-load-W1ePZQHr.js +80 -0
- package/dist/chunks/unmodify-load-W1ePZQHr.js.map +1 -0
- package/dist/chunks/{util-Bq_Mh6IQ.js → util-BLYliuUK.js} +2 -2
- package/dist/chunks/{util-Bq_Mh6IQ.js.map → util-BLYliuUK.js.map} +1 -1
- package/dist/chunks/write-result-BN7Ff0rF.js +451 -0
- package/dist/chunks/write-result-BN7Ff0rF.js.map +1 -0
- package/dist/index.d.ts +77 -7
- package/dist/index.js +630 -542
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/generate.runtime-ArKscTs9.js +0 -65
- package/dist/chunks/generate.runtime-ArKscTs9.js.map +0 -1
- package/dist/chunks/generate.runtime-BpvwX9CL.js +0 -28
- package/dist/chunks/generate.runtime-BpvwX9CL.js.map +0 -1
- package/dist/chunks/generate.runtime-BtL9FPuW.js +0 -60
- package/dist/chunks/generate.runtime-BtL9FPuW.js.map +0 -1
- package/dist/chunks/generate.runtime-CIuSkWtY.js.map +0 -1
- package/dist/chunks/generate.runtime-CRgw-aja.js.map +0 -1
- package/dist/chunks/test-setup-BBb4kcoO.js.map +0 -1
- package/dist/chunks/ts-morph-helpers-7qF9S2k7.js.map +0 -1
- package/dist/chunks/write-result-DgFUKxhP.js +0 -445
- package/dist/chunks/write-result-DgFUKxhP.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { n as e, t } from "./chunks/errors-D6gyegUK.js";
|
|
2
|
-
import { a as n, n as r, o as i, r as a, t as o } from "./chunks/util-
|
|
3
|
-
import { a as s, i as c, n as l, o as u, r as d, s as f, t as p } from "./chunks/generate-
|
|
2
|
+
import { a as n, n as r, o as i, r as a, t as o } from "./chunks/util-BLYliuUK.js";
|
|
3
|
+
import { a as s, i as c, n as l, o as u, r as d, s as f, t as p } from "./chunks/generate-Va1sxVPG.js";
|
|
4
4
|
import { t as m } from "./chunks/format-result-BdAy5M8C.js";
|
|
5
5
|
import { t as h } from "./chunks/dedent-Gq6Krl4n.js";
|
|
6
6
|
import { a as g, o as _, t as v } from "./chunks/constants-PBCzh8eY.js";
|
|
7
7
|
import { t as y } from "./chunks/taggedTemplateLiteral-CPUMuLtk.js";
|
|
8
8
|
import { n as b } from "./chunks/logger-CQONztPm.js";
|
|
9
|
-
import { t as ee } from "./chunks/generate-
|
|
9
|
+
import { t as ee } from "./chunks/generate-tOkjJFUf.js";
|
|
10
10
|
import { t as te } from "./chunks/pocketbase-DpudAAmd.js";
|
|
11
11
|
import { n as ne, r as re, t as ie } from "./chunks/nav-user-CndUO69x.js";
|
|
12
12
|
import { a as ae, c as oe, i as se, n as ce, o as le, r as ue, s as de, t as fe } from "./chunks/_server-BSm1eAiY.js";
|
|
13
13
|
import { t as pe } from "./chunks/pocketbase-C5GS-Dh5.js";
|
|
14
|
-
import { n as x, t as me } from "./chunks/shared
|
|
14
|
+
import { n as x, t as me } from "./chunks/shared--_BWnGsc.js";
|
|
15
15
|
//#region \0rolldown/runtime.js
|
|
16
16
|
var he = Object.create, ge = Object.defineProperty, _e = Object.getOwnPropertyDescriptor, ve = Object.getOwnPropertyNames, ye = Object.getPrototypeOf, be = Object.prototype.hasOwnProperty, xe = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), Se = (e, t, n, r) => {
|
|
17
17
|
if (t && typeof t == "object" || typeof t == "function") for (var i = ve(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !be.call(e, s) && s !== n && ge(e, s, {
|
|
@@ -27,7 +27,7 @@ var he = Object.create, ge = Object.defineProperty, _e = Object.getOwnPropertyDe
|
|
|
27
27
|
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
28
28
|
}), Te = {
|
|
29
29
|
name: "@velastack/patterns",
|
|
30
|
-
version: "0.2.
|
|
30
|
+
version: "0.2.7",
|
|
31
31
|
description: "Registry of VelaStack patterns: generators and modifications applied to SvelteKit projects by the VelaStack CLI.",
|
|
32
32
|
type: "module",
|
|
33
33
|
private: !1,
|
|
@@ -2314,7 +2314,7 @@ var En = "generate-form", Dn = "1.0.7", On = "src/patterns/generate/form", kn =
|
|
|
2314
2314
|
async function An(e) {
|
|
2315
2315
|
let t = await Tn(e);
|
|
2316
2316
|
if (e.env !== "runtime") return m(t, e);
|
|
2317
|
-
let { writeResult: n } = await import("./chunks/write-result-
|
|
2317
|
+
let { writeResult: n } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
2318
2318
|
return n(await m(t, e), e);
|
|
2319
2319
|
}
|
|
2320
2320
|
var jn = {
|
|
@@ -2644,12 +2644,12 @@ async function cr(e) {
|
|
|
2644
2644
|
return m(i([t, n]), e);
|
|
2645
2645
|
}
|
|
2646
2646
|
if (e.env !== "runtime") return m(t, e);
|
|
2647
|
-
let { modifyOutcomeToFile: n } = await import("./chunks/modify-file-
|
|
2647
|
+
let { modifyOutcomeToFile: n } = await import("./chunks/modify-file-Cgu_WeFk.js"), { modifySvelteConfigRemote: r } = await import("./chunks/modify-svelte-config-remote-D3eBzcZc.js");
|
|
2648
2648
|
b(e).info("Modifying config for remote functions");
|
|
2649
2649
|
let a = r(e.root), o = n(a.filePath, a.outcome), s = {
|
|
2650
2650
|
...t,
|
|
2651
2651
|
modifies: [...t.modifies, ...o ? [o] : []]
|
|
2652
|
-
}, { writeResult: c } = await import("./chunks/write-result-
|
|
2652
|
+
}, { writeResult: c } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
2653
2653
|
return c(await m(s, e), e);
|
|
2654
2654
|
}
|
|
2655
2655
|
var lr = {
|
|
@@ -2790,14 +2790,14 @@ var hr = "generate-migration", gr = "1.0.0", _r = "src/patterns/generate/migrati
|
|
|
2790
2790
|
async function yr(e) {
|
|
2791
2791
|
let t = await fr(e);
|
|
2792
2792
|
if (e.env !== "runtime") return m(t, e);
|
|
2793
|
-
let { applyCollectionFieldsPatches: n } = await import("./chunks/collections-
|
|
2793
|
+
let { applyCollectionFieldsPatches: n } = await import("./chunks/collections-B3lAtPlQ.js"), { withPocketbase: r } = await import("./chunks/pocketbase-059B1oot.js"), i = b(e), a = [];
|
|
2794
2794
|
await r(e.root, async (r) => {
|
|
2795
2795
|
a = await n(r, t.collectionPatches, e, i);
|
|
2796
2796
|
});
|
|
2797
2797
|
let o = {
|
|
2798
2798
|
...t,
|
|
2799
2799
|
creates: [...t.creates, ...a]
|
|
2800
|
-
}, { writeResult: s } = await import("./chunks/write-result-
|
|
2800
|
+
}, { writeResult: s } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
2801
2801
|
return s(await m(o, e), e);
|
|
2802
2802
|
}
|
|
2803
2803
|
var br = {
|
|
@@ -2902,10 +2902,10 @@ var wr = "generate-resource", Tr = "1.0.7", Er = "src/patterns/generate/resource
|
|
|
2902
2902
|
async function Or(e) {
|
|
2903
2903
|
let t = await Cr(e);
|
|
2904
2904
|
if (e.env !== "runtime") return m(t, e);
|
|
2905
|
-
let { createCollections: n } = await import("./chunks/collections-
|
|
2905
|
+
let { createCollections: n } = await import("./chunks/collections-B3lAtPlQ.js"), r = await n(t.collections, e), i = {
|
|
2906
2906
|
...t,
|
|
2907
2907
|
creates: [...t.creates, ...r]
|
|
2908
|
-
}, { writeResult: a } = await import("./chunks/write-result-
|
|
2908
|
+
}, { writeResult: a } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
2909
2909
|
return a(await m(i, e), e);
|
|
2910
2910
|
}
|
|
2911
2911
|
var kr = {
|
|
@@ -3314,10 +3314,10 @@ var ri = "generate-scaffold", ii = "1.0.7", ai = "src/patterns/generate/scaffold
|
|
|
3314
3314
|
async function si(e) {
|
|
3315
3315
|
let t = await ni(e);
|
|
3316
3316
|
if (e.env !== "runtime") return m(t, e);
|
|
3317
|
-
let { createCollections: n } = await import("./chunks/collections-
|
|
3317
|
+
let { createCollections: n } = await import("./chunks/collections-B3lAtPlQ.js"), r = await n(t.collections, e), i = {
|
|
3318
3318
|
...t,
|
|
3319
3319
|
creates: [...t.creates, ...r]
|
|
3320
|
-
}, { writeResult: a } = await import("./chunks/write-result-
|
|
3320
|
+
}, { writeResult: a } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
3321
3321
|
return a(await m(i, e), e);
|
|
3322
3322
|
}
|
|
3323
3323
|
var ci = {
|
|
@@ -3699,13 +3699,13 @@ async function Wi(e) {
|
|
|
3699
3699
|
return m(i([t, n]), e);
|
|
3700
3700
|
}
|
|
3701
3701
|
if (e.env !== "runtime") return m(t, e);
|
|
3702
|
-
let { createCollections: n } = await import("./chunks/collections-
|
|
3702
|
+
let { createCollections: n } = await import("./chunks/collections-B3lAtPlQ.js"), r = await n(t.collections, e), { modifyOutcomeToFile: a } = await import("./chunks/modify-file-Cgu_WeFk.js"), { modifySvelteConfigRemote: o } = await import("./chunks/modify-svelte-config-remote-D3eBzcZc.js");
|
|
3703
3703
|
b(e).info("Modifying config for remote functions");
|
|
3704
3704
|
let s = o(e.root), c = a(s.filePath, s.outcome), l = {
|
|
3705
3705
|
...t,
|
|
3706
3706
|
creates: [...t.creates, ...r],
|
|
3707
3707
|
modifies: [...t.modifies, ...c ? [c] : []]
|
|
3708
|
-
}, { writeResult: u } = await import("./chunks/write-result-
|
|
3708
|
+
}, { writeResult: u } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
3709
3709
|
return u(await m(l, e), e);
|
|
3710
3710
|
}
|
|
3711
3711
|
var Gi = {
|
|
@@ -3807,7 +3807,7 @@ var Yi = "generate-schema", Xi = "1.0.8", Zi = "src/patterns/generate/schema", Q
|
|
|
3807
3807
|
async function $i(e) {
|
|
3808
3808
|
let t = await Ji(e);
|
|
3809
3809
|
if (e.env !== "runtime") return m(t, e);
|
|
3810
|
-
let { writeResult: n } = await import("./chunks/write-result-
|
|
3810
|
+
let { writeResult: n } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
3811
3811
|
return n(await m(t, e), e);
|
|
3812
3812
|
}
|
|
3813
3813
|
var ea = {
|
|
@@ -3898,7 +3898,7 @@ async function ca(e) {
|
|
|
3898
3898
|
let n = await ra(e);
|
|
3899
3899
|
return m(i([t, n]), e);
|
|
3900
3900
|
}
|
|
3901
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
3901
|
+
let { generate: n } = await import("./chunks/generate.runtime-4Iplvp8f.js"), r = await n(e), { writeResult: a } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
3902
3902
|
return a(await m(i([t, r]), e), e);
|
|
3903
3903
|
}
|
|
3904
3904
|
var la = {
|
|
@@ -3953,7 +3953,7 @@ var la = {
|
|
|
3953
3953
|
baseline: "velastack",
|
|
3954
3954
|
providers: l,
|
|
3955
3955
|
generate: ca
|
|
3956
|
-
}, ua = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import type { ComponentProps } from 'svelte';\n import HomeIcon from '@lucide/svelte/icons/home';\n import * as Sidebar from '$lib/components/ui/sidebar';\n import NavMain from './nav-main.svelte';\n import NavUser from './nav-user.svelte';\n\n let data = {\n navMain: [\n {\n title: 'Dashboard',\n url: '/dashboard',\n icon: HomeIcon\n }\n ]\n };\n\n let {\n user,\n meta,\n ref = $bindable(null),\n ...restProps\n }: ComponentProps<typeof Sidebar.Root> & { user: any; meta: any } = $props();\n<\/script>\n\n<Sidebar.Root bind:ref variant=\"inset\" {...restProps}>\n <Sidebar.Header>\n <Sidebar.Menu>\n <Sidebar.MenuItem>\n <Sidebar.MenuButton size=\"lg\">\n {#snippet child({ props })}\n <a href=\"/dashboard\" {...props}>\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{meta.appName}</span>\n </div>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n </Sidebar.Menu>\n </Sidebar.Header>\n <Sidebar.Content>\n <NavMain items={data.navMain} />\n </Sidebar.Content>\n <Sidebar.Footer>\n <NavUser {user} />\n </Sidebar.Footer>\n</Sidebar.Root>\n", da = "<script lang=\"ts\">\n import type { Component } from 'svelte';\n import * as Sidebar from '$lib/components/ui/sidebar';\n import { page } from '$app/state';\n\n const isActive = (url: string) => {\n return page.url.pathname.startsWith(url);\n };\n\n let {\n items\n }: {\n items: {\n title: string;\n url: string;\n icon: Component;\n items?: {\n title: string;\n url: string;\n }[];\n }[];\n } = $props();\n<\/script>\n\n<Sidebar.Group>\n <Sidebar.Menu>\n {#each items as item (item.title)}\n <Sidebar.MenuItem>\n <Sidebar.MenuButton isActive={isActive(item.url)}>\n {#snippet child({ props })}\n <a href={item.url} {...props}>\n <item.icon />\n <span>{item.title}</span>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n {/each}\n </Sidebar.Menu>\n</Sidebar.Group>\n", fa = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import * as Avatar from '$lib/components/ui/avatar';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import * as Sidebar from '$lib/components/ui/sidebar';\n \n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n }\n ]\n };\n\n let {\n user\n }: {\n user: {\n id: string;\n name: string;\n email: string;\n avatar: string;\n };\n } = $props();\n\n const sidebar = Sidebar.useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n {...props}\n >\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.name?.charAt(0).toUpperCase() || user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name || user.email}</span>\n </div>\n <ChevronsUpDownIcon class=\"ml-auto size-4\" />\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n align=\"end\"\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"p-0 font-normal\">\n <div class=\"flex items-center gap-2 px-1 py-1.5 text-left text-sm\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.name?.charAt(0).toUpperCase() || user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name || user.email}</span>\n </div>\n </div>\n </DropdownMenu.Label>\n <DropdownMenu.Separator />\n <DropdownMenu.Group>\n <DropdownMenu.Item onclick={toggleMode}>\n {#if mode.current === 'dark'}\n <SunIcon />\n Light mode\n {:else}\n <MoonIcon />\n Dark mode\n {/if}\n </DropdownMenu.Item>\n {#each data.navUser as item}\n <DropdownMenu.Item class=\"p-0\">\n <a href={item.url} class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <item.icon />\n {item.title}\n </a>\n </DropdownMenu.Item>\n {/each}\n </DropdownMenu.Group>\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <form action=\"/logout\" method=\"post\" class=\"w-full\">\n <button type=\"submit\" class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <LogOutIcon />\n Log out\n </button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", pa = "import { z } from \"zod\";\n\nexport const changeEmailSchema = z.object({\n email: z.email(),\n});\n", ma = "import { z } from \"zod\";\n\nexport const changePasswordSchema = z\n .object({\n password: z.string(),\n passwordConfirm: z.string(),\n })\n .refine((data) => data.password === data.passwordConfirm, {\n message: \"Passwords don't match\",\n path: [\"passwordConfirm\"],\n });\n", ha = "import { z } from \"zod\";\n\nexport const confirmEmailChangeSchema = z.object({\n password: z.string(),\n});\n", ga = "import { z } from \"zod\";\n\nexport const confirmResetSchema = z.object({\n password: z.string(),\n passwordConfirm: z.string(),\n});\n", _a = "import { z } from \"zod\";\n\nconst otpSchema = z.object({\n type: z.literal(\"otp\"),\n email: z.email(),\n});\n\nconst passwordSchema = z.object({\n type: z.literal(\"password\"),\n email: z.email(),\n password: z.string(),\n});\n\nconst oAuth2Schema = z.object({\n type: z.literal(\"oauth2\"),\n email: z.email(),\n});\n\nexport const loginSchema = z.discriminatedUnion(\"type\", [\n otpSchema,\n passwordSchema,\n oAuth2Schema,\n]);\n", va = "import { z } from \"zod\";\n\nexport const otpSchema = z.object({\n otp: z.string(),\n});\n", ya = "import { z } from \"zod\";\n\nexport const profileSchema = z.object({\n name: z.string().optional(),\n avatar: z.union([z.instanceof(File), z.string()]).optional(),\n emailVisibility: z.boolean().optional(),\n});\n", ba = "import { z } from \"zod\";\n\nexport const resetSchema = z.object({\n email: z.email(),\n});\n", xa = "import { z } from \"zod\";\n\nexport const signupSchema = z.object({\n email: z.email(),\n password: z.string(),\n passwordConfirm: z.string(),\n});\n", Sa = "export const load = ({ locals }) => {\n const user = locals.pb.authStore.record!;\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n\n return { user, breadcrumbs };\n};\n", Ca = "<script lang=\"ts\">\n import * as Sidebar from '$lib/components/ui/sidebar';\n import { Separator } from '$lib/components/ui/separator';\n import AppSidebar from '$lib/components/app-sidebar.svelte';\n import * as Breadcrumb from '$lib/components/ui/breadcrumb';\n import { page } from '$app/state';\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as { title: string; url: string }[];\n let { data, children } = $props();\n<\/script>\n\n<div class=\"min-h-dvh dashboard\">\n <Sidebar.Provider>\n <AppSidebar user={data.user} meta={data.meta} />\n <Sidebar.Inset>\n <header class=\"flex h-16 shrink-0 items-center gap-2\">\n <div class=\"flex items-center gap-2 px-4\">\n <Sidebar.Trigger class=\"-ml-1\" />\n <Separator orientation=\"vertical\" class=\"mr-2 data-[orientation=vertical]:h-4\" />\n {#if breadcrumbs.length > 0}\n <Breadcrumb.Root>\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}>{breadcrumb.title}</Breadcrumb.Link>\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n {/if}\n </div>\n </header>\n <div class=\"flex flex-1 flex-col p-4 pt-0\">\n {@render children?.()}\n </div>\n </Sidebar.Inset>\n </Sidebar.Provider>\n</div>\n\n<style>\n :global(body:has(div.dashboard)) {\n background-color: var(--color-sidebar);\n }\n</style>\n", wa = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Dashboard'\n });\n\n return { pageMetaTags };\n};\n", Ta = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"dashboard\", () => {\n it(\"should redirect to the login page\", async (context) => {\n const response = await context.request.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(302);\n expect(response.headers.location).toBe(\"/login?redirect=%2Fdashboard\");\n });\n\n it(\"authenticated user should be able to access the dashboard\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Ea = "export const load = async ({ parent }) => {\n const { breadcrumbs } = await parent();\n\n return {\n breadcrumbs: [...breadcrumbs, { title: \"Settings\", url: \"/settings\" }],\n };\n};\n", Da = "import { superValidate, fail, withFiles } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { profileSchema } from \"$lib/schemas/profile\";\nimport { changeEmailSchema } from \"$lib/schemas/changeEmail\";\nimport { changePasswordSchema } from \"$lib/schemas/changePassword\";\n\nexport const load = async ({ parent }) => {\n const { user } = await parent();\n\n const profileForm = await superValidate(\n {\n avatar: user.avatar,\n name: user.name,\n emailVisibility: user.emailVisibility,\n },\n zod4(profileSchema),\n );\n const emailForm = await superValidate(zod4(changeEmailSchema));\n const passwordForm = await superValidate(zod4(changePasswordSchema));\n\n return { profileForm, emailForm, passwordForm, user };\n};\n\nexport const actions = {\n updateProfile: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(profileSchema));\n\n if (!form.valid) {\n return fail(400, { profileForm: form });\n }\n\n await locals.pb\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, form.data);\n\n setFlash(\n { type: \"toast\", message: \"Profile updated successfully.\" },\n cookies,\n );\n return withFiles({ profileForm: form });\n },\n changeEmail: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(changeEmailSchema));\n\n if (!form.valid) {\n return fail(400, { emailForm: form });\n }\n\n await locals.pb.collection(\"users\").requestEmailChange(form.data.email);\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a confirmation link to your new email.\",\n },\n cookies,\n );\n return { emailForm: form };\n },\n changePassword: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(changePasswordSchema));\n\n if (!form.valid) {\n return fail(400, { passwordForm: form });\n }\n\n await locals.admin\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, {\n password: form.data.password,\n passwordConfirm: form.data.passwordConfirm,\n });\n\n setFlash(\n { type: \"toast\", message: \"Password updated successfully.\" },\n cookies,\n );\n return { passwordForm: form };\n },\n resendVerificationEmail: async ({ locals, request, cookies }) => {\n await locals.pb\n .collection(\"users\")\n .requestVerification(locals.pb.authStore.record!.email);\n setFlash(\n { type: \"toast\", message: \"We sent a verification email to your email.\" },\n cookies,\n );\n return {};\n },\n};\n", Oa = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { changeEmailSchema } from '$lib/schemas/changeEmail';\n import { changePasswordSchema } from '$lib/schemas/changePassword';\n import { profileSchema } from '$lib/schemas/profile';\n import { Button, buttonVariants } from '$lib/components/ui/button';\n import * as Form from '$lib/components/ui/form';\n import * as Card from '$lib/components/ui/card';\n import { Input } from '$lib/components/ui/input';\n import { Badge } from '$lib/components/ui/badge';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Checkbox } from '$lib/components/ui/checkbox';\n import * as Avatar from '$lib/components/ui/avatar';\n import * as FileForm from '$lib/components/ui/file-form';\n\n let { data } = $props();\n\n const profileForm = superForm(\n untrack(() => data.profileForm),\n {\n validators: zod4Client(profileSchema),\n id: 'profileForm'\n }\n );\n\n const emailForm = superForm(\n untrack(() => data.emailForm),\n {\n validators: zod4Client(changeEmailSchema),\n id: 'emailForm'\n }\n );\n\n const passwordForm = superForm(\n untrack(() => data.passwordForm),\n {\n validators: zod4Client(changePasswordSchema),\n id: 'passwordForm'\n }\n );\n\n const { form: profileFormData } = profileForm;\n const { form: emailFormData } = emailForm;\n const { form: passwordFormData } = passwordForm;\n<\/script>\n\n<div class=\"divide-y divide-gray-900/10 dark:divide-white/10\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">Profile</h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">Your profile information.</p>\n </div>\n\n <form\n method=\"POST\"\n action=\"?/updateProfile\"\n enctype=\"multipart/form-data\"\n class=\"md:col-span-2\"\n >\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <FileForm.Field form={profileForm} name=\"avatar\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"flex items-center gap-3 justify-between\">\n {#if !$profileFormData.avatar}\n <div class=\"flex items-center gap-3\">\n <Avatar.Root class=\"size-16\">\n <Avatar.Fallback>\n {data.user.email.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div>\n <span class=\"text-sm font-medium leading-none\">Avatar</span>\n <p class=\"text-muted-foreground text-sm\">\n Upload a new avatar for your profile.\n </p>\n </div>\n </div>\n {/if}\n <FileForm.Single>\n {#snippet display({ file, filename, onremove })}\n <div class=\"flex-1 flex gap-2 justify-between items-center\">\n <div class=\"flex items-center gap-3\">\n <FileForm.Thumb\n {file}\n {filename}\n collectionId=\"users\"\n id={data.user.id}\n class=\"w-16 h-16 object-cover rounded-full\"\n />\n <div>\n <span class=\"text-sm font-medium leading-none\">Avatar</span>\n <p class=\"text-muted-foreground text-sm\">\n Upload a new avatar for your profile.\n </p>\n </div>\n </div>\n <Button variant=\"outline\" onclick={() => onremove(file)}>\n Remove avatar\n </Button>\n </div>\n {/snippet}\n {#snippet input()}\n <Form.Label class={buttonVariants({ variant: 'outline' })}>\n Upload new picture\n </Form.Label>\n <FileForm.Input class=\"hidden\" {...props} />\n {/snippet}\n </FileForm.Single>\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </FileForm.Field>\n\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={profileForm} name=\"name\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Name</Form.Label>\n <Input {...props} type=\"text\" bind:value={$profileFormData.name} />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={profileForm} name=\"emailVisibility\" class=\"flex items-start gap-2\">\n <Form.Control>\n {#snippet children({ props })}\n <Checkbox {...props} bind:checked={$profileFormData.emailVisibility} />\n <div class=\"grid gap-2\">\n <Form.Label>Display email publicly</Form.Label>\n <p class=\"text-muted-foreground text-sm\">\n By clicking this checkbox, your email will be displayed publicly.\n </p>\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Save changes</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">Email</h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n The email address associated with your account.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"flex justify-between items-center\">\n <span class=\"text-sm flex items-center gap-2\">\n {data.user.email}\n <Badge variant=\"secondary\">{data.user.verified ? 'Verified' : 'Unverified'}</Badge>\n </span>\n <div class=\"flex items-center gap-3\">\n {#if !data.user.verified}\n <form method=\"POST\" action=\"?/resendVerificationEmail\">\n <Button type=\"submit\" variant=\"outline\" class=\"w-fit\"\n >Resend verification email</Button\n >\n </form>\n {/if}\n\n <Dialog.Root>\n <Dialog.Trigger class={buttonVariants({ variant: 'outline' })}>\n Change email\n </Dialog.Trigger>\n <Dialog.Content>\n <Dialog.Header>\n <Dialog.Title>Change email</Dialog.Title>\n <Dialog.Description>\n Enter your new email address. You will receive a verification email.\n </Dialog.Description>\n </Dialog.Header>\n <form method=\"POST\" action=\"?/changeEmail\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={emailForm} name=\"email\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$emailFormData.email}\n required\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n </form>\n <Dialog.Footer>\n <Button type=\"submit\" class=\"w-fit\">Change email</Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog.Root>\n </div>\n </div>\n </Card.Content>\n </Card.Root>\n </div>\n\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">Password</h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n Your password is used to log in to your account.\n </p>\n </div>\n\n <form method=\"POST\" action=\"?/changePassword\" class=\"md:col-span-2\">\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={passwordForm} name=\"password\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>New password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$passwordFormData.password}\n autocomplete=\"new-password\"\n required\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n <div class=\"grid gap-3\">\n <Form.Field form={passwordForm} name=\"passwordConfirm\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm new password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$passwordFormData.passwordConfirm}\n autocomplete=\"new-password\"\n required\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Update password</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n</div>\n", ka = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Settings'\n });\n\n return { ...data, pageMetaTags };\n};\n", Aa = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { confirmEmailChangeSchema } from \"$lib/schemas/confirmEmailChange\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const load = async () => {\n return { form: await superValidate(zod4(confirmEmailChangeSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(confirmEmailChangeSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n await locals.admin\n .collection(\"users\")\n .confirmEmailChange(params.token, form.data.password);\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash(\n { type: \"toast\", message: \"Email changed successfully.\" },\n cookies,\n );\n return redirect(303, \"/login\");\n },\n};\n", ja = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import { untrack } from 'svelte';\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { confirmEmailChangeSchema } from '$lib/schemas/confirmEmailChange';\n import * as Form from '$lib/components/ui/form';\n import { Input } from '$lib/components/ui/input';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(confirmEmailChangeSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Confirm your email change</Card.Title>\n <Card.Description>Enter your password to confirm your email change</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Confirm email change</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Ma = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm email change'\n });\n\n return { ...data, pageMetaTags };\n};\n", Na = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-email-change/[token]\", () => {\n it(\"should render the confirm-email-change page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-email-change/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Pa = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { confirmResetSchema } from \"$lib/schemas/confirmReset\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const load = async () => {\n return { form: await superValidate(zod4(confirmResetSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, request, params, cookies }) => {\n const form = await superValidate(request, zod4(confirmResetSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n await locals.admin\n .collection(\"users\")\n .confirmPasswordReset(\n params.token,\n form.data.password,\n form.data.passwordConfirm,\n );\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash(\n { type: \"toast\", message: \"Password reset successfully.\" },\n cookies,\n );\n return redirect(303, \"/login\");\n },\n};\n", Fa = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import { untrack } from 'svelte';\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { confirmResetSchema } from '$lib/schemas/confirmReset';\n import * as Form from '$lib/components/ui/form';\n import { Input } from '$lib/components/ui/input';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(confirmResetSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description>Enter your new password</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field {form} name=\"passwordConfirm\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Reset password</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Ia = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm password reset'\n });\n\n return { ...data, pageMetaTags };\n};\n", La = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-reset/[token]\", () => {\n it(\"should render the confirm-reset page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-reset/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Ra = "import { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const GET = async ({ params, locals, cookies }) => {\n let message = \"\";\n let redirectPath = \"\";\n\n try {\n await locals.admin.collection(\"users\").confirmVerification(params.token);\n message = \"Email verified successfully.\";\n redirectPath = \"/dashboard\";\n } catch (error: any) {\n message =\n \"Invalid or expired verification token. Please request a new verification email.\";\n redirectPath = \"/login\";\n }\n\n setFlash({ type: \"toast\", message }, cookies);\n redirect(303, redirectPath);\n};\n", za = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-verification/[token]\", () => {\n it(\"should redirect if the token is invalid\", async (context) => {\n const response = await context.request.get(\n \"/confirm-verification/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers[\"location\"]).toBe(\"/login\");\n });\n});\n", Ba = "import { fail, superValidate, message } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { loginSchema } from \"$lib/schemas/login\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/environment\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n const type: \"password\" | \"otp\" | \"oauth2\" = authMethods.otp.enabled\n ? \"otp\"\n : authMethods.password.enabled\n ? \"password\"\n : \"oauth2\";\n\n return {\n form: await superValidate(\n zod4(loginSchema.default({ type, email: \"\", password: \"\" })),\n ),\n authMethods,\n };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(loginSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n const redirectParam = url.searchParams.get(\"redirect\");\n if (form.data.type === \"otp\") {\n const req = await locals.pb\n .collection(\"users\")\n .requestOTP(form.data.email);\n return redirect(\n 303,\n `/otp/${req.otpId}${redirectParam ? `?redirect=${encodeURIComponent(redirectParam)}` : \"\"}`,\n );\n } else if (form.data.type === \"password\") {\n try {\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n } catch (error: any) {\n return message(\n form,\n { type: \"error\", text: error.response.message },\n { status: 400 },\n );\n }\n }\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n redirect(303, redirectUrl);\n },\n};\n", Va = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { loginSchema } from \"$lib/schemas/login\";\n import * as Form from \"$lib/components/ui/form\";\n import { Input } from \"$lib/components/ui/input\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(loginSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome back</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a login method</Card.Description>\n {:else}\n <Card.Description>Use your email to login</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Login is disabled</Card.Title>\n <Card.Description\n >Check back later for login options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled || authMethods.otp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"flex justify-between\">\n <Form.Label>Password</Form.Label>\n <a\n href=\"/reset\"\n class=\"ml-auto text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", Ha = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Log in'\n });\n\n return { ...data, pageMetaTags };\n};\n", Ua = "import { describe, it, expect } from \"vitest\";\nimport * as devalue from \"devalue\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /login\", () => {\n it(\"should render the login page\", async (context) => {\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(200);\n });\n\n it(\"should redirect to the dashboard if the user is already authenticated\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/dashboard\");\n });\n});\n\ndescribe(\"POST /login\", () => {\n it(\"should login with password\", async (context) => {\n const response = await context.agent\n .post(\"/login\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: context.user.email,\n password: \"password\",\n });\n expect(response.body.status).toBe(303);\n expect(response.body.location).toBe(\"/dashboard\");\n });\n\n it(\"should error if the password is incorrect\", async (context) => {\n const response = await context.agent\n .post(\"/login\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: context.user.email,\n password: \"incorrect\",\n });\n const data = devalue.parse(response.body.data);\n expect(response.body.status).toBe(400);\n expect(data.form.message.text).toBe(\"Failed to authenticate.\");\n });\n});\n", Wa = "import { redirect } from \"@sveltejs/kit\";\n\nexport const POST = ({ cookies, locals }) => {\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n throw redirect(303, \"/\");\n};\n", Ga = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"POST /logout\", () => {\n it(\"should logout the user\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.post(\n \"/logout\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/\");\n });\n});\n", Ka = "import { fail, message, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { otpSchema } from \"$lib/schemas/otp\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/environment\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(otpSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, request, params, cookies, url }) => {\n const form = await superValidate(request, zod4(otpSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb\n .collection(\"users\")\n .authWithOTP(params.token, form.data.otp);\n } catch (error: any) {\n return message(\n form,\n { type: \"error\", text: error.response.message },\n { status: 400 },\n );\n }\n\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n redirect(303, redirectUrl);\n },\n};\n", qa = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import { untrack } from 'svelte';\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { otpSchema } from '$lib/schemas/otp';\n import * as Form from '$lib/components/ui/form';\n import { Input } from '$lib/components/ui/input';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(otpSchema)\n }\n );\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Enter your OTP code</Card.Title>\n <Card.Description>Enter the code sent to your email</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"otp\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>OTP code</Form.Label>\n <Input {...props} type=\"text\" bind:value={$formData.otp} required />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === 'error'}\n <div class=\"text-destructive text-sm font-medium -mt-2\">{$message.text}</div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Verify code</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Ja = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Verify code'\n });\n\n return { ...data, pageMetaTags };\n};\n", Ya = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /otp/[token]\", () => {\n it(\"should render the otp page\", async (context) => {\n const response = await context.request.get(\n \"/otp/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /otp/[token]\", () => {\n it(\"should throw an error if the otp is invalid\", async (context) => {\n const response = await context.agent\n .post(\"/otp/123456\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ otp: \"123456\" });\n expect(response.body.status).toBe(400);\n });\n});\n", Xa = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { resetSchema } from \"$lib/schemas/reset\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(resetSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(resetSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n await locals.pb.collection(\"users\").requestPasswordReset(form.data.email);\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a password reset link to your email.\",\n },\n cookies,\n );\n\n return { form };\n },\n};\n", Za = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import { untrack } from 'svelte';\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { resetSchema } from '$lib/schemas/reset';\n import * as Form from '$lib/components/ui/form';\n import { Input } from '$lib/components/ui/input';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(resetSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description>Enter your email to reset your password</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input {...props} type=\"email\" bind:value={$formData.email} required />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Send reset link</Button>\n </div>\n\n <div class=\"text-center text-sm\">\n Remembered your password?\n <a href=\"/login\" class=\"underline underline-offset-4\">Log in</a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Qa = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Reset password'\n });\n\n return { ...data, pageMetaTags };\n};\n", $a = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /reset\", () => {\n it(\"should render the reset page\", async (context) => {\n const response = await context.request.get(\n \"/reset\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /reset\", () => {\n it(\"should request a password reset\", async (context) => {\n const response = await context.agent\n .post(\"/reset\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ email: context.user.email });\n expect(response.body.status).toBe(200);\n });\n});\n", eo = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\nimport { dev } from \"$app/environment\";\nimport { signupSchema } from \"$lib/schemas/signup\";\n\nexport const load = async ({ locals }) => {\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(signupSchema)), authMethods };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(signupSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n let user;\n\n try {\n user = await locals.admin.collection(\"users\").create({\n email: form.data.email,\n password: form.data.password,\n passwordConfirm: form.data.passwordConfirm,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n await locals.pb.collection(\"users\").requestVerification(user.email);\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n setFlash(\n { type: \"toast\", message: \"We sent a confirmation link to your email.\" },\n cookies,\n );\n return redirect(303, redirectUrl);\n },\n};\n", to = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { signupSchema } from \"$lib/schemas/signup\";\n import * as Form from \"$lib/components/ui/form\";\n import { Input } from \"$lib/components/ui/input\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(signupSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Create an account</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a sign up method</Card.Description>\n {:else}\n <Card.Description>Use your email to sign up</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Signups are disabled</Card.Title>\n <Card.Description\n >Check back later for signup options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field {form} name=\"passwordConfirm\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Button type=\"submit\" class=\"w-full\">Create account</Button>\n </div>\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", no = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Sign up'\n });\n\n return { ...data, pageMetaTags };\n};\n", ro = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /signup\", () => {\n it(\"should render the signup page\", async (context) => {\n const response = await context.request.get(\n \"/signup\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /signup\", () => {\n it(\"should signup with password\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: \"password\",\n passwordConfirm: \"password\",\n });\n expect(response.body.status).toBe(303);\n expect(response.body.location).toBe(\"/dashboard\");\n });\n\n it(\"should error if the password does not match\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: \"password\",\n passwordConfirm: \"password2\",\n });\n expect(response.body.status).toBe(400);\n const data = devalue.parse(response.body.data);\n expect(data.form.errors.passwordConfirm).toBeDefined();\n expect(data.form.errors.passwordConfirm[0]).toBe(\"Values don't match.\");\n });\n\n it(\"should error if the email is already taken\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: context.user.email,\n password: \"password\",\n passwordConfirm: \"password\",\n });\n expect(response.body.status).toBe(400);\n const data = devalue.parse(response.body.data);\n expect(data.form.errors.email).toBeDefined();\n expect(data.form.errors.email[0]).toBe(\"Value must be unique.\");\n });\n});\n", io = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"$lib/components/ui/button\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { loginSchema } from \"$lib/schemas/login\";\n import * as Form from \"$lib/components/ui/form\";\n import { Input } from \"$lib/components/ui/input\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(loginSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"grid h-full lg:grid-cols-2\">\n <div class=\"flex flex-col gap-4 p-6 md:p-10\">\n <div class=\"flex justify-center gap-2 md:justify-start\">\n <a href=\"/\" class=\"flex items-center gap-2 font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n </div>\n <div class=\"flex flex-1 items-center justify-center\">\n <div class=\"w-full max-w-sm\">\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"flex flex-col items-center gap-2 text-center\">\n {#if hasAuthMethods}\n <h1 class=\"text-2xl font-bold\">Welcome back</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n {hasOAuth2\n ? \"Choose a login method\"\n : \"Use your email to login\"}\n </p>\n {:else}\n <h1 class=\"text-2xl font-bold\">Login is disabled</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n Check back later for login options\n </p>\n {/if}\n </div>\n\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled || authMethods.otp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-background text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"flex justify-between\">\n <Form.Label>Password</Form.Label>\n <a\n href=\"/reset\"\n class=\"ml-auto text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </div>\n </div>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n <div class=\"bg-muted relative hidden lg:block\">\n <img\n src={favicon}\n alt=\"\"\n class=\"absolute inset-0 m-auto size-32 opacity-20\"\n />\n </div>\n</div>\n", ao = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"$lib/components/ui/button\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { signupSchema } from \"$lib/schemas/signup\";\n import * as Form from \"$lib/components/ui/form\";\n import { Input } from \"$lib/components/ui/input\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(signupSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"grid h-full lg:grid-cols-2\">\n <div class=\"bg-muted relative hidden lg:block\">\n <img\n src={favicon}\n alt=\"\"\n class=\"absolute inset-0 m-auto size-32 opacity-20\"\n />\n </div>\n <div class=\"flex flex-col gap-4 p-6 md:p-10\">\n <div class=\"flex justify-center gap-2 md:justify-start\">\n <a href=\"/\" class=\"flex items-center gap-2 font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n </div>\n <div class=\"flex flex-1 items-center justify-center\">\n <div class=\"w-full max-w-sm\">\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"flex flex-col items-center gap-2 text-center\">\n {#if hasAuthMethods}\n <h1 class=\"text-2xl font-bold\">Create an account</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n {hasOAuth2\n ? \"Choose a sign up method\"\n : \"Use your email to sign up\"}\n </p>\n {:else}\n <h1 class=\"text-2xl font-bold\">Signups are disabled</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n Check back later for signup options\n </p>\n {/if}\n </div>\n\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-background text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field {form} name=\"passwordConfirm\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Button type=\"submit\" class=\"w-full\">Create account</Button>\n </div>\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </div>\n </div>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n</div>\n", oo = /* #__PURE__ */ Object.assign({
|
|
3956
|
+
}, ua = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import type { ComponentProps } from 'svelte';\n import HomeIcon from '@lucide/svelte/icons/home';\n import * as Sidebar from '$lib/components/ui/sidebar';\n import NavMain from './nav-main.svelte';\n import NavUser from './nav-user.svelte';\n\n let data = {\n navMain: [\n {\n title: 'Dashboard',\n url: '/dashboard',\n icon: HomeIcon\n }\n ]\n };\n\n let {\n user,\n meta,\n ref = $bindable(null),\n ...restProps\n }: ComponentProps<typeof Sidebar.Root> & { user: any; meta: any } = $props();\n<\/script>\n\n<Sidebar.Root bind:ref variant=\"inset\" {...restProps}>\n <Sidebar.Header>\n <Sidebar.Menu>\n <Sidebar.MenuItem>\n <Sidebar.MenuButton size=\"lg\">\n {#snippet child({ props })}\n <a href=\"/dashboard\" {...props}>\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{meta.appName}</span>\n </div>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n </Sidebar.Menu>\n </Sidebar.Header>\n <Sidebar.Content>\n <NavMain items={data.navMain} />\n </Sidebar.Content>\n <Sidebar.Footer>\n <NavUser {user} />\n </Sidebar.Footer>\n</Sidebar.Root>\n", da = "<script lang=\"ts\">\n import type { Component } from 'svelte';\n import * as Sidebar from '$lib/components/ui/sidebar';\n import { page } from '$app/state';\n\n const isActive = (url: string) => {\n return page.url.pathname.startsWith(url);\n };\n\n let {\n items\n }: {\n items: {\n title: string;\n url: string;\n icon: Component;\n items?: {\n title: string;\n url: string;\n }[];\n }[];\n } = $props();\n<\/script>\n\n<Sidebar.Group>\n <Sidebar.Menu>\n {#each items as item (item.title)}\n <Sidebar.MenuItem>\n <Sidebar.MenuButton isActive={isActive(item.url)}>\n {#snippet child({ props })}\n <a href={item.url} {...props}>\n <item.icon />\n <span>{item.title}</span>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n {/each}\n </Sidebar.Menu>\n</Sidebar.Group>\n", fa = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import * as Avatar from '$lib/components/ui/avatar';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import * as Sidebar from '$lib/components/ui/sidebar';\n \n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n }\n ]\n };\n\n let {\n user\n }: {\n user: {\n id: string;\n name: string;\n email: string;\n avatar: string;\n };\n } = $props();\n\n const sidebar = Sidebar.useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n {...props}\n >\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.name?.charAt(0).toUpperCase() || user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name || user.email}</span>\n </div>\n <ChevronsUpDownIcon class=\"ml-auto size-4\" />\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n align=\"end\"\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"p-0 font-normal\">\n <div class=\"flex items-center gap-2 px-1 py-1.5 text-left text-sm\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.name?.charAt(0).toUpperCase() || user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name || user.email}</span>\n </div>\n </div>\n </DropdownMenu.Label>\n <DropdownMenu.Separator />\n <DropdownMenu.Group>\n <DropdownMenu.Item onclick={toggleMode}>\n {#if mode.current === 'dark'}\n <SunIcon />\n Light mode\n {:else}\n <MoonIcon />\n Dark mode\n {/if}\n </DropdownMenu.Item>\n {#each data.navUser as item}\n <DropdownMenu.Item class=\"p-0\">\n <a href={item.url} class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <item.icon />\n {item.title}\n </a>\n </DropdownMenu.Item>\n {/each}\n </DropdownMenu.Group>\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <form action=\"/logout\" method=\"post\" class=\"w-full\">\n <button type=\"submit\" class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <LogOutIcon />\n Log out\n </button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", pa = "import { z } from \"zod\";\n\nexport const changeEmailSchema = z.object({\n email: z.email(),\n});\n", ma = "import { z } from \"zod\";\n\nexport const changePasswordSchema = z\n .object({\n password: z.string(),\n passwordConfirm: z.string(),\n })\n .refine((data) => data.password === data.passwordConfirm, {\n message: \"Passwords don't match\",\n path: [\"passwordConfirm\"],\n });\n", ha = "import { z } from \"zod\";\n\nexport const confirmEmailChangeSchema = z.object({\n password: z.string(),\n});\n", ga = "import { z } from \"zod\";\n\nexport const confirmResetSchema = z.object({\n password: z.string(),\n passwordConfirm: z.string(),\n});\n", _a = "import { z } from \"zod\";\n\nconst otpSchema = z.object({\n type: z.literal(\"otp\"),\n email: z.email(),\n});\n\nconst passwordSchema = z.object({\n type: z.literal(\"password\"),\n email: z.email(),\n password: z.string(),\n});\n\nconst oAuth2Schema = z.object({\n type: z.literal(\"oauth2\"),\n email: z.email(),\n});\n\nexport const loginSchema = z.discriminatedUnion(\"type\", [\n otpSchema,\n passwordSchema,\n oAuth2Schema,\n]);\n", va = "import { z } from \"zod\";\n\nexport const otpSchema = z.object({\n otp: z.string(),\n});\n", ya = "import { z } from \"zod\";\n\nexport const profileSchema = z.object({\n name: z.string().optional(),\n avatar: z.union([z.instanceof(File), z.string()]).optional(),\n emailVisibility: z.boolean().optional(),\n});\n", ba = "import { z } from \"zod\";\n\nexport const resetSchema = z.object({\n email: z.email(),\n});\n", xa = "import { z } from \"zod\";\n\nexport const signupSchema = z.object({\n email: z.email(),\n password: z.string(),\n passwordConfirm: z.string(),\n});\n", Sa = "export const load = ({ locals }) => {\n const user = locals.pb.authStore.record!;\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n\n return { user, breadcrumbs };\n};\n", Ca = "<script lang=\"ts\">\n import * as Sidebar from '$lib/components/ui/sidebar';\n import { Separator } from '$lib/components/ui/separator';\n import AppSidebar from '$lib/components/app-sidebar.svelte';\n import * as Breadcrumb from '$lib/components/ui/breadcrumb';\n import { page } from '$app/state';\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as { title: string; url: string }[];\n let { data, children } = $props();\n<\/script>\n\n<div class=\"min-h-dvh dashboard\">\n <Sidebar.Provider>\n <AppSidebar user={data.user} meta={data.meta} />\n <Sidebar.Inset>\n <header class=\"flex h-16 shrink-0 items-center gap-2\">\n <div class=\"flex items-center gap-2 px-4\">\n <Sidebar.Trigger class=\"-ml-1\" />\n <Separator orientation=\"vertical\" class=\"mr-2 data-[orientation=vertical]:h-4\" />\n {#if breadcrumbs.length > 0}\n <Breadcrumb.Root>\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}>{breadcrumb.title}</Breadcrumb.Link>\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n {/if}\n </div>\n </header>\n <div class=\"flex flex-1 flex-col p-4 pt-0\">\n {@render children?.()}\n </div>\n </Sidebar.Inset>\n </Sidebar.Provider>\n</div>\n\n<style>\n :global(body:has(div.dashboard)) {\n background-color: var(--color-sidebar);\n }\n</style>\n", wa = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Dashboard'\n });\n\n return { pageMetaTags };\n};\n", Ta = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"dashboard\", () => {\n it(\"should redirect to the login page\", async (context) => {\n const response = await context.request.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(302);\n expect(response.headers.location).toBe(\"/login?redirect=%2Fdashboard\");\n });\n\n it(\"authenticated user should be able to access the dashboard\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Ea = "export const load = async ({ parent }) => {\n const { breadcrumbs } = await parent();\n\n return {\n breadcrumbs: [...breadcrumbs, { title: \"Settings\", url: \"/settings\" }],\n };\n};\n", Da = "import { superValidate, fail, withFiles } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { profileSchema } from \"$lib/schemas/profile\";\nimport { changeEmailSchema } from \"$lib/schemas/changeEmail\";\nimport { changePasswordSchema } from \"$lib/schemas/changePassword\";\n\nexport const load = async ({ parent }) => {\n const { user } = await parent();\n\n const profileForm = await superValidate(\n {\n avatar: user.avatar,\n name: user.name,\n emailVisibility: user.emailVisibility,\n },\n zod4(profileSchema),\n );\n const emailForm = await superValidate(zod4(changeEmailSchema));\n const passwordForm = await superValidate(zod4(changePasswordSchema));\n\n return { profileForm, emailForm, passwordForm, user };\n};\n\nexport const actions = {\n updateProfile: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(profileSchema));\n\n if (!form.valid) {\n return fail(400, { profileForm: form });\n }\n\n await locals.pb\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, form.data);\n\n setFlash(\n { type: \"toast\", message: \"Profile updated successfully.\" },\n cookies,\n );\n return withFiles({ profileForm: form });\n },\n changeEmail: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(changeEmailSchema));\n\n if (!form.valid) {\n return fail(400, { emailForm: form });\n }\n\n await locals.pb.collection(\"users\").requestEmailChange(form.data.email);\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a confirmation link to your new email.\",\n },\n cookies,\n );\n return { emailForm: form };\n },\n changePassword: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(changePasswordSchema));\n\n if (!form.valid) {\n return fail(400, { passwordForm: form });\n }\n\n await locals.admin\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, {\n password: form.data.password,\n passwordConfirm: form.data.passwordConfirm,\n });\n\n setFlash(\n { type: \"toast\", message: \"Password updated successfully.\" },\n cookies,\n );\n return { passwordForm: form };\n },\n resendVerificationEmail: async ({ locals, request, cookies }) => {\n await locals.pb\n .collection(\"users\")\n .requestVerification(locals.pb.authStore.record!.email);\n setFlash(\n { type: \"toast\", message: \"We sent a verification email to your email.\" },\n cookies,\n );\n return {};\n },\n};\n", Oa = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { changeEmailSchema } from '$lib/schemas/changeEmail';\n import { changePasswordSchema } from '$lib/schemas/changePassword';\n import { profileSchema } from '$lib/schemas/profile';\n import { Button, buttonVariants } from '$lib/components/ui/button';\n import * as Form from '$lib/components/ui/form';\n import * as Card from '$lib/components/ui/card';\n import { Input } from '$lib/components/ui/input';\n import { Badge } from '$lib/components/ui/badge';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Checkbox } from '$lib/components/ui/checkbox';\n import * as Avatar from '$lib/components/ui/avatar';\n import * as FileForm from '$lib/components/ui/file-form';\n\n let { data } = $props();\n\n const profileForm = superForm(\n untrack(() => data.profileForm),\n {\n validators: zod4Client(profileSchema),\n id: 'profileForm'\n }\n );\n\n const emailForm = superForm(\n untrack(() => data.emailForm),\n {\n validators: zod4Client(changeEmailSchema),\n id: 'emailForm'\n }\n );\n\n const passwordForm = superForm(\n untrack(() => data.passwordForm),\n {\n validators: zod4Client(changePasswordSchema),\n id: 'passwordForm'\n }\n );\n\n const { form: profileFormData } = profileForm;\n const { form: emailFormData } = emailForm;\n const { form: passwordFormData } = passwordForm;\n<\/script>\n\n<div class=\"divide-y divide-gray-900/10 dark:divide-white/10\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">Profile</h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">Your profile information.</p>\n </div>\n\n <form\n method=\"POST\"\n action=\"?/updateProfile\"\n enctype=\"multipart/form-data\"\n class=\"md:col-span-2\"\n >\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <FileForm.Field form={profileForm} name=\"avatar\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"flex items-center gap-3 justify-between\">\n {#if !$profileFormData.avatar}\n <div class=\"flex items-center gap-3\">\n <Avatar.Root class=\"size-16\">\n <Avatar.Fallback>\n {data.user.email.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div>\n <span class=\"text-sm font-medium leading-none\">Avatar</span>\n <p class=\"text-muted-foreground text-sm\">\n Upload a new avatar for your profile.\n </p>\n </div>\n </div>\n {/if}\n <FileForm.Single>\n {#snippet display({ file, filename, onremove })}\n <div class=\"flex-1 flex gap-2 justify-between items-center\">\n <div class=\"flex items-center gap-3\">\n <FileForm.Thumb\n {file}\n {filename}\n collectionId=\"users\"\n id={data.user.id}\n class=\"w-16 h-16 object-cover rounded-full\"\n />\n <div>\n <span class=\"text-sm font-medium leading-none\">Avatar</span>\n <p class=\"text-muted-foreground text-sm\">\n Upload a new avatar for your profile.\n </p>\n </div>\n </div>\n <Button variant=\"outline\" onclick={() => onremove(file)}>\n Remove avatar\n </Button>\n </div>\n {/snippet}\n {#snippet input()}\n <FileForm.Input class=\"peer sr-only\" {...props} />\n <Form.Label\n class=\"{buttonVariants({\n variant: 'outline'\n })} peer-focus-visible:border-ring peer-focus-visible:ring-3 peer-focus-visible:ring-ring/50\"\n >\n Upload new picture\n </Form.Label>\n {/snippet}\n </FileForm.Single>\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </FileForm.Field>\n\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={profileForm} name=\"name\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Name</Form.Label>\n <Input\n {...props}\n type=\"text\"\n autocomplete=\"name\"\n bind:value={$profileFormData.name}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={profileForm} name=\"emailVisibility\" class=\"flex items-start gap-2\">\n <Form.Control>\n {#snippet children({ props })}\n <Checkbox {...props} bind:checked={$profileFormData.emailVisibility} />\n <div class=\"grid gap-2\">\n <Form.Label>Display email publicly</Form.Label>\n <p class=\"text-muted-foreground text-sm\">\n By clicking this checkbox, your email will be displayed publicly.\n </p>\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Save changes</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">Email</h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n The email address associated with your account.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"flex justify-between items-center\">\n <span class=\"text-sm flex items-center gap-2\">\n {data.user.email}\n <Badge variant=\"secondary\">{data.user.verified ? 'Verified' : 'Unverified'}</Badge>\n </span>\n <div class=\"flex items-center gap-3\">\n {#if !data.user.verified}\n <form method=\"POST\" action=\"?/resendVerificationEmail\">\n <Button type=\"submit\" variant=\"outline\" class=\"w-fit\"\n >Resend verification email</Button\n >\n </form>\n {/if}\n\n <Dialog.Root>\n <Dialog.Trigger class={buttonVariants({ variant: 'outline' })}>\n Change email\n </Dialog.Trigger>\n <Dialog.Content>\n <Dialog.Header>\n <Dialog.Title>Change email</Dialog.Title>\n <Dialog.Description>\n Enter your new email address. You will receive a verification email.\n </Dialog.Description>\n </Dialog.Header>\n <form method=\"POST\" action=\"?/changeEmail\" class=\"grid gap-4\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={emailForm} name=\"email\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$emailFormData.email}\n required\n autocomplete=\"email\"\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n <Dialog.Footer>\n <Button type=\"submit\" class=\"w-fit\">Change email</Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n </Dialog.Root>\n </div>\n </div>\n </Card.Content>\n </Card.Root>\n </div>\n\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">Password</h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n Your password is used to log in to your account.\n </p>\n </div>\n\n <form method=\"POST\" action=\"?/changePassword\" class=\"md:col-span-2\">\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <input\n type=\"email\"\n value={data.user.email}\n autocomplete=\"username\"\n readonly\n tabindex=\"-1\"\n aria-hidden=\"true\"\n class=\"sr-only\"\n />\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={passwordForm} name=\"password\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>New password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$passwordFormData.password}\n autocomplete=\"new-password\"\n required\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n <div class=\"grid gap-3\">\n <Form.Field form={passwordForm} name=\"passwordConfirm\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm new password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$passwordFormData.passwordConfirm}\n autocomplete=\"new-password\"\n required\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Update password</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n</div>\n", ka = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Settings'\n });\n\n return { ...data, pageMetaTags };\n};\n", Aa = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { confirmEmailChangeSchema } from \"$lib/schemas/confirmEmailChange\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const load = async () => {\n return { form: await superValidate(zod4(confirmEmailChangeSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(confirmEmailChangeSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n await locals.admin\n .collection(\"users\")\n .confirmEmailChange(params.token, form.data.password);\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash(\n { type: \"toast\", message: \"Email changed successfully.\" },\n cookies,\n );\n return redirect(303, \"/login\");\n },\n};\n", ja = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import { untrack } from 'svelte';\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { confirmEmailChangeSchema } from '$lib/schemas/confirmEmailChange';\n import * as Form from '$lib/components/ui/form';\n import { Input } from '$lib/components/ui/input';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(confirmEmailChangeSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Confirm your email change</Card.Title>\n <Card.Description>Enter your password to confirm your email change</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Confirm email change</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Ma = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm email change'\n });\n\n return { ...data, pageMetaTags };\n};\n", Na = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-email-change/[token]\", () => {\n it(\"should render the confirm-email-change page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-email-change/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Pa = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { confirmResetSchema } from \"$lib/schemas/confirmReset\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\n\nexport const load = async ({ params }) => {\n // The reset token is a JWT carrying the account email. Expose it so the\n // page can render a hidden username field for password managers.\n const { email } = getTokenPayload(params.token);\n\n return {\n form: await superValidate(zod4(confirmResetSchema)),\n email: typeof email === \"string\" ? email : null,\n };\n};\n\nexport const actions = {\n default: async ({ locals, request, params, cookies }) => {\n const form = await superValidate(request, zod4(confirmResetSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n await locals.admin\n .collection(\"users\")\n .confirmPasswordReset(\n params.token,\n form.data.password,\n form.data.passwordConfirm,\n );\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash(\n { type: \"toast\", message: \"Password reset successfully.\" },\n cookies,\n );\n return redirect(303, \"/login\");\n },\n};\n", Fa = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import { untrack } from 'svelte';\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { confirmResetSchema } from '$lib/schemas/confirmReset';\n import * as Form from '$lib/components/ui/form';\n import { Input } from '$lib/components/ui/input';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(confirmResetSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description>Enter your new password</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n {#if data.email}\n <input\n type=\"email\"\n value={data.email}\n autocomplete=\"username\"\n readonly\n tabindex=\"-1\"\n aria-hidden=\"true\"\n class=\"sr-only\"\n />\n {/if}\n\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n minlength={8}\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field {form} name=\"passwordConfirm\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Reset password</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Ia = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm password reset'\n });\n\n return { ...data, pageMetaTags };\n};\n", La = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-reset/[token]\", () => {\n it(\"should render the confirm-reset page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-reset/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Ra = "import { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const GET = async ({ params, locals, cookies }) => {\n let message = \"\";\n let redirectPath = \"\";\n\n try {\n await locals.admin.collection(\"users\").confirmVerification(params.token);\n message = \"Email verified successfully.\";\n redirectPath = \"/dashboard\";\n } catch (error: any) {\n message =\n \"Invalid or expired verification token. Please request a new verification email.\";\n redirectPath = \"/login\";\n }\n\n setFlash({ type: \"toast\", message }, cookies);\n redirect(303, redirectPath);\n};\n", za = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-verification/[token]\", () => {\n it(\"should redirect if the token is invalid\", async (context) => {\n const response = await context.request.get(\n \"/confirm-verification/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers[\"location\"]).toBe(\"/login\");\n });\n});\n", Ba = "import { fail, superValidate, message } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { loginSchema } from \"$lib/schemas/login\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/environment\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n const type: \"password\" | \"otp\" | \"oauth2\" = authMethods.otp.enabled\n ? \"otp\"\n : authMethods.password.enabled\n ? \"password\"\n : \"oauth2\";\n\n return {\n form: await superValidate(\n zod4(loginSchema.default({ type, email: \"\", password: \"\" })),\n ),\n authMethods,\n };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(loginSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n const redirectParam = url.searchParams.get(\"redirect\");\n if (form.data.type === \"otp\") {\n const req = await locals.pb\n .collection(\"users\")\n .requestOTP(form.data.email);\n return redirect(\n 303,\n `/otp/${req.otpId}${redirectParam ? `?redirect=${encodeURIComponent(redirectParam)}` : \"\"}`,\n );\n } else if (form.data.type === \"password\") {\n try {\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n } catch (error: any) {\n return message(\n form,\n { type: \"error\", text: error.response.message },\n { status: 400 },\n );\n }\n }\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n redirect(303, redirectUrl);\n },\n};\n", Va = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { loginSchema } from \"$lib/schemas/login\";\n import * as Form from \"$lib/components/ui/form\";\n import { Input } from \"$lib/components/ui/input\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(loginSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome back</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a login method</Card.Description>\n {:else}\n <Card.Description>Use your email to login</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Login is disabled</Card.Title>\n <Card.Description\n >Check back later for login options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled || authMethods.otp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"grid grid-cols-[1fr_auto] gap-2\">\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n class=\"col-span-2\"\n />\n <a\n href=\"/reset\"\n class=\"col-start-2 row-start-1 text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", Ha = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Log in'\n });\n\n return { ...data, pageMetaTags };\n};\n", Ua = "import { describe, it, expect } from \"vitest\";\nimport * as devalue from \"devalue\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /login\", () => {\n it(\"should render the login page\", async (context) => {\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(200);\n });\n\n it(\"should redirect to the dashboard if the user is already authenticated\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/dashboard\");\n });\n});\n\ndescribe(\"POST /login\", () => {\n it(\"should login with password\", async (context) => {\n const response = await context.agent\n .post(\"/login\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: context.user.email,\n password: \"password\",\n });\n expect(response.body.status).toBe(303);\n expect(response.body.location).toBe(\"/dashboard\");\n });\n\n it(\"should error if the password is incorrect\", async (context) => {\n const response = await context.agent\n .post(\"/login\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: context.user.email,\n password: \"incorrect\",\n });\n const data = devalue.parse(response.body.data);\n expect(response.body.status).toBe(400);\n expect(data.form.message.text).toBe(\"Failed to authenticate.\");\n });\n});\n", Wa = "import { redirect } from \"@sveltejs/kit\";\n\nexport const POST = ({ cookies, locals }) => {\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n throw redirect(303, \"/\");\n};\n", Ga = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"POST /logout\", () => {\n it(\"should logout the user\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.post(\n \"/logout\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/\");\n });\n});\n", Ka = "import { fail, message, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { otpSchema } from \"$lib/schemas/otp\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/environment\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(otpSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, request, params, cookies, url }) => {\n const form = await superValidate(request, zod4(otpSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb\n .collection(\"users\")\n .authWithOTP(params.token, form.data.otp);\n } catch (error: any) {\n return message(\n form,\n { type: \"error\", text: error.response.message },\n { status: 400 },\n );\n }\n\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n redirect(303, redirectUrl);\n },\n};\n", qa = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import { untrack } from 'svelte';\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { otpSchema } from '$lib/schemas/otp';\n import * as Form from '$lib/components/ui/form';\n import { Input } from '$lib/components/ui/input';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(otpSchema)\n }\n );\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Enter your OTP code</Card.Title>\n <Card.Description>Enter the code sent to your email</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"otp\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>OTP code</Form.Label>\n <Input\n {...props}\n type=\"text\"\n inputmode=\"numeric\"\n autocomplete=\"one-time-code\"\n bind:value={$formData.otp}\n required\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === 'error'}\n <div class=\"text-destructive text-sm font-medium -mt-2\">{$message.text}</div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Verify code</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Ja = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Verify code'\n });\n\n return { ...data, pageMetaTags };\n};\n", Ya = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /otp/[token]\", () => {\n it(\"should render the otp page\", async (context) => {\n const response = await context.request.get(\n \"/otp/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /otp/[token]\", () => {\n it(\"should throw an error if the otp is invalid\", async (context) => {\n const response = await context.agent\n .post(\"/otp/123456\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ otp: \"123456\" });\n expect(response.body.status).toBe(400);\n });\n});\n", Xa = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { resetSchema } from \"$lib/schemas/reset\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(resetSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(resetSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n await locals.pb.collection(\"users\").requestPasswordReset(form.data.email);\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a password reset link to your email.\",\n },\n cookies,\n );\n\n return { form };\n },\n};\n", Za = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import { untrack } from 'svelte';\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { resetSchema } from '$lib/schemas/reset';\n import * as Form from '$lib/components/ui/form';\n import { Input } from '$lib/components/ui/input';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(resetSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description>Enter your email to reset your password</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Send reset link</Button>\n </div>\n\n <div class=\"text-center text-sm\">\n Remembered your password?\n <a href=\"/login\" class=\"underline underline-offset-4\">Log in</a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Qa = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Reset password'\n });\n\n return { ...data, pageMetaTags };\n};\n", $a = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /reset\", () => {\n it(\"should render the reset page\", async (context) => {\n const response = await context.request.get(\n \"/reset\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /reset\", () => {\n it(\"should request a password reset\", async (context) => {\n const response = await context.agent\n .post(\"/reset\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ email: context.user.email });\n expect(response.body.status).toBe(200);\n });\n});\n", eo = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\nimport { dev } from \"$app/environment\";\nimport { signupSchema } from \"$lib/schemas/signup\";\n\nexport const load = async ({ locals }) => {\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(signupSchema)), authMethods };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(signupSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n let user;\n\n try {\n user = await locals.admin.collection(\"users\").create({\n email: form.data.email,\n password: form.data.password,\n passwordConfirm: form.data.passwordConfirm,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n await locals.pb.collection(\"users\").requestVerification(user.email);\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n setFlash(\n { type: \"toast\", message: \"We sent a confirmation link to your email.\" },\n cookies,\n );\n return redirect(303, redirectUrl);\n },\n};\n", to = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { signupSchema } from \"$lib/schemas/signup\";\n import * as Form from \"$lib/components/ui/form\";\n import { Input } from \"$lib/components/ui/input\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(signupSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Create an account</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a sign up method</Card.Description>\n {:else}\n <Card.Description>Use your email to sign up</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Signups are disabled</Card.Title>\n <Card.Description\n >Check back later for signup options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Sign up with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field {form} name=\"passwordConfirm\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Button type=\"submit\" class=\"w-full\">Create account</Button>\n </div>\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", no = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Sign up'\n });\n\n return { ...data, pageMetaTags };\n};\n", ro = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /signup\", () => {\n it(\"should render the signup page\", async (context) => {\n const response = await context.request.get(\n \"/signup\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /signup\", () => {\n it(\"should signup with password\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: \"password\",\n passwordConfirm: \"password\",\n });\n expect(response.body.status).toBe(303);\n expect(response.body.location).toBe(\"/dashboard\");\n });\n\n it(\"should error if the password does not match\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: \"password\",\n passwordConfirm: \"password2\",\n });\n expect(response.body.status).toBe(400);\n const data = devalue.parse(response.body.data);\n expect(data.form.errors.passwordConfirm).toBeDefined();\n expect(data.form.errors.passwordConfirm[0]).toBe(\"Values don't match.\");\n });\n\n it(\"should error if the email is already taken\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: context.user.email,\n password: \"password\",\n passwordConfirm: \"password\",\n });\n expect(response.body.status).toBe(400);\n const data = devalue.parse(response.body.data);\n expect(data.form.errors.email).toBeDefined();\n expect(data.form.errors.email[0]).toBe(\"Value must be unique.\");\n });\n});\n", io = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"$lib/components/ui/button\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { loginSchema } from \"$lib/schemas/login\";\n import * as Form from \"$lib/components/ui/form\";\n import { Input } from \"$lib/components/ui/input\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(loginSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"grid h-full lg:grid-cols-2\">\n <div class=\"flex flex-col gap-4 p-6 md:p-10\">\n <div class=\"flex justify-center gap-2 md:justify-start\">\n <a href=\"/\" class=\"flex items-center gap-2 font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n </div>\n <div class=\"flex flex-1 items-center justify-center\">\n <div class=\"w-full max-w-sm\">\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"flex flex-col items-center gap-2 text-center\">\n {#if hasAuthMethods}\n <h1 class=\"text-2xl font-bold\">Welcome back</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n {hasOAuth2\n ? \"Choose a login method\"\n : \"Use your email to login\"}\n </p>\n {:else}\n <h1 class=\"text-2xl font-bold\">Login is disabled</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n Check back later for login options\n </p>\n {/if}\n </div>\n\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled || authMethods.otp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-background text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"grid grid-cols-[1fr_auto] gap-2\">\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n class=\"col-span-2\"\n />\n <a\n href=\"/reset\"\n class=\"col-start-2 row-start-1 text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </div>\n </div>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n <div class=\"bg-muted relative hidden lg:block\">\n <img\n src={favicon}\n alt=\"\"\n class=\"absolute inset-0 m-auto size-32 opacity-20\"\n />\n </div>\n</div>\n", ao = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"$lib/components/ui/button\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { signupSchema } from \"$lib/schemas/signup\";\n import * as Form from \"$lib/components/ui/form\";\n import { Input } from \"$lib/components/ui/input\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(signupSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"grid h-full lg:grid-cols-2\">\n <div class=\"bg-muted relative hidden lg:block\">\n <img\n src={favicon}\n alt=\"\"\n class=\"absolute inset-0 m-auto size-32 opacity-20\"\n />\n </div>\n <div class=\"flex flex-col gap-4 p-6 md:p-10\">\n <div class=\"flex justify-center gap-2 md:justify-start\">\n <a href=\"/\" class=\"flex items-center gap-2 font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n </div>\n <div class=\"flex flex-1 items-center justify-center\">\n <div class=\"w-full max-w-sm\">\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"flex flex-col items-center gap-2 text-center\">\n {#if hasAuthMethods}\n <h1 class=\"text-2xl font-bold\">Create an account</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n {hasOAuth2\n ? \"Choose a sign up method\"\n : \"Use your email to sign up\"}\n </p>\n {:else}\n <h1 class=\"text-2xl font-bold\">Signups are disabled</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n Check back later for signup options\n </p>\n {/if}\n </div>\n\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Sign up with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-background text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field {form} name=\"passwordConfirm\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Button type=\"submit\" class=\"w-full\">Create account</Button>\n </div>\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </div>\n </div>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n</div>\n", oo = /* #__PURE__ */ Object.assign({
|
|
3957
3957
|
"./creates/src/lib/components/app-sidebar.svelte": ua,
|
|
3958
3958
|
"./creates/src/lib/components/nav-main.svelte": da,
|
|
3959
3959
|
"./creates/src/lib/components/nav-user.svelte": fa,
|
|
@@ -4031,7 +4031,12 @@ async function lo(e) {
|
|
|
4031
4031
|
modifies: [],
|
|
4032
4032
|
deletes: [],
|
|
4033
4033
|
components: i,
|
|
4034
|
-
packages: [
|
|
4034
|
+
packages: [
|
|
4035
|
+
"formsnap@^2.0.1",
|
|
4036
|
+
"sveltekit-flash-message@^2.4.6",
|
|
4037
|
+
"sveltekit-superforms@^2.30.2",
|
|
4038
|
+
"zod@^4.1.11"
|
|
4039
|
+
],
|
|
4035
4040
|
collections: [{
|
|
4036
4041
|
listRule: "@request.auth.id = user.id",
|
|
4037
4042
|
viewRule: "@request.auth.id = user.id",
|
|
@@ -4130,8 +4135,11 @@ async function vo(e) {
|
|
|
4130
4135
|
let n = await po(e);
|
|
4131
4136
|
return m(i([t, n]), e);
|
|
4132
4137
|
}
|
|
4133
|
-
let {
|
|
4134
|
-
|
|
4138
|
+
let { createCollections: n } = await import("./chunks/collections-B3lAtPlQ.js"), r = await n(t.collections, e), { writeResult: a } = await import("./chunks/write-result-BN7Ff0rF.js"), o = await a(await m({
|
|
4139
|
+
...t,
|
|
4140
|
+
creates: [...t.creates, ...r]
|
|
4141
|
+
}, e), e), { generate: s } = await import("./chunks/generate.runtime-FMYR64DL.js"), c = await s(e), l = await a(await m(c, e), e);
|
|
4142
|
+
return i([o, l]);
|
|
4135
4143
|
}
|
|
4136
4144
|
var yo = {
|
|
4137
4145
|
version: ho,
|
|
@@ -4172,7 +4180,7 @@ var yo = {
|
|
|
4172
4180
|
baseline: "velastack",
|
|
4173
4181
|
variants: ["split"],
|
|
4174
4182
|
generate: vo
|
|
4175
|
-
}, bo = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import type { ComponentProps } from 'svelte';\n import HomeIcon from '@lucide/svelte/icons/home';\n import * as Sidebar from '$lib/components/ui/sidebar';\n import NavMain from './nav-main.svelte';\n import NavUser from './nav-user.svelte';\n\n let data = {\n navMain: [\n {\n title: 'Dashboard',\n url: '/dashboard',\n icon: HomeIcon\n }\n ]\n };\n\n let {\n user,\n meta,\n ref = $bindable(null),\n ...restProps\n }: ComponentProps<typeof Sidebar.Root> & { user: any; meta: any } = $props();\n<\/script>\n\n<Sidebar.Root bind:ref variant=\"inset\" {...restProps}>\n <Sidebar.Header>\n <Sidebar.Menu>\n <Sidebar.MenuItem>\n <Sidebar.MenuButton size=\"lg\">\n {#snippet child({ props })}\n <a href=\"/dashboard\" {...props}>\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{meta.appName}</span>\n </div>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n </Sidebar.Menu>\n </Sidebar.Header>\n <Sidebar.Content>\n <NavMain items={data.navMain} />\n </Sidebar.Content>\n <Sidebar.Footer>\n <NavUser {user} />\n </Sidebar.Footer>\n</Sidebar.Root>\n", xo = "<script lang=\"ts\">\n import type { Component } from 'svelte';\n import * as Sidebar from '$lib/components/ui/sidebar';\n import { page } from '$app/state';\n\n const isActive = (url: string) => {\n return page.url.pathname.startsWith(url);\n };\n\n let {\n items\n }: {\n items: {\n title: string;\n url: string;\n icon: Component;\n items?: {\n title: string;\n url: string;\n }[];\n }[];\n } = $props();\n<\/script>\n\n<Sidebar.Group>\n <Sidebar.Menu>\n {#each items as item (item.title)}\n <Sidebar.MenuItem>\n <Sidebar.MenuButton isActive={isActive(item.url)}>\n {#snippet child({ props })}\n <a href={item.url} {...props}>\n <item.icon />\n <span>{item.title}</span>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n {/each}\n </Sidebar.Menu>\n</Sidebar.Group>\n", So = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import * as Avatar from '$lib/components/ui/avatar';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import * as Sidebar from '$lib/components/ui/sidebar';\n \n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n }\n ]\n };\n\n let {\n user\n }: {\n user: {\n id: string;\n name: string;\n email: string;\n avatar: string;\n };\n } = $props();\n\n const sidebar = Sidebar.useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n {...props}\n >\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name}</span>\n <span class=\"truncate text-xs\">{user.email}</span>\n </div>\n <ChevronsUpDownIcon class=\"ml-auto size-4\" />\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n align=\"end\"\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"p-0 font-normal\">\n <div class=\"flex items-center gap-2 px-1 py-1.5 text-left text-sm\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name}</span>\n <span class=\"truncate text-xs\">{user.email}</span>\n </div>\n </div>\n </DropdownMenu.Label>\n <DropdownMenu.Separator />\n <DropdownMenu.Group>\n <DropdownMenu.Item onclick={toggleMode}>\n {#if mode.current === 'dark'}\n <SunIcon />\n Light mode\n {:else}\n <MoonIcon />\n Dark mode\n {/if}\n </DropdownMenu.Item>\n {#each data.navUser as item}\n <DropdownMenu.Item class=\"p-0\">\n <a href={item.url} class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <item.icon />\n {item.title}\n </a>\n </DropdownMenu.Item>\n {/each}\n </DropdownMenu.Group>\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <form action=\"/logout\" method=\"post\" class=\"w-full\">\n <button type=\"submit\" class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <LogOutIcon />\n Log out\n </button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", Co = "import { z } from \"zod\";\n\nexport const changeEmailSchema = z.object({\n email: z.email(),\n});\n", wo = "import { z } from \"zod\";\n\nexport const changePasswordSchema = z\n .object({\n password: z.string(),\n passwordConfirm: z.string(),\n })\n .refine((data) => data.password === data.passwordConfirm, {\n message: \"Passwords don't match\",\n path: [\"passwordConfirm\"],\n });\n", To = "import { z } from \"zod\";\n\nexport const confirmEmailChangeSchema = z.object({\n password: z.string(),\n});\n", Eo = "import { z } from \"zod\";\n\nexport const confirmResetSchema = z.object({\n password: z.string(),\n passwordConfirm: z.string(),\n});\n", Do = "import { z } from \"zod\";\n\nconst otpSchema = z.object({\n type: z.literal(\"otp\"),\n email: z.email(),\n});\n\nconst passwordSchema = z.object({\n type: z.literal(\"password\"),\n email: z.email(),\n password: z.string(),\n});\n\nconst oAuth2Schema = z.object({\n type: z.literal(\"oauth2\"),\n email: z.email(),\n});\n\nexport const loginSchema = z.discriminatedUnion(\"type\", [\n otpSchema,\n passwordSchema,\n oAuth2Schema,\n]);\n", Oo = "import { z } from \"zod\";\n\nexport const otpSchema = z.object({\n otp: z.string(),\n});\n", ko = "import { z } from \"zod\";\n\nexport const profileSchema = z.object({\n name: z.string().optional(),\n avatar: z.union([z.instanceof(File), z.string()]).optional(),\n emailVisibility: z.boolean().optional(),\n});\n", Ao = "import { z } from \"zod\";\n\nexport const resetSchema = z.object({\n email: z.email(),\n});\n", jo = "import { z } from \"zod\";\n\nexport const signupSchema = z.object({\n email: z.email(),\n password: z.string(),\n passwordConfirm: z.string(),\n});\n", Mo = "export const load = ({ locals }) => {\n const user = locals.pb.authStore.record!;\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n\n return { user, breadcrumbs };\n};\n", No = "<script lang=\"ts\">\n import * as Sidebar from '$lib/components/ui/sidebar';\n import { Separator } from '$lib/components/ui/separator';\n import AppSidebar from '$lib/components/app-sidebar.svelte';\n import * as Breadcrumb from '$lib/components/ui/breadcrumb';\n import { page } from '$app/state';\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as { title: string; url: string }[];\n let { data, children } = $props();\n<\/script>\n\n<div class=\"min-h-dvh dashboard\">\n <Sidebar.Provider>\n <AppSidebar user={data.user} meta={data.meta} />\n <Sidebar.Inset>\n <header class=\"flex h-16 shrink-0 items-center gap-2\">\n <div class=\"flex items-center gap-2 px-4\">\n <Sidebar.Trigger class=\"-ml-1\" />\n <Separator orientation=\"vertical\" class=\"mr-2 data-[orientation=vertical]:h-4\" />\n {#if breadcrumbs.length > 0}\n <Breadcrumb.Root>\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}>{breadcrumb.title}</Breadcrumb.Link>\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n {/if}\n </div>\n </header>\n <div class=\"flex flex-1 flex-col p-4 pt-0\">\n {@render children?.()}\n </div>\n </Sidebar.Inset>\n </Sidebar.Provider>\n</div>\n\n<style>\n :global(body:has(div.dashboard)) {\n background-color: var(--color-sidebar);\n }\n</style>\n", Po = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Dashboard'\n });\n\n return { pageMetaTags };\n};\n", Fo = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"dashboard\", () => {\n it(\"should redirect to the login page\", async (context) => {\n const response = await context.request.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(302);\n expect(response.headers.location).toBe(\"/login?redirect=%2Fdashboard\");\n });\n\n it(\"authenticated user should be able to access the dashboard\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Io = "export const load = async ({ parent }) => {\n const { breadcrumbs } = await parent();\n\n return {\n breadcrumbs: [...breadcrumbs, { title: \"Settings\", url: \"/settings\" }],\n };\n};\n", Lo = "export const load = async ({ parent }) => {\n const { user } = await parent();\n\n return { user };\n};\n", Ro = "<script lang=\"ts\">\n import { Button, buttonVariants } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import { Badge } from \"$lib/components/ui/badge\";\n import * as Dialog from \"$lib/components/ui/dialog\";\n import { Checkbox } from \"$lib/components/ui/checkbox\";\n import * as Avatar from \"$lib/components/ui/avatar\";\n import {\n updateProfileForm,\n changeEmailForm,\n changePasswordForm,\n resendVerificationForm,\n } from \"./form.remote\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"divide-y divide-gray-900/10 dark:divide-white/10\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">\n Profile\n </h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n Your profile information.\n </p>\n </div>\n\n <form\n {...updateProfileForm}\n enctype=\"multipart/form-data\"\n class=\"md:col-span-2\"\n >\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"flex items-center gap-3 justify-between\">\n <div class=\"flex items-center gap-3\">\n <Avatar.Root class=\"size-16\">\n <Avatar.Fallback>\n {data.user.email.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div>\n <span class=\"text-sm font-medium leading-none\">Avatar</span>\n <p class=\"text-muted-foreground text-sm\">\n Upload a new avatar for your profile.\n </p>\n </div>\n </div>\n <label class={buttonVariants({ variant: \"outline\" })}>\n Upload new picture\n <input\n {...updateProfileForm.fields.avatar.as(\"file\")}\n type=\"file\"\n class=\"hidden\"\n />\n </label>\n </div>\n {#each updateProfileForm.fields.avatar.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <label for=\"name\" class=\"text-sm font-medium\">Name</label>\n <Input\n id=\"name\"\n {...updateProfileForm.fields.name.as(\"text\")}\n type=\"text\"\n />\n {#each updateProfileForm.fields.name.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <div class=\"flex items-start gap-2\">\n <Checkbox\n {...updateProfileForm.fields.emailVisibility.as(\"checkbox\")}\n />\n <div class=\"grid gap-2\">\n <label\n for=\"emailVisibility\"\n class=\"text-sm font-medium leading-none\"\n >Display email publicly</label\n >\n <p class=\"text-muted-foreground text-sm\">\n By clicking this checkbox, your email will be displayed\n publicly.\n </p>\n </div>\n </div>\n {#each updateProfileForm.fields.emailVisibility.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Save changes</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">\n Email\n </h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n The email address associated with your account.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"flex justify-between items-center\">\n <span class=\"text-sm flex items-center gap-2\">\n {data.user.email}\n <Badge variant=\"secondary\"\n >{data.user.verified ? \"Verified\" : \"Unverified\"}</Badge\n >\n </span>\n <div class=\"flex items-center gap-3\">\n {#if !data.user.verified}\n <form {...resendVerificationForm}>\n <Button type=\"submit\" variant=\"outline\" class=\"w-fit\"\n >Resend verification email</Button\n >\n </form>\n {/if}\n\n <Dialog.Root>\n <Dialog.Trigger class={buttonVariants({ variant: \"outline\" })}>\n Change email\n </Dialog.Trigger>\n <Dialog.Content>\n <Dialog.Header>\n <Dialog.Title>Change email</Dialog.Title>\n <Dialog.Description>\n Enter your new email address. You will receive a\n verification email.\n </Dialog.Description>\n </Dialog.Header>\n <form {...changeEmailForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <label for=\"email\" class=\"text-sm font-medium\"\n >Email</label\n >\n <Input\n id=\"email\"\n {...changeEmailForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n />\n {#each changeEmailForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n <Dialog.Footer>\n <Button type=\"submit\" class=\"w-fit\">Change email</Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n </Dialog.Root>\n </div>\n </div>\n </Card.Content>\n </Card.Root>\n </div>\n\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">\n Password\n </h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n Your password is used to log in to your account.\n </p>\n </div>\n\n <form {...changePasswordForm} class=\"md:col-span-2\">\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >New password</label\n >\n <Input\n id=\"password\"\n {...changePasswordForm.fields.password.as(\"text\")}\n type=\"password\"\n autocomplete=\"new-password\"\n required\n />\n {#each changePasswordForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n <div class=\"grid gap-3\">\n <label for=\"passwordConfirm\" class=\"text-sm font-medium\"\n >Confirm new password</label\n >\n <Input\n id=\"passwordConfirm\"\n {...changePasswordForm.fields.passwordConfirm.as(\"text\")}\n type=\"password\"\n autocomplete=\"new-password\"\n required\n />\n {#each changePasswordForm.fields.passwordConfirm.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Update password</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n</div>\n", zo = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Settings'\n });\n\n return { ...data, pageMetaTags };\n};\n", Bo = "import { form, getRequestEvent } from \"$app/server\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { profileSchema } from \"$lib/schemas/profile\";\nimport { changeEmailSchema } from \"$lib/schemas/changeEmail\";\nimport { changePasswordSchema } from \"$lib/schemas/changePassword\";\n\nexport const updateProfileForm = form(profileSchema, async (data) => {\n const { locals, cookies } = getRequestEvent();\n\n await locals.pb.collection(\"users\").update(locals.pb.authStore.record!.id, {\n name: data.name,\n avatar: data.avatar,\n emailVisibility: data.emailVisibility,\n });\n\n setFlash(\n { type: \"toast\", message: \"Profile updated successfully.\" },\n cookies,\n );\n return { success: true };\n});\n\nexport const changeEmailForm = form(changeEmailSchema, async (data) => {\n const { locals, cookies } = getRequestEvent();\n\n await locals.pb.collection(\"users\").requestEmailChange(data.email);\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a confirmation link to your new email.\",\n },\n cookies,\n );\n return { success: true };\n});\n\nexport const changePasswordForm = form(changePasswordSchema, async (data) => {\n const { locals, cookies } = getRequestEvent();\n\n await locals.admin\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, {\n password: data.password,\n passwordConfirm: data.passwordConfirm,\n });\n\n setFlash(\n { type: \"toast\", message: \"Password updated successfully.\" },\n cookies,\n );\n return { success: true };\n});\n\nexport const resendVerificationForm = form(async () => {\n const { locals, cookies } = getRequestEvent();\n await locals.pb\n .collection(\"users\")\n .requestVerification(locals.pb.authStore.record!.email);\n setFlash(\n { type: \"toast\", message: \"We sent a verification email to your email.\" },\n cookies,\n );\n return { success: true };\n});\n", Vo = "export const load = async () => {\n return {};\n};\n", Ho = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import { confirmEmailChangeForm } from \"./form.remote\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Confirm your email change</Card.Title>\n <Card.Description\n >Enter your password to confirm your email change</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...confirmEmailChangeForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...confirmEmailChangeForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"current-password\"\n />\n {#each confirmEmailChangeForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Confirm email change</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Uo = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm email change'\n });\n\n return { ...data, pageMetaTags };\n};\n", Wo = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { confirmEmailChangeSchema } from \"$lib/schemas/confirmEmailChange\";\n\nexport const confirmEmailChangeForm = form(\n confirmEmailChangeSchema,\n async (data) => {\n const { locals, cookies, params } = getRequestEvent();\n\n await locals.admin\n .collection(\"users\")\n .confirmEmailChange(params.token as string, data.password);\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash(\n { type: \"toast\", message: \"Email changed successfully.\" },\n cookies,\n );\n redirect(303, \"/login\");\n },\n);\n", Go = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-email-change/[token]\", () => {\n it(\"should render the confirm-email-change page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-email-change/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Ko = "export const load = async () => {\n return {};\n};\n", qo = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import { confirmResetForm } from \"./form.remote\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description>Enter your new password</Card.Description>\n </Card.Header>\n <Card.Content>\n <form {...confirmResetForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...confirmResetForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n />\n {#each confirmResetForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <div class=\"space-y-2 col-span-1\">\n <label for=\"passwordConfirm\" class=\"text-sm font-medium\"\n >Confirm Password</label\n >\n <Input\n id=\"passwordConfirm\"\n {...confirmResetForm.fields.passwordConfirm.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n />\n {#each confirmResetForm.fields.passwordConfirm.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Reset password</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Jo = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm password reset'\n });\n\n return { ...data, pageMetaTags };\n};\n", Yo = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { confirmResetSchema } from \"$lib/schemas/confirmReset\";\n\nexport const confirmResetForm = form(confirmResetSchema, async (data) => {\n const { locals, cookies, params } = getRequestEvent();\n\n await locals.admin\n .collection(\"users\")\n .confirmPasswordReset(\n params.token as string,\n data.password,\n data.passwordConfirm,\n );\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash({ type: \"toast\", message: \"Password reset successfully.\" }, cookies);\n redirect(303, \"/login\");\n});\n", Xo = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-reset/[token]\", () => {\n it(\"should render the confirm-reset page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-reset/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Zo = "import { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const GET = async ({ params, locals, cookies }) => {\n let message = \"\";\n let redirectPath = \"\";\n\n try {\n await locals.admin.collection(\"users\").confirmVerification(params.token);\n message = \"Email verified successfully.\";\n redirectPath = \"/dashboard\";\n } catch (error: any) {\n message =\n \"Invalid or expired verification token. Please request a new verification email.\";\n redirectPath = \"/login\";\n }\n\n setFlash({ type: \"toast\", message }, cookies);\n redirect(303, redirectPath);\n};\n", Qo = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-verification/[token]\", () => {\n it(\"should redirect if the token is invalid\", async (context) => {\n const response = await context.request.get(\n \"/confirm-verification/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers[\"location\"]).toBe(\"/login\");\n });\n});\n", $o = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n return { authMethods };\n};\n", es = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n import { loginForm } from \"./form.remote\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const initialType: \"password\" | \"otp\" | \"oauth2\" = $derived(\n authMethods.otp.enabled\n ? \"otp\"\n : authMethods.password.enabled\n ? \"password\"\n : \"oauth2\",\n );\n let mode = $state<\"password\" | \"otp\" | \"oauth2\">(\"password\");\n $effect(() => {\n mode = initialType;\n });\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome back</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a login method</Card.Description>\n {:else}\n <Card.Description>Use your email to login</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Login is disabled</Card.Title>\n <Card.Description\n >Check back later for login options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form {...loginForm}>\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled || authMethods.otp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"email\" class=\"text-sm font-medium\">Email</label>\n <Input\n id=\"email\"\n {...loginForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n />\n {#each loginForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if mode === \"password\" && authMethods.password.enabled}\n <div class=\"space-y-2 col-span-1\">\n <div class=\"flex justify-between\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <a\n href=\"/reset\"\n class=\"ml-auto text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n <Input\n id=\"password\"\n {...loginForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"current-password\"\n />\n {#each loginForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if loginForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {loginForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => (mode = \"otp\")}\n type=\"button\"\n >Use one-time code instead</Button\n >\n {/if}\n {:else if mode === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => (mode = \"password\")}\n type=\"button\"\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input\n type=\"hidden\"\n {...loginForm.fields.type.as(\"text\")}\n value={mode}\n />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", ts = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Log in'\n });\n\n return { ...data, pageMetaTags };\n};\n", ns = "import { form, getRequestEvent } from \"$app/server\";\nimport { error, redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/environment\";\nimport { loginSchema } from \"$lib/schemas/login\";\n\nexport const loginForm = form(loginSchema, async (data) => {\n const { locals, cookies, url } = getRequestEvent();\n\n const redirectParam = url.searchParams.get(\"redirect\");\n if (data.type === \"otp\") {\n const req = await locals.pb.collection(\"users\").requestOTP(data.email);\n redirect(\n 303,\n `/otp/${req.otpId}${redirectParam ? `?redirect=${encodeURIComponent(redirectParam)}` : \"\"}`,\n );\n } else if (data.type === \"password\") {\n try {\n await locals.pb\n .collection(\"users\")\n .authWithPassword(data.email, data.password);\n } catch (err: any) {\n error(400, err.response?.message ?? \"Failed to authenticate.\");\n }\n }\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n redirect(303, redirectUrl);\n});\n", rs = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /login\", () => {\n it(\"should render the login page\", async (context) => {\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(200);\n });\n\n it(\"should redirect to the dashboard if the user is already authenticated\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/dashboard\");\n });\n});\n", is = "import { redirect } from \"@sveltejs/kit\";\n\nexport const POST = ({ cookies, locals }) => {\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n throw redirect(303, \"/\");\n};\n", as = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"POST /logout\", () => {\n it(\"should logout the user\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.post(\n \"/logout\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/\");\n });\n});\n", os = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return {};\n};\n", ss = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import { otpForm } from \"./form.remote\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Enter your OTP code</Card.Title>\n <Card.Description\n >Enter the code sent to your email</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...otpForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"otp\" class=\"text-sm font-medium\">OTP code</label>\n <Input\n id=\"otp\"\n {...otpForm.fields.otp.as(\"text\")}\n type=\"text\"\n required\n />\n {#each otpForm.fields.otp.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if otpForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {otpForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Verify code</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", cs = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Verify code'\n });\n\n return { ...data, pageMetaTags };\n};\n", ls = "import { form, getRequestEvent } from \"$app/server\";\nimport { error, redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/environment\";\nimport { otpSchema } from \"$lib/schemas/otp\";\n\nexport const otpForm = form(otpSchema, async (data) => {\n const { locals, cookies, params, url } = getRequestEvent();\n\n try {\n await locals.pb\n .collection(\"users\")\n .authWithOTP(params.token as string, data.otp);\n } catch (err: any) {\n error(400, err.response?.message ?? \"Failed to verify code.\");\n }\n\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n redirect(303, redirectUrl);\n});\n", us = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /otp/[token]\", () => {\n it(\"should render the otp page\", async (context) => {\n const response = await context.request.get(\n \"/otp/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", ds = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return {};\n};\n", fs = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import { resetForm } from \"./form.remote\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description\n >Enter your email to reset your password</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...resetForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"email\" class=\"text-sm font-medium\">Email</label>\n <Input\n id=\"email\"\n {...resetForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n />\n {#each resetForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Send reset link</Button>\n </div>\n\n <div class=\"text-center text-sm\">\n Remembered your password?\n <a href=\"/login\" class=\"underline underline-offset-4\">Log in</a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", ps = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Reset password'\n });\n\n return { ...data, pageMetaTags };\n};\n", ms = "import { form, getRequestEvent } from \"$app/server\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { resetSchema } from \"$lib/schemas/reset\";\n\nexport const resetForm = form(resetSchema, async (data) => {\n const { locals, cookies } = getRequestEvent();\n\n await locals.pb.collection(\"users\").requestPasswordReset(data.email);\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a password reset link to your email.\",\n },\n cookies,\n );\n\n return { success: true };\n});\n", hs = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /reset\", () => {\n it(\"should render the reset page\", async (context) => {\n const response = await context.request.get(\n \"/reset\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", gs = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { authMethods };\n};\n", _s = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n import { signupForm } from \"./form.remote\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Create an account</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a sign up method</Card.Description>\n {:else}\n <Card.Description>Use your email to sign up</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Signups are disabled</Card.Title>\n <Card.Description\n >Check back later for signup options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form {...signupForm}>\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"email\" class=\"text-sm font-medium\">Email</label>\n <Input\n id=\"email\"\n {...signupForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n />\n {#each signupForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <div class=\"space-y-2 col-span-1\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...signupForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n />\n {#each signupForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <div class=\"space-y-2 col-span-1\">\n <label for=\"passwordConfirm\" class=\"text-sm font-medium\"\n >Confirm Password</label\n >\n <Input\n id=\"passwordConfirm\"\n {...signupForm.fields.passwordConfirm.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n />\n {#each signupForm.fields.passwordConfirm.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if signupForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {signupForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Create account</Button>\n </div>\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", vs = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Sign up'\n });\n\n return { ...data, pageMetaTags };\n};\n", ys = "import { form, getRequestEvent } from \"$app/server\";\nimport { error, redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { dev } from \"$app/environment\";\nimport { signupSchema } from \"$lib/schemas/signup\";\n\nexport const signupForm = form(signupSchema, async (data) => {\n const { locals, cookies, url } = getRequestEvent();\n\n let user;\n\n try {\n user = await locals.admin.collection(\"users\").create({\n email: data.email,\n password: data.password,\n passwordConfirm: data.passwordConfirm,\n });\n } catch (err: any) {\n const response = err?.response ?? {};\n const fieldError = response?.data\n ? Object.values(response.data)[0]\n : undefined;\n const message =\n (fieldError as any)?.message ??\n response?.message ??\n \"Failed to create account.\";\n error(400, message);\n }\n\n await locals.pb.collection(\"users\").requestVerification(user.email);\n await locals.pb\n .collection(\"users\")\n .authWithPassword(data.email, data.password);\n\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n setFlash(\n { type: \"toast\", message: \"We sent a confirmation link to your email.\" },\n cookies,\n );\n redirect(303, redirectUrl);\n});\n", bs = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /signup\", () => {\n it(\"should render the signup page\", async (context) => {\n const response = await context.request.get(\n \"/signup\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", xs = /* #__PURE__ */ Object.assign({
|
|
4183
|
+
}, bo = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import type { ComponentProps } from 'svelte';\n import HomeIcon from '@lucide/svelte/icons/home';\n import * as Sidebar from '$lib/components/ui/sidebar';\n import NavMain from './nav-main.svelte';\n import NavUser from './nav-user.svelte';\n\n let data = {\n navMain: [\n {\n title: 'Dashboard',\n url: '/dashboard',\n icon: HomeIcon\n }\n ]\n };\n\n let {\n user,\n meta,\n ref = $bindable(null),\n ...restProps\n }: ComponentProps<typeof Sidebar.Root> & { user: any; meta: any } = $props();\n<\/script>\n\n<Sidebar.Root bind:ref variant=\"inset\" {...restProps}>\n <Sidebar.Header>\n <Sidebar.Menu>\n <Sidebar.MenuItem>\n <Sidebar.MenuButton size=\"lg\">\n {#snippet child({ props })}\n <a href=\"/dashboard\" {...props}>\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{meta.appName}</span>\n </div>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n </Sidebar.Menu>\n </Sidebar.Header>\n <Sidebar.Content>\n <NavMain items={data.navMain} />\n </Sidebar.Content>\n <Sidebar.Footer>\n <NavUser {user} />\n </Sidebar.Footer>\n</Sidebar.Root>\n", xo = "<script lang=\"ts\">\n import type { Component } from 'svelte';\n import * as Sidebar from '$lib/components/ui/sidebar';\n import { page } from '$app/state';\n\n const isActive = (url: string) => {\n return page.url.pathname.startsWith(url);\n };\n\n let {\n items\n }: {\n items: {\n title: string;\n url: string;\n icon: Component;\n items?: {\n title: string;\n url: string;\n }[];\n }[];\n } = $props();\n<\/script>\n\n<Sidebar.Group>\n <Sidebar.Menu>\n {#each items as item (item.title)}\n <Sidebar.MenuItem>\n <Sidebar.MenuButton isActive={isActive(item.url)}>\n {#snippet child({ props })}\n <a href={item.url} {...props}>\n <item.icon />\n <span>{item.title}</span>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n {/each}\n </Sidebar.Menu>\n</Sidebar.Group>\n", So = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import * as Avatar from '$lib/components/ui/avatar';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import * as Sidebar from '$lib/components/ui/sidebar';\n \n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n }\n ]\n };\n\n let {\n user\n }: {\n user: {\n id: string;\n name: string;\n email: string;\n avatar: string;\n };\n } = $props();\n\n const sidebar = Sidebar.useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n {...props}\n >\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name}</span>\n <span class=\"truncate text-xs\">{user.email}</span>\n </div>\n <ChevronsUpDownIcon class=\"ml-auto size-4\" />\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n align=\"end\"\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"p-0 font-normal\">\n <div class=\"flex items-center gap-2 px-1 py-1.5 text-left text-sm\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name}</span>\n <span class=\"truncate text-xs\">{user.email}</span>\n </div>\n </div>\n </DropdownMenu.Label>\n <DropdownMenu.Separator />\n <DropdownMenu.Group>\n <DropdownMenu.Item onclick={toggleMode}>\n {#if mode.current === 'dark'}\n <SunIcon />\n Light mode\n {:else}\n <MoonIcon />\n Dark mode\n {/if}\n </DropdownMenu.Item>\n {#each data.navUser as item}\n <DropdownMenu.Item class=\"p-0\">\n <a href={item.url} class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <item.icon />\n {item.title}\n </a>\n </DropdownMenu.Item>\n {/each}\n </DropdownMenu.Group>\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <form action=\"/logout\" method=\"post\" class=\"w-full\">\n <button type=\"submit\" class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <LogOutIcon />\n Log out\n </button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", Co = "import { z } from \"zod\";\n\nexport const changeEmailSchema = z.object({\n email: z.email(),\n});\n", wo = "import { z } from \"zod\";\n\nexport const changePasswordSchema = z\n .object({\n password: z.string(),\n passwordConfirm: z.string(),\n })\n .refine((data) => data.password === data.passwordConfirm, {\n message: \"Passwords don't match\",\n path: [\"passwordConfirm\"],\n });\n", To = "import { z } from \"zod\";\n\nexport const confirmEmailChangeSchema = z.object({\n password: z.string(),\n});\n", Eo = "import { z } from \"zod\";\n\nexport const confirmResetSchema = z.object({\n password: z.string(),\n passwordConfirm: z.string(),\n});\n", Do = "import { z } from \"zod\";\n\n// A flat shape (rather than a discriminated union) keeps\n// `loginForm.fields.password` addressable in the page regardless of mode.\nexport const loginSchema = z\n .object({\n type: z.enum([\"password\", \"otp\", \"oauth2\"]),\n email: z.email(),\n password: z.string().optional(),\n })\n .refine((data) => data.type !== \"password\" || !!data.password, {\n message: \"Password is required\",\n path: [\"password\"],\n });\n", Oo = "import { z } from \"zod\";\n\nexport const otpSchema = z.object({\n otp: z.string(),\n});\n", ko = "import { z } from \"zod\";\n\nexport const profileSchema = z.object({\n name: z.string().optional(),\n avatar: z.union([z.instanceof(File), z.string()]).optional(),\n emailVisibility: z.boolean().optional(),\n});\n", Ao = "import { z } from \"zod\";\n\nexport const resetSchema = z.object({\n email: z.email(),\n});\n", jo = "import { z } from \"zod\";\n\nexport const signupSchema = z.object({\n email: z.email(),\n password: z.string(),\n passwordConfirm: z.string(),\n});\n", Mo = "export const load = ({ locals }) => {\n const user = locals.pb.authStore.record!;\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n\n return { user, breadcrumbs };\n};\n", No = "<script lang=\"ts\">\n import * as Sidebar from '$lib/components/ui/sidebar';\n import { Separator } from '$lib/components/ui/separator';\n import AppSidebar from '$lib/components/app-sidebar.svelte';\n import * as Breadcrumb from '$lib/components/ui/breadcrumb';\n import { page } from '$app/state';\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as { title: string; url: string }[];\n let { data, children } = $props();\n<\/script>\n\n<div class=\"min-h-dvh dashboard\">\n <Sidebar.Provider>\n <AppSidebar user={data.user} meta={data.meta} />\n <Sidebar.Inset>\n <header class=\"flex h-16 shrink-0 items-center gap-2\">\n <div class=\"flex items-center gap-2 px-4\">\n <Sidebar.Trigger class=\"-ml-1\" />\n <Separator orientation=\"vertical\" class=\"mr-2 data-[orientation=vertical]:h-4\" />\n {#if breadcrumbs.length > 0}\n <Breadcrumb.Root>\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}>{breadcrumb.title}</Breadcrumb.Link>\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n {/if}\n </div>\n </header>\n <div class=\"flex flex-1 flex-col p-4 pt-0\">\n {@render children?.()}\n </div>\n </Sidebar.Inset>\n </Sidebar.Provider>\n</div>\n\n<style>\n :global(body:has(div.dashboard)) {\n background-color: var(--color-sidebar);\n }\n</style>\n", Po = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Dashboard'\n });\n\n return { pageMetaTags };\n};\n", Fo = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"dashboard\", () => {\n it(\"should redirect to the login page\", async (context) => {\n const response = await context.request.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(302);\n expect(response.headers.location).toBe(\"/login?redirect=%2Fdashboard\");\n });\n\n it(\"authenticated user should be able to access the dashboard\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Io = "export const load = async ({ parent }) => {\n const { breadcrumbs } = await parent();\n\n return {\n breadcrumbs: [...breadcrumbs, { title: \"Settings\", url: \"/settings\" }],\n };\n};\n", Lo = "export const load = async ({ parent }) => {\n const { user } = await parent();\n\n return { user };\n};\n", Ro = "<script lang=\"ts\">\n import { Button, buttonVariants } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import { Badge } from \"$lib/components/ui/badge\";\n import * as Dialog from \"$lib/components/ui/dialog\";\n import { Checkbox } from \"$lib/components/ui/checkbox\";\n import * as Avatar from \"$lib/components/ui/avatar\";\n import {\n updateProfileForm,\n changeEmailForm,\n changePasswordForm,\n resendVerificationForm,\n } from \"./form.remote\";\n\n let { data } = $props();\n\n // bits-ui's Checkbox renders a <button>, so drop the native type=\"checkbox\"\n // from the field props before spreading them.\n const emailVisibilityProps = $derived.by(() => {\n const { type, ...props } =\n updateProfileForm.fields.emailVisibility.as(\"checkbox\");\n return props;\n });\n<\/script>\n\n<div class=\"divide-y divide-gray-900/10 dark:divide-white/10\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">\n Profile\n </h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n Your profile information.\n </p>\n </div>\n\n <form\n {...updateProfileForm}\n enctype=\"multipart/form-data\"\n class=\"md:col-span-2\"\n >\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"flex items-center gap-3 justify-between\">\n <div class=\"flex items-center gap-3\">\n <Avatar.Root class=\"size-16\">\n <Avatar.Fallback>\n {data.user.email.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div>\n <span class=\"text-sm font-medium leading-none\">Avatar</span>\n <p class=\"text-muted-foreground text-sm\">\n Upload a new avatar for your profile.\n </p>\n </div>\n </div>\n <label\n class=\"{buttonVariants({\n variant: 'outline',\n })} has-focus-visible:border-ring has-focus-visible:ring-3 has-focus-visible:ring-ring/50\"\n >\n Upload new picture\n <input\n {...updateProfileForm.fields.avatar.as(\"file\")}\n type=\"file\"\n class=\"sr-only\"\n />\n </label>\n </div>\n {#each updateProfileForm.fields.avatar.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <label for=\"name\" class=\"text-sm font-medium\">Name</label>\n <Input\n id=\"name\"\n {...updateProfileForm.fields.name.as(\"text\")}\n type=\"text\"\n autocomplete=\"name\"\n />\n {#each updateProfileForm.fields.name.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <div class=\"flex items-start gap-2\">\n <Checkbox id=\"emailVisibility\" {...emailVisibilityProps} />\n <div class=\"grid gap-2\">\n <label\n for=\"emailVisibility\"\n class=\"text-sm font-medium leading-none\"\n >Display email publicly</label\n >\n <p class=\"text-muted-foreground text-sm\">\n By clicking this checkbox, your email will be displayed\n publicly.\n </p>\n </div>\n </div>\n {#each updateProfileForm.fields.emailVisibility.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Save changes</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">\n Email\n </h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n The email address associated with your account.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"flex justify-between items-center\">\n <span class=\"text-sm flex items-center gap-2\">\n {data.user.email}\n <Badge variant=\"secondary\"\n >{data.user.verified ? \"Verified\" : \"Unverified\"}</Badge\n >\n </span>\n <div class=\"flex items-center gap-3\">\n {#if !data.user.verified}\n <form {...resendVerificationForm}>\n <Button type=\"submit\" variant=\"outline\" class=\"w-fit\"\n >Resend verification email</Button\n >\n </form>\n {/if}\n\n <Dialog.Root>\n <Dialog.Trigger class={buttonVariants({ variant: \"outline\" })}>\n Change email\n </Dialog.Trigger>\n <Dialog.Content>\n <Dialog.Header>\n <Dialog.Title>Change email</Dialog.Title>\n <Dialog.Description>\n Enter your new email address. You will receive a\n verification email.\n </Dialog.Description>\n </Dialog.Header>\n <form {...changeEmailForm} class=\"grid gap-4\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <label for=\"email\" class=\"text-sm font-medium\"\n >Email</label\n >\n <Input\n id=\"email\"\n {...changeEmailForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n autocomplete=\"email\"\n />\n {#each changeEmailForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n <Dialog.Footer>\n <Button type=\"submit\" class=\"w-fit\">Change email</Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n </Dialog.Root>\n </div>\n </div>\n </Card.Content>\n </Card.Root>\n </div>\n\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">\n Password\n </h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n Your password is used to log in to your account.\n </p>\n </div>\n\n <form {...changePasswordForm} class=\"md:col-span-2\">\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <input\n type=\"email\"\n value={data.user.email}\n autocomplete=\"username\"\n readonly\n tabindex=\"-1\"\n aria-hidden=\"true\"\n class=\"sr-only\"\n />\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >New password</label\n >\n <Input\n id=\"password\"\n {...changePasswordForm.fields.password.as(\"text\")}\n type=\"password\"\n autocomplete=\"new-password\"\n required\n minlength={8}\n />\n {#each changePasswordForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n <div class=\"grid gap-3\">\n <label for=\"passwordConfirm\" class=\"text-sm font-medium\"\n >Confirm new password</label\n >\n <Input\n id=\"passwordConfirm\"\n {...changePasswordForm.fields.passwordConfirm.as(\"text\")}\n type=\"password\"\n autocomplete=\"new-password\"\n required\n minlength={8}\n />\n {#each changePasswordForm.fields.passwordConfirm.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Update password</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n</div>\n", zo = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Settings'\n });\n\n return { ...data, pageMetaTags };\n};\n", Bo = "import { form, getRequestEvent } from \"$app/server\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { profileSchema } from \"$lib/schemas/profile\";\nimport { changeEmailSchema } from \"$lib/schemas/changeEmail\";\nimport { changePasswordSchema } from \"$lib/schemas/changePassword\";\n\nexport const updateProfileForm = form(profileSchema, async (data) => {\n const { locals, cookies } = getRequestEvent();\n\n await locals.pb.collection(\"users\").update(locals.pb.authStore.record!.id, {\n name: data.name,\n avatar: data.avatar,\n emailVisibility: data.emailVisibility,\n });\n\n setFlash(\n { type: \"toast\", message: \"Profile updated successfully.\" },\n cookies,\n );\n return { success: true };\n});\n\nexport const changeEmailForm = form(changeEmailSchema, async (data) => {\n const { locals, cookies } = getRequestEvent();\n\n await locals.pb.collection(\"users\").requestEmailChange(data.email);\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a confirmation link to your new email.\",\n },\n cookies,\n );\n return { success: true };\n});\n\nexport const changePasswordForm = form(changePasswordSchema, async (data) => {\n const { locals, cookies } = getRequestEvent();\n\n await locals.admin\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, {\n password: data.password,\n passwordConfirm: data.passwordConfirm,\n });\n\n setFlash(\n { type: \"toast\", message: \"Password updated successfully.\" },\n cookies,\n );\n return { success: true };\n});\n\nexport const resendVerificationForm = form(async () => {\n const { locals, cookies } = getRequestEvent();\n await locals.pb\n .collection(\"users\")\n .requestVerification(locals.pb.authStore.record!.email);\n setFlash(\n { type: \"toast\", message: \"We sent a verification email to your email.\" },\n cookies,\n );\n return { success: true };\n});\n", Vo = "export const load = async () => {\n return {};\n};\n", Ho = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import { confirmEmailChangeForm } from \"./form.remote\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Confirm your email change</Card.Title>\n <Card.Description\n >Enter your password to confirm your email change</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...confirmEmailChangeForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...confirmEmailChangeForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"current-password\"\n autofocus\n />\n {#each confirmEmailChangeForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Confirm email change</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Uo = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm email change'\n });\n\n return { ...data, pageMetaTags };\n};\n", Wo = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { confirmEmailChangeSchema } from \"$lib/schemas/confirmEmailChange\";\n\nexport const confirmEmailChangeForm = form(\n confirmEmailChangeSchema,\n async (data) => {\n const { locals, cookies, params } = getRequestEvent();\n\n await locals.admin\n .collection(\"users\")\n .confirmEmailChange(params.token as string, data.password);\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash(\n { type: \"toast\", message: \"Email changed successfully.\" },\n cookies,\n );\n redirect(303, \"/login\");\n },\n);\n", Go = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-email-change/[token]\", () => {\n it(\"should render the confirm-email-change page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-email-change/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Ko = "import { getTokenPayload } from \"pocketbase-sveltekit\";\n\nexport const load = async ({ params }) => {\n // The reset token is a JWT carrying the account email. Expose it so the\n // page can render a hidden username field for password managers.\n const { email } = getTokenPayload(params.token);\n\n return { email: typeof email === \"string\" ? email : null };\n};\n", qo = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import { confirmResetForm } from \"./form.remote\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description>Enter your new password</Card.Description>\n </Card.Header>\n <Card.Content>\n <form {...confirmResetForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n {#if data.email}\n <input\n type=\"email\"\n value={data.email}\n autocomplete=\"username\"\n readonly\n tabindex=\"-1\"\n aria-hidden=\"true\"\n class=\"sr-only\"\n />\n {/if}\n\n <div class=\"space-y-2 col-span-1\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...confirmResetForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n minlength={8}\n autofocus\n />\n {#each confirmResetForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <div class=\"space-y-2 col-span-1\">\n <label for=\"passwordConfirm\" class=\"text-sm font-medium\"\n >Confirm Password</label\n >\n <Input\n id=\"passwordConfirm\"\n {...confirmResetForm.fields.passwordConfirm.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {#each confirmResetForm.fields.passwordConfirm.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Reset password</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Jo = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm password reset'\n });\n\n return { ...data, pageMetaTags };\n};\n", Yo = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { confirmResetSchema } from \"$lib/schemas/confirmReset\";\n\nexport const confirmResetForm = form(confirmResetSchema, async (data) => {\n const { locals, cookies, params } = getRequestEvent();\n\n await locals.admin\n .collection(\"users\")\n .confirmPasswordReset(\n params.token as string,\n data.password,\n data.passwordConfirm,\n );\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash({ type: \"toast\", message: \"Password reset successfully.\" }, cookies);\n redirect(303, \"/login\");\n});\n", Xo = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-reset/[token]\", () => {\n it(\"should render the confirm-reset page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-reset/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Zo = "import { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const GET = async ({ params, locals, cookies }) => {\n let message = \"\";\n let redirectPath = \"\";\n\n try {\n await locals.admin.collection(\"users\").confirmVerification(params.token);\n message = \"Email verified successfully.\";\n redirectPath = \"/dashboard\";\n } catch (error: any) {\n message =\n \"Invalid or expired verification token. Please request a new verification email.\";\n redirectPath = \"/login\";\n }\n\n setFlash({ type: \"toast\", message }, cookies);\n redirect(303, redirectPath);\n};\n", Qo = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-verification/[token]\", () => {\n it(\"should redirect if the token is invalid\", async (context) => {\n const response = await context.request.get(\n \"/confirm-verification/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers[\"location\"]).toBe(\"/login\");\n });\n});\n", $o = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n return { authMethods };\n};\n", es = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n import { loginForm } from \"./form.remote\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const initialType: \"password\" | \"otp\" | \"oauth2\" = $derived(\n authMethods.otp.enabled\n ? \"otp\"\n : authMethods.password.enabled\n ? \"password\"\n : \"oauth2\",\n );\n let mode = $state<\"password\" | \"otp\" | \"oauth2\">(\"password\");\n $effect(() => {\n mode = initialType;\n });\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome back</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a login method</Card.Description>\n {:else}\n <Card.Description>Use your email to login</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Login is disabled</Card.Title>\n <Card.Description\n >Check back later for login options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form {...loginForm}>\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled || authMethods.otp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"email\" class=\"text-sm font-medium\">Email</label>\n <Input\n id=\"email\"\n {...loginForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n autocomplete=\"username\"\n autofocus\n />\n {#each loginForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if mode === \"password\" && authMethods.password.enabled}\n <div class=\"space-y-2 col-span-1\">\n <div class=\"grid grid-cols-[1fr_auto] gap-2\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...loginForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"current-password\"\n class=\"col-span-2\"\n />\n <a\n href=\"/reset\"\n class=\"col-start-2 row-start-1 text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n {#each loginForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if loginForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {loginForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => (mode = \"otp\")}\n type=\"button\"\n >Use one-time code instead</Button\n >\n {/if}\n {:else if mode === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => (mode = \"password\")}\n type=\"button\"\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input\n type=\"hidden\"\n {...loginForm.fields.type.as(\"text\")}\n value={mode}\n />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", ts = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Log in'\n });\n\n return { ...data, pageMetaTags };\n};\n", ns = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/environment\";\nimport { loginSchema } from \"$lib/schemas/login\";\n\nexport const loginForm = form(loginSchema, async (data) => {\n const { locals, cookies, url } = getRequestEvent();\n\n const redirectParam = url.searchParams.get(\"redirect\");\n if (data.type === \"otp\") {\n const req = await locals.pb.collection(\"users\").requestOTP(data.email);\n redirect(\n 303,\n `/otp/${req.otpId}${redirectParam ? `?redirect=${encodeURIComponent(redirectParam)}` : \"\"}`,\n );\n } else if (data.type === \"password\") {\n try {\n await locals.pb\n .collection(\"users\")\n .authWithPassword(data.email, data.password ?? \"\");\n } catch (err: any) {\n return {\n message: (err.response?.message as string) ?? \"Failed to authenticate.\",\n };\n }\n }\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n redirect(303, redirectUrl);\n});\n", rs = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /login\", () => {\n it(\"should render the login page\", async (context) => {\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(200);\n });\n\n it(\"should redirect to the dashboard if the user is already authenticated\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/dashboard\");\n });\n});\n", is = "import { redirect } from \"@sveltejs/kit\";\n\nexport const POST = ({ cookies, locals }) => {\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n throw redirect(303, \"/\");\n};\n", as = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"POST /logout\", () => {\n it(\"should logout the user\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.post(\n \"/logout\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/\");\n });\n});\n", os = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return {};\n};\n", ss = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import { otpForm } from \"./form.remote\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Enter your OTP code</Card.Title>\n <Card.Description\n >Enter the code sent to your email</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...otpForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"otp\" class=\"text-sm font-medium\">OTP code</label>\n <Input\n id=\"otp\"\n {...otpForm.fields.otp.as(\"text\")}\n type=\"text\"\n inputmode=\"numeric\"\n autocomplete=\"one-time-code\"\n required\n autofocus\n />\n {#each otpForm.fields.otp.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if otpForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {otpForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Verify code</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", cs = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Verify code'\n });\n\n return { ...data, pageMetaTags };\n};\n", ls = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/environment\";\nimport { otpSchema } from \"$lib/schemas/otp\";\n\nexport const otpForm = form(otpSchema, async (data) => {\n const { locals, cookies, params, url } = getRequestEvent();\n\n try {\n await locals.pb\n .collection(\"users\")\n .authWithOTP(params.token as string, data.otp);\n } catch (err: any) {\n return {\n message: (err.response?.message as string) ?? \"Failed to verify code.\",\n };\n }\n\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n redirect(303, redirectUrl);\n});\n", us = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /otp/[token]\", () => {\n it(\"should render the otp page\", async (context) => {\n const response = await context.request.get(\n \"/otp/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", ds = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return {};\n};\n", fs = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import { resetForm } from \"./form.remote\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description\n >Enter your email to reset your password</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...resetForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"email\" class=\"text-sm font-medium\">Email</label>\n <Input\n id=\"email\"\n {...resetForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n autocomplete=\"username\"\n autofocus\n />\n {#each resetForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Send reset link</Button>\n </div>\n\n <div class=\"text-center text-sm\">\n Remembered your password?\n <a href=\"/login\" class=\"underline underline-offset-4\">Log in</a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", ps = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Reset password'\n });\n\n return { ...data, pageMetaTags };\n};\n", ms = "import { form, getRequestEvent } from \"$app/server\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { resetSchema } from \"$lib/schemas/reset\";\n\nexport const resetForm = form(resetSchema, async (data) => {\n const { locals, cookies } = getRequestEvent();\n\n await locals.pb.collection(\"users\").requestPasswordReset(data.email);\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a password reset link to your email.\",\n },\n cookies,\n );\n\n return { success: true };\n});\n", hs = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /reset\", () => {\n it(\"should render the reset page\", async (context) => {\n const response = await context.request.get(\n \"/reset\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", gs = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { authMethods };\n};\n", _s = "<script lang=\"ts\">\n import favicon from \"$lib/assets/favicon.svg\";\n\n import { Button } from \"$lib/components/ui/button\";\n import * as Card from \"$lib/components/ui/card\";\n import { Input } from \"$lib/components/ui/input\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n import { signupForm } from \"./form.remote\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Create an account</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a sign up method</Card.Description>\n {:else}\n <Card.Description>Use your email to sign up</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Signups are disabled</Card.Title>\n <Card.Description\n >Check back later for signup options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form {...signupForm}>\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Sign up with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"email\" class=\"text-sm font-medium\">Email</label>\n <Input\n id=\"email\"\n {...signupForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n autocomplete=\"username\"\n autofocus\n />\n {#each signupForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <div class=\"space-y-2 col-span-1\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...signupForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {#each signupForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <div class=\"space-y-2 col-span-1\">\n <label for=\"passwordConfirm\" class=\"text-sm font-medium\"\n >Confirm Password</label\n >\n <Input\n id=\"passwordConfirm\"\n {...signupForm.fields.passwordConfirm.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {#each signupForm.fields.passwordConfirm.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if signupForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {signupForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Create account</Button>\n </div>\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", vs = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Sign up'\n });\n\n return { ...data, pageMetaTags };\n};\n", ys = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { dev } from \"$app/environment\";\nimport { signupSchema } from \"$lib/schemas/signup\";\n\nexport const signupForm = form(signupSchema, async (data) => {\n const { locals, cookies, url } = getRequestEvent();\n\n let user: { email: string };\n\n try {\n user = await locals.admin.collection(\"users\").create({\n email: data.email,\n password: data.password,\n passwordConfirm: data.passwordConfirm,\n });\n } catch (err: any) {\n const response = err?.response ?? {};\n const fieldError = response?.data\n ? Object.values(response.data)[0]\n : undefined;\n const message: string =\n (fieldError as any)?.message ??\n response?.message ??\n \"Failed to create account.\";\n return { message };\n }\n\n await locals.pb.collection(\"users\").requestVerification(user.email);\n await locals.pb\n .collection(\"users\")\n .authWithPassword(data.email, data.password);\n\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n setFlash(\n { type: \"toast\", message: \"We sent a confirmation link to your email.\" },\n cookies,\n );\n redirect(303, redirectUrl);\n});\n", bs = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /signup\", () => {\n it(\"should render the signup page\", async (context) => {\n const response = await context.request.get(\n \"/signup\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", xs = /* #__PURE__ */ Object.assign({
|
|
4176
4184
|
"./creates/src/lib/components/app-sidebar.svelte": bo,
|
|
4177
4185
|
"./creates/src/lib/components/nav-main.svelte": xo,
|
|
4178
4186
|
"./creates/src/lib/components/nav-user.svelte": So,
|
|
@@ -4260,7 +4268,7 @@ async function Cs(e) {
|
|
|
4260
4268
|
modifies: [],
|
|
4261
4269
|
deletes: [],
|
|
4262
4270
|
components: r,
|
|
4263
|
-
packages: [],
|
|
4271
|
+
packages: ["sveltekit-flash-message@^2.4.6", "zod@^4.1.11"],
|
|
4264
4272
|
collections: [{
|
|
4265
4273
|
listRule: "@request.auth.id = user.id",
|
|
4266
4274
|
viewRule: "@request.auth.id = user.id",
|
|
@@ -4359,8 +4367,11 @@ async function js(e) {
|
|
|
4359
4367
|
let n = await Es(e);
|
|
4360
4368
|
return m(i([t, n]), e);
|
|
4361
4369
|
}
|
|
4362
|
-
let {
|
|
4363
|
-
return
|
|
4370
|
+
let { createCollections: n } = await import("./chunks/collections-B3lAtPlQ.js"), r = await n(t.collections, e), { generate: a } = await import("./chunks/generate.runtime-C-Val7lP.js"), o = await a(e), { writeResult: s } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
4371
|
+
return s(await m(i([{
|
|
4372
|
+
...t,
|
|
4373
|
+
creates: [...t.creates, ...r]
|
|
4374
|
+
}, o]), e), e);
|
|
4364
4375
|
}
|
|
4365
4376
|
var Ms = {
|
|
4366
4377
|
version: Os,
|
|
@@ -4454,7 +4465,7 @@ async function Ws(e) {
|
|
|
4454
4465
|
let n = await zs(e);
|
|
4455
4466
|
return m(i([t, n]), e);
|
|
4456
4467
|
}
|
|
4457
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
4468
|
+
let { generate: n } = await import("./chunks/generate.runtime-SQhCLSah.js"), r = await n(e), { writeResult: a } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
4458
4469
|
return a(await m(i([t, r]), e), e);
|
|
4459
4470
|
}
|
|
4460
4471
|
var Gs = {
|
|
@@ -4609,7 +4620,7 @@ async function mc(e) {
|
|
|
4609
4620
|
let n = await lc(e);
|
|
4610
4621
|
return m(i([t, n]), e);
|
|
4611
4622
|
}
|
|
4612
|
-
let { createCollections: n } = await import("./chunks/collections-
|
|
4623
|
+
let { createCollections: n } = await import("./chunks/collections-B3lAtPlQ.js"), r = await n(t.collections, e), { generate: a } = await import("./chunks/generate.runtime-B9gdCz4t.js"), o = await a(e), { writeResult: s } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
4613
4624
|
return s(await m(i([{
|
|
4614
4625
|
...t,
|
|
4615
4626
|
creates: [...t.creates, ...r]
|
|
@@ -4677,7 +4688,10 @@ async function Sc(e) {
|
|
|
4677
4688
|
"@velastack/pocketbase",
|
|
4678
4689
|
"@velastack/kit",
|
|
4679
4690
|
"pocketbase-sveltekit",
|
|
4680
|
-
"@sveltejs/adapter-node"
|
|
4691
|
+
"@sveltejs/adapter-node",
|
|
4692
|
+
"vitest@^4.1.11",
|
|
4693
|
+
"supertest@^7.2.2",
|
|
4694
|
+
"@types/supertest@^6.0.3"
|
|
4681
4695
|
],
|
|
4682
4696
|
collections: [],
|
|
4683
4697
|
collectionPatches: [],
|
|
@@ -4719,7 +4733,7 @@ async function Ac(e) {
|
|
|
4719
4733
|
let n = await Tc(e);
|
|
4720
4734
|
return m(i([t, n]), e);
|
|
4721
4735
|
}
|
|
4722
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
4736
|
+
let { generate: n } = await import("./chunks/generate.runtime-DaPNrIyg.js"), r = await n(e), { writeResult: a } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
4723
4737
|
return a(await m(i([t, r]), e), e);
|
|
4724
4738
|
}
|
|
4725
4739
|
var jc = {
|
|
@@ -4758,7 +4772,7 @@ var jc = {
|
|
|
4758
4772
|
tests: 0,
|
|
4759
4773
|
baseline: "velastack",
|
|
4760
4774
|
generate: Ac
|
|
4761
|
-
}, Mc = "pre[class*='language-'],\ncode[class*='language-'] {\n color: #d4d4d4;\n font-size: 13px;\n text-shadow: none;\n font-family: Menlo, Monaco, Consolas, 'Andale Mono', 'Ubuntu Mono', 'Courier New', monospace;\n direction: ltr;\n text-align: left;\n white-space: pre;\n word-spacing: normal;\n word-break: normal;\n line-height: 1.5;\n -moz-tab-size: 4;\n -o-tab-size: 4;\n tab-size: 4;\n -webkit-hyphens: none;\n -moz-hyphens: none;\n -ms-hyphens: none;\n hyphens: none;\n}\n\npre[class*='language-']::selection,\ncode[class*='language-']::selection,\npre[class*='language-'] *::selection,\ncode[class*='language-'] *::selection {\n text-shadow: none;\n background: #264f78;\n}\n\n@media print {\n pre[class*='language-'],\n code[class*='language-'] {\n text-shadow: none;\n }\n}\n\npre[class*='language-'] {\n padding: 1em;\n margin: 0.5em 0;\n overflow: auto;\n background: oklch(0.21 0.034 264.665);\n}\n\n:not(pre) > code[class*='language-'] {\n padding: 0.1em 0.3em;\n border-radius: 0.3em;\n color: #db4c69;\n background: oklch(0.21 0.034 264.665);\n}\n/*********************************************************\n* Tokens\n*/\n.namespace {\n opacity: 0.7;\n}\n\n.token.doctype .token.doctype-tag {\n color: #569cd6;\n}\n\n.token.doctype .token.name {\n color: #9cdcfe;\n}\n\n.token.comment,\n.token.prolog {\n color: #6a9955;\n}\n\n.token.punctuation,\n.language-html .language-css .token.punctuation,\n.language-html .language-javascript .token.punctuation {\n color: #d4d4d4;\n}\n\n.token.property,\n.token.tag,\n.token.boolean,\n.token.number,\n.token.constant,\n.token.symbol,\n.token.inserted,\n.token.unit {\n color: #b5cea8;\n}\n\n.token.selector,\n.token.attr-name,\n.token.string,\n.token.char,\n.token.builtin,\n.token.deleted {\n color: #ce9178;\n}\n\n.language-css .token.string.url {\n text-decoration: underline;\n}\n\n.token.operator,\n.token.entity {\n color: #d4d4d4;\n}\n\n.token.operator.arrow {\n color: #569cd6;\n}\n\n.token.atrule {\n color: #ce9178;\n}\n\n.token.atrule .token.rule {\n color: #c586c0;\n}\n\n.token.atrule .token.url {\n color: #9cdcfe;\n}\n\n.token.atrule .token.url .token.function {\n color: #dcdcaa;\n}\n\n.token.atrule .token.url .token.punctuation {\n color: #d4d4d4;\n}\n\n.token.keyword {\n color: #569cd6;\n}\n\n.token.keyword.module,\n.token.keyword.control-flow {\n color: #c586c0;\n}\n\n.token.function,\n.token.function .token.maybe-class-name {\n color: #dcdcaa;\n}\n\n.token.regex {\n color: #d16969;\n}\n\n.token.important {\n color: #569cd6;\n}\n\n.token.italic {\n font-style: italic;\n}\n\n.token.constant {\n color: #9cdcfe;\n}\n\n.token.class-name,\n.token.maybe-class-name {\n color: #4ec9b0;\n}\n\n.token.console {\n color: #9cdcfe;\n}\n\n.token.parameter {\n color: #9cdcfe;\n}\n\n.token.interpolation {\n color: #9cdcfe;\n}\n\n.token.punctuation.interpolation-punctuation {\n color: #569cd6;\n}\n\n.token.boolean {\n color: #569cd6;\n}\n\n.token.property,\n.token.variable,\n.token.imports .token.maybe-class-name,\n.token.exports .token.maybe-class-name {\n color: #9cdcfe;\n}\n\n.token.selector {\n color: #d7ba7d;\n}\n\n.token.escape {\n color: #d7ba7d;\n}\n\n.token.tag {\n color: #569cd6;\n}\n\n.token.tag .token.punctuation {\n color: #808080;\n}\n\n.token.cdata {\n color: #808080;\n}\n\n.token.attr-name {\n color: #9cdcfe;\n}\n\n.token.attr-value,\n.token.attr-value .token.punctuation {\n color: #ce9178;\n}\n\n.token.attr-value .token.punctuation.attr-equals {\n color: #d4d4d4;\n}\n\n.token.entity {\n color: #569cd6;\n}\n\n.token.namespace {\n color: #4ec9b0;\n}\n/*********************************************************\n* Language Specific\n*/\n\npre[class*='language-javascript'],\ncode[class*='language-javascript'],\npre[class*='language-jsx'],\ncode[class*='language-jsx'],\npre[class*='language-typescript'],\ncode[class*='language-typescript'],\npre[class*='language-tsx'],\ncode[class*='language-tsx'] {\n color: #9cdcfe;\n}\n\npre[class*='language-css'],\ncode[class*='language-css'] {\n color: #ce9178;\n}\n\npre[class*='language-html'],\ncode[class*='language-html'] {\n color: #d4d4d4;\n}\n\n.language-regex .token.anchor {\n color: #dcdcaa;\n}\n\n.language-html .token.punctuation {\n color: #808080;\n}\n/*********************************************************\n* Line highlighting\n*/\npre[class*='language-'] > code[class*='language-'] {\n position: relative;\n z-index: 1;\n}\n\n.line-highlight.line-highlight {\n background: #f7ebc6;\n box-shadow: inset 5px 0 0 #f7d87c;\n z-index: 0;\n}\n", Nc = "<script lang=\"ts\">\n import * as Avatar from '$lib/components/ui/avatar';\n import type { BlogAuthor } from '$lib/content';\n\n let {\n author,\n size = 'sm'\n }: { author: BlogAuthor; size?: 'sm' | 'default' | 'lg' } = $props();\n\n const initials = $derived(\n author.name\n .split(/\\s+/)\n .map((part) => part[0])\n .filter(Boolean)\n .slice(0, 2)\n .join('')\n .toUpperCase()\n );\n<\/script>\n\n<span class=\"inline-flex items-center gap-2\">\n <Avatar.Root {size}>\n {#if author.avatar}\n <Avatar.Image src={author.avatar} alt={author.name} />\n {/if}\n <Avatar.Fallback class=\"text-xs\">{initials}</Avatar.Fallback>\n </Avatar.Root>\n <span class=\"text-foreground text-sm font-medium\">{author.name}</span>\n</span>\n", Pc = "<script lang=\"ts\">\n import * as Card from \"$lib/components/ui/card\";\n import { Badge } from \"$lib/components/ui/badge\";\n import AuthorChip from \"./AuthorChip.svelte\";\n import { formatDate } from \"$lib/utils/date\";\n import type { BlogPost, BlogPostSummary } from \"$lib/content\";\n\n let { post }: { post: BlogPost | BlogPostSummary } = $props();\n<\/script>\n\n<Card.Root class=\"hover:ring-foreground/20 h-full transition-shadow w-full\">\n <Card.Header>\n <Card.Title class=\"text-lg leading-snug\">\n <a href={`/blog/${post.slug}`} class=\"hover:underline\">\n {post.title}\n </a>\n </Card.Title>\n <Card.Description class=\"line-clamp-2\">\n {post.description}\n </Card.Description>\n </Card.Header>\n <Card.Content class=\"flex flex-1 flex-col justify-end gap-3\">\n {#if post.tags?.length}\n <div class=\"flex flex-wrap gap-1.5\">\n {#each post.tags as tag (tag)}\n <Badge href={`/blog/tags/${tag}`} variant=\"secondary\">{tag}</Badge>\n {/each}\n </div>\n {/if}\n <div\n class=\"text-muted-foreground flex items-center justify-between gap-3 text-xs\"\n >\n {#if post.author}\n <AuthorChip author={post.author} />\n {:else}\n <span></span>\n {/if}\n <span class=\"whitespace-nowrap\">\n <time datetime={post.createdDate.toISOString()}\n >{formatDate(post.createdDate)}</time\n >\n <span aria-hidden=\"true\">•</span>\n <span>{post.readingTime} min read</span>\n </span>\n </div>\n </Card.Content>\n</Card.Root>\n", Fc = "---\ntitle: Design System Notes\ndescription: Small choices that make a design system feel coherent — spacing, radius, and the case for fewer variants.\ncreatedDate: 2025-12-15\ntags:\n - design\n - shadcn\nauthor:\n name: Ada Chen\n---\n\nWe've been cleaning up the design system recently. A few notes from the\npass, mostly for ourselves, partially in case they're useful to anyone\nelse building on top of shadcn.\n\n## The variants we actually use\n\nEvery primitive ships with a dozen variants. In practice our product\nleans on two or three per component:\n\n- **Buttons** — `default`, `ghost`, and `outline`. Destructive shows up\n rarely enough to be worth the extra click.\n- **Badges** — `default` and `secondary`. Tags and counts, nothing else.\n- **Cards** — one shape, with optional footer. Multiple card styles\n became indistinguishable from \"padded div,\" so we stopped.\n\nIf a variant hasn't appeared in a design in six months, it gets deleted.\nThe point isn't minimalism; it's that every extra variant is a decision\na future designer has to relitigate.\n\n## Spacing\n\nTailwind's default scale is good. We only locked in one rule: never use\nodd gaps. `gap-3` and `gap-5` stay; `gap-2.5` goes. It's a small thing\nthat quietly keeps vertical rhythm predictable across pages.\n\n## Radius\n\nOne radius token, applied everywhere. If a surface needs to feel\ndifferent, that's a structural decision — a card, a sheet, a popover —\nnot a one-off `rounded-md`. We ended up at `0.625rem` as our default\nand haven't wanted to change it.\n\n## Dark mode\n\nWe treat dark mode as a different palette, not a filter. Every token\nhas an explicit OKLCH value in both themes. When a component looks\noff in dark mode, the fix is almost always a token, not a tweak.\n", Ic = "---\ntitle: Getting Started with SvelteKit\ndescription: The smallest useful SvelteKit project, explained end to end — routing, loading data, and the dev loop.\ncreatedDate: 2026-03-12\ntags:\n - sveltekit\n - tutorial\nauthor:\n name: Marco Alvarez\n---\n\nSvelteKit is the piece that turns Svelte — a component library — into\nsomething you can ship. Routing, server endpoints, data loading, builds,\nand deployment adapters all live in one place.\n\n## Creating a project\n\nThe fastest path is the CLI. It scaffolds a minimal project, installs\ndependencies, and leaves you with a working dev server.\n\n```bash\nnpx sv create my-app\ncd my-app\nnpm install\nnpm run dev\n```\n\n## Routes are files\n\nA route is a folder under `src/routes` with a `+page.svelte` inside.\nNested folders produce nested URLs. Dynamic segments use `[brackets]`.\n\n```\nsrc/routes/\n +page.svelte # /\n about/\n +page.svelte # /about\n blog/\n [slug]/\n +page.svelte # /blog/:slug\n```\n\n## Loading data\n\nA route's `+page.ts` (or `+page.server.ts` for server-only data) exports\na `load` function. Whatever it returns becomes `data` on the page.\n\n```ts\n// src/routes/blog/[slug]/+page.ts\nimport { error } from '@sveltejs/kit';\n\nexport const load = async ({ params }) => {\n const post = await fetchPost(params.slug);\n if (!post) throw error(404, 'Not found');\n return { post };\n};\n```\n\nThat's most of SvelteKit. The rest — form actions, hooks, adapters — are\nopt-in once you need them.\n", Lc = "---\ntitle: A Pragmatic Performance Checklist\ndescription: The small set of things that have given us the biggest performance wins — in rough order of impact.\ncreatedDate: 2025-11-03\ntags:\n - performance\n - tutorial\nauthor:\n name: Marco Alvarez\n---\n\nWe don't have a performance budget so much as a performance allergy.\nWhen something feels slow, we profile, fix the obvious thing, and move\non. The list below is what \"the obvious thing\" usually is.\n\n> Premature optimization is the root of all evil, but ignoring a 3s\n> cold-start isn't optimization — it's negligence.\n\n## The checklist\n\n1. **Measure with real numbers.** Lighthouse and the Network tab answer\n most questions. If you're not measuring, you're guessing.\n2. **Serve fewer bytes.** Compress images (AVIF or WebP), remove unused\n fonts, and audit any dependency over 50KB gzipped.\n3. **Defer the non-critical.** Scripts that aren't needed above the\n fold can wait. `loading=\"lazy\"` on images, `defer` on scripts, and\n dynamic `import()` for interactive widgets.\n4. **Cache at the edge.** If the same HTML could serve a thousand users,\n it should. Use your adapter's cache headers; don't hand-roll it.\n5. **Avoid waterfalls.** If page load depends on three sequential fetches,\n collapse them into one endpoint or preload the critical ones.\n6. **Trust the framework.** SvelteKit's `load` functions run in parallel\n by default and the compiler already strips unused code. Most hand-rolled\n cleverness just gets in the way.\n\n## What we stopped worrying about\n\n- Micro-optimizations inside component code — the bundle is small, the\n diff is fast. The savings are real but rarely matter.\n- Third-party tooling that promises \"speed.\" If it adds a build step,\n the benefit needs to be measurable, not theoretical.\n\n## When to go deeper\n\nIf the checklist doesn't move the needle, the next step is almost\nalways a deeper look at the data layer — query plans, N+1 fetches, cold\ncache behavior. But you should have exhausted the list above before\ngetting there. Most slowness is boring, and most fixes are too.\n", Rc = "---\ntitle: Welcome to the Blog\ndescription: A quick note on what this space is for and what to expect from us.\ncreatedDate: 2026-04-20\ntags:\n - announcements\nauthor:\n name: Ada Chen\n---\n\nWelcome in. This blog is where we write about the things we build, the\ndecisions behind them, and what we learn when they go sideways.\n\nYou can expect a mix of short notes and longer walkthroughs. No schedule,\nno filler. If a post exists it's because something was worth writing down.\n\nA few threads you'll see pop up often:\n\n- Product notes on what we're shipping and why\n- Practical tutorials for the tools we use every day\n- Design and engineering decisions that took more than five minutes\n\nIf you'd rather not check back manually, the [RSS feed](/blog/rss.xml)\nhas every post. Thanks for reading.\n", zc = "---\ntitle: Why We Chose Tailwind v4\ndescription: Notes on moving from a traditional CSS pipeline to Tailwind v4's zero-config, CSS-first setup.\ncreatedDate: 2026-02-18\ntags:\n - tailwind\n - design\nauthor:\n name: Ada Chen\n---\n\nTailwind v4 is a meaningful rewrite. The surface API still looks the same\n— utility classes on elements — but the compiler, configuration model,\nand theming story all changed in ways that made us want to adopt it.\n\n> The point of a design system isn't to ship fewer classes. It's to make\n> the next decision easier than the last.\n\n## What changed for us\n\nThree things mattered:\n\n1. **CSS-first config.** `tailwind.config.js` is gone. Tokens live in\n `app.css` as real CSS custom properties, which means they also work\n outside of Tailwind — SVG fills, inline styles, wherever.\n2. **OKLCH colors.** Designers can reason about lightness and chroma\n independently. Contrast checks become much easier to eyeball.\n3. **Speed.** The new engine compiles fast enough that we stopped\n thinking about purge lists. Dev feedback is effectively instant.\n\n## The config we kept\n\nWe pinned two things in `app.css`:\n\n```css\n@import 'tailwindcss';\n@plugin '@tailwindcss/typography';\n\n:root {\n --radius: 0.625rem;\n --background: oklch(1 0 0);\n --foreground: oklch(0.129 0.042 264.695);\n}\n```\n\nEverything else — spacing, typography, breakpoints — falls back to\ndefaults until we have a reason to override it.\n\n## What we'd tell a team evaluating it\n\nIf you're already using Tailwind v3, the migration is mostly a config\nmove. If you're starting from scratch, v4 removes a pile of decisions\nyou'd otherwise be making on day one. That alone made it worth it.\n", Bc = "---\ntitle: Writing Posts with MDsveX\ndescription: How this blog turns markdown files into real Svelte components — frontmatter, code, and embedded UI.\ncreatedDate: 2026-01-28\nupdatedDate: 2026-02-02\ntags:\n - mdsvex\n - tutorial\nauthor:\n name: Priya Shah\n---\n\nPosts on this blog are `.svx` files. Each one is a real Svelte component\nat build time, so Markdown and Svelte sit side by side with no glue\ncode.\n\n## Frontmatter\n\nYAML at the top of a post becomes the `metadata` export. The loader\nreads it to build the list view, tag pages, and RSS feed.\n\n```yaml\n---\ntitle: Writing Posts with MDsveX\ndescription: A short description shown in previews.\ncreatedDate: 2026-01-28\ntags:\n - mdsvex\n - tutorial\nauthor:\n name: Priya Shah\n---\n```\n\n## Markdown works the way you'd expect\n\nHeadings, lists, links, blockquotes, and inline `code` all render.\nFenced code blocks pick up language hints for syntax highlighting when a\nplugin is enabled.\n\n```ts\nfunction greet(name: string) {\n return `hello, ${name}`;\n}\n```\n\n## Images\n\nPut images in `static/` and reference them with a root-relative path:\n\n```md\n\n```\n\n## Svelte in your posts\n\nThe superpower is that you can drop components straight into a post —\na chart, an interactive demo, a call-to-action card. The rules are the\nsame as any other Svelte file:\n\n```svelte\n<script>\n import Callout from '$lib/components/Callout.svelte';\n<\/script>\n\n<Callout>This is a real component inside a markdown post.</Callout>\n```\n\nThat's the whole pipeline. Write markdown, sprinkle in components when\nplain text stops being enough, and the rest is just Svelte.\n", Vc = "import type { Component } from \"svelte\";\n\nexport type BlogAuthor = {\n name: string;\n avatar?: string;\n};\n\nexport type BlogMetadata = {\n title: string;\n description: string;\n createdDate: string;\n updatedDate?: string;\n tags?: string[];\n author?: BlogAuthor;\n};\n\nexport type BlogModules = Record<\n string,\n { default: Component; metadata: BlogMetadata }\n>;\n\nexport type BlogRawModules = Record<string, string>;\n\nexport type BlogPost = {\n slug: string;\n title: string;\n description: string;\n createdDate: Date;\n updatedDate?: Date;\n tags?: string[];\n author?: BlogAuthor;\n readingTime: number;\n component: Component;\n};\n\nexport type BlogPostSummary = Omit<BlogPost, \"component\">;\n\nconst WORDS_PER_MINUTE = 220;\n\nfunction getBlogModules() {\n return import.meta.glob(\"$lib/content/blog/*.svx\", {\n eager: true,\n }) as BlogModules;\n}\n\nfunction getBlogRawModules() {\n return import.meta.glob(\"$lib/content/blog/*.svx\", {\n eager: true,\n query: \"?raw\",\n import: \"default\",\n }) as BlogRawModules;\n}\n\nfunction stripFrontmatter(raw: string) {\n if (!raw.startsWith(\"---\")) return raw;\n const end = raw.indexOf(\"\\n---\", 3);\n if (end === -1) return raw;\n return raw.slice(end + 4);\n}\n\nfunction computeReadingTime(raw: string) {\n const body = stripFrontmatter(raw);\n const words = body.split(/\\s+/).filter(Boolean).length;\n return Math.max(1, Math.ceil(words / WORDS_PER_MINUTE));\n}\n\nexport function getBlogPosts(): BlogPost[] {\n const modules = getBlogModules();\n const rawModules = getBlogRawModules();\n\n const posts = Object.entries(modules).map(([path, module]) => {\n const filename = path.split(\"/\").pop() ?? \"\";\n const slug = filename.replace(\".svx\", \"\");\n const raw = rawModules[path] ?? \"\";\n\n return {\n slug,\n title: module.metadata.title,\n description: module.metadata.description,\n createdDate: new Date(module.metadata.createdDate),\n updatedDate: module.metadata.updatedDate\n ? new Date(module.metadata.updatedDate)\n : undefined,\n tags: module.metadata.tags,\n author: module.metadata.author,\n readingTime: computeReadingTime(raw),\n component: module.default,\n };\n });\n\n posts.sort((a, b) => b.createdDate.getTime() - a.createdDate.getTime());\n return posts;\n}\n\nexport function getBlogPost(slug: string) {\n const posts = getBlogPosts();\n return posts.find((post) => post.slug === slug) ?? null;\n}\n\nexport function getBlogPostRaw(slug: string): string | null {\n const rawModules = getBlogRawModules();\n for (const [path, raw] of Object.entries(rawModules)) {\n const filename = path.split(\"/\").pop() ?? \"\";\n if (filename.replace(\".svx\", \"\") === slug) return raw;\n }\n return null;\n}\n\nexport function getBlogPostsByTag(tag: string) {\n return getBlogPosts().filter((post) => post.tags?.includes(tag));\n}\n\nexport function getAllTags(): { tag: string; count: number }[] {\n const counts = new Map<string, number>();\n for (const post of getBlogPosts()) {\n for (const tag of post.tags ?? []) {\n counts.set(tag, (counts.get(tag) ?? 0) + 1);\n }\n }\n return [...counts.entries()]\n .map(([tag, count]) => ({ tag, count }))\n .sort((a, b) => b.count - a.count || a.tag.localeCompare(b.tag));\n}\n\nexport function getAdjacentPosts(slug: string): {\n prev: BlogPost | null;\n next: BlogPost | null;\n} {\n const posts = getBlogPosts();\n const index = posts.findIndex((post) => post.slug === slug);\n if (index === -1) return { prev: null, next: null };\n return {\n next: index > 0 ? posts[index - 1] : null,\n prev: index < posts.length - 1 ? posts[index + 1] : null,\n };\n}\n\nexport function getRelatedPosts(slug: string, limit = 3): BlogPost[] {\n const posts = getBlogPosts();\n const current = posts.find((post) => post.slug === slug);\n if (!current?.tags?.length) return [];\n\n const currentTags = new Set(current.tags);\n\n return posts\n .filter((post) => post.slug !== slug && post.tags?.length)\n .map((post) => ({\n post,\n overlap: post.tags!.filter((tag) => currentTags.has(tag)).length,\n }))\n .filter(({ overlap }) => overlap > 0)\n .sort(\n (a, b) =>\n b.overlap - a.overlap ||\n b.post.createdDate.getTime() - a.post.createdDate.getTime(),\n )\n .slice(0, limit)\n .map(({ post }) => post);\n}\n", Hc = "const formatter = new Intl.DateTimeFormat(\"en-US\", {\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n});\n\nexport function formatDate(date: Date) {\n return formatter.format(date);\n}\n", Uc = "<script lang=\"ts\">\n import * as Breadcrumb from \"$lib/components/ui/breadcrumb\";\n import { page } from \"$app/state\";\n\n let { children } = $props();\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as {\n title: string;\n url: string;\n }[];\n<\/script>\n\n<section data-role=\"content\">\n <Breadcrumb.Root class=\"mb-6\">\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}\n >{breadcrumb.title}</Breadcrumb.Link\n >\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n\n {@render children?.()}\n</section>\n", Wc = "<script lang=\"ts\">\n import { Badge } from \"$lib/components/ui/badge\";\n import { Button } from \"$lib/components/ui/button\";\n import PostCard from \"$lib/components/blog/PostCard.svelte\";\n import Rss from \"@lucide/svelte/icons/rss\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-10\">\n <header\n class=\"flex flex-col gap-4 md:flex-row md:items-end md:justify-between\"\n >\n <div class=\"max-w-2xl\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">Blog</h1>\n <p class=\"text-muted-foreground mt-2 text-base\">\n Product notes, tutorials, and engineering posts from the team.\n </p>\n </div>\n <Button href=\"/blog/rss.xml\" variant=\"outline\" size=\"sm\" class=\"w-fit\">\n <Rss class=\"size-4\" />\n RSS\n </Button>\n </header>\n\n <ul class=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.blogPosts as post (post.slug)}\n <li class=\"flex w-full\">\n <PostCard {post} />\n </li>\n {/each}\n </ul>\n</div>\n", Gc = "import { definePageMetaTags } from \"svelte-meta-tags\";\nimport { getAllTags, getBlogPosts } from \"$lib/content\";\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const blogPosts = getBlogPosts();\n const allTags = getAllTags();\n\n const pageMetaTags = definePageMetaTags({\n title: \"Blog\",\n description: \"Product notes, tutorials, and engineering posts.\",\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n ];\n\n return { blogPosts, allTags, breadcrumbs, ...pageMetaTags };\n};\n", Kc = "<script lang=\"ts\">\n import { Badge } from \"$lib/components/ui/badge\";\n import { Separator } from \"$lib/components/ui/separator\";\n import AuthorChip from \"$lib/components/blog/AuthorChip.svelte\";\n import PostCard from \"$lib/components/blog/PostCard.svelte\";\n import { formatDate } from \"$lib/utils/date\";\n import * as Breadcrumb from \"$lib/components/ui/breadcrumb\";\n import ArrowLeft from \"@lucide/svelte/icons/arrow-left\";\n import ArrowRight from \"@lucide/svelte/icons/arrow-right\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as {\n title: string;\n url: string;\n }[];\n<\/script>\n\n<div class=\"flex flex-col gap-6\">\n <header class=\"flex flex-col gap-5 border-b border-border pb-8\">\n <div class=\"flex flex-col gap-3\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">\n {data.blogPost.title}\n </h1>\n <p class=\"text-muted-foreground text-lg\">\n {data.blogPost.description}\n </p>\n </div>\n\n <div\n class=\"text-muted-foreground flex flex-wrap items-center gap-x-1 gap-y-2 text-sm\"\n >\n {#if data.blogPost.author}\n <AuthorChip author={data.blogPost.author} />\n <span aria-hidden=\"true\" class=\"text-muted-foreground/50\">•</span>\n {/if}\n <time datetime={data.blogPost.createdDate.toISOString()}>\n {formatDate(data.blogPost.createdDate)}\n </time>\n {#if data.blogPost.updatedDate}\n <span aria-hidden=\"true\" class=\"text-muted-foreground/50\">•</span>\n <span>Updated {formatDate(data.blogPost.updatedDate)}</span>\n {/if}\n <span aria-hidden=\"true\" class=\"text-muted-foreground/50\">•</span>\n <span>{data.blogPost.readingTime} min read</span>\n </div>\n\n {#if data.blogPost.tags?.length}\n <div class=\"flex flex-wrap gap-1.5\">\n {#each data.blogPost.tags as tag (tag)}\n <Badge href={`/blog/tags/${tag}`} variant=\"secondary\">{tag}</Badge>\n {/each}\n </div>\n {/if}\n </header>\n\n <article\n class=\"prose dark:prose-invert max-w-prose prose-headings:mb-0 prose-headings:mt-4\"\n >\n <data.blogPost.component />\n </article>\n\n <Separator />\n\n <nav class=\"grid gap-3 sm:grid-cols-2\" aria-label=\"Post navigation\">\n {#if data.adjacent.prev}\n <a\n href={`/blog/${data.adjacent.prev.slug}`}\n class=\"ring-foreground/10 hover:ring-foreground/20 bg-card text-card-foreground group flex flex-col gap-1 rounded-xl p-4 ring-1 transition-shadow\"\n >\n <span\n class=\"text-muted-foreground inline-flex items-center gap-1 text-xs font-medium uppercase tracking-wide\"\n >\n <ArrowLeft class=\"size-3.5\" />\n Previous\n </span>\n <span class=\"font-medium group-hover:underline\"\n >{data.adjacent.prev.title}</span\n >\n </a>\n {:else}\n <div></div>\n {/if}\n\n {#if data.adjacent.next}\n <a\n href={`/blog/${data.adjacent.next.slug}`}\n class=\"ring-foreground/10 hover:ring-foreground/20 bg-card text-card-foreground group flex flex-col gap-1 rounded-xl p-4 text-right ring-1 transition-shadow sm:col-start-2\"\n >\n <span\n class=\"text-muted-foreground inline-flex items-center justify-end gap-1 text-xs font-medium uppercase tracking-wide\"\n >\n Next\n <ArrowRight class=\"size-3.5\" />\n </span>\n <span class=\"font-medium group-hover:underline\"\n >{data.adjacent.next.title}</span\n >\n </a>\n {/if}\n </nav>\n\n {#if data.related.length}\n <section class=\"flex flex-col gap-4\">\n <Separator />\n <h2 class=\"text-xl font-semibold tracking-tight\">Related posts</h2>\n <ul class=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.related as post (post.slug)}\n <li class=\"flex\">\n <PostCard {post} />\n </li>\n {/each}\n </ul>\n </section>\n {/if}\n</div>\n", qc = "import { error } from \"@sveltejs/kit\";\nimport { definePageMetaTags } from \"svelte-meta-tags\";\nimport {\n getAdjacentPosts,\n getBlogPost,\n getBlogPosts,\n getRelatedPosts,\n} from \"$lib/content\";\n\nexport const load = async ({ params, parent }) => {\n await parent();\n\n const blogPost = getBlogPost(params.slug);\n\n if (blogPost === null) {\n throw error(404, \"Page not found\");\n }\n\n const adjacent = getAdjacentPosts(params.slug);\n const related = getRelatedPosts(params.slug);\n\n const pageMetaTags = definePageMetaTags({\n title: blogPost.title,\n description: blogPost.description,\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n { title: blogPost.title, url: `/blog/${blogPost.slug}` },\n ];\n\n return { blogPost, adjacent, related, breadcrumbs, ...pageMetaTags };\n};\n\nexport const entries = async () => {\n return getBlogPosts().map((post) => ({ slug: post.slug }));\n};\n", Jc = "import { getBlogPosts } from \"$lib/content\";\n\nexport const prerender = true;\n\nfunction escapeXml(value: string) {\n return value\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\nexport const GET = async ({ locals, url }) => {\n const { appName } = locals.meta;\n const posts = getBlogPosts();\n // `url.origin`, not `locals.meta.appURL`: this feed is prerendered, and the\n // origin comes from the build's own configuration rather than from whichever\n // database the build could reach. Every `<link>` and `<guid>` below is\n // permanent once published, so pointing them at a developer's localhost is\n // not something a later deploy can take back.\n const siteURL = url.origin.replace(/\\/$/, \"\");\n const feedURL = `${siteURL}/blog/rss.xml`;\n const lastBuild = (\n posts[0]?.updatedDate ??\n posts[0]?.createdDate ??\n new Date()\n ).toUTCString();\n\n const items = posts\n .map((post) => {\n const link = `${siteURL}/blog/${post.slug}`;\n const pubDate = post.createdDate.toUTCString();\n const categories = (post.tags ?? [])\n .map((tag) => ` <category>${escapeXml(tag)}</category>`)\n .join(\"\\n\");\n const creator = post.author\n ? ` <dc:creator>${escapeXml(post.author.name)}</dc:creator>`\n : \"\";\n\n return [\n \" <item>\",\n ` <title>${escapeXml(post.title)}</title>`,\n ` <link>${escapeXml(link)}</link>`,\n ` <guid isPermaLink=\"true\">${escapeXml(link)}</guid>`,\n ` <description>${escapeXml(post.description)}</description>`,\n ` <pubDate>${pubDate}</pubDate>`,\n creator,\n categories,\n \" </item>\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n })\n .join(\"\\n\");\n\n const xml = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n<channel>\n <title>${escapeXml(appName)}</title>\n <link>${escapeXml(`${siteURL}/blog`)}</link>\n <atom:link href=\"${escapeXml(feedURL)}\" rel=\"self\" type=\"application/rss+xml\" />\n <description>${escapeXml(`Latest posts from ${appName}.`)}</description>\n <language>en</language>\n <lastBuildDate>${lastBuild}</lastBuildDate>\n${items}\n</channel>\n</rss>\n`;\n\n return new Response(xml, {\n headers: {\n \"Content-Type\": \"application/xml; charset=utf-8\",\n \"Cache-Control\": \"max-age=0, s-maxage=3600\",\n },\n });\n};\n", Yc = "<script lang=\"ts\">\n import { Badge } from \"$lib/components/ui/badge\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-8\">\n <header class=\"flex flex-col gap-2\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">Tags</h1>\n <p class=\"text-muted-foreground text-base\">\n {data.allTags.length}\n {data.allTags.length === 1 ? \"tag\" : \"tags\"} used across the blog.\n </p>\n </header>\n\n {#if data.allTags.length}\n <ul class=\"flex flex-wrap gap-2\">\n {#each data.allTags as { tag, count } (tag)}\n <li>\n <Badge href={`/blog/tags/${tag}`} variant=\"secondary\">\n {tag}\n <span class=\"text-muted-foreground ml-0.5\">{count}</span>\n </Badge>\n </li>\n {/each}\n </ul>\n {:else}\n <p class=\"text-muted-foreground\">No tags yet.</p>\n {/if}\n</div>\n", Xc = "import { definePageMetaTags } from \"svelte-meta-tags\";\nimport { getAllTags } from \"$lib/content\";\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const allTags = getAllTags();\n\n const pageMetaTags = definePageMetaTags({\n title: \"Tags\",\n description: \"All tags used on the blog.\",\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n { title: \"Tags\", url: \"/blog/tags\" },\n ];\n\n return { allTags, breadcrumbs, ...pageMetaTags };\n};\n", Zc = "<script lang=\"ts\">\n import PostCard from \"$lib/components/blog/PostCard.svelte\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-8\">\n <header class=\"flex flex-col gap-2\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">\n {data.tag}\n </h1>\n <p class=\"text-muted-foreground text-base\">\n {data.blogPosts.length}\n {data.blogPosts.length === 1 ? \"post\" : \"posts\"} tagged \"{data.tag}\".\n </p>\n </header>\n\n <ul class=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.blogPosts as post (post.slug)}\n <li class=\"flex\">\n <PostCard {post} />\n </li>\n {/each}\n </ul>\n</div>\n", Qc = "import { error } from \"@sveltejs/kit\";\nimport { definePageMetaTags } from \"svelte-meta-tags\";\nimport { getAllTags, getBlogPostsByTag } from \"$lib/content\";\n\nexport const load = async ({ params, parent }) => {\n await parent();\n\n const blogPosts = getBlogPostsByTag(params.tag);\n\n if (blogPosts.length === 0) {\n throw error(404, \"Tag not found\");\n }\n\n const pageMetaTags = definePageMetaTags({\n title: `Posts tagged \"${params.tag}\"`,\n description: `Blog posts tagged \"${params.tag}\".`,\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n { title: \"Tags\", url: \"/blog/tags\" },\n { title: params.tag, url: `/blog/tags/${params.tag}` },\n ];\n\n return { blogPosts, tag: params.tag, breadcrumbs, ...pageMetaTags };\n};\n\nexport const entries = async () => {\n return getAllTags().map(({ tag }) => ({ tag }));\n};\n", $c = "import { negotiate } from \"$lib/negotiate\";\nimport { getBlogPostRaw } from \"$lib/content\";\n\nexport const load = async ({ params, locals }) => {\n return {\n ...negotiate(locals, {\n \"text/markdown\": () => getBlogPostRaw(params.slug) ?? \"\",\n }),\n };\n};\n", el = /* #__PURE__ */ Object.assign({
|
|
4775
|
+
}, Mc = "pre[class*='language-'],\ncode[class*='language-'] {\n color: #d4d4d4;\n font-size: 13px;\n text-shadow: none;\n font-family: Menlo, Monaco, Consolas, 'Andale Mono', 'Ubuntu Mono', 'Courier New', monospace;\n direction: ltr;\n text-align: left;\n white-space: pre;\n word-spacing: normal;\n word-break: normal;\n line-height: 1.5;\n -moz-tab-size: 4;\n -o-tab-size: 4;\n tab-size: 4;\n -webkit-hyphens: none;\n -moz-hyphens: none;\n -ms-hyphens: none;\n hyphens: none;\n}\n\npre[class*='language-']::selection,\ncode[class*='language-']::selection,\npre[class*='language-'] *::selection,\ncode[class*='language-'] *::selection {\n text-shadow: none;\n background: #264f78;\n}\n\n@media print {\n pre[class*='language-'],\n code[class*='language-'] {\n text-shadow: none;\n }\n}\n\npre[class*='language-'] {\n padding: 1em;\n margin: 0.5em 0;\n overflow: auto;\n background: oklch(0.21 0.034 264.665);\n}\n\n:not(pre) > code[class*='language-'] {\n padding: 0.1em 0.3em;\n border-radius: 0.3em;\n color: #db4c69;\n background: oklch(0.21 0.034 264.665);\n}\n/*********************************************************\n* Tokens\n*/\n.namespace {\n opacity: 0.7;\n}\n\n.token.doctype .token.doctype-tag {\n color: #569cd6;\n}\n\n.token.doctype .token.name {\n color: #9cdcfe;\n}\n\n.token.comment,\n.token.prolog {\n color: #6a9955;\n}\n\n.token.punctuation,\n.language-html .language-css .token.punctuation,\n.language-html .language-javascript .token.punctuation {\n color: #d4d4d4;\n}\n\n.token.property,\n.token.tag,\n.token.boolean,\n.token.number,\n.token.constant,\n.token.symbol,\n.token.inserted,\n.token.unit {\n color: #b5cea8;\n}\n\n.token.selector,\n.token.attr-name,\n.token.string,\n.token.char,\n.token.builtin,\n.token.deleted {\n color: #ce9178;\n}\n\n.language-css .token.string.url {\n text-decoration: underline;\n}\n\n.token.operator,\n.token.entity {\n color: #d4d4d4;\n}\n\n.token.operator.arrow {\n color: #569cd6;\n}\n\n.token.atrule {\n color: #ce9178;\n}\n\n.token.atrule .token.rule {\n color: #c586c0;\n}\n\n.token.atrule .token.url {\n color: #9cdcfe;\n}\n\n.token.atrule .token.url .token.function {\n color: #dcdcaa;\n}\n\n.token.atrule .token.url .token.punctuation {\n color: #d4d4d4;\n}\n\n.token.keyword {\n color: #569cd6;\n}\n\n.token.keyword.module,\n.token.keyword.control-flow {\n color: #c586c0;\n}\n\n.token.function,\n.token.function .token.maybe-class-name {\n color: #dcdcaa;\n}\n\n.token.regex {\n color: #d16969;\n}\n\n.token.important {\n color: #569cd6;\n}\n\n.token.italic {\n font-style: italic;\n}\n\n.token.constant {\n color: #9cdcfe;\n}\n\n.token.class-name,\n.token.maybe-class-name {\n color: #4ec9b0;\n}\n\n.token.console {\n color: #9cdcfe;\n}\n\n.token.parameter {\n color: #9cdcfe;\n}\n\n.token.interpolation {\n color: #9cdcfe;\n}\n\n.token.punctuation.interpolation-punctuation {\n color: #569cd6;\n}\n\n.token.boolean {\n color: #569cd6;\n}\n\n.token.property,\n.token.variable,\n.token.imports .token.maybe-class-name,\n.token.exports .token.maybe-class-name {\n color: #9cdcfe;\n}\n\n.token.selector {\n color: #d7ba7d;\n}\n\n.token.escape {\n color: #d7ba7d;\n}\n\n.token.tag {\n color: #569cd6;\n}\n\n.token.tag .token.punctuation {\n color: #808080;\n}\n\n.token.cdata {\n color: #808080;\n}\n\n.token.attr-name {\n color: #9cdcfe;\n}\n\n.token.attr-value,\n.token.attr-value .token.punctuation {\n color: #ce9178;\n}\n\n.token.attr-value .token.punctuation.attr-equals {\n color: #d4d4d4;\n}\n\n.token.entity {\n color: #569cd6;\n}\n\n.token.namespace {\n color: #4ec9b0;\n}\n/*********************************************************\n* Language Specific\n*/\n\npre[class*='language-javascript'],\ncode[class*='language-javascript'],\npre[class*='language-jsx'],\ncode[class*='language-jsx'],\npre[class*='language-typescript'],\ncode[class*='language-typescript'],\npre[class*='language-tsx'],\ncode[class*='language-tsx'] {\n color: #9cdcfe;\n}\n\npre[class*='language-css'],\ncode[class*='language-css'] {\n color: #ce9178;\n}\n\npre[class*='language-html'],\ncode[class*='language-html'] {\n color: #d4d4d4;\n}\n\n.language-regex .token.anchor {\n color: #dcdcaa;\n}\n\n.language-html .token.punctuation {\n color: #808080;\n}\n/*********************************************************\n* Line highlighting\n*/\npre[class*='language-'] > code[class*='language-'] {\n position: relative;\n z-index: 1;\n}\n\n.line-highlight.line-highlight {\n background: #f7ebc6;\n box-shadow: inset 5px 0 0 #f7d87c;\n z-index: 0;\n}\n", Nc = "<script lang=\"ts\">\n import * as Avatar from '$lib/components/ui/avatar';\n import type { BlogAuthor } from '$lib/content';\n\n let {\n author,\n size = 'sm'\n }: { author: BlogAuthor; size?: 'sm' | 'default' | 'lg' } = $props();\n\n const initials = $derived(\n author.name\n .split(/\\s+/)\n .map((part) => part[0])\n .filter(Boolean)\n .slice(0, 2)\n .join('')\n .toUpperCase()\n );\n<\/script>\n\n<span class=\"inline-flex items-center gap-2\">\n <Avatar.Root {size}>\n {#if author.avatar}\n <Avatar.Image src={author.avatar} alt={author.name} />\n {/if}\n <Avatar.Fallback class=\"text-xs\">{initials}</Avatar.Fallback>\n </Avatar.Root>\n <span class=\"text-foreground text-sm font-medium\">{author.name}</span>\n</span>\n", Pc = "<script lang=\"ts\">\n import * as Card from \"$lib/components/ui/card\";\n import { Badge } from \"$lib/components/ui/badge\";\n import AuthorChip from \"./AuthorChip.svelte\";\n import { formatDate } from \"$lib/utils/date\";\n import type { BlogPost, BlogPostSummary } from \"$lib/content\";\n\n let { post }: { post: BlogPost | BlogPostSummary } = $props();\n<\/script>\n\n<Card.Root class=\"hover:ring-foreground/20 h-full transition-shadow w-full\">\n <Card.Header>\n <Card.Title class=\"text-lg leading-snug\">\n <a href={`/blog/${post.slug}`} class=\"hover:underline\">\n {post.title}\n </a>\n </Card.Title>\n <Card.Description class=\"line-clamp-2\">\n {post.description}\n </Card.Description>\n </Card.Header>\n <Card.Content class=\"flex flex-1 flex-col justify-end gap-3\">\n {#if post.tags?.length}\n <div class=\"flex flex-wrap gap-1.5\">\n {#each post.tags as tag (tag)}\n <Badge href={`/blog/tags/${tag}`} variant=\"secondary\">{tag}</Badge>\n {/each}\n </div>\n {/if}\n <div\n class=\"text-muted-foreground flex items-center justify-between gap-3 text-xs\"\n >\n {#if post.author}\n <AuthorChip author={post.author} />\n {:else}\n <span></span>\n {/if}\n <span class=\"whitespace-nowrap\">\n <time datetime={post.createdDate.toISOString()}\n >{formatDate(post.createdDate)}</time\n >\n <span aria-hidden=\"true\">•</span>\n <span>{post.readingTime} min read</span>\n </span>\n </div>\n </Card.Content>\n</Card.Root>\n", Fc = "---\ntitle: Design System Notes\ndescription: Small choices that make a design system feel coherent — spacing, radius, and the case for fewer variants.\ncreatedDate: 2025-12-15\ntags:\n - design\n - shadcn\nauthor:\n name: Ada Chen\n---\n\nWe've been cleaning up the design system recently. A few notes from the\npass, mostly for ourselves, partially in case they're useful to anyone\nelse building on top of shadcn.\n\n## The variants we actually use\n\nEvery primitive ships with a dozen variants. In practice our product\nleans on two or three per component:\n\n- **Buttons** — `default`, `ghost`, and `outline`. Destructive shows up\n rarely enough to be worth the extra click.\n- **Badges** — `default` and `secondary`. Tags and counts, nothing else.\n- **Cards** — one shape, with optional footer. Multiple card styles\n became indistinguishable from \"padded div,\" so we stopped.\n\nIf a variant hasn't appeared in a design in six months, it gets deleted.\nThe point isn't minimalism; it's that every extra variant is a decision\na future designer has to relitigate.\n\n## Spacing\n\nTailwind's default scale is good. We only locked in one rule: never use\nodd gaps. `gap-3` and `gap-5` stay; `gap-2.5` goes. It's a small thing\nthat quietly keeps vertical rhythm predictable across pages.\n\n## Radius\n\nOne radius token, applied everywhere. If a surface needs to feel\ndifferent, that's a structural decision — a card, a sheet, a popover —\nnot a one-off `rounded-md`. We ended up at `0.625rem` as our default\nand haven't wanted to change it.\n\n## Dark mode\n\nWe treat dark mode as a different palette, not a filter. Every token\nhas an explicit OKLCH value in both themes. When a component looks\noff in dark mode, the fix is almost always a token, not a tweak.\n", Ic = "---\ntitle: Getting Started with SvelteKit\ndescription: The smallest useful SvelteKit project, explained end to end — routing, loading data, and the dev loop.\ncreatedDate: 2026-03-12\ntags:\n - sveltekit\n - tutorial\nauthor:\n name: Marco Alvarez\n---\n\nSvelteKit is the piece that turns Svelte — a component library — into\nsomething you can ship. Routing, server endpoints, data loading, builds,\nand deployment adapters all live in one place.\n\n## Creating a project\n\nThe fastest path is the CLI. It scaffolds a minimal project, installs\ndependencies, and leaves you with a working dev server.\n\n```bash\nnpx sv create my-app\ncd my-app\nnpm install\nnpm run dev\n```\n\n## Routes are files\n\nA route is a folder under `src/routes` with a `+page.svelte` inside.\nNested folders produce nested URLs. Dynamic segments use `[brackets]`.\n\n```\nsrc/routes/\n +page.svelte # /\n about/\n +page.svelte # /about\n blog/\n [slug]/\n +page.svelte # /blog/:slug\n```\n\n## Loading data\n\nA route's `+page.ts` (or `+page.server.ts` for server-only data) exports\na `load` function. Whatever it returns becomes `data` on the page.\n\n```ts\n// src/routes/blog/[slug]/+page.ts\nimport { error } from '@sveltejs/kit';\n\nexport const load = async ({ params }) => {\n const post = await fetchPost(params.slug);\n if (!post) throw error(404, 'Not found');\n return { post };\n};\n```\n\nThat's most of SvelteKit. The rest — form actions, hooks, adapters — are\nopt-in once you need them.\n", Lc = "---\ntitle: A Pragmatic Performance Checklist\ndescription: The small set of things that have given us the biggest performance wins — in rough order of impact.\ncreatedDate: 2025-11-03\ntags:\n - performance\n - tutorial\nauthor:\n name: Marco Alvarez\n---\n\nWe don't have a performance budget so much as a performance allergy.\nWhen something feels slow, we profile, fix the obvious thing, and move\non. The list below is what \"the obvious thing\" usually is.\n\n> Premature optimization is the root of all evil, but ignoring a 3s\n> cold-start isn't optimization — it's negligence.\n\n## The checklist\n\n1. **Measure with real numbers.** Lighthouse and the Network tab answer\n most questions. If you're not measuring, you're guessing.\n2. **Serve fewer bytes.** Compress images (AVIF or WebP), remove unused\n fonts, and audit any dependency over 50KB gzipped.\n3. **Defer the non-critical.** Scripts that aren't needed above the\n fold can wait. `loading=\"lazy\"` on images, `defer` on scripts, and\n dynamic `import()` for interactive widgets.\n4. **Cache at the edge.** If the same HTML could serve a thousand users,\n it should. Use your adapter's cache headers; don't hand-roll it.\n5. **Avoid waterfalls.** If page load depends on three sequential fetches,\n collapse them into one endpoint or preload the critical ones.\n6. **Trust the framework.** SvelteKit's `load` functions run in parallel\n by default and the compiler already strips unused code. Most hand-rolled\n cleverness just gets in the way.\n\n## What we stopped worrying about\n\n- Micro-optimizations inside component code — the bundle is small, the\n diff is fast. The savings are real but rarely matter.\n- Third-party tooling that promises \"speed.\" If it adds a build step,\n the benefit needs to be measurable, not theoretical.\n\n## When to go deeper\n\nIf the checklist doesn't move the needle, the next step is almost\nalways a deeper look at the data layer — query plans, N+1 fetches, cold\ncache behavior. But you should have exhausted the list above before\ngetting there. Most slowness is boring, and most fixes are too.\n", Rc = "---\ntitle: Welcome to the Blog\ndescription: A quick note on what this space is for and what to expect from us.\ncreatedDate: 2026-04-20\ntags:\n - announcements\nauthor:\n name: Ada Chen\n---\n\nWelcome in. This blog is where we write about the things we build, the\ndecisions behind them, and what we learn when they go sideways.\n\nYou can expect a mix of short notes and longer walkthroughs. No schedule,\nno filler. If a post exists it's because something was worth writing down.\n\nA few threads you'll see pop up often:\n\n- Product notes on what we're shipping and why\n- Practical tutorials for the tools we use every day\n- Design and engineering decisions that took more than five minutes\n\nIf you'd rather not check back manually, the [RSS feed](/blog/rss.xml)\nhas every post. Thanks for reading.\n", zc = "---\ntitle: Why We Chose Tailwind v4\ndescription: Notes on moving from a traditional CSS pipeline to Tailwind v4's zero-config, CSS-first setup.\ncreatedDate: 2026-02-18\ntags:\n - tailwind\n - design\nauthor:\n name: Ada Chen\n---\n\nTailwind v4 is a meaningful rewrite. The surface API still looks the same\n— utility classes on elements — but the compiler, configuration model,\nand theming story all changed in ways that made us want to adopt it.\n\n> The point of a design system isn't to ship fewer classes. It's to make\n> the next decision easier than the last.\n\n## What changed for us\n\nThree things mattered:\n\n1. **CSS-first config.** `tailwind.config.js` is gone. Tokens live in\n `app.css` as real CSS custom properties, which means they also work\n outside of Tailwind — SVG fills, inline styles, wherever.\n2. **OKLCH colors.** Designers can reason about lightness and chroma\n independently. Contrast checks become much easier to eyeball.\n3. **Speed.** The new engine compiles fast enough that we stopped\n thinking about purge lists. Dev feedback is effectively instant.\n\n## The config we kept\n\nWe pinned two things in `app.css`:\n\n```css\n@import 'tailwindcss';\n@plugin '@tailwindcss/typography';\n\n:root {\n --radius: 0.625rem;\n --background: oklch(1 0 0);\n --foreground: oklch(0.129 0.042 264.695);\n}\n```\n\nEverything else — spacing, typography, breakpoints — falls back to\ndefaults until we have a reason to override it.\n\n## What we'd tell a team evaluating it\n\nIf you're already using Tailwind v3, the migration is mostly a config\nmove. If you're starting from scratch, v4 removes a pile of decisions\nyou'd otherwise be making on day one. That alone made it worth it.\n", Bc = "---\ntitle: Writing Posts with MDsveX\ndescription: How this blog turns markdown files into real Svelte components — frontmatter, code, and embedded UI.\ncreatedDate: 2026-01-28\nupdatedDate: 2026-02-02\ntags:\n - mdsvex\n - tutorial\nauthor:\n name: Priya Shah\n---\n\nPosts on this blog are `.svx` files. Each one is a real Svelte component\nat build time, so Markdown and Svelte sit side by side with no glue\ncode.\n\n## Frontmatter\n\nYAML at the top of a post becomes the `metadata` export. The loader\nreads it to build the list view, tag pages, and RSS feed.\n\n```yaml\n---\ntitle: Writing Posts with MDsveX\ndescription: A short description shown in previews.\ncreatedDate: 2026-01-28\ntags:\n - mdsvex\n - tutorial\nauthor:\n name: Priya Shah\n---\n```\n\n## Markdown works the way you'd expect\n\nHeadings, lists, links, blockquotes, and inline `code` all render.\nFenced code blocks pick up language hints for syntax highlighting when a\nplugin is enabled.\n\n```ts\nfunction greet(name: string) {\n return `hello, ${name}`;\n}\n```\n\n## Images\n\nPut images in `static/` and reference them with a root-relative path:\n\n```md\n\n```\n\n## Svelte in your posts\n\nThe superpower is that you can drop components straight into a post —\na chart, an interactive demo, a call-to-action card. The rules are the\nsame as any other Svelte file:\n\n```svelte\n<script>\n import Callout from '$lib/components/Callout.svelte';\n<\/script>\n\n<Callout>This is a real component inside a markdown post.</Callout>\n```\n\nThat's the whole pipeline. Write markdown, sprinkle in components when\nplain text stops being enough, and the rest is just Svelte.\n", Vc = "import type { Component } from \"svelte\";\n\nexport type BlogAuthor = {\n name: string;\n avatar?: string;\n};\n\nexport type BlogMetadata = {\n title: string;\n description: string;\n createdDate: string;\n updatedDate?: string;\n tags?: string[];\n author?: BlogAuthor;\n};\n\nexport type BlogModules = Record<\n string,\n { default: Component; metadata: BlogMetadata }\n>;\n\nexport type BlogRawModules = Record<string, string>;\n\nexport type BlogPost = {\n slug: string;\n title: string;\n description: string;\n createdDate: Date;\n updatedDate?: Date;\n tags?: string[];\n author?: BlogAuthor;\n readingTime: number;\n component: Component;\n};\n\nexport type BlogPostSummary = Omit<BlogPost, \"component\">;\n\nconst WORDS_PER_MINUTE = 220;\n\nfunction getBlogModules() {\n return import.meta.glob(\"$lib/content/blog/*.svx\", {\n eager: true,\n }) as BlogModules;\n}\n\nfunction getBlogRawModules() {\n return import.meta.glob(\"$lib/content/blog/*.svx\", {\n eager: true,\n query: \"?raw\",\n import: \"default\",\n }) as BlogRawModules;\n}\n\nfunction stripFrontmatter(raw: string) {\n if (!raw.startsWith(\"---\")) return raw;\n const end = raw.indexOf(\"\\n---\", 3);\n if (end === -1) return raw;\n return raw.slice(end + 4);\n}\n\nfunction computeReadingTime(raw: string) {\n const body = stripFrontmatter(raw);\n const words = body.split(/\\s+/).filter(Boolean).length;\n return Math.max(1, Math.ceil(words / WORDS_PER_MINUTE));\n}\n\nexport function getBlogPosts(): BlogPost[] {\n const modules = getBlogModules();\n const rawModules = getBlogRawModules();\n\n const posts = Object.entries(modules).map(([path, module]) => {\n const filename = path.split(\"/\").pop() ?? \"\";\n const slug = filename.replace(\".svx\", \"\");\n const raw = rawModules[path] ?? \"\";\n\n return {\n slug,\n title: module.metadata.title,\n description: module.metadata.description,\n createdDate: new Date(module.metadata.createdDate),\n updatedDate: module.metadata.updatedDate\n ? new Date(module.metadata.updatedDate)\n : undefined,\n tags: module.metadata.tags,\n author: module.metadata.author,\n readingTime: computeReadingTime(raw),\n component: module.default,\n };\n });\n\n posts.sort((a, b) => b.createdDate.getTime() - a.createdDate.getTime());\n return posts;\n}\n\nexport function getBlogPost(slug: string) {\n const posts = getBlogPosts();\n return posts.find((post) => post.slug === slug) ?? null;\n}\n\nexport function getBlogPostRaw(slug: string): string | null {\n const rawModules = getBlogRawModules();\n for (const [path, raw] of Object.entries(rawModules)) {\n const filename = path.split(\"/\").pop() ?? \"\";\n if (filename.replace(\".svx\", \"\") === slug) return raw;\n }\n return null;\n}\n\nexport function getBlogPostsByTag(tag: string) {\n return getBlogPosts().filter((post) => post.tags?.includes(tag));\n}\n\nexport function getAllTags(): { tag: string; count: number }[] {\n const counts = new Map<string, number>();\n for (const post of getBlogPosts()) {\n for (const tag of post.tags ?? []) {\n counts.set(tag, (counts.get(tag) ?? 0) + 1);\n }\n }\n return [...counts.entries()]\n .map(([tag, count]) => ({ tag, count }))\n .sort((a, b) => b.count - a.count || a.tag.localeCompare(b.tag));\n}\n\nexport function getAdjacentPosts(slug: string): {\n prev: BlogPost | null;\n next: BlogPost | null;\n} {\n const posts = getBlogPosts();\n const index = posts.findIndex((post) => post.slug === slug);\n if (index === -1) return { prev: null, next: null };\n return {\n next: index > 0 ? posts[index - 1] : null,\n prev: index < posts.length - 1 ? posts[index + 1] : null,\n };\n}\n\nexport function getRelatedPosts(slug: string, limit = 3): BlogPost[] {\n const posts = getBlogPosts();\n const current = posts.find((post) => post.slug === slug);\n if (!current?.tags?.length) return [];\n\n const currentTags = new Set(current.tags);\n\n return posts\n .filter((post) => post.slug !== slug && post.tags?.length)\n .map((post) => ({\n post,\n overlap: post.tags!.filter((tag) => currentTags.has(tag)).length,\n }))\n .filter(({ overlap }) => overlap > 0)\n .sort(\n (a, b) =>\n b.overlap - a.overlap ||\n b.post.createdDate.getTime() - a.post.createdDate.getTime(),\n )\n .slice(0, limit)\n .map(({ post }) => post);\n}\n", Hc = "const formatter = new Intl.DateTimeFormat(\"en-US\", {\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n});\n\nexport function formatDate(date: Date) {\n return formatter.format(date);\n}\n", Uc = "<script lang=\"ts\">\n import * as Breadcrumb from \"$lib/components/ui/breadcrumb\";\n import { page } from \"$app/state\";\n\n let { children } = $props();\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as {\n title: string;\n url: string;\n }[];\n<\/script>\n\n<section data-role=\"content\">\n <Breadcrumb.Root class=\"mb-6\">\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}\n >{breadcrumb.title}</Breadcrumb.Link\n >\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n\n {@render children?.()}\n</section>\n", Wc = "<script lang=\"ts\">\n import { Button } from \"$lib/components/ui/button\";\n import PostCard from \"$lib/components/blog/PostCard.svelte\";\n import Rss from \"@lucide/svelte/icons/rss\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-10\">\n <header\n class=\"flex flex-col gap-4 md:flex-row md:items-end md:justify-between\"\n >\n <div class=\"max-w-2xl\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">Blog</h1>\n <p class=\"text-muted-foreground mt-2 text-base\">\n Product notes, tutorials, and engineering posts from the team.\n </p>\n </div>\n <Button href=\"/blog/rss.xml\" variant=\"outline\" size=\"sm\" class=\"w-fit\">\n <Rss class=\"size-4\" />\n RSS\n </Button>\n </header>\n\n <ul class=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.blogPosts as post (post.slug)}\n <li class=\"flex w-full\">\n <PostCard {post} />\n </li>\n {/each}\n </ul>\n</div>\n", Gc = "import { definePageMetaTags } from \"svelte-meta-tags\";\nimport { getAllTags, getBlogPosts } from \"$lib/content\";\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const blogPosts = getBlogPosts();\n const allTags = getAllTags();\n\n const pageMetaTags = definePageMetaTags({\n title: \"Blog\",\n description: \"Product notes, tutorials, and engineering posts.\",\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n ];\n\n return { blogPosts, allTags, breadcrumbs, ...pageMetaTags };\n};\n", Kc = "<script lang=\"ts\">\n import { Badge } from \"$lib/components/ui/badge\";\n import { Separator } from \"$lib/components/ui/separator\";\n import AuthorChip from \"$lib/components/blog/AuthorChip.svelte\";\n import PostCard from \"$lib/components/blog/PostCard.svelte\";\n import { formatDate } from \"$lib/utils/date\";\n import ArrowLeft from \"@lucide/svelte/icons/arrow-left\";\n import ArrowRight from \"@lucide/svelte/icons/arrow-right\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-6\">\n <header class=\"flex flex-col gap-5 border-b border-border pb-8\">\n <div class=\"flex flex-col gap-3\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">\n {data.blogPost.title}\n </h1>\n <p class=\"text-muted-foreground text-lg\">\n {data.blogPost.description}\n </p>\n </div>\n\n <div\n class=\"text-muted-foreground flex flex-wrap items-center gap-x-1 gap-y-2 text-sm\"\n >\n {#if data.blogPost.author}\n <AuthorChip author={data.blogPost.author} />\n <span aria-hidden=\"true\" class=\"text-muted-foreground/50\">•</span>\n {/if}\n <time datetime={data.blogPost.createdDate.toISOString()}>\n {formatDate(data.blogPost.createdDate)}\n </time>\n {#if data.blogPost.updatedDate}\n <span aria-hidden=\"true\" class=\"text-muted-foreground/50\">•</span>\n <span>Updated {formatDate(data.blogPost.updatedDate)}</span>\n {/if}\n <span aria-hidden=\"true\" class=\"text-muted-foreground/50\">•</span>\n <span>{data.blogPost.readingTime} min read</span>\n </div>\n\n {#if data.blogPost.tags?.length}\n <div class=\"flex flex-wrap gap-1.5\">\n {#each data.blogPost.tags as tag (tag)}\n <Badge href={`/blog/tags/${tag}`} variant=\"secondary\">{tag}</Badge>\n {/each}\n </div>\n {/if}\n </header>\n\n <article\n class=\"prose dark:prose-invert max-w-prose prose-headings:mb-0 prose-headings:mt-4\"\n >\n <data.blogPost.component />\n </article>\n\n <Separator />\n\n <nav class=\"grid gap-3 sm:grid-cols-2\" aria-label=\"Post navigation\">\n {#if data.adjacent.prev}\n <a\n href={`/blog/${data.adjacent.prev.slug}`}\n class=\"ring-foreground/10 hover:ring-foreground/20 bg-card text-card-foreground group flex flex-col gap-1 rounded-xl p-4 ring-1 transition-shadow\"\n >\n <span\n class=\"text-muted-foreground inline-flex items-center gap-1 text-xs font-medium uppercase tracking-wide\"\n >\n <ArrowLeft class=\"size-3.5\" />\n Previous\n </span>\n <span class=\"font-medium group-hover:underline\"\n >{data.adjacent.prev.title}</span\n >\n </a>\n {:else}\n <div></div>\n {/if}\n\n {#if data.adjacent.next}\n <a\n href={`/blog/${data.adjacent.next.slug}`}\n class=\"ring-foreground/10 hover:ring-foreground/20 bg-card text-card-foreground group flex flex-col gap-1 rounded-xl p-4 text-right ring-1 transition-shadow sm:col-start-2\"\n >\n <span\n class=\"text-muted-foreground inline-flex items-center justify-end gap-1 text-xs font-medium uppercase tracking-wide\"\n >\n Next\n <ArrowRight class=\"size-3.5\" />\n </span>\n <span class=\"font-medium group-hover:underline\"\n >{data.adjacent.next.title}</span\n >\n </a>\n {/if}\n </nav>\n\n {#if data.related.length}\n <section class=\"flex flex-col gap-4\">\n <Separator />\n <h2 class=\"text-xl font-semibold tracking-tight\">Related posts</h2>\n <ul class=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.related as post (post.slug)}\n <li class=\"flex\">\n <PostCard {post} />\n </li>\n {/each}\n </ul>\n </section>\n {/if}\n</div>\n", qc = "import { error } from \"@sveltejs/kit\";\nimport { definePageMetaTags } from \"svelte-meta-tags\";\nimport {\n getAdjacentPosts,\n getBlogPost,\n getBlogPosts,\n getRelatedPosts,\n} from \"$lib/content\";\n\nexport const load = async ({ params, parent }) => {\n await parent();\n\n const blogPost = getBlogPost(params.slug);\n\n if (blogPost === null) {\n throw error(404, \"Page not found\");\n }\n\n const adjacent = getAdjacentPosts(params.slug);\n const related = getRelatedPosts(params.slug);\n\n const pageMetaTags = definePageMetaTags({\n title: blogPost.title,\n description: blogPost.description,\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n { title: blogPost.title, url: `/blog/${blogPost.slug}` },\n ];\n\n return { blogPost, adjacent, related, breadcrumbs, ...pageMetaTags };\n};\n\nexport const entries = async () => {\n return getBlogPosts().map((post) => ({ slug: post.slug }));\n};\n", Jc = "import { getBlogPosts } from \"$lib/content\";\n\nexport const prerender = true;\n\nfunction escapeXml(value: string) {\n return value\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\nexport const GET = async ({ locals, url }) => {\n const { appName } = locals.meta;\n const posts = getBlogPosts();\n // `url.origin`, not `locals.meta.appURL`: this feed is prerendered, and the\n // origin comes from the build's own configuration rather than from whichever\n // database the build could reach. Every `<link>` and `<guid>` below is\n // permanent once published, so pointing them at a developer's localhost is\n // not something a later deploy can take back.\n const siteURL = url.origin.replace(/\\/$/, \"\");\n const feedURL = `${siteURL}/blog/rss.xml`;\n const lastBuild = (\n posts[0]?.updatedDate ??\n posts[0]?.createdDate ??\n new Date()\n ).toUTCString();\n\n const items = posts\n .map((post) => {\n const link = `${siteURL}/blog/${post.slug}`;\n const pubDate = post.createdDate.toUTCString();\n const categories = (post.tags ?? [])\n .map((tag) => ` <category>${escapeXml(tag)}</category>`)\n .join(\"\\n\");\n const creator = post.author\n ? ` <dc:creator>${escapeXml(post.author.name)}</dc:creator>`\n : \"\";\n\n return [\n \" <item>\",\n ` <title>${escapeXml(post.title)}</title>`,\n ` <link>${escapeXml(link)}</link>`,\n ` <guid isPermaLink=\"true\">${escapeXml(link)}</guid>`,\n ` <description>${escapeXml(post.description)}</description>`,\n ` <pubDate>${pubDate}</pubDate>`,\n creator,\n categories,\n \" </item>\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n })\n .join(\"\\n\");\n\n const xml = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n<channel>\n <title>${escapeXml(appName)}</title>\n <link>${escapeXml(`${siteURL}/blog`)}</link>\n <atom:link href=\"${escapeXml(feedURL)}\" rel=\"self\" type=\"application/rss+xml\" />\n <description>${escapeXml(`Latest posts from ${appName}.`)}</description>\n <language>en</language>\n <lastBuildDate>${lastBuild}</lastBuildDate>\n${items}\n</channel>\n</rss>\n`;\n\n return new Response(xml, {\n headers: {\n \"Content-Type\": \"application/xml; charset=utf-8\",\n \"Cache-Control\": \"max-age=0, s-maxage=3600\",\n },\n });\n};\n", Yc = "<script lang=\"ts\">\n import { Badge } from \"$lib/components/ui/badge\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-8\">\n <header class=\"flex flex-col gap-2\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">Tags</h1>\n <p class=\"text-muted-foreground text-base\">\n {data.allTags.length}\n {data.allTags.length === 1 ? \"tag\" : \"tags\"} used across the blog.\n </p>\n </header>\n\n {#if data.allTags.length}\n <ul class=\"flex flex-wrap gap-2\">\n {#each data.allTags as { tag, count } (tag)}\n <li>\n <Badge href={`/blog/tags/${tag}`} variant=\"secondary\">\n {tag}\n <span class=\"text-muted-foreground ml-0.5\">{count}</span>\n </Badge>\n </li>\n {/each}\n </ul>\n {:else}\n <p class=\"text-muted-foreground\">No tags yet.</p>\n {/if}\n</div>\n", Xc = "import { definePageMetaTags } from \"svelte-meta-tags\";\nimport { getAllTags } from \"$lib/content\";\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const allTags = getAllTags();\n\n const pageMetaTags = definePageMetaTags({\n title: \"Tags\",\n description: \"All tags used on the blog.\",\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n { title: \"Tags\", url: \"/blog/tags\" },\n ];\n\n return { allTags, breadcrumbs, ...pageMetaTags };\n};\n", Zc = "<script lang=\"ts\">\n import PostCard from \"$lib/components/blog/PostCard.svelte\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-8\">\n <header class=\"flex flex-col gap-2\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">\n {data.tag}\n </h1>\n <p class=\"text-muted-foreground text-base\">\n {data.blogPosts.length}\n {data.blogPosts.length === 1 ? \"post\" : \"posts\"} tagged \"{data.tag}\".\n </p>\n </header>\n\n <ul class=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.blogPosts as post (post.slug)}\n <li class=\"flex\">\n <PostCard {post} />\n </li>\n {/each}\n </ul>\n</div>\n", Qc = "import { error } from \"@sveltejs/kit\";\nimport { definePageMetaTags } from \"svelte-meta-tags\";\nimport { getAllTags, getBlogPostsByTag } from \"$lib/content\";\n\nexport const load = async ({ params, parent }) => {\n await parent();\n\n const blogPosts = getBlogPostsByTag(params.tag);\n\n if (blogPosts.length === 0) {\n throw error(404, \"Tag not found\");\n }\n\n const pageMetaTags = definePageMetaTags({\n title: `Posts tagged \"${params.tag}\"`,\n description: `Blog posts tagged \"${params.tag}\".`,\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n { title: \"Tags\", url: \"/blog/tags\" },\n { title: params.tag, url: `/blog/tags/${params.tag}` },\n ];\n\n return { blogPosts, tag: params.tag, breadcrumbs, ...pageMetaTags };\n};\n\nexport const entries = async () => {\n return getAllTags().map(({ tag }) => ({ tag }));\n};\n", $c = "import { negotiate } from \"$lib/negotiate\";\nimport { getBlogPostRaw } from \"$lib/content\";\n\nexport const load = async ({ params, locals }) => {\n return {\n ...negotiate(locals, {\n \"text/markdown\": () => getBlogPostRaw(params.slug) ?? \"\",\n }),\n };\n};\n", el = /* #__PURE__ */ Object.assign({
|
|
4762
4776
|
"./creates/src/css/prism-vsc-dark-plus.css": Mc,
|
|
4763
4777
|
"./creates/src/lib/components/blog/AuthorChip.svelte": Nc,
|
|
4764
4778
|
"./creates/src/lib/components/blog/PostCard.svelte": Pc,
|
|
@@ -4853,7 +4867,7 @@ async function pl(e) {
|
|
|
4853
4867
|
let n = await cl(e);
|
|
4854
4868
|
return m(i([t, n]), e);
|
|
4855
4869
|
}
|
|
4856
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
4870
|
+
let { generate: n } = await import("./chunks/generate.runtime-BltGUllM.js"), r = await n(e), { writeResult: a } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
4857
4871
|
return a(await m(i([t, r]), e), e);
|
|
4858
4872
|
}
|
|
4859
4873
|
var ml = {
|
|
@@ -4928,7 +4942,7 @@ async function Sl(e) {
|
|
|
4928
4942
|
let n = await _l(e);
|
|
4929
4943
|
return m(i([t, n]), e);
|
|
4930
4944
|
}
|
|
4931
|
-
let { generate: n, keepMissing: r } = await import("./chunks/generate.runtime-
|
|
4945
|
+
let { generate: n, keepMissing: r } = await import("./chunks/generate.runtime-BsuyMwoj.js"), a = await n(e), { writeResult: o } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
4932
4946
|
return o(await m(i([{
|
|
4933
4947
|
...t,
|
|
4934
4948
|
creates: r(t.creates, e.root)
|
|
@@ -5046,7 +5060,7 @@ async function Hl(e) {
|
|
|
5046
5060
|
let n = await Ll(e);
|
|
5047
5061
|
return m(i([t, n]), e);
|
|
5048
5062
|
}
|
|
5049
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
5063
|
+
let { generate: n } = await import("./chunks/generate.runtime-CXXwLatT.js"), r = await n(e), { writeResult: a } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
5050
5064
|
return a(await m(i([t, r]), e), e);
|
|
5051
5065
|
}
|
|
5052
5066
|
var Ul = {
|
|
@@ -5151,7 +5165,7 @@ async function iu(e) {
|
|
|
5151
5165
|
let n = await $l(e);
|
|
5152
5166
|
return m(i([t, n]), e);
|
|
5153
5167
|
}
|
|
5154
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
5168
|
+
let { generate: n } = await import("./chunks/generate.runtime-BKb9thdE.js"), r = await n(e), { writeResult: a } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
5155
5169
|
return a(await m(i([t, r]), e), e);
|
|
5156
5170
|
}
|
|
5157
5171
|
var au = {
|
|
@@ -5191,16 +5205,16 @@ var au = {
|
|
|
5191
5205
|
tests: 0,
|
|
5192
5206
|
baseline: "velastack",
|
|
5193
5207
|
generate: iu
|
|
5194
|
-
}, ou = /* #__PURE__ */ Object.assign({
|
|
5195
|
-
"./creates/src/lib/components/notifications-bell.svelte":
|
|
5196
|
-
"./creates/src/lib/server/notifications.ts":
|
|
5197
|
-
"./creates/src/routes/(app)/notifications/+page.server.ts":
|
|
5198
|
-
"./creates/src/routes/(app)/notifications/+page.svelte":
|
|
5199
|
-
}),
|
|
5200
|
-
async function
|
|
5208
|
+
}, ou = "<script lang=\"ts\">\n import { onMount } from 'svelte';\n import { goto, invalidate } from '$app/navigation';\n import { page } from '$app/state';\n import { toast } from 'svelte-sonner';\n import BellIcon from '@lucide/svelte/icons/bell';\n import { Button } from '$lib/components/ui/button';\n import { Badge } from '$lib/components/ui/badge';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import { timeAgo } from '$lib/utils';\n\n interface NotificationItem {\n id: string;\n title: string;\n body: string;\n read: boolean;\n created: string;\n }\n\n const POLL_MS = 30_000;\n const INVALIDATE_KEY = 'app:notifications';\n\n const notifications = $derived(\n (page.data.notifications ?? { count: 0, items: [] }) as {\n count: number;\n items: NotificationItem[];\n }\n );\n const badgeText = $derived(notifications.count > 99 ? '99+' : String(notifications.count));\n\n let lastSeenId: string | null = null;\n let primed = false;\n\n $effect(() => {\n const newest = notifications.items[0]?.id ?? null;\n if (!primed) {\n primed = true;\n lastSeenId = newest;\n return;\n }\n if (!newest || newest === lastSeenId) return;\n for (const item of notifications.items) {\n if (lastSeenId && item.id <= lastSeenId) break;\n toast.info(item.title, {\n description: item.body || undefined,\n action: { label: 'View', onClick: () => goto('/notifications') }\n });\n }\n lastSeenId = newest;\n });\n\n onMount(() => {\n const id = setInterval(() => {\n if (document.visibilityState === 'hidden') return;\n invalidate(INVALIDATE_KEY);\n }, POLL_MS);\n const onVisible = () => {\n if (document.visibilityState === 'visible') invalidate(INVALIDATE_KEY);\n };\n document.addEventListener('visibilitychange', onVisible);\n return () => {\n clearInterval(id);\n document.removeEventListener('visibilitychange', onVisible);\n };\n });\n<\/script>\n\n<DropdownMenu.Root onOpenChange={(open) => open && invalidate(INVALIDATE_KEY)}>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Button variant=\"ghost\" size=\"icon\" class=\"relative\" aria-label=\"Notifications\" {...props}>\n <BellIcon class=\"size-5\" />\n {#if notifications.count > 0}\n <Badge\n variant=\"destructive\"\n class=\"absolute -top-1 -right-1 h-4 min-w-4 px-1 text-[10px] leading-none\"\n >\n {badgeText}\n </Badge>\n {/if}\n </Button>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"end\" class=\"w-80 shadow-2xl shadow-black/40\">\n <DropdownMenu.Label>Notifications</DropdownMenu.Label>\n <DropdownMenu.Separator />\n {#if notifications.items.length === 0}\n <div class=\"px-2 py-6 text-center text-sm text-muted-foreground\">\n You're all caught up.\n </div>\n {:else}\n {#each notifications.items as item (item.id)}\n <DropdownMenu.Item class=\"p-0\">\n <a\n href=\"/notifications\"\n class=\"flex w-full flex-col gap-0.5 px-2 py-2 cursor-default\"\n >\n <div class=\"flex items-center justify-between gap-2\">\n <span class=\"text-sm font-medium truncate\">{item.title}</span>\n <span\n class=\"shrink-0 text-[10px] text-muted-foreground tabular-nums\"\n title={new Date(item.created).toLocaleString()}\n >\n {timeAgo(item.created)}\n </span>\n </div>\n {#if item.body}\n <span class=\"text-xs text-muted-foreground line-clamp-2\">{item.body}</span>\n {/if}\n </a>\n </DropdownMenu.Item>\n {/each}\n {/if}\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <a href=\"/notifications\" class=\"flex w-full justify-center px-2 py-1.5 text-sm cursor-default\">\n View all\n </a>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n</DropdownMenu.Root>\n", su = "import type PocketBase from \"pocketbase-sveltekit\";\n\nexport interface NotifyInput {\n title: string;\n body?: string;\n}\n\n/** Drop a notification on a user. Server-only ($lib/server). */\nexport async function notify(pb: PocketBase, userId: string, input: NotifyInput) {\n return pb.collection('notifications').create({\n user: userId,\n title: input.title,\n body: input.body ?? '',\n read: false\n });\n}\n", cu = "import { fail } from '@sveltejs/kit';\n\nexport const load = async ({ locals }) => {\n const userId = locals.pb.authStore.record!.id;\n const items = await locals.pb.collection('notifications').getFullList({\n filter: `user = \"${userId}\"`,\n sort: '-created',\n requestKey: 'notifications'\n });\n const unread = items.filter((n) => !n.read).length;\n const breadcrumbs = [\n { title: 'Home', url: '/dashboard' },\n { title: 'Notifications', url: '/notifications' }\n ];\n return { items, unread, breadcrumbs };\n};\n\nexport const actions = {\n markRead: async ({ request, locals }) => {\n const form = await request.formData();\n const id = form.get('id');\n if (typeof id !== 'string' || !id) return fail(400, { error: 'missing id' });\n await locals.pb.collection('notifications').update(id, { read: true });\n return { success: true };\n },\n markAllRead: async ({ locals }) => {\n const userId = locals.pb.authStore.record!.id;\n const unread = await locals.pb.collection('notifications').getFullList({\n filter: `user = \"${userId}\" && read = false`\n });\n for (const n of unread) {\n await locals.pb.collection('notifications').update(n.id, { read: true });\n }\n return { success: true, count: unread.length };\n }\n};\n", lu = "<script lang=\"ts\">\n import { enhance } from '$app/forms';\n import { Button } from '$lib/components/ui/button';\n import { Badge } from '$lib/components/ui/badge';\n import * as Card from '$lib/components/ui/card';\n import { timeAgo } from '$lib/utils';\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-4\">\n <div class=\"flex items-center justify-between\">\n <div class=\"flex items-center gap-2\">\n <h1 class=\"text-2xl font-semibold\">Notifications</h1>\n {#if data.unread > 0}\n <Badge variant=\"secondary\">{data.unread} unread</Badge>\n {/if}\n </div>\n {#if data.unread > 0}\n <form method=\"post\" action=\"?/markAllRead\" use:enhance>\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Mark all read</Button>\n </form>\n {/if}\n </div>\n\n {#if data.items.length === 0}\n <Card.Root>\n <Card.Content class=\"py-10 text-center text-sm text-muted-foreground\">\n You don't have any notifications yet.\n </Card.Content>\n </Card.Root>\n {:else}\n <div class=\"flex flex-col gap-2\">\n {#each data.items as item (item.id)}\n <Card.Root\n size=\"sm\"\n class={['relative transition-colors', item.read ? 'opacity-70' : '']}\n >\n <Card.Content class=\"flex items-start justify-between gap-4\">\n <div class=\"flex min-w-0 flex-col gap-0.5\">\n <div class=\"flex items-center gap-2\">\n <span class=\"font-medium\">{item.title}</span>\n {#if !item.read}\n <span class=\"size-2 rounded-full bg-primary\" aria-label=\"unread\"></span>\n {/if}\n </div>\n {#if item.body}\n <p class=\"text-sm text-muted-foreground\">{item.body}</p>\n {/if}\n {#if item.created}\n <span\n class=\"text-xs text-muted-foreground\"\n title={new Date(item.created).toLocaleString()}\n >\n {timeAgo(item.created)}\n </span>\n {/if}\n </div>\n {#if !item.read}\n <form method=\"post\" action=\"?/markRead\" use:enhance>\n <input type=\"hidden\" name=\"id\" value={item.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Mark read</Button>\n </form>\n {/if}\n </Card.Content>\n </Card.Root>\n {/each}\n </div>\n {/if}\n</div>\n", uu = /* #__PURE__ */ Object.assign({
|
|
5209
|
+
"./creates/src/lib/components/notifications-bell.svelte": ou,
|
|
5210
|
+
"./creates/src/lib/server/notifications.ts": su,
|
|
5211
|
+
"./creates/src/routes/(app)/notifications/+page.server.ts": cu,
|
|
5212
|
+
"./creates/src/routes/(app)/notifications/+page.svelte": lu
|
|
5213
|
+
}), du = "./creates/";
|
|
5214
|
+
async function fu(e) {
|
|
5201
5215
|
return {
|
|
5202
|
-
creates: Object.entries(
|
|
5203
|
-
let r = o(e,
|
|
5216
|
+
creates: Object.entries(uu).map(([e, t]) => {
|
|
5217
|
+
let r = o(e, du);
|
|
5204
5218
|
return {
|
|
5205
5219
|
path: r,
|
|
5206
5220
|
language: n(r),
|
|
@@ -5219,8 +5233,8 @@ async function cu(e) {
|
|
|
5219
5233
|
}
|
|
5220
5234
|
//#endregion
|
|
5221
5235
|
//#region src/patterns/enable/notifications/preview-modifies/src/lib/utils.ts?raw
|
|
5222
|
-
var
|
|
5223
|
-
function
|
|
5236
|
+
var pu = "import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type WithoutChild<T> = T extends { child?: any } ? Omit<T, \"child\"> : T;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type WithoutChildren<T> = T extends { children?: any }\n ? Omit<T, \"children\">\n : T;\nexport type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;\nexport type WithElementRef<T, U extends HTMLElement = HTMLElement> = T & {\n ref?: U | null;\n};\n\n// [!code highlight:9]\nconst TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n [\"year\", 60 * 60 * 24 * 365],\n [\"month\", 60 * 60 * 24 * 30],\n [\"day\", 60 * 60 * 24],\n [\"hour\", 60 * 60],\n [\"minute\", 60],\n [\"second\", 1],\n];\n\n// [!code highlight:10]\nexport function timeAgo(date: Date | string | number, locale?: string) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: \"auto\" });\n const diff = (new Date(date).getTime() - Date.now()) / 1000;\n\n for (const [unit, secs] of TIME_AGO_UNITS) {\n if (Math.abs(diff) >= secs || unit === \"second\") {\n return rtf.format(Math.round(diff / secs), unit);\n }\n }\n}\n", mu = "users";
|
|
5237
|
+
function hu(e) {
|
|
5224
5238
|
let t = te.find((t) => t.collectionName === e);
|
|
5225
5239
|
if (!t) throw Error(`notifications: missing NOTIFICATION_RULE_PATCHES entry for "${e}"`);
|
|
5226
5240
|
return {
|
|
@@ -5231,10 +5245,10 @@ function du(e) {
|
|
|
5231
5245
|
deleteRule: t.deleteRule
|
|
5232
5246
|
};
|
|
5233
5247
|
}
|
|
5234
|
-
var
|
|
5248
|
+
var gu = [{
|
|
5235
5249
|
name: "notifications",
|
|
5236
5250
|
type: "base",
|
|
5237
|
-
...
|
|
5251
|
+
...hu("notifications"),
|
|
5238
5252
|
indexes: ["CREATE INDEX `idx_notifications_user_read_created` ON `notifications` (`user`, `read`, `created` DESC)"],
|
|
5239
5253
|
fields: [
|
|
5240
5254
|
{
|
|
@@ -5251,7 +5265,7 @@ var fu = [{
|
|
|
5251
5265
|
name: "user",
|
|
5252
5266
|
type: "relation",
|
|
5253
5267
|
cascadeDelete: !0,
|
|
5254
|
-
collectionId:
|
|
5268
|
+
collectionId: mu,
|
|
5255
5269
|
maxSelect: 1,
|
|
5256
5270
|
minSelect: 0,
|
|
5257
5271
|
required: !0
|
|
@@ -5282,12 +5296,12 @@ var fu = [{
|
|
|
5282
5296
|
onUpdate: !0
|
|
5283
5297
|
}
|
|
5284
5298
|
]
|
|
5285
|
-
}],
|
|
5286
|
-
async function
|
|
5299
|
+
}], _u = /* #__PURE__ */ Object.assign({ "./preview-modifies/src/lib/utils.ts": pu }), vu = "./preview-modifies/";
|
|
5300
|
+
async function yu(e) {
|
|
5287
5301
|
return {
|
|
5288
5302
|
creates: [],
|
|
5289
|
-
modifies: Object.entries(
|
|
5290
|
-
let r = o(e,
|
|
5303
|
+
modifies: Object.entries(_u).map(([e, t]) => {
|
|
5304
|
+
let r = o(e, vu);
|
|
5291
5305
|
return {
|
|
5292
5306
|
path: r,
|
|
5293
5307
|
language: n(r),
|
|
@@ -5298,28 +5312,28 @@ async function hu(e) {
|
|
|
5298
5312
|
deletes: [],
|
|
5299
5313
|
components: [],
|
|
5300
5314
|
packages: [],
|
|
5301
|
-
collections:
|
|
5315
|
+
collections: gu,
|
|
5302
5316
|
collectionPatches: [],
|
|
5303
5317
|
collectionDrops: []
|
|
5304
5318
|
};
|
|
5305
5319
|
}
|
|
5306
5320
|
//#endregion
|
|
5307
5321
|
//#region src/patterns/enable/notifications/index.ts
|
|
5308
|
-
var
|
|
5309
|
-
async function
|
|
5310
|
-
let t = await
|
|
5322
|
+
var bu = "enable-notifications", xu = "1.0.0", Su = "src/patterns/enable/notifications", Cu = "/enable/notifications";
|
|
5323
|
+
async function wu(e) {
|
|
5324
|
+
let t = await fu(e);
|
|
5311
5325
|
if (e.env === "preview") {
|
|
5312
|
-
let n = await
|
|
5326
|
+
let n = await yu(e);
|
|
5313
5327
|
return m(i([t, n]), e);
|
|
5314
5328
|
}
|
|
5315
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
5329
|
+
let { generate: n } = await import("./chunks/generate.runtime-tAbxWeq-.js"), r = await n(e), { writeResult: a } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
5316
5330
|
return a(await m(i([t, r]), e), e);
|
|
5317
5331
|
}
|
|
5318
|
-
var
|
|
5319
|
-
version:
|
|
5320
|
-
slug:
|
|
5321
|
-
source:
|
|
5322
|
-
docs:
|
|
5332
|
+
var Tu = {
|
|
5333
|
+
version: xu,
|
|
5334
|
+
slug: bu,
|
|
5335
|
+
source: Su,
|
|
5336
|
+
docs: Cu,
|
|
5323
5337
|
plan: "open",
|
|
5324
5338
|
title: "Enable notifications",
|
|
5325
5339
|
summary: "Adds an in-app notifications collection, a bell dropdown with 30s polling, and a /notifications page for managing read state.",
|
|
@@ -5352,50 +5366,50 @@ var xu = {
|
|
|
5352
5366
|
examples: [],
|
|
5353
5367
|
tests: 6,
|
|
5354
5368
|
baseline: "velastack",
|
|
5355
|
-
generate:
|
|
5356
|
-
}, Su = "/// <reference path=\"../types.d.ts\" />\n\ncronAdd(\"stripe-products\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/products\");\n});\n\ncronAdd(\"stripe-prices\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/prices\");\n});\n", Cu = "/// <reference path=\"../types.d.ts\" />\n\nmodule.exports = {\n triggerJob: (jobUrl) => {\n $http.send({\n method: \"POST\",\n url: `${$app.settings().meta.appURL}${jobUrl}`,\n headers: {\n Authorization: `Bearer ${$os.getenv(\"INTERNAL_JOB_SECRET\")}`,\n },\n });\n },\n};\n", wu = "<script lang=\"ts\">\n import type { Stripe } from '@stripe/stripe-js';\n import { Button } from '$lib/components/ui/button';\n import * as Dialog from '$lib/components/ui/dialog';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n amount: number;\n currency: string;\n brand?: string;\n last4?: string;\n clientSecret?: string;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let {\n stripe,\n open = $bindable(),\n amount,\n currency,\n brand,\n last4,\n clientSecret,\n onopenchange,\n onsuccess\n }: Props = $props();\n\n const brandNames = {\n amex: 'American Express',\n cartes_bancaires: 'Cartes Bancaires',\n diners: 'Diners',\n discover: 'Discover',\n eftpos_au: 'Eftpos Au',\n jcb: 'Jcb',\n link: 'Link',\n mastercard: 'Mastercard',\n unionpay: 'Unionpay',\n visa: 'Visa',\n unknown: 'Unknown'\n };\n\n let isProcessing = $state(false);\n\n let amountFormatted = $derived.by(() => {\n let formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: currency });\n return formatter.format(amount / 100);\n });\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n }\n\n async function handlePaymentMethod() {\n if (!stripe || !clientSecret) return;\n\n isProcessing = true;\n\n try {\n const { error: confirmError } = await stripe.confirmPayment({\n clientSecret,\n confirmParams: {\n return_url: page.url.toString()\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to pay for your purchase');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment successful');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error paying for your purchase:', err);\n toast.error('Failed to pay for your purchase');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <Dialog.Content class=\"sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>Confirm payment</Dialog.Title>\n <Dialog.Description>\n Are you sure you want to pay {amountFormatted} with your\n {brandNames[brand as keyof typeof brandNames]}\n credit card ending in **** {last4}?\n </Dialog.Description>\n </Dialog.Header>\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handlePaymentMethod} disabled={isProcessing}>\n {isProcessing ? 'Processing...' : 'Pay Now'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", Tu = "<script lang=\"ts\">\n import { Button } from '$lib/components/ui/button';\n import PaymentDialog from '$lib/components/payments/payment-dialog.svelte';\n import ConfirmDialog from '$lib/components/payments/confirm-dialog.svelte';\n import { useStripe } from '$lib/components/payments/use-stripe.svelte';\n import { usePaymentIntent } from '$lib/components/payments/use-payment-intent.svelte';\n import type { ButtonProps } from '$lib/components/ui/button';\n\n interface Props {\n priceId: string;\n user?: { email: string; name: string } | null;\n disabled?: boolean;\n isProcessing?: boolean;\n label?: string;\n processingLabel?: string;\n onsuccess?: () => void;\n }\n\n let {\n priceId,\n user,\n disabled = false,\n isProcessing = false,\n label = 'Purchase',\n processingLabel = 'Processing...',\n onsuccess,\n ...rest\n }: Props & ButtonProps = $props();\n\n const stripeManager = useStripe();\n const paymentIntentManager = usePaymentIntent();\n\n let mode = $state<'payment' | 'confirm'>('payment');\n let showDialog = $state(false);\n let amount = $state<number>(0);\n let currency = $state<string>('usd');\n let clientSecret = $state<string>();\n let brand = $state<string>();\n let last4 = $state<string>();\n\n async function handleBuyClick() {\n const result = await paymentIntentManager.fetchPaymentIntent({\n priceId\n });\n\n if (!result) return;\n\n if (result.type === 'confirm') {\n mode = 'confirm';\n brand = result.brand;\n last4 = result.last4;\n } else if (result.type === 'payment') {\n mode = 'payment';\n }\n\n amount = result.amount || 0;\n currency = result.currency || 'usd';\n clientSecret = result.clientSecret;\n showDialog = true;\n }\n\n function handleDialogOpenChange(open: boolean) {\n showDialog = open;\n }\n\n function handlePaymentSuccess() {\n onsuccess?.();\n }\n<\/script>\n\n<Button disabled={disabled || isProcessing} onclick={handleBuyClick} {...rest}>\n {#if isProcessing}\n {processingLabel}\n {:else}\n {label}\n {/if}\n</Button>\n\n{#if mode === 'confirm'}\n <ConfirmDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {amount}\n {currency}\n {brand}\n {last4}\n {clientSecret}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n />\n{:else if mode === 'payment'}\n <PaymentDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {amount}\n {currency}\n {clientSecret}\n {user}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n />\n{/if}\n", Eu = "<script lang=\"ts\">\n import type { Stripe, StripeElements } from '@stripe/stripe-js';\n import { Button } from '$lib/components/ui/button';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Input } from '$lib/components/ui/input';\n import { Label } from '$lib/components/ui/label';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n import StripePaymentForm from './stripe-payment-form.svelte';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n amount: number;\n currency: string;\n clientSecret?: string;\n user?: { email: string; name: string } | null;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let {\n stripe,\n open = $bindable(),\n amount,\n currency,\n clientSecret,\n user = null,\n onopenchange,\n onsuccess\n }: Props = $props();\n\n let isProcessing = $state(false);\n let cardComplete = $state(false);\n let savePaymentMethod = $state(false);\n let email = $state<string>();\n let formRef = $state<{\n getElements: () => StripeElements | null;\n }>();\n\n let amountFormatted = $derived.by(() => {\n let formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: currency });\n return formatter.format(amount / 100);\n });\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n cardComplete = false;\n }\n\n function handleCardChange(complete: boolean) {\n cardComplete = complete;\n }\n\n async function handlePaymentMethod() {\n if (!stripe || !formRef || !cardComplete || !clientSecret) return;\n\n const elements = formRef.getElements();\n if (!elements) return;\n\n isProcessing = true;\n\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n toast.error(submitError.message || 'Failed to pay for your purchase');\n return;\n }\n\n const { error: confirmError } = await stripe.confirmPayment({\n elements,\n clientSecret,\n confirmParams: {\n return_url: page.url.toString(),\n payment_method_data: {\n billing_details: {\n email: email || user?.email\n },\n allow_redisplay: savePaymentMethod ? 'always' : 'unspecified'\n }\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to pay for your purchase');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment successful');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error paying for your purchase:', err);\n toast.error('Failed to pay for your purchase');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <Dialog.Content class=\"sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>{amountFormatted}</Dialog.Title>\n <Dialog.Description>Enter your card details to pay for your purchase.</Dialog.Description>\n </Dialog.Header>\n {#if !user}\n <div class=\"space-y-2\">\n <Label for=\"email\">Email</Label>\n <Input type=\"email\" bind:value={email} />\n </div>\n {/if}\n <div>\n {#if stripe && open}\n <StripePaymentForm\n bind:this={formRef}\n mode=\"payment\"\n {stripe}\n {amount}\n {currency}\n {savePaymentMethod}\n {user}\n onchange={handleCardChange}\n />\n {/if}\n </div>\n {#if user}\n <div class=\"flex items-center gap-2\">\n <input type=\"checkbox\" id=\"savePaymentMethod\" bind:checked={savePaymentMethod} />\n <label for=\"savePaymentMethod\" class=\"text-sm text-muted-foreground\">\n Save payment method for future purchases\n </label>\n </div>\n {/if}\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handlePaymentMethod} disabled={!cardComplete || isProcessing}>\n {isProcessing ? 'Processing...' : 'Pay Now'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", Du = "export const TERMS_AUTO = {\n applePay: \"auto\" as const,\n auBecsDebit: \"auto\" as const,\n bancontact: \"auto\" as const,\n card: \"auto\" as const,\n cashapp: \"auto\" as const,\n googlePay: \"auto\" as const,\n ideal: \"auto\" as const,\n paypal: \"auto\" as const,\n sepaDebit: \"auto\" as const,\n sofort: \"auto\" as const,\n usBankAccount: \"auto\" as const,\n};\n\nexport const TERMS_NEVER = {\n applePay: \"never\" as const,\n auBecsDebit: \"never\" as const,\n bancontact: \"never\" as const,\n card: \"never\" as const,\n cashapp: \"never\" as const,\n googlePay: \"never\" as const,\n ideal: \"never\" as const,\n paypal: \"never\" as const,\n sepaDebit: \"never\" as const,\n sofort: \"never\" as const,\n usBankAccount: \"never\" as const,\n};\n", Ou = "<script lang=\"ts\">\n import type {\n Stripe,\n StripeElements,\n StripePaymentElement,\n StripeElementsOptionsMode\n } from '@stripe/stripe-js';\n import { mode as modeWatcher } from 'mode-watcher';\n import { TERMS_AUTO, TERMS_NEVER } from './stripe-constants';\n import { onMount } from 'svelte';\n\n interface Props {\n stripe: Stripe;\n mode: 'payment' | 'setup';\n amount?: number;\n currency?: string;\n savePaymentMethod?: boolean;\n user?: { email: string; name: string } | null;\n onchange: (complete: boolean) => void;\n }\n\n let {\n stripe,\n mode,\n amount = 0,\n currency = 'usd',\n savePaymentMethod = false,\n user,\n onchange\n }: Props = $props();\n\n let cardContainer = $state<HTMLDivElement | null>(null);\n let elements = $state<StripeElements | null>(null);\n let paymentElement = $state<StripePaymentElement | null>(null);\n\n function initializeElements() {\n if (!stripe) return;\n\n // Clean up previous elements\n if (paymentElement) {\n paymentElement.destroy();\n paymentElement = null;\n }\n\n const appearance = {\n theme: modeWatcher.current === 'dark' ? ('night' as const) : ('stripe' as const),\n inputs: 'condensed' as const,\n labels: 'floating' as const\n };\n\n elements = stripe.elements({\n mode,\n appearance,\n currency,\n ...(mode === 'payment' && {\n amount: amount\n }),\n ...(user || mode === 'setup'\n ? {\n setupFutureUsage: 'off_session' as const\n }\n : {})\n } as StripeElementsOptionsMode);\n\n paymentElement = elements.create('payment', {\n layout: 'tabs',\n defaultValues: {\n billingDetails: {\n email: user?.email,\n name: user?.name\n }\n },\n terms: savePaymentMethod ? TERMS_AUTO : TERMS_NEVER\n });\n\n if (cardContainer && paymentElement) {\n paymentElement.mount(cardContainer);\n paymentElement.on('change', (event: any) => {\n onchange(event.complete);\n });\n }\n }\n\n // Initialize elements when component mounts\n onMount(() => {\n initializeElements();\n\n return () => {\n if (paymentElement) {\n paymentElement.destroy();\n }\n };\n });\n\n // Update terms when savePaymentMethod changes\n $effect(() => {\n if (paymentElement) {\n paymentElement.update({\n terms: savePaymentMethod ? TERMS_AUTO : TERMS_NEVER\n });\n }\n });\n\n export function getElements() {\n return elements;\n }\n<\/script>\n\n<div bind:this={cardContainer}></div>\n", ku = "import { toast } from \"svelte-sonner\";\n\nexport interface PaymentIntentResult {\n type: \"payment\" | \"confirm\";\n amount?: number;\n currency?: string;\n clientSecret?: string;\n brand?: string;\n last4?: string;\n}\n\nexport function usePaymentIntent() {\n let isLoading = $state(false);\n\n async function fetchPaymentIntent({\n priceId,\n }: {\n priceId: string;\n }): Promise<PaymentIntentResult | null> {\n isLoading = true;\n\n const res = await fetch(\"/api/stripe/payment-intent\", {\n method: \"POST\",\n body: JSON.stringify({\n priceId: priceId,\n }),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (!res.ok) {\n toast.error(\"Failed to initialize payment\");\n return null;\n }\n\n return res.json();\n }\n\n async function fetchSetupIntent(): Promise<PaymentIntentResult | null> {\n isLoading = true;\n\n const res = await fetch(\"/api/stripe/setup-intent\", {\n method: \"POST\",\n });\n\n if (!res.ok) {\n toast.error(\"Failed to initialize setup\");\n return null;\n }\n\n return res.json();\n }\n\n return {\n get isLoading() {\n return isLoading;\n },\n fetchPaymentIntent,\n fetchSetupIntent,\n };\n}\n", Au = "import { loadStripe, type Stripe } from \"@stripe/stripe-js\";\nimport { toast } from \"svelte-sonner\";\nimport { env } from \"$env/dynamic/public\";\n\nexport function useStripe() {\n let stripe = $state<Stripe | null>(null);\n let isLoading = $state(true);\n let error = $state<string | null>(null);\n\n async function initialize() {\n try {\n stripe = await loadStripe(env.PUBLIC_STRIPE_PUBLISHABLE_KEY);\n isLoading = false;\n } catch (err) {\n console.error(\"Failed to load Stripe:\", err);\n error = \"Failed to initialize payment system\";\n toast.error(\"Failed to initialize payment system\");\n isLoading = false;\n }\n }\n\n // Auto-initialize\n initialize();\n\n return {\n get stripe() {\n return stripe;\n },\n get isLoading() {\n return isLoading;\n },\n get error() {\n return error;\n },\n };\n}\n", ju = "import { env } from \"$env/dynamic/private\";\nimport Stripe from \"stripe\";\n\nconst stripe = new Stripe(env.STRIPE_SECRET_KEY, {\n apiVersion: \"2026-04-22.dahlia\",\n});\n\nexport default stripe;\n", Mu = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport type { Stripe } from \"stripe\";\n\nconst createPaymentIntent = async (price: Stripe.Price) => {\n if (price.unit_amount === null || price.unit_amount === undefined) {\n console.error(\"Price does not have a per unit amount\");\n throw new Error(\"Price does not have a per unit amount\");\n }\n\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n };\n};\n\nexport const POST = async ({ request, locals }) => {\n let body;\n try {\n body = await request.json();\n } catch (error) {\n console.error(\"Invalid JSON in request body\");\n return json({ error: \"Invalid request body\" }, { status: 400 });\n }\n\n const { priceId } = body as { priceId?: string };\n\n // Validate required fields\n if (!priceId || typeof priceId !== \"string\" || priceId === \"\") {\n console.error(\"Missing or invalid priceId\");\n return json({ error: \"Price ID is required\" }, { status: 400 });\n }\n\n // Retrieve price from Stripe\n let price;\n try {\n price = await stripe.prices.retrieve(priceId);\n } catch (error) {\n console.error(\"Failed to retrieve price from Stripe:\", priceId);\n return json(\n { error: \"Invalid price ID or price not found\" },\n { status: 404 },\n );\n }\n\n // Validate price is active\n if (!price.active) {\n console.error(\"Price is not active:\", priceId);\n return json(\n { error: \"This price is no longer available\" },\n { status: 400 },\n );\n }\n\n try {\n const res = await createPaymentIntent(price);\n return json(res, { status: 200 });\n } catch (error) {\n console.error(\"Error creating payment intent for price:\", priceId);\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to create payment intent\";\n return json({ error: errorMessage }, { status: 500 });\n }\n};\n", Nu = "import { describe, it, expect, beforeAll } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\nimport stripe from \"$lib/stripe\";\nimport type Stripe from \"stripe\";\n\ndescribe(\"POST /api/stripe/payment-intent\", () => {\n let product: Stripe.Product;\n let activePrice: Stripe.Price;\n let inactivePrice: Stripe.Price;\n\n beforeAll(async () => {\n const productName = \"Test Product - Payment Intent\";\n const products = await stripe.products.search({\n query: `name:\"${productName}\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n product = products.data[0];\n\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n\n if (prices.data.length > 0) {\n activePrice = prices.data[0];\n }\n\n const inactivePrices = await stripe.prices.list({\n product: product.id,\n active: false,\n limit: 1,\n });\n\n if (inactivePrices.data.length > 0) {\n inactivePrice = inactivePrices.data[0];\n }\n }\n\n // Create if not found or no active price\n if (!product) {\n product = await stripe.products.create({\n name: productName,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!activePrice) {\n activePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!inactivePrice) {\n inactivePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 2000,\n currency: \"usd\",\n active: false,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent-inactive\",\n },\n });\n }\n });\n\n describe(\"Request validation\", () => {\n it(\"should return 400 if request body is not valid JSON\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .set(\"Content-Type\", \"application/json\")\n .send(\"invalid json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Invalid request body\");\n });\n\n it(\"should return 400 if priceId is missing\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({});\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is not a string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: 12345 });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is an empty string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"\" });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 404 if price does not exist\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"price_nonexistent123\" });\n\n expect(response.status).toBe(404);\n expect(response.body.error).toBe(\"Invalid price ID or price not found\");\n });\n\n it(\"should return 400 if price is not active\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: inactivePrice.id });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"This price is no longer available\");\n });\n });\n\n describe(\"Guest user (unauthenticated)\", () => {\n it(\"should create payment intent for guest user\", async (context) => {\n const response = await context.request\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n\n // Verify the payment intent was created in Stripe\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.currency).toBe(\"usd\");\n expect(intent.customer).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n});\n", Pu = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\n\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const prices = await stripe.prices.list();\n\n for (const price of prices.data) {\n try {\n await locals.admin\n .collection(\"stripe_prices\")\n .getFirstListItem(`id = \"${price.id}\"`);\n continue;\n } catch {}\n\n await locals.admin.collection(\"stripe_prices\").create({\n id: price.id,\n billing_scheme: price.billing_scheme,\n currency: price.currency,\n product: price.product,\n recurring: price.recurring,\n type: price.type,\n unit_amount: price.unit_amount,\n active: price.active,\n });\n }\n\n console.log(\"Prices synced\");\n return json({ message: \"Prices synced\" });\n};\n", Fu = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\n\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const products = await stripe.products.list();\n\n for (const product of products.data) {\n try {\n await locals.admin\n .collection(\"stripe_products\")\n .getFirstListItem(`id = \"${product.id}\"`);\n continue;\n } catch {}\n\n await locals.admin.collection(\"stripe_products\").create({\n id: product.id,\n name: product.name,\n active: product.active,\n default_price: product.default_price,\n });\n }\n\n console.log(\"Products synced\");\n return json({ message: \"Products synced\" });\n};\n", Iu = "import Stripe from \"stripe\";\nimport { json } from \"@sveltejs/kit\";\nimport { env } from \"$env/dynamic/private\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./handlers/payment-intent/succeeded\";\n\nconst processedEvents = new Set<string>();\n\nasync function verifyWebhookSignature(\n request: Request,\n webhookSecret: string,\n): Promise<Stripe.Event> {\n const body = await request.text();\n const signature = request.headers.get(\"stripe-signature\");\n\n if (!signature) {\n throw new Error(\"Missing stripe-signature header\");\n }\n\n if (!webhookSecret) {\n throw new Error(\"Missing webhook secret\");\n }\n\n try {\n return stripe.webhooks.constructEvent(body, signature, webhookSecret);\n } catch (err) {\n console.error(\"Webhook signature verification failed:\", err);\n throw new Error(\"Invalid signature\");\n }\n}\n\nexport const POST = async ({ request, locals }) => {\n try {\n const event = await verifyWebhookSignature(\n request,\n env.STRIPE_WEBHOOK_SECRET,\n );\n\n if (processedEvents.has(event.id)) {\n console.log(`Event ${event.id} already processed, skipping`);\n return json({ received: true, message: \"Event already processed\" });\n }\n\n processedEvents.add(event.id);\n\n console.log(`Processing webhook event: ${event.type} (${event.id})`);\n\n switch (event.type) {\n case \"payment_intent.succeeded\":\n await handlePaymentIntentSucceeded(event.data.object, locals);\n break;\n\n default:\n console.log(`Unhandled event type: ${event.type}`);\n }\n\n return json({\n received: true,\n eventId: event.id,\n eventType: event.type,\n });\n } catch (error) {\n console.error(\"Webhook processing error:\", error);\n\n return json(\n {\n error: \"Webhook processing failed\",\n message: error instanceof Error ? error.message : \"Unknown error\",\n },\n { status: 400 },\n );\n }\n};\n", Lu = "import { describe, it, expect } from \"vitest\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./succeeded\";\n\ndescribe(\"payment_intent.succeeded\", () => {\n it(\"handles a payment intent successfully\", async (context) => {\n const paymentIntent = await stripe.paymentIntents.create({\n amount: 2000,\n currency: \"usd\",\n });\n const locals = { admin: context.admin } as App.Locals;\n const result = await handlePaymentIntentSucceeded(paymentIntent, locals);\n\n expect(result).toEqual({});\n });\n});\n", Ru = "import Stripe from \"stripe\";\n\n/**\n * Handles payment_intent.succeeded event\n */\nexport async function handlePaymentIntentSucceeded(\n paymentIntent: Stripe.PaymentIntent,\n locals: App.Locals,\n) {\n return {};\n}\n", zu = "import { describe, it, expect } from \"vitest\";\nimport type { RouteId } from \"./$types\";\nimport type { Match } from \"@velastack/kit\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\n\ndescribe(\"POST /webhooks/stripe\", () => {\n it(\"accepts valid webhook signature\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET!;\n\n const signature = stripe.webhooks.generateTestHeaderString({\n payload,\n secret: webhookSecret,\n });\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(200);\n expect(response.body.received).toBe(true);\n expect(response.body.eventId).toBe(event.id);\n expect(response.body.eventType).toBe(\"test.event\");\n });\n\n it(\"rejects invalid webhook signature\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", \"invalid_signature\")\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Webhook processing failed\");\n });\n\n it(\"rejects request without signature header\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Webhook processing failed\");\n expect(response.body.message).toBe(\"Missing stripe-signature header\");\n });\n\n it(\"handles duplicate webhook events\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET!;\n const signature = stripe.webhooks.generateTestHeaderString({\n payload,\n secret: webhookSecret,\n });\n\n // Send first webhook\n const response1 = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response1.status).toBe(200);\n expect(response1.body.received).toBe(true);\n\n // Send duplicate webhook\n const response2 = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response2.status).toBe(200);\n expect(response2.body.received).toBe(true);\n expect(response2.body.message).toBe(\"Event already processed\");\n });\n});\n", Bu = "/// <reference path=\"../types.d.ts\" />\n\ncronAdd(\"stripe-products\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/products\");\n});\n\ncronAdd(\"stripe-prices\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/prices\");\n});\n\ncronAdd(\"stripe-customers\", \"* * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/customers\");\n});\n", Vu = "/// <reference path=\"../types.d.ts\" />\n\nmodule.exports = {\n triggerJob: (jobUrl) => {\n $http.send({\n method: \"POST\",\n url: `${$app.settings().meta.appURL}${jobUrl}`,\n headers: {\n Authorization: `Bearer ${$os.getenv(\"INTERNAL_JOB_SECRET\")}`,\n },\n });\n },\n};\n", Hu = "<script lang=\"ts\">\n import { Button } from '$lib/components/ui/button';\n import SetupDialog from '$lib/components/payments/setup-dialog.svelte';\n import { useStripe } from '$lib/components/payments/use-stripe.svelte';\n import { usePaymentIntent } from '$lib/components/payments/use-payment-intent.svelte';\n\n interface Props {\n disabled?: boolean;\n isProcessing?: boolean;\n label?: string;\n processingLabel?: string;\n onsuccess?: () => void;\n }\n\n let {\n disabled = false,\n isProcessing = false,\n label,\n processingLabel,\n onsuccess\n }: Props = $props();\n\n const stripeManager = useStripe();\n const paymentIntentManager = usePaymentIntent();\n\n let showDialog = $state(false);\n let clientSecret = $state<string>();\n\n async function handleSetupClick() {\n const result = await paymentIntentManager.fetchSetupIntent();\n\n if (!result) return;\n\n clientSecret = result.clientSecret;\n showDialog = true;\n }\n\n function handleDialogOpenChange(open: boolean) {\n showDialog = open;\n }\n\n function handlePaymentSuccess() {\n onsuccess?.();\n }\n<\/script>\n\n<Button disabled={disabled || isProcessing} onclick={handleSetupClick}>\n {#if isProcessing}\n {processingLabel}\n {:else}\n {label}\n {/if}\n</Button>\n\n<SetupDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {clientSecret}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n/>\n", Uu = "<script lang=\"ts\">\n import type { Stripe, StripeElements } from '@stripe/stripe-js';\n import { Button } from '$lib/components/ui/button';\n import * as Dialog from '$lib/components/ui/dialog';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n import StripePaymentForm from './stripe-payment-form.svelte';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n clientSecret?: string;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let { stripe, open = $bindable(), clientSecret, onopenchange, onsuccess }: Props = $props();\n\n let isProcessing = $state(false);\n let cardComplete = $state(false);\n let formRef = $state<{\n getElements: () => StripeElements | null;\n }>();\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n cardComplete = false;\n }\n\n function handleCardChange(complete: boolean) {\n cardComplete = complete;\n }\n\n async function handleSetupPaymentMethod() {\n if (!stripe || !formRef || !cardComplete || !clientSecret) return;\n\n const elements = formRef.getElements();\n if (!elements) return;\n\n isProcessing = true;\n\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n toast.error(submitError.message || 'Failed to add payment method');\n return;\n }\n\n const { error: confirmError } = await stripe.confirmSetup({\n elements,\n clientSecret,\n confirmParams: {\n return_url: page.url.toString(),\n payment_method_data: {\n allow_redisplay: 'always'\n }\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to add payment method');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment method added successfully');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error adding payment method:', err);\n toast.error('Failed to add payment method');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <Dialog.Content class=\"sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>Add payment method</Dialog.Title>\n <Dialog.Description>Enter your card details to add a new payment method.</Dialog.Description>\n </Dialog.Header>\n <div>\n {#if stripe && open}\n <StripePaymentForm\n bind:this={formRef}\n mode=\"setup\"\n {stripe}\n onchange={handleCardChange}\n savePaymentMethod={true}\n />\n {/if}\n </div>\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handleSetupPaymentMethod} disabled={!cardComplete || isProcessing}>\n {isProcessing ? 'Processing...' : 'Add Card'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", Wu = "export const load = async ({ parent }) => {\n const { breadcrumbs } = await parent();\n\n return {\n breadcrumbs: [...breadcrumbs, { title: \"Billing\", url: \"/billing\" }],\n };\n};\n", Gu = "# Billing Page - Stripe Payment Methods\n\nThis billing page provides a modern UI for managing payment methods with Stripe.\n\n## Features\n\n✅ **Display Payment Methods** - Shows all saved cards with brand, last 4 digits, and expiration\n✅ **Add Payment Methods** - Secure card input using Stripe Elements\n✅ **Remove Payment Methods** - Delete cards with confirmation dialog\n✅ **Default Payment Method** - Set and display the default payment method\n✅ **Responsive Design** - Mobile-friendly layout\n✅ **Error Handling** - Toast notifications for user feedback\n\n## Current Status\n\nThe frontend is **fully functional** with mock data. To connect to your backend, follow the integration steps below.\n\n## Backend Integration\n\n### 1. Update Stripe Publishable Key\n\nIn `+page.svelte`, replace the placeholder with your actual Stripe publishable key:\n\n```typescript\nconst STRIPE_PUBLISHABLE_KEY = \"pk_test_YOUR_KEY_HERE\";\n```\n\nOr better yet, load it from environment variables:\n\n```typescript\nimport { env } from \"$env/dynamic/public\";\nconst STRIPE_PUBLISHABLE_KEY = env.PUBLIC_STRIPE_PUBLISHABLE_KEY;\n```\n\n### 2. Fetch Payment Methods on Load\n\nUpdate `+page.server.ts` to fetch payment methods:\n\n```typescript\nexport const load: PageServerLoad = async ({ locals }) => {\n const user = locals.user;\n\n if (!user?.stripeCustomerId) {\n return { paymentMethods: [] };\n }\n\n // Fetch payment methods from Stripe\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n const paymentMethods = await stripe.paymentMethods.list({\n customer: user.stripeCustomerId,\n type: \"card\",\n });\n\n return {\n paymentMethods: paymentMethods.data.map((pm) => ({\n id: pm.id,\n brand: pm.card?.brand || \"unknown\",\n last4: pm.card?.last4 || \"0000\",\n expMonth: pm.card?.exp_month || 1,\n expYear: pm.card?.exp_year || 2025,\n isDefault: false, // You'll need to track this separately\n })),\n };\n};\n```\n\n### 3. Create API Endpoints\n\nCreate the following server endpoints:\n\n#### Add Payment Method: `+page.server.ts`\n\n```typescript\nexport const actions = {\n addPaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Attach payment method to customer\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n await stripe.paymentMethods.attach(paymentMethodId, {\n customer: locals.user.stripeCustomerId,\n });\n\n return { success: true };\n },\n\n removePaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Detach payment method from customer\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n await stripe.paymentMethods.detach(paymentMethodId);\n\n return { success: true };\n },\n\n setDefaultPaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Update customer's default payment method\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n await stripe.customers.update(locals.user.stripeCustomerId, {\n invoice_settings: {\n default_payment_method: paymentMethodId,\n },\n });\n\n return { success: true };\n },\n};\n```\n\n### 4. Update Frontend to Use Actions\n\nReplace the mock functions in `+page.svelte`:\n\n```typescript\nasync function handleAddPaymentMethod() {\n if (!stripe || !cardElement || !cardComplete) return;\n\n isProcessing = true;\n\n try {\n const { error, paymentMethod } = await stripe.createPaymentMethod({\n type: \"card\",\n card: cardElement,\n });\n\n if (error) {\n toast.error(error.message);\n return;\n }\n\n // Submit to your backend\n const formData = new FormData();\n formData.append(\"paymentMethodId\", paymentMethod.id);\n\n const response = await fetch(\"?/addPaymentMethod\", {\n method: \"POST\",\n body: formData,\n });\n\n if (response.ok) {\n toast.success(\"Payment method added\");\n // Reload page to fetch updated payment methods\n window.location.reload();\n }\n } finally {\n isProcessing = false;\n }\n}\n```\n\n## Security Considerations\n\n⚠️ **Important**: Never expose your Stripe secret key on the frontend\n✅ All sensitive operations should happen on your backend\n✅ Use Stripe's publishable key for frontend operations\n✅ Validate user permissions before modifying payment methods\n✅ Use HTTPS in production\n\n## Testing\n\nUse [Stripe's test cards](https://stripe.com/docs/testing) for testing:\n\n- **Success**: 4242 4242 4242 4242\n- **Decline**: 4000 0000 0000 0002\n- **Requires authentication**: 4000 0025 0000 3155\n\nUse any future expiration date and any 3-digit CVC.\n\n## Styling\n\nThe page uses Tailwind CSS and shadcn/ui components. All components are styled to match your existing design system with support for light/dark modes.\n\n### Stripe Elements Styling\n\nSince Stripe Elements render in an iframe, they cannot access CSS variables directly. Additionally, Stripe only accepts HEX, RGB, or HSL colors (not modern formats like OKLCH).\n\nThe implementation:\n\n1. **Creates temporary DOM elements** with CSS variables applied\n2. **Lets the browser compute colors** - converts OKLCH/HSL/any format to RGB\n3. **Extracts RGB values** that Stripe Elements can understand\n4. **Passes computed colors** to Stripe Elements on initialization\n5. **Matches the current theme** automatically (light/dark mode)\n\nThis approach works with any CSS color format (oklch, hsl, rgb, hex) and ensures Stripe Elements always match your theme when the \"Add Payment Method\" dialog opens.\n\n## Dependencies\n\n- `@stripe/stripe-js` - Stripe.js for frontend\n- `stripe` - Stripe Node.js SDK for backend\n- `svelte-sonner` - Toast notifications\n- `@lucide/svelte` - Icons\n- shadcn/ui components\n", Ku = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport type { Stripe } from \"stripe\";\n\nconst createPaymentIntent = async (\n price: Stripe.Price,\n customer?: { id: string; default_payment_method?: string },\n) => {\n if (price.unit_amount === null || price.unit_amount === undefined) {\n console.error(\"Price does not have a per unit amount\");\n throw new Error(\"Price does not have a per unit amount\");\n }\n\n // Guest\n if (!customer) {\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n };\n }\n\n // Customer with saved payment method\n if (customer.default_payment_method) {\n const paymentMethod = await stripe.customers.retrievePaymentMethod(\n customer.id,\n customer.default_payment_method,\n );\n\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n customer: customer.id,\n payment_method: customer.default_payment_method,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n return {\n type: \"confirm\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n };\n }\n\n // Customer without saved payment method\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n customer: customer.id,\n setup_future_usage: \"off_session\",\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n };\n};\n\nexport const POST = async ({ request, locals }) => {\n const user = locals.pb.authStore.record?.id;\n\n let body;\n try {\n body = await request.json();\n } catch (error) {\n console.error(\"Invalid JSON in request body\");\n return json({ error: \"Invalid request body\" }, { status: 400 });\n }\n\n const { priceId } = body as { priceId?: string };\n\n // Validate required fields\n if (!priceId || typeof priceId !== \"string\" || priceId === \"\") {\n console.error(\"Missing or invalid priceId\");\n return json({ error: \"Price ID is required\" }, { status: 400 });\n }\n\n // Retrieve price from Stripe\n let price;\n try {\n price = await stripe.prices.retrieve(priceId);\n } catch (error) {\n console.error(\"Failed to retrieve price from Stripe:\", priceId);\n return json(\n { error: \"Invalid price ID or price not found\" },\n { status: 404 },\n );\n }\n\n // Validate price is active\n if (!price.active) {\n console.error(\"Price is not active:\", priceId);\n return json(\n { error: \"This price is no longer available\" },\n { status: 400 },\n );\n }\n\n let customer;\n\n if (user) {\n try {\n customer = await locals.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(\n locals.admin.filter(\"user = {:user}\", { user: user }),\n );\n } catch (error) {\n // Customer not found is expected for new users, log for debugging only\n console.log(\"No Stripe customer found for user:\", user);\n }\n }\n\n try {\n const res = await createPaymentIntent(price, customer);\n return json(res, { status: 200 });\n } catch (error) {\n console.error(\"Error creating payment intent for price:\", priceId);\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to create payment intent\";\n return json({ error: errorMessage }, { status: 500 });\n }\n};\n", qu = "import { describe, it, expect, beforeAll, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\nimport stripe from \"$lib/stripe\";\nimport type Stripe from \"stripe\";\n\ndescribe(\"POST /api/stripe/payment-intent\", () => {\n let product: Stripe.Product;\n let activePrice: Stripe.Price;\n let inactivePrice: Stripe.Price;\n let stripeCustomer: Stripe.Customer;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeAll(async () => {\n const productName = \"Test Product - Payment Intent\";\n const products = await stripe.products.search({\n query: `name:\"${productName}\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n product = products.data[0];\n\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n\n if (prices.data.length > 0) {\n activePrice = prices.data[0];\n }\n\n const inactivePrices = await stripe.prices.list({\n product: product.id,\n active: false,\n limit: 1,\n });\n\n if (inactivePrices.data.length > 0) {\n inactivePrice = inactivePrices.data[0];\n }\n }\n\n // Create if not found or no active price\n if (!product) {\n product = await stripe.products.create({\n name: productName,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!activePrice) {\n activePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!inactivePrice) {\n inactivePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 2000,\n currency: \"usd\",\n active: false,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent-inactive\",\n },\n });\n }\n });\n\n beforeEach(async (context) => {\n // Create a Stripe customer for authenticated user tests\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n // Create a payment method for the customer\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n });\n\n afterEach(async () => {\n if (paymentMethod?.id) {\n await stripe.paymentMethods.detach(paymentMethod.id);\n }\n\n if (stripeCustomer?.id) {\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n describe(\"Request validation\", () => {\n it(\"should return 400 if request body is not valid JSON\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .set(\"Content-Type\", \"application/json\")\n .send(\"invalid json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Invalid request body\");\n });\n\n it(\"should return 400 if priceId is missing\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({});\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is not a string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: 12345 });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is an empty string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"\" });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 404 if price does not exist\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"price_nonexistent123\" });\n\n expect(response.status).toBe(404);\n expect(response.body.error).toBe(\"Invalid price ID or price not found\");\n });\n\n it(\"should return 400 if price is not active\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: inactivePrice.id });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"This price is no longer available\");\n });\n });\n\n describe(\"Guest user (unauthenticated)\", () => {\n it(\"should create payment intent for guest user\", async (context) => {\n const response = await context.request\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n\n // Verify the payment intent was created in Stripe\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.currency).toBe(\"usd\");\n expect(intent.customer).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n\n describe(\"Authenticated user without Stripe customer\", () => {\n it(\"should create payment intent for user without Stripe customer\", async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n\n // Verify the payment intent\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.setup_future_usage).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n\n describe(\"Authenticated user with Stripe customer\", () => {\n let customerRecord: { id: string };\n\n beforeEach(async (context) => {\n // Link the Stripe customer to the PocketBase user\n customerRecord = await context.admin\n .collection(\"stripe_customers\")\n .create({\n user: context.user.id,\n id: stripeCustomer.id,\n email: stripeCustomer.email,\n });\n });\n\n afterEach(async (context) => {\n // Clean up the PocketBase customer record\n await context.admin\n .collection(\"stripe_customers\")\n .delete(customerRecord.id);\n });\n\n it(\"should create payment intent with setup_future_usage for user without default payment method\", async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n\n // Verify the payment intent has setup_future_usage\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.customer).toBe(stripeCustomer.id);\n expect(intent.setup_future_usage).toBe(\"off_session\");\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n\n it(\"should create payment intent with default payment method for customer with saved payment method\", async (context) => {\n // Set default payment method\n await stripe.customers.update(stripeCustomer.id, {\n invoice_settings: {\n default_payment_method: paymentMethod.id,\n },\n });\n\n const customerRecord = await context.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(\n context.admin.filter(\"user = {:user}\", { user: context.user.id }),\n );\n\n await context.admin.collection(\"stripe_payment_methods\").create({\n id: paymentMethod.id,\n customer: customerRecord.id,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n exp_month: paymentMethod.card?.exp_month,\n exp_year: paymentMethod.card?.exp_year,\n });\n\n await context.admin\n .collection(\"stripe_customers\")\n .update(customerRecord.id, {\n default_payment_method: paymentMethod.id,\n });\n\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"confirm\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBe(\"visa\");\n expect(response.body.last4).toBeDefined();\n expect(response.body.last4).toMatch(/^\\d{4}$/);\n\n // Verify the payment intent has the payment method attached\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.customer).toBe(stripeCustomer.id);\n expect(intent.payment_method).toBe(paymentMethod.id);\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n});\n", Ju = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\n\nexport const POST = async ({ locals }) => {\n const user = locals.pb.authStore.record?.id;\n\n if (!user) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(locals.admin.filter(\"user = {:user}\", { user }));\n\n if (!customer) {\n return json({ error: \"Customer not found\" }, { status: 404 });\n }\n\n const setupIntent = await stripe.setupIntents.create({\n customer: customer.id,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n return json({ clientSecret: setupIntent.client_secret });\n};\n", Yu = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"POST /api/stripe/setup-intent\", () => {\n let stripeCustomer: Stripe.Customer;\n\n beforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n });\n\n afterEach(async (context) => {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n });\n\n it(\"creates a setup intent\", async (context) => {\n const response = await context.agent.post(\n \"/api/stripe/setup-intent\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n expect(response.body.clientSecret).toBeDefined();\n });\n});\n", Xu = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\n\n// Sync users to Stripe customers\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n // Ensure all users have a Stripe customer\n const users = await locals.admin\n .collection(\"users\")\n .getFullList({ filter: \"stripe_customers_via_user.id = null\" });\n\n for (const user of users) {\n const customer = await stripe.customers.create({\n email: user.email,\n name: user.name,\n });\n\n await locals.admin.collection(\"stripe_customers\").create({\n id: customer.id,\n user: user.id,\n });\n }\n\n console.log(\"Customers synced\");\n return json({ message: \"Customers synced\" });\n};\n", Zu = "import Stripe from \"stripe\";\nimport { json } from \"@sveltejs/kit\";\nimport { env } from \"$env/dynamic/private\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./handlers/payment-intent/succeeded\";\nimport { handlePaymentMethodAttached } from \"./handlers/payment-method/attached\";\n\nconst processedEvents = new Set<string>();\n\nasync function verifyWebhookSignature(\n request: Request,\n webhookSecret: string,\n): Promise<Stripe.Event> {\n const body = await request.text();\n const signature = request.headers.get(\"stripe-signature\");\n\n if (!signature) {\n throw new Error(\"Missing stripe-signature header\");\n }\n\n if (!webhookSecret) {\n throw new Error(\"Missing webhook secret\");\n }\n\n try {\n return stripe.webhooks.constructEvent(body, signature, webhookSecret);\n } catch (err) {\n console.error(\"Webhook signature verification failed:\", err);\n throw new Error(\"Invalid signature\");\n }\n}\n\nexport const POST = async ({ request, locals }) => {\n try {\n const event = await verifyWebhookSignature(\n request,\n env.STRIPE_WEBHOOK_SECRET,\n );\n\n if (processedEvents.has(event.id)) {\n console.log(`Event ${event.id} already processed, skipping`);\n return json({ received: true, message: \"Event already processed\" });\n }\n\n processedEvents.add(event.id);\n\n console.log(`Processing webhook event: ${event.type} (${event.id})`);\n\n switch (event.type) {\n case \"payment_intent.succeeded\":\n await handlePaymentIntentSucceeded(event.data.object, locals);\n break;\n\n case \"payment_method.attached\":\n await handlePaymentMethodAttached(event.data.object, locals);\n break;\n\n default:\n console.log(`Unhandled event type: ${event.type}`);\n }\n\n return json({\n received: true,\n eventId: event.id,\n eventType: event.type,\n });\n } catch (error) {\n console.error(\"Webhook processing error:\", error);\n\n return json(\n {\n error: \"Webhook processing failed\",\n message: error instanceof Error ? error.message : \"Unknown error\",\n },\n { status: 400 },\n );\n }\n};\n", Qu = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./succeeded\";\n\ndescribe(\"payment_intent.succeeded\", () => {\n let stripeCustomer: Stripe.Customer;\n let paymentIntent: Stripe.PaymentIntent;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeEach(async (context) => {\n // Create a Stripe customer\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n // Link the Stripe customer to the test user\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n\n // Create a payment method for testing\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n // Attach payment method to customer\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n // Create a payment intent\n paymentIntent = await stripe.paymentIntents.create({\n amount: 2000, // $20.00\n currency: \"usd\",\n customer: stripeCustomer.id,\n payment_method: paymentMethod.id,\n confirm: true,\n return_url: \"https://example.com/return\",\n });\n });\n\n afterEach(async (context) => {\n // Clean up transactions\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\"stripe_customer = {:stripeCustomer}\", {\n stripeCustomer: stripeCustomer.id,\n }),\n });\n for (const transaction of transactions) {\n await context.admin.collection(\"transactions\").delete(transaction.id);\n }\n\n // Clean up Stripe resources\n if (paymentMethod?.id) {\n try {\n await stripe.paymentMethods.detach(paymentMethod.id);\n } catch (e) {\n // Payment method may already be detached\n }\n }\n\n // Delete customer (this will also delete associated payment methods)\n if (stripeCustomer?.id) {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n it(\"creates a transaction record when payment intent succeeds\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n const transaction = transactions[0];\n\n expect(transaction.stripe_payment_intent).toBe(paymentIntent.id);\n expect(transaction.stripe_customer).toBe(stripeCustomer.id);\n expect(transaction.amount).toBe(2000);\n expect(transaction.currency).toBe(\"usd\");\n expect(transaction.user).toBe(context.user.id);\n expect(transaction.stripe_charge).toBeDefined();\n expect(transaction.last4).toBeDefined();\n expect(transaction.brand).toBeDefined();\n expect(transaction.created).toBeDefined();\n expect(transaction.receipt_url).toBeDefined();\n });\n\n it(\"handles payment intent with charge object instead of string\", async (context) => {\n // Retrieve the payment intent with expanded charge\n const expandedPaymentIntent = await stripe.paymentIntents.retrieve(\n paymentIntent.id,\n {\n expand: [\"latest_charge\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(expandedPaymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n const transaction = transactions[0];\n\n expect(transaction.stripe_payment_intent).toBe(paymentIntent.id);\n expect(transaction.stripe_charge).toBeDefined();\n });\n\n it(\"handles payment intent with customer object instead of string\", async (context) => {\n // Retrieve the payment intent with expanded customer\n const expandedPaymentIntent = await stripe.paymentIntents.retrieve(\n paymentIntent.id,\n {\n expand: [\"customer\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(expandedPaymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n expect(transactions[0].stripe_customer).toBe(stripeCustomer.id);\n });\n\n it(\"handles missing charge ID gracefully\", async (context) => {\n const paymentIntentWithoutCharge = {\n ...paymentIntent,\n latest_charge: null,\n } as Stripe.PaymentIntent;\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntentWithoutCharge, locals);\n\n // Verify no transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(0);\n });\n\n it(\"handles missing customer ID gracefully\", async (context) => {\n const paymentIntentWithoutCustomer = {\n ...paymentIntent,\n customer: null,\n } as Stripe.PaymentIntent;\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntentWithoutCustomer, locals);\n\n // Verify no transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(0);\n });\n});\n", $u = "import Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\n/**\n * Handles payment_intent.succeeded event\n */\nexport async function handlePaymentIntentSucceeded(\n paymentIntent: Stripe.PaymentIntent,\n locals: App.Locals,\n) {\n const chargeId =\n typeof paymentIntent.latest_charge === \"string\"\n ? paymentIntent.latest_charge\n : paymentIntent.latest_charge?.id;\n\n if (!chargeId) {\n console.error(\"No charge ID found for payment intent\");\n return;\n }\n\n const charge = await stripe.charges.retrieve(chargeId);\n\n const customerId =\n typeof paymentIntent.customer === \"string\"\n ? paymentIntent.customer\n : paymentIntent.customer?.id;\n\n if (!customerId) {\n console.error(\"No customer ID found for payment intent\");\n return;\n }\n\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getOne(customerId);\n const created = new Date(charge.created * 1000);\n\n await locals.admin.collection(\"transactions\").create({\n stripe_payment_intent: paymentIntent.id,\n stripe_charge: chargeId,\n stripe_customer: customerId,\n amount: paymentIntent.amount,\n currency: paymentIntent.currency,\n created: created.toISOString(),\n last4: charge.payment_method_details?.card?.last4,\n brand: charge.payment_method_details?.card?.brand,\n receipt_url: charge.receipt_url,\n user: customer.user,\n });\n}\n", ed = "import Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\n\n/**\n * Handles payment_method.attached event\n */\nexport async function handlePaymentMethodAttached(\n paymentMethod: Stripe.PaymentMethod,\n locals: App.Locals,\n) {\n if (\n paymentMethod.allow_redisplay === \"unspecified\" ||\n !paymentMethod.customer\n ) {\n return;\n }\n\n const customer =\n typeof paymentMethod.customer === \"string\"\n ? paymentMethod.customer\n : paymentMethod.customer?.id;\n\n await locals.admin.collection(\"stripe_payment_methods\").create({\n id: paymentMethod.id,\n customer: customer,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n exp_month: paymentMethod.card?.exp_month,\n exp_year: paymentMethod.card?.exp_year,\n });\n\n const paymentMethodRecords = await locals.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: locals.admin.filter(\"customer = {:customer}\", {\n customer: customer,\n }),\n });\n\n if (paymentMethodRecords.length === 1) {\n const paymentMethod = paymentMethodRecords[0];\n\n await stripe.customers.update(customer, {\n invoice_settings: {\n default_payment_method: paymentMethod.id,\n },\n });\n\n await locals.admin.collection(\"stripe_customers\").update(customer, {\n default_payment_method: paymentMethod.id,\n });\n }\n}\n", td = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentMethodAttached } from \"./attached\";\n\ndescribe(\"payment_method.attached\", () => {\n let stripeCustomer: Stripe.Customer;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeEach(async (context) => {\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n paymentMethod = await stripe.paymentMethods.update(paymentMethod.id, {\n allow_redisplay: \"always\",\n });\n });\n\n afterEach(async (context) => {\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"customer = {:stripeCustomer}\", {\n stripeCustomer: stripeCustomer.id,\n }),\n });\n\n for (const pm of paymentMethods) {\n await context.admin.collection(\"stripe_payment_methods\").delete(pm.id);\n }\n\n if (paymentMethod?.id) {\n try {\n await stripe.paymentMethods.detach(paymentMethod.id);\n } catch {}\n }\n\n if (stripeCustomer?.id) {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n it(\"creates a payment method record when payment method is attached\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(1);\n const pm = paymentMethods[0];\n\n expect(pm.id).toBe(paymentMethod.id);\n expect(pm.customer).toBe(stripeCustomer.id);\n expect(pm.brand).toBe(paymentMethod.card?.brand);\n expect(pm.last4).toBe(paymentMethod.card?.last4);\n expect(pm.exp_month).toBe(paymentMethod.card?.exp_month);\n expect(pm.exp_year).toBe(paymentMethod.card?.exp_year);\n });\n\n it(\"sets payment method as default when it is the first one\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify it was set as default in database\n const customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Verify it was set as default in Stripe\n const stripeCustomerUpdated = await stripe.customers.retrieve(\n stripeCustomer.id,\n );\n if (\"deleted\" in stripeCustomerUpdated) {\n throw new Error(\"Customer should not be deleted\");\n }\n expect(stripeCustomerUpdated.invoice_settings.default_payment_method).toBe(\n paymentMethod.id,\n );\n });\n\n it(\"does not set as default when there are already payment methods\", async (context) => {\n // Handle the first payment method\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify it was set as default\n let customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Create and attach a first payment method\n let secondPaymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_mastercard\",\n },\n });\n\n await stripe.paymentMethods.attach(secondPaymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n secondPaymentMethod = await stripe.paymentMethods.update(\n secondPaymentMethod.id,\n {\n allow_redisplay: \"always\",\n },\n );\n\n // Now handle the second payment method\n await handlePaymentMethodAttached(secondPaymentMethod, locals);\n\n // Verify the default did NOT change\n customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Clean up the second payment method\n await context.admin\n .collection(\"stripe_payment_methods\")\n .delete(secondPaymentMethod.id);\n await stripe.paymentMethods.detach(secondPaymentMethod.id);\n });\n\n it(\"handles payment method with customer object instead of string\", async (context) => {\n // Retrieve the payment method with expanded customer\n const expandedPaymentMethod = await stripe.paymentMethods.retrieve(\n paymentMethod.id,\n {\n expand: [\"customer\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(expandedPaymentMethod, locals);\n\n // Verify payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(1);\n expect(paymentMethods[0].customer).toBe(stripeCustomer.id);\n });\n\n it(\"does not create record when allow_redisplay is unspecified\", async (context) => {\n // Update payment method to have unspecified allow_redisplay\n const unspecifiedPaymentMethod = await stripe.paymentMethods.update(\n paymentMethod.id,\n {\n allow_redisplay: \"unspecified\",\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(unspecifiedPaymentMethod, locals);\n\n // Verify no payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(0);\n });\n});\n", nd = /* #__PURE__ */ Object.assign({
|
|
5357
|
-
"./creates/data/hooks/stripe.pb.js":
|
|
5358
|
-
"./creates/data/hooks/utils.js":
|
|
5359
|
-
"./creates/src/lib/components/payments/confirm-dialog.svelte":
|
|
5360
|
-
"./creates/src/lib/components/payments/payment-button.svelte":
|
|
5361
|
-
"./creates/src/lib/components/payments/payment-dialog.svelte":
|
|
5362
|
-
"./creates/src/lib/components/payments/stripe-constants.ts":
|
|
5363
|
-
"./creates/src/lib/components/payments/stripe-payment-form.svelte":
|
|
5364
|
-
"./creates/src/lib/components/payments/use-payment-intent.svelte.ts":
|
|
5365
|
-
"./creates/src/lib/components/payments/use-stripe.svelte.ts":
|
|
5366
|
-
"./creates/src/lib/stripe.ts":
|
|
5367
|
-
"./creates/src/routes/api/stripe/payment-intent/+server.ts":
|
|
5368
|
-
"./creates/src/routes/api/stripe/payment-intent/server.test.ts":
|
|
5369
|
-
"./creates/src/routes/api/stripe/sync/prices/+server.ts":
|
|
5370
|
-
"./creates/src/routes/api/stripe/sync/products/+server.ts":
|
|
5371
|
-
"./creates/src/routes/webhooks/stripe/+server.ts":
|
|
5372
|
-
"./creates/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts":
|
|
5373
|
-
"./creates/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts":
|
|
5374
|
-
"./creates/src/routes/webhooks/stripe/server.test.ts":
|
|
5375
|
-
}),
|
|
5376
|
-
"./creates-app-mode/data/hooks/stripe.pb.js":
|
|
5377
|
-
"./creates-app-mode/data/hooks/utils.js":
|
|
5378
|
-
"./creates-app-mode/src/lib/components/payments/setup-button.svelte":
|
|
5379
|
-
"./creates-app-mode/src/lib/components/payments/setup-dialog.svelte":
|
|
5380
|
-
"./creates-app-mode/src/routes/(app)/billing/+layout.server.ts":
|
|
5369
|
+
generate: wu
|
|
5370
|
+
}, Eu = "/// <reference path=\"../types.d.ts\" />\n\ncronAdd(\"stripe-products\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/products\");\n});\n\ncronAdd(\"stripe-prices\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/prices\");\n});\n", Du = "/// <reference path=\"../types.d.ts\" />\n\nmodule.exports = {\n triggerJob: (jobUrl) => {\n $http.send({\n method: \"POST\",\n url: `${$app.settings().meta.appURL}${jobUrl}`,\n headers: {\n Authorization: `Bearer ${$os.getenv(\"INTERNAL_JOB_SECRET\")}`,\n },\n });\n },\n};\n", Ou = "<script lang=\"ts\">\n import type { Stripe } from '@stripe/stripe-js';\n import { Button } from '$lib/components/ui/button';\n import * as Dialog from '$lib/components/ui/dialog';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n amount: number;\n currency: string;\n brand?: string;\n last4?: string;\n clientSecret?: string;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let {\n stripe,\n open = $bindable(),\n amount,\n currency,\n brand,\n last4,\n clientSecret,\n onopenchange,\n onsuccess\n }: Props = $props();\n\n const brandNames = {\n amex: 'American Express',\n cartes_bancaires: 'Cartes Bancaires',\n diners: 'Diners',\n discover: 'Discover',\n eftpos_au: 'Eftpos Au',\n jcb: 'Jcb',\n link: 'Link',\n mastercard: 'Mastercard',\n unionpay: 'Unionpay',\n visa: 'Visa',\n unknown: 'Unknown'\n };\n\n let isProcessing = $state(false);\n\n let amountFormatted = $derived.by(() => {\n let formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: currency });\n return formatter.format(amount / 100);\n });\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n }\n\n async function handlePaymentMethod() {\n if (!stripe || !clientSecret) return;\n\n isProcessing = true;\n\n try {\n const { error: confirmError } = await stripe.confirmPayment({\n clientSecret,\n confirmParams: {\n return_url: page.url.toString()\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to pay for your purchase');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment successful');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error paying for your purchase:', err);\n toast.error('Failed to pay for your purchase');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <Dialog.Content class=\"sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>Confirm payment</Dialog.Title>\n <Dialog.Description>\n Are you sure you want to pay {amountFormatted} with your\n {brandNames[brand as keyof typeof brandNames]}\n credit card ending in **** {last4}?\n </Dialog.Description>\n </Dialog.Header>\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handlePaymentMethod} disabled={isProcessing}>\n {isProcessing ? 'Processing...' : 'Pay Now'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", ku = "<script lang=\"ts\">\n import { Button } from '$lib/components/ui/button';\n import PaymentDialog from '$lib/components/payments/payment-dialog.svelte';\n import ConfirmDialog from '$lib/components/payments/confirm-dialog.svelte';\n import { useStripe } from '$lib/components/payments/use-stripe.svelte';\n import { usePaymentIntent } from '$lib/components/payments/use-payment-intent.svelte';\n import type { ButtonProps } from '$lib/components/ui/button';\n\n interface Props {\n priceId: string;\n user?: { email: string; name: string } | null;\n disabled?: boolean;\n isProcessing?: boolean;\n label?: string;\n processingLabel?: string;\n onsuccess?: () => void;\n }\n\n let {\n priceId,\n user,\n disabled = false,\n isProcessing = false,\n label = 'Purchase',\n processingLabel = 'Processing...',\n onsuccess,\n ...rest\n }: Props & ButtonProps = $props();\n\n const stripeManager = useStripe();\n const paymentIntentManager = usePaymentIntent();\n\n let mode = $state<'payment' | 'confirm'>('payment');\n let showDialog = $state(false);\n let amount = $state<number>(0);\n let currency = $state<string>('usd');\n let clientSecret = $state<string>();\n let brand = $state<string>();\n let last4 = $state<string>();\n\n async function handleBuyClick() {\n const result = await paymentIntentManager.fetchPaymentIntent({\n priceId\n });\n\n if (!result) return;\n\n if (result.type === 'confirm') {\n mode = 'confirm';\n brand = result.brand;\n last4 = result.last4;\n } else if (result.type === 'payment') {\n mode = 'payment';\n }\n\n amount = result.amount || 0;\n currency = result.currency || 'usd';\n clientSecret = result.clientSecret;\n showDialog = true;\n }\n\n function handleDialogOpenChange(open: boolean) {\n showDialog = open;\n }\n\n function handlePaymentSuccess() {\n onsuccess?.();\n }\n<\/script>\n\n<Button disabled={disabled || isProcessing} onclick={handleBuyClick} {...rest}>\n {#if isProcessing}\n {processingLabel}\n {:else}\n {label}\n {/if}\n</Button>\n\n{#if mode === 'confirm'}\n <ConfirmDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {amount}\n {currency}\n {brand}\n {last4}\n {clientSecret}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n />\n{:else if mode === 'payment'}\n <PaymentDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {amount}\n {currency}\n {clientSecret}\n {user}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n />\n{/if}\n", Au = "<script lang=\"ts\">\n import type { Stripe, StripeElements } from '@stripe/stripe-js';\n import { Button } from '$lib/components/ui/button';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Input } from '$lib/components/ui/input';\n import { Label } from '$lib/components/ui/label';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n import StripePaymentForm from './stripe-payment-form.svelte';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n amount: number;\n currency: string;\n clientSecret?: string;\n user?: { email: string; name: string } | null;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let {\n stripe,\n open = $bindable(),\n amount,\n currency,\n clientSecret,\n user = null,\n onopenchange,\n onsuccess\n }: Props = $props();\n\n let isProcessing = $state(false);\n let cardComplete = $state(false);\n let savePaymentMethod = $state(false);\n let email = $state<string>();\n let formRef = $state<{\n getElements: () => StripeElements | null;\n }>();\n\n let amountFormatted = $derived.by(() => {\n let formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: currency });\n return formatter.format(amount / 100);\n });\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n cardComplete = false;\n }\n\n function handleCardChange(complete: boolean) {\n cardComplete = complete;\n }\n\n async function handlePaymentMethod() {\n if (!stripe || !formRef || !cardComplete || !clientSecret) return;\n\n const elements = formRef.getElements();\n if (!elements) return;\n\n isProcessing = true;\n\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n toast.error(submitError.message || 'Failed to pay for your purchase');\n return;\n }\n\n const { error: confirmError } = await stripe.confirmPayment({\n elements,\n clientSecret,\n confirmParams: {\n return_url: page.url.toString(),\n payment_method_data: {\n billing_details: {\n email: email || user?.email\n },\n allow_redisplay: savePaymentMethod ? 'always' : 'unspecified'\n }\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to pay for your purchase');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment successful');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error paying for your purchase:', err);\n toast.error('Failed to pay for your purchase');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <Dialog.Content class=\"sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>{amountFormatted}</Dialog.Title>\n <Dialog.Description>Enter your card details to pay for your purchase.</Dialog.Description>\n </Dialog.Header>\n {#if !user}\n <div class=\"space-y-2\">\n <Label for=\"email\">Email</Label>\n <Input type=\"email\" bind:value={email} />\n </div>\n {/if}\n <div>\n {#if stripe && open}\n <StripePaymentForm\n bind:this={formRef}\n mode=\"payment\"\n {stripe}\n {amount}\n {currency}\n {savePaymentMethod}\n {user}\n onchange={handleCardChange}\n />\n {/if}\n </div>\n {#if user}\n <div class=\"flex items-center gap-2\">\n <input type=\"checkbox\" id=\"savePaymentMethod\" bind:checked={savePaymentMethod} />\n <label for=\"savePaymentMethod\" class=\"text-sm text-muted-foreground\">\n Save payment method for future purchases\n </label>\n </div>\n {/if}\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handlePaymentMethod} disabled={!cardComplete || isProcessing}>\n {isProcessing ? 'Processing...' : 'Pay Now'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", ju = "export const TERMS_AUTO = {\n applePay: \"auto\" as const,\n auBecsDebit: \"auto\" as const,\n bancontact: \"auto\" as const,\n card: \"auto\" as const,\n cashapp: \"auto\" as const,\n googlePay: \"auto\" as const,\n ideal: \"auto\" as const,\n paypal: \"auto\" as const,\n sepaDebit: \"auto\" as const,\n sofort: \"auto\" as const,\n usBankAccount: \"auto\" as const,\n};\n\nexport const TERMS_NEVER = {\n applePay: \"never\" as const,\n auBecsDebit: \"never\" as const,\n bancontact: \"never\" as const,\n card: \"never\" as const,\n cashapp: \"never\" as const,\n googlePay: \"never\" as const,\n ideal: \"never\" as const,\n paypal: \"never\" as const,\n sepaDebit: \"never\" as const,\n sofort: \"never\" as const,\n usBankAccount: \"never\" as const,\n};\n", Mu = "<script lang=\"ts\">\n import type {\n Stripe,\n StripeElements,\n StripePaymentElement,\n StripeElementsOptionsMode\n } from '@stripe/stripe-js';\n import { mode as modeWatcher } from 'mode-watcher';\n import { TERMS_AUTO, TERMS_NEVER } from './stripe-constants';\n import { onMount } from 'svelte';\n\n interface Props {\n stripe: Stripe;\n mode: 'payment' | 'setup';\n amount?: number;\n currency?: string;\n savePaymentMethod?: boolean;\n user?: { email: string; name: string } | null;\n onchange: (complete: boolean) => void;\n }\n\n let {\n stripe,\n mode,\n amount = 0,\n currency = 'usd',\n savePaymentMethod = false,\n user,\n onchange\n }: Props = $props();\n\n let cardContainer = $state<HTMLDivElement | null>(null);\n let elements = $state<StripeElements | null>(null);\n let paymentElement = $state<StripePaymentElement | null>(null);\n\n function initializeElements() {\n if (!stripe) return;\n\n // Clean up previous elements\n if (paymentElement) {\n paymentElement.destroy();\n paymentElement = null;\n }\n\n const appearance = {\n theme: modeWatcher.current === 'dark' ? ('night' as const) : ('stripe' as const),\n inputs: 'condensed' as const,\n labels: 'floating' as const\n };\n\n elements = stripe.elements({\n mode,\n appearance,\n currency,\n ...(mode === 'payment' && {\n amount: amount\n }),\n ...(user || mode === 'setup'\n ? {\n setupFutureUsage: 'off_session' as const\n }\n : {})\n } as StripeElementsOptionsMode);\n\n paymentElement = elements.create('payment', {\n layout: 'tabs',\n defaultValues: {\n billingDetails: {\n email: user?.email,\n name: user?.name\n }\n },\n terms: savePaymentMethod ? TERMS_AUTO : TERMS_NEVER\n });\n\n if (cardContainer && paymentElement) {\n paymentElement.mount(cardContainer);\n paymentElement.on('change', (event: any) => {\n onchange(event.complete);\n });\n }\n }\n\n // Initialize elements when component mounts\n onMount(() => {\n initializeElements();\n\n return () => {\n if (paymentElement) {\n paymentElement.destroy();\n }\n };\n });\n\n // Update terms when savePaymentMethod changes\n $effect(() => {\n if (paymentElement) {\n paymentElement.update({\n terms: savePaymentMethod ? TERMS_AUTO : TERMS_NEVER\n });\n }\n });\n\n export function getElements() {\n return elements;\n }\n<\/script>\n\n<div bind:this={cardContainer}></div>\n", Nu = "import { toast } from \"svelte-sonner\";\n\nexport interface PaymentIntentResult {\n type: \"payment\" | \"confirm\";\n amount?: number;\n currency?: string;\n clientSecret?: string;\n brand?: string;\n last4?: string;\n}\n\nexport function usePaymentIntent() {\n let isLoading = $state(false);\n\n async function fetchPaymentIntent({\n priceId,\n }: {\n priceId: string;\n }): Promise<PaymentIntentResult | null> {\n isLoading = true;\n\n const res = await fetch(\"/api/stripe/payment-intent\", {\n method: \"POST\",\n body: JSON.stringify({\n priceId: priceId,\n }),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (!res.ok) {\n toast.error(\"Failed to initialize payment\");\n return null;\n }\n\n return res.json();\n }\n\n async function fetchSetupIntent(): Promise<PaymentIntentResult | null> {\n isLoading = true;\n\n const res = await fetch(\"/api/stripe/setup-intent\", {\n method: \"POST\",\n });\n\n if (!res.ok) {\n toast.error(\"Failed to initialize setup\");\n return null;\n }\n\n return res.json();\n }\n\n return {\n get isLoading() {\n return isLoading;\n },\n fetchPaymentIntent,\n fetchSetupIntent,\n };\n}\n", Pu = "import { loadStripe, type Stripe } from \"@stripe/stripe-js\";\nimport { toast } from \"svelte-sonner\";\nimport { env } from \"$env/dynamic/public\";\n\nexport function useStripe() {\n let stripe = $state<Stripe | null>(null);\n let isLoading = $state(true);\n let error = $state<string | null>(null);\n\n async function initialize() {\n try {\n stripe = await loadStripe(env.PUBLIC_STRIPE_PUBLISHABLE_KEY);\n isLoading = false;\n } catch (err) {\n console.error(\"Failed to load Stripe:\", err);\n error = \"Failed to initialize payment system\";\n toast.error(\"Failed to initialize payment system\");\n isLoading = false;\n }\n }\n\n // Auto-initialize\n initialize();\n\n return {\n get stripe() {\n return stripe;\n },\n get isLoading() {\n return isLoading;\n },\n get error() {\n return error;\n },\n };\n}\n", Fu = "import { env } from \"$env/dynamic/private\";\nimport Stripe from \"stripe\";\n\nconst stripe = new Stripe(env.STRIPE_SECRET_KEY, {\n apiVersion: \"2026-04-22.dahlia\",\n});\n\nexport default stripe;\n", Iu = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport type { Stripe } from \"stripe\";\n\nconst createPaymentIntent = async (price: Stripe.Price) => {\n if (price.unit_amount === null || price.unit_amount === undefined) {\n console.error(\"Price does not have a per unit amount\");\n throw new Error(\"Price does not have a per unit amount\");\n }\n\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n };\n};\n\nexport const POST = async ({ request, locals }) => {\n let body;\n try {\n body = await request.json();\n } catch (error) {\n console.error(\"Invalid JSON in request body\");\n return json({ error: \"Invalid request body\" }, { status: 400 });\n }\n\n const { priceId } = body as { priceId?: string };\n\n // Validate required fields\n if (!priceId || typeof priceId !== \"string\" || priceId === \"\") {\n console.error(\"Missing or invalid priceId\");\n return json({ error: \"Price ID is required\" }, { status: 400 });\n }\n\n // Retrieve price from Stripe\n let price;\n try {\n price = await stripe.prices.retrieve(priceId);\n } catch (error) {\n console.error(\"Failed to retrieve price from Stripe:\", priceId);\n return json(\n { error: \"Invalid price ID or price not found\" },\n { status: 404 },\n );\n }\n\n // Validate price is active\n if (!price.active) {\n console.error(\"Price is not active:\", priceId);\n return json(\n { error: \"This price is no longer available\" },\n { status: 400 },\n );\n }\n\n try {\n const res = await createPaymentIntent(price);\n return json(res, { status: 200 });\n } catch (error) {\n console.error(\"Error creating payment intent for price:\", priceId);\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to create payment intent\";\n return json({ error: errorMessage }, { status: 500 });\n }\n};\n", Lu = "import { describe, it, expect, beforeAll } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\nimport stripe from \"$lib/stripe\";\nimport type Stripe from \"stripe\";\n\ndescribe(\"POST /api/stripe/payment-intent\", () => {\n let product: Stripe.Product;\n let activePrice: Stripe.Price;\n let inactivePrice: Stripe.Price;\n\n beforeAll(async () => {\n const productName = \"Test Product - Payment Intent\";\n const products = await stripe.products.search({\n query: `name:\"${productName}\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n product = products.data[0];\n\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n\n if (prices.data.length > 0) {\n activePrice = prices.data[0];\n }\n\n const inactivePrices = await stripe.prices.list({\n product: product.id,\n active: false,\n limit: 1,\n });\n\n if (inactivePrices.data.length > 0) {\n inactivePrice = inactivePrices.data[0];\n }\n }\n\n // Create if not found or no active price\n if (!product) {\n product = await stripe.products.create({\n name: productName,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!activePrice) {\n activePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!inactivePrice) {\n inactivePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 2000,\n currency: \"usd\",\n active: false,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent-inactive\",\n },\n });\n }\n });\n\n describe(\"Request validation\", () => {\n it(\"should return 400 if request body is not valid JSON\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .set(\"Content-Type\", \"application/json\")\n .send(\"invalid json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Invalid request body\");\n });\n\n it(\"should return 400 if priceId is missing\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({});\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is not a string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: 12345 });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is an empty string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"\" });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 404 if price does not exist\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"price_nonexistent123\" });\n\n expect(response.status).toBe(404);\n expect(response.body.error).toBe(\"Invalid price ID or price not found\");\n });\n\n it(\"should return 400 if price is not active\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: inactivePrice.id });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"This price is no longer available\");\n });\n });\n\n describe(\"Guest user (unauthenticated)\", () => {\n it(\"should create payment intent for guest user\", async (context) => {\n const response = await context.request\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n\n // Verify the payment intent was created in Stripe\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.currency).toBe(\"usd\");\n expect(intent.customer).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n});\n", Ru = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\n\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const prices = await stripe.prices.list();\n\n for (const price of prices.data) {\n try {\n await locals.admin\n .collection(\"stripe_prices\")\n .getFirstListItem(`id = \"${price.id}\"`);\n continue;\n } catch {}\n\n await locals.admin.collection(\"stripe_prices\").create({\n id: price.id,\n billing_scheme: price.billing_scheme,\n currency: price.currency,\n product: price.product,\n recurring: price.recurring,\n type: price.type,\n unit_amount: price.unit_amount,\n active: price.active,\n });\n }\n\n console.log(\"Prices synced\");\n return json({ message: \"Prices synced\" });\n};\n", zu = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\n\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const products = await stripe.products.list();\n\n for (const product of products.data) {\n try {\n await locals.admin\n .collection(\"stripe_products\")\n .getFirstListItem(`id = \"${product.id}\"`);\n continue;\n } catch {}\n\n await locals.admin.collection(\"stripe_products\").create({\n id: product.id,\n name: product.name,\n active: product.active,\n default_price: product.default_price,\n });\n }\n\n console.log(\"Products synced\");\n return json({ message: \"Products synced\" });\n};\n", Bu = "import Stripe from \"stripe\";\nimport { json } from \"@sveltejs/kit\";\nimport { env } from \"$env/dynamic/private\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./handlers/payment-intent/succeeded\";\n\nconst processedEvents = new Set<string>();\n\nasync function verifyWebhookSignature(\n request: Request,\n webhookSecret: string,\n): Promise<Stripe.Event> {\n const body = await request.text();\n const signature = request.headers.get(\"stripe-signature\");\n\n if (!signature) {\n throw new Error(\"Missing stripe-signature header\");\n }\n\n if (!webhookSecret) {\n throw new Error(\"Missing webhook secret\");\n }\n\n try {\n return stripe.webhooks.constructEvent(body, signature, webhookSecret);\n } catch (err) {\n console.error(\"Webhook signature verification failed:\", err);\n throw new Error(\"Invalid signature\");\n }\n}\n\nexport const POST = async ({ request, locals }) => {\n try {\n const event = await verifyWebhookSignature(\n request,\n env.STRIPE_WEBHOOK_SECRET,\n );\n\n if (processedEvents.has(event.id)) {\n console.log(`Event ${event.id} already processed, skipping`);\n return json({ received: true, message: \"Event already processed\" });\n }\n\n processedEvents.add(event.id);\n\n console.log(`Processing webhook event: ${event.type} (${event.id})`);\n\n switch (event.type) {\n case \"payment_intent.succeeded\":\n await handlePaymentIntentSucceeded(event.data.object, locals);\n break;\n\n default:\n console.log(`Unhandled event type: ${event.type}`);\n }\n\n return json({\n received: true,\n eventId: event.id,\n eventType: event.type,\n });\n } catch (error) {\n console.error(\"Webhook processing error:\", error);\n\n return json(\n {\n error: \"Webhook processing failed\",\n message: error instanceof Error ? error.message : \"Unknown error\",\n },\n { status: 400 },\n );\n }\n};\n", Vu = "import { describe, it, expect } from \"vitest\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./succeeded\";\n\ndescribe(\"payment_intent.succeeded\", () => {\n it(\"handles a payment intent successfully\", async (context) => {\n const paymentIntent = await stripe.paymentIntents.create({\n amount: 2000,\n currency: \"usd\",\n });\n const locals = { admin: context.admin } as App.Locals;\n const result = await handlePaymentIntentSucceeded(paymentIntent, locals);\n\n expect(result).toEqual({});\n });\n});\n", Hu = "import Stripe from \"stripe\";\n\n/**\n * Handles payment_intent.succeeded event\n */\nexport async function handlePaymentIntentSucceeded(\n paymentIntent: Stripe.PaymentIntent,\n locals: App.Locals,\n) {\n return {};\n}\n", Uu = "import { describe, it, expect } from \"vitest\";\nimport type { RouteId } from \"./$types\";\nimport type { Match } from \"@velastack/kit\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\n\ndescribe(\"POST /webhooks/stripe\", () => {\n it(\"accepts valid webhook signature\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET!;\n\n const signature = stripe.webhooks.generateTestHeaderString({\n payload,\n secret: webhookSecret,\n });\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(200);\n expect(response.body.received).toBe(true);\n expect(response.body.eventId).toBe(event.id);\n expect(response.body.eventType).toBe(\"test.event\");\n });\n\n it(\"rejects invalid webhook signature\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", \"invalid_signature\")\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Webhook processing failed\");\n });\n\n it(\"rejects request without signature header\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Webhook processing failed\");\n expect(response.body.message).toBe(\"Missing stripe-signature header\");\n });\n\n it(\"handles duplicate webhook events\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET!;\n const signature = stripe.webhooks.generateTestHeaderString({\n payload,\n secret: webhookSecret,\n });\n\n // Send first webhook\n const response1 = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response1.status).toBe(200);\n expect(response1.body.received).toBe(true);\n\n // Send duplicate webhook\n const response2 = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response2.status).toBe(200);\n expect(response2.body.received).toBe(true);\n expect(response2.body.message).toBe(\"Event already processed\");\n });\n});\n", Wu = "/// <reference path=\"../types.d.ts\" />\n\ncronAdd(\"stripe-products\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/products\");\n});\n\ncronAdd(\"stripe-prices\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/prices\");\n});\n\ncronAdd(\"stripe-customers\", \"* * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/customers\");\n});\n", Gu = "/// <reference path=\"../types.d.ts\" />\n\nmodule.exports = {\n triggerJob: (jobUrl) => {\n $http.send({\n method: \"POST\",\n url: `${$app.settings().meta.appURL}${jobUrl}`,\n headers: {\n Authorization: `Bearer ${$os.getenv(\"INTERNAL_JOB_SECRET\")}`,\n },\n });\n },\n};\n", Ku = "<script lang=\"ts\">\n import { Button } from '$lib/components/ui/button';\n import SetupDialog from '$lib/components/payments/setup-dialog.svelte';\n import { useStripe } from '$lib/components/payments/use-stripe.svelte';\n import { usePaymentIntent } from '$lib/components/payments/use-payment-intent.svelte';\n\n interface Props {\n disabled?: boolean;\n isProcessing?: boolean;\n label?: string;\n processingLabel?: string;\n onsuccess?: () => void;\n }\n\n let {\n disabled = false,\n isProcessing = false,\n label,\n processingLabel,\n onsuccess\n }: Props = $props();\n\n const stripeManager = useStripe();\n const paymentIntentManager = usePaymentIntent();\n\n let showDialog = $state(false);\n let clientSecret = $state<string>();\n\n async function handleSetupClick() {\n const result = await paymentIntentManager.fetchSetupIntent();\n\n if (!result) return;\n\n clientSecret = result.clientSecret;\n showDialog = true;\n }\n\n function handleDialogOpenChange(open: boolean) {\n showDialog = open;\n }\n\n function handlePaymentSuccess() {\n onsuccess?.();\n }\n<\/script>\n\n<Button disabled={disabled || isProcessing} onclick={handleSetupClick}>\n {#if isProcessing}\n {processingLabel}\n {:else}\n {label}\n {/if}\n</Button>\n\n<SetupDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {clientSecret}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n/>\n", qu = "<script lang=\"ts\">\n import type { Stripe, StripeElements } from '@stripe/stripe-js';\n import { Button } from '$lib/components/ui/button';\n import * as Dialog from '$lib/components/ui/dialog';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n import StripePaymentForm from './stripe-payment-form.svelte';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n clientSecret?: string;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let { stripe, open = $bindable(), clientSecret, onopenchange, onsuccess }: Props = $props();\n\n let isProcessing = $state(false);\n let cardComplete = $state(false);\n let formRef = $state<{\n getElements: () => StripeElements | null;\n }>();\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n cardComplete = false;\n }\n\n function handleCardChange(complete: boolean) {\n cardComplete = complete;\n }\n\n async function handleSetupPaymentMethod() {\n if (!stripe || !formRef || !cardComplete || !clientSecret) return;\n\n const elements = formRef.getElements();\n if (!elements) return;\n\n isProcessing = true;\n\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n toast.error(submitError.message || 'Failed to add payment method');\n return;\n }\n\n const { error: confirmError } = await stripe.confirmSetup({\n elements,\n clientSecret,\n confirmParams: {\n return_url: page.url.toString(),\n payment_method_data: {\n allow_redisplay: 'always'\n }\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to add payment method');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment method added successfully');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error adding payment method:', err);\n toast.error('Failed to add payment method');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <Dialog.Content class=\"sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>Add payment method</Dialog.Title>\n <Dialog.Description>Enter your card details to add a new payment method.</Dialog.Description>\n </Dialog.Header>\n <div>\n {#if stripe && open}\n <StripePaymentForm\n bind:this={formRef}\n mode=\"setup\"\n {stripe}\n onchange={handleCardChange}\n savePaymentMethod={true}\n />\n {/if}\n </div>\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handleSetupPaymentMethod} disabled={!cardComplete || isProcessing}>\n {isProcessing ? 'Processing...' : 'Add Card'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", Ju = "export const load = async ({ parent }) => {\n const { breadcrumbs } = await parent();\n\n return {\n breadcrumbs: [...breadcrumbs, { title: \"Billing\", url: \"/billing\" }],\n };\n};\n", Yu = "# Billing Page - Stripe Payment Methods\n\nThis billing page provides a modern UI for managing payment methods with Stripe.\n\n## Features\n\n✅ **Display Payment Methods** - Shows all saved cards with brand, last 4 digits, and expiration\n✅ **Add Payment Methods** - Secure card input using Stripe Elements\n✅ **Remove Payment Methods** - Delete cards with confirmation dialog\n✅ **Default Payment Method** - Set and display the default payment method\n✅ **Responsive Design** - Mobile-friendly layout\n✅ **Error Handling** - Toast notifications for user feedback\n\n## Current Status\n\nThe frontend is **fully functional** with mock data. To connect to your backend, follow the integration steps below.\n\n## Backend Integration\n\n### 1. Update Stripe Publishable Key\n\nIn `+page.svelte`, replace the placeholder with your actual Stripe publishable key:\n\n```typescript\nconst STRIPE_PUBLISHABLE_KEY = \"pk_test_YOUR_KEY_HERE\";\n```\n\nOr better yet, load it from environment variables:\n\n```typescript\nimport { env } from \"$env/dynamic/public\";\nconst STRIPE_PUBLISHABLE_KEY = env.PUBLIC_STRIPE_PUBLISHABLE_KEY;\n```\n\n### 2. Fetch Payment Methods on Load\n\nUpdate `+page.server.ts` to fetch payment methods:\n\n```typescript\nexport const load: PageServerLoad = async ({ locals }) => {\n const user = locals.user;\n\n if (!user?.stripeCustomerId) {\n return { paymentMethods: [] };\n }\n\n // Fetch payment methods from Stripe\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n const paymentMethods = await stripe.paymentMethods.list({\n customer: user.stripeCustomerId,\n type: \"card\",\n });\n\n return {\n paymentMethods: paymentMethods.data.map((pm) => ({\n id: pm.id,\n brand: pm.card?.brand || \"unknown\",\n last4: pm.card?.last4 || \"0000\",\n expMonth: pm.card?.exp_month || 1,\n expYear: pm.card?.exp_year || 2025,\n isDefault: false, // You'll need to track this separately\n })),\n };\n};\n```\n\n### 3. Create API Endpoints\n\nCreate the following server endpoints:\n\n#### Add Payment Method: `+page.server.ts`\n\n```typescript\nexport const actions = {\n addPaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Attach payment method to customer\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n await stripe.paymentMethods.attach(paymentMethodId, {\n customer: locals.user.stripeCustomerId,\n });\n\n return { success: true };\n },\n\n removePaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Detach payment method from customer\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n await stripe.paymentMethods.detach(paymentMethodId);\n\n return { success: true };\n },\n\n setDefaultPaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Update customer's default payment method\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n await stripe.customers.update(locals.user.stripeCustomerId, {\n invoice_settings: {\n default_payment_method: paymentMethodId,\n },\n });\n\n return { success: true };\n },\n};\n```\n\n### 4. Update Frontend to Use Actions\n\nReplace the mock functions in `+page.svelte`:\n\n```typescript\nasync function handleAddPaymentMethod() {\n if (!stripe || !cardElement || !cardComplete) return;\n\n isProcessing = true;\n\n try {\n const { error, paymentMethod } = await stripe.createPaymentMethod({\n type: \"card\",\n card: cardElement,\n });\n\n if (error) {\n toast.error(error.message);\n return;\n }\n\n // Submit to your backend\n const formData = new FormData();\n formData.append(\"paymentMethodId\", paymentMethod.id);\n\n const response = await fetch(\"?/addPaymentMethod\", {\n method: \"POST\",\n body: formData,\n });\n\n if (response.ok) {\n toast.success(\"Payment method added\");\n // Reload page to fetch updated payment methods\n window.location.reload();\n }\n } finally {\n isProcessing = false;\n }\n}\n```\n\n## Security Considerations\n\n⚠️ **Important**: Never expose your Stripe secret key on the frontend\n✅ All sensitive operations should happen on your backend\n✅ Use Stripe's publishable key for frontend operations\n✅ Validate user permissions before modifying payment methods\n✅ Use HTTPS in production\n\n## Testing\n\nUse [Stripe's test cards](https://stripe.com/docs/testing) for testing:\n\n- **Success**: 4242 4242 4242 4242\n- **Decline**: 4000 0000 0000 0002\n- **Requires authentication**: 4000 0025 0000 3155\n\nUse any future expiration date and any 3-digit CVC.\n\n## Styling\n\nThe page uses Tailwind CSS and shadcn/ui components. All components are styled to match your existing design system with support for light/dark modes.\n\n### Stripe Elements Styling\n\nSince Stripe Elements render in an iframe, they cannot access CSS variables directly. Additionally, Stripe only accepts HEX, RGB, or HSL colors (not modern formats like OKLCH).\n\nThe implementation:\n\n1. **Creates temporary DOM elements** with CSS variables applied\n2. **Lets the browser compute colors** - converts OKLCH/HSL/any format to RGB\n3. **Extracts RGB values** that Stripe Elements can understand\n4. **Passes computed colors** to Stripe Elements on initialization\n5. **Matches the current theme** automatically (light/dark mode)\n\nThis approach works with any CSS color format (oklch, hsl, rgb, hex) and ensures Stripe Elements always match your theme when the \"Add Payment Method\" dialog opens.\n\n## Dependencies\n\n- `@stripe/stripe-js` - Stripe.js for frontend\n- `stripe` - Stripe Node.js SDK for backend\n- `svelte-sonner` - Toast notifications\n- `@lucide/svelte` - Icons\n- shadcn/ui components\n", Xu = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport type { Stripe } from \"stripe\";\n\nconst createPaymentIntent = async (\n price: Stripe.Price,\n customer?: { id: string; default_payment_method?: string },\n) => {\n if (price.unit_amount === null || price.unit_amount === undefined) {\n console.error(\"Price does not have a per unit amount\");\n throw new Error(\"Price does not have a per unit amount\");\n }\n\n // Guest\n if (!customer) {\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n };\n }\n\n // Customer with saved payment method\n if (customer.default_payment_method) {\n const paymentMethod = await stripe.customers.retrievePaymentMethod(\n customer.id,\n customer.default_payment_method,\n );\n\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n customer: customer.id,\n payment_method: customer.default_payment_method,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n return {\n type: \"confirm\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n };\n }\n\n // Customer without saved payment method\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n customer: customer.id,\n setup_future_usage: \"off_session\",\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n };\n};\n\nexport const POST = async ({ request, locals }) => {\n const user = locals.pb.authStore.record?.id;\n\n let body;\n try {\n body = await request.json();\n } catch (error) {\n console.error(\"Invalid JSON in request body\");\n return json({ error: \"Invalid request body\" }, { status: 400 });\n }\n\n const { priceId } = body as { priceId?: string };\n\n // Validate required fields\n if (!priceId || typeof priceId !== \"string\" || priceId === \"\") {\n console.error(\"Missing or invalid priceId\");\n return json({ error: \"Price ID is required\" }, { status: 400 });\n }\n\n // Retrieve price from Stripe\n let price;\n try {\n price = await stripe.prices.retrieve(priceId);\n } catch (error) {\n console.error(\"Failed to retrieve price from Stripe:\", priceId);\n return json(\n { error: \"Invalid price ID or price not found\" },\n { status: 404 },\n );\n }\n\n // Validate price is active\n if (!price.active) {\n console.error(\"Price is not active:\", priceId);\n return json(\n { error: \"This price is no longer available\" },\n { status: 400 },\n );\n }\n\n let customer;\n\n if (user) {\n try {\n customer = await locals.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(\n locals.admin.filter(\"user = {:user}\", { user: user }),\n );\n } catch (error) {\n // Customer not found is expected for new users, log for debugging only\n console.log(\"No Stripe customer found for user:\", user);\n }\n }\n\n try {\n const res = await createPaymentIntent(price, customer);\n return json(res, { status: 200 });\n } catch (error) {\n console.error(\"Error creating payment intent for price:\", priceId);\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to create payment intent\";\n return json({ error: errorMessage }, { status: 500 });\n }\n};\n", Zu = "import { describe, it, expect, beforeAll, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\nimport stripe from \"$lib/stripe\";\nimport type Stripe from \"stripe\";\n\ndescribe(\"POST /api/stripe/payment-intent\", () => {\n let product: Stripe.Product;\n let activePrice: Stripe.Price;\n let inactivePrice: Stripe.Price;\n let stripeCustomer: Stripe.Customer;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeAll(async () => {\n const productName = \"Test Product - Payment Intent\";\n const products = await stripe.products.search({\n query: `name:\"${productName}\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n product = products.data[0];\n\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n\n if (prices.data.length > 0) {\n activePrice = prices.data[0];\n }\n\n const inactivePrices = await stripe.prices.list({\n product: product.id,\n active: false,\n limit: 1,\n });\n\n if (inactivePrices.data.length > 0) {\n inactivePrice = inactivePrices.data[0];\n }\n }\n\n // Create if not found or no active price\n if (!product) {\n product = await stripe.products.create({\n name: productName,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!activePrice) {\n activePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!inactivePrice) {\n inactivePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 2000,\n currency: \"usd\",\n active: false,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent-inactive\",\n },\n });\n }\n });\n\n beforeEach(async (context) => {\n // Create a Stripe customer for authenticated user tests\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n // Create a payment method for the customer\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n });\n\n afterEach(async () => {\n if (paymentMethod?.id) {\n await stripe.paymentMethods.detach(paymentMethod.id);\n }\n\n if (stripeCustomer?.id) {\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n describe(\"Request validation\", () => {\n it(\"should return 400 if request body is not valid JSON\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .set(\"Content-Type\", \"application/json\")\n .send(\"invalid json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Invalid request body\");\n });\n\n it(\"should return 400 if priceId is missing\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({});\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is not a string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: 12345 });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is an empty string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"\" });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 404 if price does not exist\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"price_nonexistent123\" });\n\n expect(response.status).toBe(404);\n expect(response.body.error).toBe(\"Invalid price ID or price not found\");\n });\n\n it(\"should return 400 if price is not active\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: inactivePrice.id });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"This price is no longer available\");\n });\n });\n\n describe(\"Guest user (unauthenticated)\", () => {\n it(\"should create payment intent for guest user\", async (context) => {\n const response = await context.request\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n\n // Verify the payment intent was created in Stripe\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.currency).toBe(\"usd\");\n expect(intent.customer).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n\n describe(\"Authenticated user without Stripe customer\", () => {\n it(\"should create payment intent for user without Stripe customer\", async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n\n // Verify the payment intent\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.setup_future_usage).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n\n describe(\"Authenticated user with Stripe customer\", () => {\n let customerRecord: { id: string };\n\n beforeEach(async (context) => {\n // Link the Stripe customer to the PocketBase user\n customerRecord = await context.admin\n .collection(\"stripe_customers\")\n .create({\n user: context.user.id,\n id: stripeCustomer.id,\n email: stripeCustomer.email,\n });\n });\n\n afterEach(async (context) => {\n // Clean up the PocketBase customer record\n await context.admin\n .collection(\"stripe_customers\")\n .delete(customerRecord.id);\n });\n\n it(\"should create payment intent with setup_future_usage for user without default payment method\", async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n\n // Verify the payment intent has setup_future_usage\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.customer).toBe(stripeCustomer.id);\n expect(intent.setup_future_usage).toBe(\"off_session\");\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n\n it(\"should create payment intent with default payment method for customer with saved payment method\", async (context) => {\n // Set default payment method\n await stripe.customers.update(stripeCustomer.id, {\n invoice_settings: {\n default_payment_method: paymentMethod.id,\n },\n });\n\n const customerRecord = await context.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(\n context.admin.filter(\"user = {:user}\", { user: context.user.id }),\n );\n\n await context.admin.collection(\"stripe_payment_methods\").create({\n id: paymentMethod.id,\n customer: customerRecord.id,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n exp_month: paymentMethod.card?.exp_month,\n exp_year: paymentMethod.card?.exp_year,\n });\n\n await context.admin\n .collection(\"stripe_customers\")\n .update(customerRecord.id, {\n default_payment_method: paymentMethod.id,\n });\n\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"confirm\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBe(\"visa\");\n expect(response.body.last4).toBeDefined();\n expect(response.body.last4).toMatch(/^\\d{4}$/);\n\n // Verify the payment intent has the payment method attached\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.customer).toBe(stripeCustomer.id);\n expect(intent.payment_method).toBe(paymentMethod.id);\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n});\n", Qu = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\n\nexport const POST = async ({ locals }) => {\n const user = locals.pb.authStore.record?.id;\n\n if (!user) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(locals.admin.filter(\"user = {:user}\", { user }));\n\n if (!customer) {\n return json({ error: \"Customer not found\" }, { status: 404 });\n }\n\n const setupIntent = await stripe.setupIntents.create({\n customer: customer.id,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n return json({ clientSecret: setupIntent.client_secret });\n};\n", $u = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"POST /api/stripe/setup-intent\", () => {\n let stripeCustomer: Stripe.Customer;\n\n beforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n });\n\n afterEach(async (context) => {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n });\n\n it(\"creates a setup intent\", async (context) => {\n const response = await context.agent.post(\n \"/api/stripe/setup-intent\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n expect(response.body.clientSecret).toBeDefined();\n });\n});\n", ed = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\n\n// Sync users to Stripe customers\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n // Ensure all users have a Stripe customer\n const users = await locals.admin\n .collection(\"users\")\n .getFullList({ filter: \"stripe_customers_via_user.id = null\" });\n\n for (const user of users) {\n const customer = await stripe.customers.create({\n email: user.email,\n name: user.name,\n });\n\n await locals.admin.collection(\"stripe_customers\").create({\n id: customer.id,\n user: user.id,\n });\n }\n\n console.log(\"Customers synced\");\n return json({ message: \"Customers synced\" });\n};\n", td = "import Stripe from \"stripe\";\nimport { json } from \"@sveltejs/kit\";\nimport { env } from \"$env/dynamic/private\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./handlers/payment-intent/succeeded\";\nimport { handlePaymentMethodAttached } from \"./handlers/payment-method/attached\";\n\nconst processedEvents = new Set<string>();\n\nasync function verifyWebhookSignature(\n request: Request,\n webhookSecret: string,\n): Promise<Stripe.Event> {\n const body = await request.text();\n const signature = request.headers.get(\"stripe-signature\");\n\n if (!signature) {\n throw new Error(\"Missing stripe-signature header\");\n }\n\n if (!webhookSecret) {\n throw new Error(\"Missing webhook secret\");\n }\n\n try {\n return stripe.webhooks.constructEvent(body, signature, webhookSecret);\n } catch (err) {\n console.error(\"Webhook signature verification failed:\", err);\n throw new Error(\"Invalid signature\");\n }\n}\n\nexport const POST = async ({ request, locals }) => {\n try {\n const event = await verifyWebhookSignature(\n request,\n env.STRIPE_WEBHOOK_SECRET,\n );\n\n if (processedEvents.has(event.id)) {\n console.log(`Event ${event.id} already processed, skipping`);\n return json({ received: true, message: \"Event already processed\" });\n }\n\n processedEvents.add(event.id);\n\n console.log(`Processing webhook event: ${event.type} (${event.id})`);\n\n switch (event.type) {\n case \"payment_intent.succeeded\":\n await handlePaymentIntentSucceeded(event.data.object, locals);\n break;\n\n case \"payment_method.attached\":\n await handlePaymentMethodAttached(event.data.object, locals);\n break;\n\n default:\n console.log(`Unhandled event type: ${event.type}`);\n }\n\n return json({\n received: true,\n eventId: event.id,\n eventType: event.type,\n });\n } catch (error) {\n console.error(\"Webhook processing error:\", error);\n\n return json(\n {\n error: \"Webhook processing failed\",\n message: error instanceof Error ? error.message : \"Unknown error\",\n },\n { status: 400 },\n );\n }\n};\n", nd = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./succeeded\";\n\ndescribe(\"payment_intent.succeeded\", () => {\n let stripeCustomer: Stripe.Customer;\n let paymentIntent: Stripe.PaymentIntent;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeEach(async (context) => {\n // Create a Stripe customer\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n // Link the Stripe customer to the test user\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n\n // Create a payment method for testing\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n // Attach payment method to customer\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n // Create a payment intent\n paymentIntent = await stripe.paymentIntents.create({\n amount: 2000, // $20.00\n currency: \"usd\",\n customer: stripeCustomer.id,\n payment_method: paymentMethod.id,\n confirm: true,\n return_url: \"https://example.com/return\",\n });\n });\n\n afterEach(async (context) => {\n // Clean up transactions\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\"stripe_customer = {:stripeCustomer}\", {\n stripeCustomer: stripeCustomer.id,\n }),\n });\n for (const transaction of transactions) {\n await context.admin.collection(\"transactions\").delete(transaction.id);\n }\n\n // Clean up Stripe resources\n if (paymentMethod?.id) {\n try {\n await stripe.paymentMethods.detach(paymentMethod.id);\n } catch (e) {\n // Payment method may already be detached\n }\n }\n\n // Delete customer (this will also delete associated payment methods)\n if (stripeCustomer?.id) {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n it(\"creates a transaction record when payment intent succeeds\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n const transaction = transactions[0];\n\n expect(transaction.stripe_payment_intent).toBe(paymentIntent.id);\n expect(transaction.stripe_customer).toBe(stripeCustomer.id);\n expect(transaction.amount).toBe(2000);\n expect(transaction.currency).toBe(\"usd\");\n expect(transaction.user).toBe(context.user.id);\n expect(transaction.stripe_charge).toBeDefined();\n expect(transaction.last4).toBeDefined();\n expect(transaction.brand).toBeDefined();\n expect(transaction.created).toBeDefined();\n expect(transaction.receipt_url).toBeDefined();\n });\n\n it(\"handles payment intent with charge object instead of string\", async (context) => {\n // Retrieve the payment intent with expanded charge\n const expandedPaymentIntent = await stripe.paymentIntents.retrieve(\n paymentIntent.id,\n {\n expand: [\"latest_charge\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(expandedPaymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n const transaction = transactions[0];\n\n expect(transaction.stripe_payment_intent).toBe(paymentIntent.id);\n expect(transaction.stripe_charge).toBeDefined();\n });\n\n it(\"handles payment intent with customer object instead of string\", async (context) => {\n // Retrieve the payment intent with expanded customer\n const expandedPaymentIntent = await stripe.paymentIntents.retrieve(\n paymentIntent.id,\n {\n expand: [\"customer\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(expandedPaymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n expect(transactions[0].stripe_customer).toBe(stripeCustomer.id);\n });\n\n it(\"handles missing charge ID gracefully\", async (context) => {\n const paymentIntentWithoutCharge = {\n ...paymentIntent,\n latest_charge: null,\n } as Stripe.PaymentIntent;\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntentWithoutCharge, locals);\n\n // Verify no transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(0);\n });\n\n it(\"handles missing customer ID gracefully\", async (context) => {\n const paymentIntentWithoutCustomer = {\n ...paymentIntent,\n customer: null,\n } as Stripe.PaymentIntent;\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntentWithoutCustomer, locals);\n\n // Verify no transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(0);\n });\n});\n", rd = "import Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\n/**\n * Handles payment_intent.succeeded event\n */\nexport async function handlePaymentIntentSucceeded(\n paymentIntent: Stripe.PaymentIntent,\n locals: App.Locals,\n) {\n const chargeId =\n typeof paymentIntent.latest_charge === \"string\"\n ? paymentIntent.latest_charge\n : paymentIntent.latest_charge?.id;\n\n if (!chargeId) {\n console.error(\"No charge ID found for payment intent\");\n return;\n }\n\n const charge = await stripe.charges.retrieve(chargeId);\n\n const customerId =\n typeof paymentIntent.customer === \"string\"\n ? paymentIntent.customer\n : paymentIntent.customer?.id;\n\n if (!customerId) {\n console.error(\"No customer ID found for payment intent\");\n return;\n }\n\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getOne(customerId);\n const created = new Date(charge.created * 1000);\n\n await locals.admin.collection(\"transactions\").create({\n stripe_payment_intent: paymentIntent.id,\n stripe_charge: chargeId,\n stripe_customer: customerId,\n amount: paymentIntent.amount,\n currency: paymentIntent.currency,\n created: created.toISOString(),\n last4: charge.payment_method_details?.card?.last4,\n brand: charge.payment_method_details?.card?.brand,\n receipt_url: charge.receipt_url,\n user: customer.user,\n });\n}\n", id = "import Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\n\n/**\n * Handles payment_method.attached event\n */\nexport async function handlePaymentMethodAttached(\n paymentMethod: Stripe.PaymentMethod,\n locals: App.Locals,\n) {\n if (\n paymentMethod.allow_redisplay === \"unspecified\" ||\n !paymentMethod.customer\n ) {\n return;\n }\n\n const customer =\n typeof paymentMethod.customer === \"string\"\n ? paymentMethod.customer\n : paymentMethod.customer?.id;\n\n await locals.admin.collection(\"stripe_payment_methods\").create({\n id: paymentMethod.id,\n customer: customer,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n exp_month: paymentMethod.card?.exp_month,\n exp_year: paymentMethod.card?.exp_year,\n });\n\n const paymentMethodRecords = await locals.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: locals.admin.filter(\"customer = {:customer}\", {\n customer: customer,\n }),\n });\n\n if (paymentMethodRecords.length === 1) {\n const paymentMethod = paymentMethodRecords[0];\n\n await stripe.customers.update(customer, {\n invoice_settings: {\n default_payment_method: paymentMethod.id,\n },\n });\n\n await locals.admin.collection(\"stripe_customers\").update(customer, {\n default_payment_method: paymentMethod.id,\n });\n }\n}\n", ad = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentMethodAttached } from \"./attached\";\n\ndescribe(\"payment_method.attached\", () => {\n let stripeCustomer: Stripe.Customer;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeEach(async (context) => {\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n paymentMethod = await stripe.paymentMethods.update(paymentMethod.id, {\n allow_redisplay: \"always\",\n });\n });\n\n afterEach(async (context) => {\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"customer = {:stripeCustomer}\", {\n stripeCustomer: stripeCustomer.id,\n }),\n });\n\n for (const pm of paymentMethods) {\n await context.admin.collection(\"stripe_payment_methods\").delete(pm.id);\n }\n\n if (paymentMethod?.id) {\n try {\n await stripe.paymentMethods.detach(paymentMethod.id);\n } catch {}\n }\n\n if (stripeCustomer?.id) {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n it(\"creates a payment method record when payment method is attached\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(1);\n const pm = paymentMethods[0];\n\n expect(pm.id).toBe(paymentMethod.id);\n expect(pm.customer).toBe(stripeCustomer.id);\n expect(pm.brand).toBe(paymentMethod.card?.brand);\n expect(pm.last4).toBe(paymentMethod.card?.last4);\n expect(pm.exp_month).toBe(paymentMethod.card?.exp_month);\n expect(pm.exp_year).toBe(paymentMethod.card?.exp_year);\n });\n\n it(\"sets payment method as default when it is the first one\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify it was set as default in database\n const customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Verify it was set as default in Stripe\n const stripeCustomerUpdated = await stripe.customers.retrieve(\n stripeCustomer.id,\n );\n if (\"deleted\" in stripeCustomerUpdated) {\n throw new Error(\"Customer should not be deleted\");\n }\n expect(stripeCustomerUpdated.invoice_settings.default_payment_method).toBe(\n paymentMethod.id,\n );\n });\n\n it(\"does not set as default when there are already payment methods\", async (context) => {\n // Handle the first payment method\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify it was set as default\n let customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Create and attach a first payment method\n let secondPaymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_mastercard\",\n },\n });\n\n await stripe.paymentMethods.attach(secondPaymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n secondPaymentMethod = await stripe.paymentMethods.update(\n secondPaymentMethod.id,\n {\n allow_redisplay: \"always\",\n },\n );\n\n // Now handle the second payment method\n await handlePaymentMethodAttached(secondPaymentMethod, locals);\n\n // Verify the default did NOT change\n customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Clean up the second payment method\n await context.admin\n .collection(\"stripe_payment_methods\")\n .delete(secondPaymentMethod.id);\n await stripe.paymentMethods.detach(secondPaymentMethod.id);\n });\n\n it(\"handles payment method with customer object instead of string\", async (context) => {\n // Retrieve the payment method with expanded customer\n const expandedPaymentMethod = await stripe.paymentMethods.retrieve(\n paymentMethod.id,\n {\n expand: [\"customer\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(expandedPaymentMethod, locals);\n\n // Verify payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(1);\n expect(paymentMethods[0].customer).toBe(stripeCustomer.id);\n });\n\n it(\"does not create record when allow_redisplay is unspecified\", async (context) => {\n // Update payment method to have unspecified allow_redisplay\n const unspecifiedPaymentMethod = await stripe.paymentMethods.update(\n paymentMethod.id,\n {\n allow_redisplay: \"unspecified\",\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(unspecifiedPaymentMethod, locals);\n\n // Verify no payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(0);\n });\n});\n", od = /* #__PURE__ */ Object.assign({
|
|
5371
|
+
"./creates/data/hooks/stripe.pb.js": Eu,
|
|
5372
|
+
"./creates/data/hooks/utils.js": Du,
|
|
5373
|
+
"./creates/src/lib/components/payments/confirm-dialog.svelte": Ou,
|
|
5374
|
+
"./creates/src/lib/components/payments/payment-button.svelte": ku,
|
|
5375
|
+
"./creates/src/lib/components/payments/payment-dialog.svelte": Au,
|
|
5376
|
+
"./creates/src/lib/components/payments/stripe-constants.ts": ju,
|
|
5377
|
+
"./creates/src/lib/components/payments/stripe-payment-form.svelte": Mu,
|
|
5378
|
+
"./creates/src/lib/components/payments/use-payment-intent.svelte.ts": Nu,
|
|
5379
|
+
"./creates/src/lib/components/payments/use-stripe.svelte.ts": Pu,
|
|
5380
|
+
"./creates/src/lib/stripe.ts": Fu,
|
|
5381
|
+
"./creates/src/routes/api/stripe/payment-intent/+server.ts": Iu,
|
|
5382
|
+
"./creates/src/routes/api/stripe/payment-intent/server.test.ts": Lu,
|
|
5383
|
+
"./creates/src/routes/api/stripe/sync/prices/+server.ts": Ru,
|
|
5384
|
+
"./creates/src/routes/api/stripe/sync/products/+server.ts": zu,
|
|
5385
|
+
"./creates/src/routes/webhooks/stripe/+server.ts": Bu,
|
|
5386
|
+
"./creates/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": Vu,
|
|
5387
|
+
"./creates/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": Hu,
|
|
5388
|
+
"./creates/src/routes/webhooks/stripe/server.test.ts": Uu
|
|
5389
|
+
}), sd = /* #__PURE__ */ Object.assign({
|
|
5390
|
+
"./creates-app-mode/data/hooks/stripe.pb.js": Wu,
|
|
5391
|
+
"./creates-app-mode/data/hooks/utils.js": Gu,
|
|
5392
|
+
"./creates-app-mode/src/lib/components/payments/setup-button.svelte": Ku,
|
|
5393
|
+
"./creates-app-mode/src/lib/components/payments/setup-dialog.svelte": qu,
|
|
5394
|
+
"./creates-app-mode/src/routes/(app)/billing/+layout.server.ts": Ju,
|
|
5381
5395
|
"./creates-app-mode/src/routes/(app)/billing/+page.server.ts": re,
|
|
5382
5396
|
"./creates-app-mode/src/routes/(app)/billing/+page.svelte": ne,
|
|
5383
|
-
"./creates-app-mode/src/routes/(app)/billing/README.md":
|
|
5384
|
-
"./creates-app-mode/src/routes/api/stripe/payment-intent/+server.ts":
|
|
5385
|
-
"./creates-app-mode/src/routes/api/stripe/payment-intent/server.test.ts":
|
|
5386
|
-
"./creates-app-mode/src/routes/api/stripe/setup-intent/+server.ts":
|
|
5387
|
-
"./creates-app-mode/src/routes/api/stripe/setup-intent/server.test.ts":
|
|
5388
|
-
"./creates-app-mode/src/routes/api/stripe/sync/customers/+server.ts":
|
|
5389
|
-
"./creates-app-mode/src/routes/webhooks/stripe/+server.ts":
|
|
5390
|
-
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts":
|
|
5391
|
-
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts":
|
|
5392
|
-
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/attached.ts":
|
|
5393
|
-
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts":
|
|
5394
|
-
}),
|
|
5395
|
-
async function
|
|
5396
|
-
let t = e.features.auth, n = { ...a(
|
|
5397
|
+
"./creates-app-mode/src/routes/(app)/billing/README.md": Yu,
|
|
5398
|
+
"./creates-app-mode/src/routes/api/stripe/payment-intent/+server.ts": Xu,
|
|
5399
|
+
"./creates-app-mode/src/routes/api/stripe/payment-intent/server.test.ts": Zu,
|
|
5400
|
+
"./creates-app-mode/src/routes/api/stripe/setup-intent/+server.ts": Qu,
|
|
5401
|
+
"./creates-app-mode/src/routes/api/stripe/setup-intent/server.test.ts": $u,
|
|
5402
|
+
"./creates-app-mode/src/routes/api/stripe/sync/customers/+server.ts": ed,
|
|
5403
|
+
"./creates-app-mode/src/routes/webhooks/stripe/+server.ts": td,
|
|
5404
|
+
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": nd,
|
|
5405
|
+
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": rd,
|
|
5406
|
+
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/attached.ts": id,
|
|
5407
|
+
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts": ad
|
|
5408
|
+
}), cd = "./creates/", ld = "./creates-app-mode/";
|
|
5409
|
+
async function ud(e) {
|
|
5410
|
+
let t = e.features.auth, n = { ...a(od, cd) };
|
|
5397
5411
|
if (t) {
|
|
5398
|
-
let e = a(
|
|
5412
|
+
let e = a(sd, ld);
|
|
5399
5413
|
Object.assign(n, e);
|
|
5400
5414
|
}
|
|
5401
5415
|
let r = Object.values(n).sort((e, t) => e.path.localeCompare(t.path)), i = [
|
|
@@ -5416,7 +5430,7 @@ async function od(e) {
|
|
|
5416
5430
|
}
|
|
5417
5431
|
//#endregion
|
|
5418
5432
|
//#region src/patterns/enable/payments/preview-modifies/src/routes/(public)/(auth)/signup/+page.server.ts?raw
|
|
5419
|
-
var
|
|
5433
|
+
var dd = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\nimport { dev } from \"$app/environment\";\nimport { signupSchema } from \"$lib/schemas/signup\";\n// [!code highlight:1]\nimport stripe from \"$lib/stripe\";\n\nexport const load = async ({ locals }) => {\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(signupSchema)), authMethods };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(signupSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n let user;\n\n try {\n user = await locals.admin.collection(\"users\").create({\n email: form.data.email,\n password: form.data.password,\n passwordConfirm: form.data.passwordConfirm,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n // [!code highlight:1]\n await linkStripeCustomer(form.data.email, user, locals);\n\n await locals.pb.collection(\"users\").requestVerification(user.email);\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n setFlash(\n { type: \"toast\", message: \"We sent a confirmation link to your email.\" },\n cookies,\n );\n return redirect(303, redirectUrl);\n },\n};\n\n// [!code highlight:66]\nconst linkStripeCustomer = async (\n email: string,\n user: { id: string },\n locals: App.Locals,\n) => {\n const matchingCustomer = await stripe.customers.list({\n email: email,\n limit: 1,\n expand: [\"data.invoice_settings\"],\n });\n\n let customer;\n let isExistingCustomer = false;\n\n if (matchingCustomer.data.length > 0) {\n isExistingCustomer = true;\n customer = matchingCustomer.data[0];\n } else {\n customer = await stripe.customers.create({\n email: email,\n });\n }\n\n await locals.admin.collection(\"stripe_customers\").create({\n id: customer.id,\n user: user.id,\n });\n\n if (!isExistingCustomer) {\n return;\n }\n\n const paymentMethods = await stripe.customers.listPaymentMethods(\n customer.id,\n {\n type: \"card\",\n allow_redisplay: \"always\",\n },\n );\n\n for (const paymentMethod of paymentMethods.data) {\n if (paymentMethod.allow_redisplay === \"unspecified\") {\n continue;\n }\n\n await locals.admin.collection(\"stripe_payment_methods\").create({\n id: paymentMethod.id,\n customer: customer.id,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n exp_month: paymentMethod.card?.exp_month,\n exp_year: paymentMethod.card?.exp_year,\n });\n }\n\n const defaultPaymentMethod =\n customer.invoice_settings?.default_payment_method;\n\n if (defaultPaymentMethod) {\n try {\n await locals.admin.collection(\"stripe_customers\").update(customer.id, {\n default_payment_method: defaultPaymentMethod,\n });\n } catch {}\n }\n};\n", fd = "users", pd = "stripe_customers", md = "stripe_payment_methods", hd = {
|
|
5420
5434
|
name: "stripe_products",
|
|
5421
5435
|
type: "base",
|
|
5422
5436
|
fields: [
|
|
@@ -5455,7 +5469,7 @@ var sd = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5455
5469
|
type: "autodate"
|
|
5456
5470
|
}
|
|
5457
5471
|
]
|
|
5458
|
-
},
|
|
5472
|
+
}, gd = {
|
|
5459
5473
|
name: "stripe_prices",
|
|
5460
5474
|
type: "base",
|
|
5461
5475
|
fields: [
|
|
@@ -5514,8 +5528,8 @@ var sd = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5514
5528
|
type: "autodate"
|
|
5515
5529
|
}
|
|
5516
5530
|
]
|
|
5517
|
-
},
|
|
5518
|
-
name:
|
|
5531
|
+
}, _d = {
|
|
5532
|
+
name: pd,
|
|
5519
5533
|
type: "base",
|
|
5520
5534
|
fields: [
|
|
5521
5535
|
{
|
|
@@ -5526,7 +5540,7 @@ var sd = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5526
5540
|
type: "text"
|
|
5527
5541
|
},
|
|
5528
5542
|
{
|
|
5529
|
-
collectionId:
|
|
5543
|
+
collectionId: fd,
|
|
5530
5544
|
maxSelect: 1,
|
|
5531
5545
|
minSelect: 0,
|
|
5532
5546
|
name: "user",
|
|
@@ -5534,7 +5548,7 @@ var sd = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5534
5548
|
type: "relation"
|
|
5535
5549
|
},
|
|
5536
5550
|
{
|
|
5537
|
-
collectionId:
|
|
5551
|
+
collectionId: md,
|
|
5538
5552
|
maxSelect: 1,
|
|
5539
5553
|
minSelect: 0,
|
|
5540
5554
|
name: "default_payment_method",
|
|
@@ -5554,8 +5568,8 @@ var sd = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5554
5568
|
type: "autodate"
|
|
5555
5569
|
}
|
|
5556
5570
|
]
|
|
5557
|
-
},
|
|
5558
|
-
name:
|
|
5571
|
+
}, vd = {
|
|
5572
|
+
name: md,
|
|
5559
5573
|
type: "base",
|
|
5560
5574
|
fields: [
|
|
5561
5575
|
{
|
|
@@ -5586,7 +5600,7 @@ var sd = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5586
5600
|
type: "number"
|
|
5587
5601
|
},
|
|
5588
5602
|
{
|
|
5589
|
-
collectionId:
|
|
5603
|
+
collectionId: pd,
|
|
5590
5604
|
maxSelect: 1,
|
|
5591
5605
|
minSelect: 0,
|
|
5592
5606
|
name: "customer",
|
|
@@ -5607,7 +5621,7 @@ var sd = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5607
5621
|
type: "autodate"
|
|
5608
5622
|
}
|
|
5609
5623
|
]
|
|
5610
|
-
},
|
|
5624
|
+
}, yd = {
|
|
5611
5625
|
name: "transactions",
|
|
5612
5626
|
type: "base",
|
|
5613
5627
|
fields: [
|
|
@@ -5662,7 +5676,7 @@ var sd = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5662
5676
|
type: "text"
|
|
5663
5677
|
},
|
|
5664
5678
|
{
|
|
5665
|
-
collectionId:
|
|
5679
|
+
collectionId: fd,
|
|
5666
5680
|
maxSelect: 1,
|
|
5667
5681
|
minSelect: 0,
|
|
5668
5682
|
name: "user",
|
|
@@ -5675,20 +5689,20 @@ var sd = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5675
5689
|
type: "url"
|
|
5676
5690
|
}
|
|
5677
5691
|
]
|
|
5678
|
-
},
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
],
|
|
5692
|
+
}, bd = [hd, gd], xd = [
|
|
5693
|
+
_d,
|
|
5694
|
+
vd,
|
|
5695
|
+
yd
|
|
5696
|
+
], Sd, Cd = /* #__PURE__ */ Object.assign({
|
|
5683
5697
|
"./preview-modifies/src/lib/components/nav-user.svelte": ie,
|
|
5684
|
-
"./preview-modifies/src/routes/(public)/(auth)/signup/+page.server.ts":
|
|
5685
|
-
}),
|
|
5686
|
-
function
|
|
5687
|
-
return h(
|
|
5688
|
-
}
|
|
5689
|
-
async function
|
|
5690
|
-
let t = e.features.auth, r = Object.entries(
|
|
5691
|
-
let r = o(e,
|
|
5698
|
+
"./preview-modifies/src/routes/(public)/(auth)/signup/+page.server.ts": dd
|
|
5699
|
+
}), wd = "./preview-modifies/", Td = "price_preview_placeholder";
|
|
5700
|
+
function Ed(e) {
|
|
5701
|
+
return h(Sd ||= y(["\n <script lang=\"ts\">\n import PaymentButton from '$lib/components/payments/payment-button.svelte';\n <\/script>\n\n <section data-role=\"content\">\n <PaymentButton priceId=\"", "\" />\n </section>\n "]), e);
|
|
5702
|
+
}
|
|
5703
|
+
async function Dd(e) {
|
|
5704
|
+
let t = e.features.auth, r = Object.entries(Cd).map(([e, t]) => {
|
|
5705
|
+
let r = o(e, wd);
|
|
5692
5706
|
return {
|
|
5693
5707
|
path: r,
|
|
5694
5708
|
language: n(r),
|
|
@@ -5698,9 +5712,9 @@ async function Cd(e) {
|
|
|
5698
5712
|
}).sort((e, t) => e.path.localeCompare(t.path)), i = {
|
|
5699
5713
|
path: "src/routes/(public)/payment/+page.svelte",
|
|
5700
5714
|
language: "svelte",
|
|
5701
|
-
content:
|
|
5715
|
+
content: Ed(Td),
|
|
5702
5716
|
status: "success"
|
|
5703
|
-
}, a = [...
|
|
5717
|
+
}, a = [...bd, ...t ? xd : []];
|
|
5704
5718
|
return {
|
|
5705
5719
|
creates: [i],
|
|
5706
5720
|
modifies: r,
|
|
@@ -5714,21 +5728,21 @@ async function Cd(e) {
|
|
|
5714
5728
|
}
|
|
5715
5729
|
//#endregion
|
|
5716
5730
|
//#region src/patterns/enable/payments/index.ts
|
|
5717
|
-
var
|
|
5718
|
-
async function
|
|
5719
|
-
let t = await
|
|
5731
|
+
var Od = "enable-payments", kd = "1.0.0", Ad = "src/patterns/enable/payments", jd = "/enable/payments";
|
|
5732
|
+
async function Md(e) {
|
|
5733
|
+
let t = await ud(e);
|
|
5720
5734
|
if (e.env === "preview") {
|
|
5721
|
-
let n = await
|
|
5735
|
+
let n = await Dd(e);
|
|
5722
5736
|
return m(i([t, n]), e);
|
|
5723
5737
|
}
|
|
5724
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
5738
|
+
let { generate: n } = await import("./chunks/generate.runtime-DCvLLO7w.js"), r = await n(e), { writeResult: a } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
5725
5739
|
return a(await m(i([t, r]), e), e);
|
|
5726
5740
|
}
|
|
5727
|
-
var
|
|
5728
|
-
version:
|
|
5729
|
-
slug:
|
|
5730
|
-
source:
|
|
5731
|
-
docs:
|
|
5741
|
+
var Nd = {
|
|
5742
|
+
version: kd,
|
|
5743
|
+
slug: Od,
|
|
5744
|
+
source: Ad,
|
|
5745
|
+
docs: jd,
|
|
5732
5746
|
plan: "pro",
|
|
5733
5747
|
title: "Enable payments",
|
|
5734
5748
|
summary: "Adds Stripe payments with product/price sync, checkout flow, and optional saved payment methods when auth is enabled.",
|
|
@@ -5761,14 +5775,14 @@ var kd = {
|
|
|
5761
5775
|
examples: [],
|
|
5762
5776
|
tests: 0,
|
|
5763
5777
|
baseline: "velastack",
|
|
5764
|
-
generate:
|
|
5765
|
-
},
|
|
5766
|
-
"./creates/src/routes/api/stripe/sync/subscriptions/+server.ts":
|
|
5767
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/created.ts":
|
|
5768
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts":
|
|
5769
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts":
|
|
5770
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts":
|
|
5771
|
-
}),
|
|
5778
|
+
generate: Md
|
|
5779
|
+
}, Pd = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\nimport { subscriptionRecordFields } from \"../../../../webhooks/stripe/handlers/subscription/shared\";\n\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const subscriptions = await stripe.subscriptions.list({\n status: \"all\",\n limit: 100,\n });\n\n for (const subscription of subscriptions.data) {\n const fields = subscriptionRecordFields(subscription);\n if (!fields) continue;\n\n let customer;\n try {\n customer = await locals.admin\n .collection(\"stripe_customers\")\n .getOne(fields.customer);\n } catch {\n console.log(\n `Skipping subscription ${subscription.id}: customer ${fields.customer} not found locally`,\n );\n continue;\n }\n\n try {\n await locals.admin\n .collection(\"stripe_subscriptions\")\n .update(subscription.id, fields);\n } catch {\n await locals.admin.collection(\"stripe_subscriptions\").create({\n ...fields,\n user: customer.user,\n });\n }\n }\n\n console.log(\"Subscriptions synced\");\n return json({ message: \"Subscriptions synced\" });\n};\n", Fd = "import Stripe from \"stripe\";\nimport { subscriptionRecordFields } from \"./shared\";\n\n/**\n * Handles customer.subscription.created event\n */\nexport async function handleSubscriptionCreated(\n subscription: Stripe.Subscription,\n locals: App.Locals,\n) {\n const fields = subscriptionRecordFields(subscription);\n if (!fields) return;\n\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getOne(fields.customer);\n\n await locals.admin.collection(\"stripe_subscriptions\").create({\n ...fields,\n user: customer.user,\n });\n}\n", Id = "import Stripe from \"stripe\";\nimport { subscriptionRecordFields } from \"./shared\";\n\n/**\n * Handles customer.subscription.deleted event\n */\nexport async function handleSubscriptionDeleted(\n subscription: Stripe.Subscription,\n locals: App.Locals,\n) {\n const fields = subscriptionRecordFields(subscription);\n if (!fields) return;\n\n try {\n await locals.admin\n .collection(\"stripe_subscriptions\")\n .update(subscription.id, {\n ...fields,\n status: \"canceled\",\n canceled_at: fields.canceled_at ?? new Date().toISOString(),\n });\n } catch {\n // Row may not exist; ignore.\n console.log(`Subscription ${subscription.id} not found for deletion`);\n }\n}\n", Ld = "import Stripe from \"stripe\";\n\nfunction unixToIso(unix: number | null | undefined): string | null {\n if (!unix) return null;\n return new Date(unix * 1000).toISOString();\n}\n\n/**\n * Extracts the subset of Stripe.Subscription fields that map to a\n * stripe_subscriptions row. Returns null if the subscription has no\n * price (shouldn't happen, but guard).\n *\n * `current_period_start`/`current_period_end` live on the subscription item\n * in API versions >= 2025-03-31 — read from there with a fallback to the\n * subscription-level field for older events.\n */\nexport function subscriptionRecordFields(subscription: Stripe.Subscription) {\n const item = subscription.items.data[0];\n const priceId = item?.price.id;\n if (!priceId) {\n console.error(`Subscription ${subscription.id} has no price`);\n return null;\n }\n\n const customerId =\n typeof subscription.customer === \"string\"\n ? subscription.customer\n : subscription.customer.id;\n\n const itemPeriodStart = (item as unknown as { current_period_start?: number })\n .current_period_start;\n const itemPeriodEnd = (item as unknown as { current_period_end?: number })\n .current_period_end;\n const subPeriodStart = (\n subscription as unknown as { current_period_start?: number }\n ).current_period_start;\n const subPeriodEnd = (\n subscription as unknown as { current_period_end?: number }\n ).current_period_end;\n\n return {\n id: subscription.id,\n customer: customerId,\n price: priceId,\n status: subscription.status,\n current_period_start: unixToIso(itemPeriodStart ?? subPeriodStart),\n current_period_end: unixToIso(itemPeriodEnd ?? subPeriodEnd),\n cancel_at_period_end: subscription.cancel_at_period_end,\n canceled_at: unixToIso(subscription.canceled_at),\n };\n}\n", Rd = "import Stripe from \"stripe\";\nimport { subscriptionRecordFields } from \"./shared\";\n\n/**\n * Handles customer.subscription.updated event\n */\nexport async function handleSubscriptionUpdated(\n subscription: Stripe.Subscription,\n locals: App.Locals,\n) {\n const fields = subscriptionRecordFields(subscription);\n if (!fields) return;\n\n try {\n await locals.admin\n .collection(\"stripe_subscriptions\")\n .update(subscription.id, fields);\n } catch {\n // Row may not exist if the created event was missed; upsert instead.\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getOne(fields.customer);\n\n await locals.admin.collection(\"stripe_subscriptions\").create({\n ...fields,\n user: customer.user,\n });\n }\n}\n", zd = /* #__PURE__ */ Object.assign({
|
|
5780
|
+
"./creates/src/routes/api/stripe/sync/subscriptions/+server.ts": Pd,
|
|
5781
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/created.ts": Fd,
|
|
5782
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts": Id,
|
|
5783
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts": Ld,
|
|
5784
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts": Rd
|
|
5785
|
+
}), Bd = "./creates/", Vd = {
|
|
5772
5786
|
name: "stripe_subscriptions",
|
|
5773
5787
|
type: "base",
|
|
5774
5788
|
fields: [
|
|
@@ -5843,10 +5857,10 @@ var kd = {
|
|
|
5843
5857
|
}
|
|
5844
5858
|
]
|
|
5845
5859
|
};
|
|
5846
|
-
async function
|
|
5860
|
+
async function Hd(e) {
|
|
5847
5861
|
return {
|
|
5848
|
-
creates: Object.entries(
|
|
5849
|
-
let r = o(e,
|
|
5862
|
+
creates: Object.entries(zd).map(([e, t]) => {
|
|
5863
|
+
let r = o(e, Bd);
|
|
5850
5864
|
return {
|
|
5851
5865
|
path: r,
|
|
5852
5866
|
language: n(r),
|
|
@@ -5858,14 +5872,14 @@ async function Rd(e) {
|
|
|
5858
5872
|
deletes: [],
|
|
5859
5873
|
components: [],
|
|
5860
5874
|
packages: [],
|
|
5861
|
-
collections: [
|
|
5875
|
+
collections: [Vd],
|
|
5862
5876
|
collectionPatches: [],
|
|
5863
5877
|
collectionDrops: []
|
|
5864
5878
|
};
|
|
5865
5879
|
}
|
|
5866
5880
|
//#endregion
|
|
5867
5881
|
//#region src/patterns/enable/subscriptions/generate.preview.ts
|
|
5868
|
-
var
|
|
5882
|
+
var Ud = /* #__PURE__ */ Object.assign({
|
|
5869
5883
|
"./preview-modifies/data/hooks/stripe.pb.js": oe,
|
|
5870
5884
|
"./preview-modifies/src/lib/components/app-sidebar.svelte": de,
|
|
5871
5885
|
"./preview-modifies/src/lib/components/nav-user.svelte": le,
|
|
@@ -5874,12 +5888,12 @@ var zd = /* #__PURE__ */ Object.assign({
|
|
|
5874
5888
|
"./preview-modifies/src/routes/(app)/billing/+page.server.ts": ue,
|
|
5875
5889
|
"./preview-modifies/src/routes/(app)/billing/+page.svelte": ce,
|
|
5876
5890
|
"./preview-modifies/src/routes/webhooks/stripe/+server.ts": fe
|
|
5877
|
-
}),
|
|
5878
|
-
async function
|
|
5891
|
+
}), Wd = "./preview-modifies/";
|
|
5892
|
+
async function Gd(e) {
|
|
5879
5893
|
return {
|
|
5880
5894
|
creates: [],
|
|
5881
|
-
modifies: Object.entries(
|
|
5882
|
-
let r = o(e,
|
|
5895
|
+
modifies: Object.entries(Ud).map(([e, t]) => {
|
|
5896
|
+
let r = o(e, Wd);
|
|
5883
5897
|
return {
|
|
5884
5898
|
path: r,
|
|
5885
5899
|
language: n(r),
|
|
@@ -5897,24 +5911,24 @@ async function Vd(e) {
|
|
|
5897
5911
|
}
|
|
5898
5912
|
//#endregion
|
|
5899
5913
|
//#region src/patterns/enable/subscriptions/index.ts
|
|
5900
|
-
var
|
|
5901
|
-
async function
|
|
5902
|
-
let t = await
|
|
5914
|
+
var Kd = "enable-subscriptions", qd = "1.0.0", Jd = "src/patterns/enable/subscriptions", Yd = "/enable/subscriptions";
|
|
5915
|
+
async function Xd(e) {
|
|
5916
|
+
let t = await Hd(e);
|
|
5903
5917
|
if (e.env === "preview") {
|
|
5904
|
-
let n = await
|
|
5918
|
+
let n = await Gd(e);
|
|
5905
5919
|
return m(i([t, n]), e);
|
|
5906
5920
|
}
|
|
5907
|
-
let { createCollections: n } = await import("./chunks/collections-
|
|
5921
|
+
let { createCollections: n } = await import("./chunks/collections-B3lAtPlQ.js"), r = await n(t.collections, e), { generate: a } = await import("./chunks/generate.runtime-BlQ1vx8j.js"), o = await a(e), { writeResult: s } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
5908
5922
|
return s(await m(i([{
|
|
5909
5923
|
...t,
|
|
5910
5924
|
creates: [...t.creates, ...r]
|
|
5911
5925
|
}, o]), e), e);
|
|
5912
5926
|
}
|
|
5913
|
-
var
|
|
5914
|
-
version:
|
|
5915
|
-
slug:
|
|
5916
|
-
source:
|
|
5917
|
-
docs:
|
|
5927
|
+
var Zd = {
|
|
5928
|
+
version: qd,
|
|
5929
|
+
slug: Kd,
|
|
5930
|
+
source: Jd,
|
|
5931
|
+
docs: Yd,
|
|
5918
5932
|
plan: "pro",
|
|
5919
5933
|
title: "Enable subscriptions",
|
|
5920
5934
|
summary: "Adds Stripe subscription billing with plan selection, cancel/resume, and webhook-synced subscription state. Requires enable-payments.",
|
|
@@ -5948,52 +5962,52 @@ var qd = {
|
|
|
5948
5962
|
examples: [],
|
|
5949
5963
|
tests: 0,
|
|
5950
5964
|
baseline: "velastack",
|
|
5951
|
-
generate:
|
|
5952
|
-
}, Jd = "<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';\n import * as Sidebar from '$lib/components/ui/sidebar/index.js';\n import { useSidebar } from '$lib/components/ui/sidebar/index.js';\n import PlusIcon from '@lucide/svelte/icons/plus';\n import UsersIcon from '@lucide/svelte/icons/users';\n import { page } from '$app/state';\n import { goto, invalidate } from '$app/navigation';\n\n let { teams, children }: { teams: { id: string; name: string }[] } & { children: Snippet } =\n $props();\n\n const switchTeam = async (teamId: string) => {\n await goto(`/teams/switch/${teamId}?redirect=${encodeURIComponent(page.url.pathname)}`);\n invalidate('app:team');\n };\n\n const sidebar = useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n {...props}\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n >\n {@render children?.()}\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n align=\"start\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"text-muted-foreground text-xs\">Teams</DropdownMenu.Label>\n {#each teams as team (team.name)}\n <DropdownMenu.Item onSelect={() => switchTeam(team.id)} class=\"gap-2 p-2\">\n <div class=\"flex size-6 items-center justify-center rounded-md border\">\n <UsersIcon class=\"size-3.5 shrink-0\" />\n </div>\n {team.name}\n </DropdownMenu.Item>\n {/each}\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"gap-2 p-2\">\n <div class=\"flex size-6 items-center justify-center rounded-md border bg-transparent\">\n <PlusIcon class=\"size-4\" />\n </div>\n <a href=\"/teams/new\" class=\"text-muted-foreground font-medium\">Add team</a>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", Yd = "import { z } from \"zod\";\n\nexport const teamSchema = z.object({\n name: z.string(),\n});\n", Xd = "import { z } from \"zod\";\n\nexport const teamInviteSchema = z.object({\n email: z.email(),\n});\n", Zd = "import { z } from \"zod\";\n\nexport const teamRoleSchema = z.object({\n role: z.enum([\"owner\", \"admin\", \"member\"]),\n});\n", Qd = "<script lang=\"ts\">\n import RootLayout from '../../../(public)/root-layout.svelte';\n\n let { data, children } = $props();\n<\/script>\n\n<RootLayout {data}>\n {@render children?.()}\n</RootLayout>\n", $d = "import { error } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\n\nexport const load = async ({ params, locals }) => {\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invites\").getOne(params.id, {\n expand: \"team\",\n });\n } catch {\n return error(404, { message: \"Invite not found\" });\n }\n\n return { invite };\n};\n\nexport const actions = {\n default: async ({ locals, params, cookies }) => {\n const user = locals.pb.authStore.record!;\n\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invites\").getOne(params.id);\n } catch {\n return error(404, { message: \"Invite not found\" });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: invite.team,\n role: \"member\",\n });\n\n await locals.admin.collection(\"team_invites\").delete(invite.id);\n\n redirect(\n 303,\n `/dashboard`,\n { type: \"toast\", message: \"Joined team\" },\n cookies,\n );\n },\n};\n", ef = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\"\n >{data.invite.expand?.team.name} invited you to join their team</Card.Title\n >\n <Card.Description>Accept the invite to join the team</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Button type=\"submit\" class=\"w-full\">Accept Invite</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", tf = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Invitation'\n });\n\n return { ...data, pageMetaTags };\n};\n", nf = "<script lang=\"ts\">\n import RootLayout from '../../../(public)/root-layout.svelte';\n\n let { data, children } = $props();\n<\/script>\n\n<RootLayout {data}>\n {@render children?.()}\n</RootLayout>\n", rf = "import { error } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\n\nexport const load = async ({ params, locals }) => {\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invite_links\").getOne(params.id, {\n expand: \"team\",\n });\n } catch {\n return error(404, { message: \"Invite link not found\" });\n }\n\n return { invite };\n};\n\nexport const actions = {\n default: async ({ locals, params, cookies }) => {\n const user = locals.pb.authStore.record!;\n\n let invite;\n try {\n invite = await locals.pb\n .collection(\"team_invite_links\")\n .getOne(params.id, {\n expand: \"team\",\n });\n } catch {\n return error(404, { message: \"Invite link not found\" });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: invite.team,\n role: \"member\",\n });\n\n redirect(\n 303,\n `/dashboard`,\n { type: \"toast\", message: \"Joined team\" },\n cookies,\n );\n },\n};\n", af = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\"\n >{data.invite.expand?.team.name} invited you to join their team</Card.Title\n >\n <Card.Description>Accept the invite to join the team</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Button type=\"submit\" class=\"w-full\">Accept Invite</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", of = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Join team'\n });\n\n return { ...data, pageMetaTags };\n};\n", sf = "export const load = async ({ locals, parent }) => {\n const { user, breadcrumbs } = await parent();\n\n const ownedTeams = await locals.pb.collection(\"teams\").getFullList({\n filter: locals.pb.filter(\"owner = {:owner}\", { owner: user.id }),\n expand: \"team_users_via_team\",\n });\n\n const memberships = await locals.pb\n .collection(\"team_memberships\")\n .getFullList({\n filter: locals.pb.filter(\"user = {:user}\", { user: user.id }),\n expand: \"team\",\n });\n\n const pendingInvites = await locals.pb\n .collection(\"team_invites\")\n .getFullList({\n filter: locals.pb.filter(\"email = {:email}\", { email: user.email }),\n expand: \"team\",\n });\n\n const teams = [\n ...ownedTeams.map((team) => ({\n type: \"team\" as const,\n id: team.id,\n name: team.name,\n role: \"owner\" as const,\n members: team.expand?.team_users_via_team?.length || 0,\n })),\n ...memberships\n .filter((membership) => membership.expand?.team.owner !== membership.user)\n .map((membership) => ({\n type: \"membership\" as const,\n id: membership.team,\n name: membership.expand?.team.name,\n role: membership.role,\n })),\n ...pendingInvites.map((invite) => ({\n type: \"invite\" as const,\n id: invite.team,\n name: invite.expand?.team.name,\n role: null,\n invite_id: invite.id,\n })),\n ];\n\n return {\n teams,\n breadcrumbs: [...breadcrumbs, { title: \"Teams\", url: \"/teams\" }],\n };\n};\n", cf = "<script lang=\"ts\">\n import * as Card from '$lib/components/ui/card';\n import { Button } from '$lib/components/ui/button';\n import UserIcon from '@lucide/svelte/icons/user';\n import UserPlusIcon from '@lucide/svelte/icons/user-plus';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import * as Avatar from '$lib/components/ui/avatar';\n\n const roleLabels = {\n owner: 'Owner',\n admin: 'Admin',\n member: 'Member'\n };\n\n let { data, children } = $props();\n<\/script>\n\n<section data-slot=\"content\">\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Management</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Organize your workspace with teams. Collaborate with members, manage permissions, and\n streamline your workflow.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Your Teams</Card.Title>\n <Card.Description>Manage and view your team memberships</Card.Description>\n </Card.Header>\n <Card.Content class=\"space-y-4\">\n {#if data.teams && data.teams.length > 0}\n <div class=\"grid gap-3\">\n {#each data.teams as team}\n <div\n class=\"flex items-center justify-between p-4 border rounded-lg hover:bg-muted/50 transition-colors\"\n >\n <div class=\"flex items-center space-x-3\">\n <Avatar.Root class=\"size-10 rounded-lg\">\n <Avatar.Fallback\n class=\"rounded-lg bg-primary text-primary-foreground font-medium\"\n >\n {team.name?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n {#if team.role === 'owner' || team.role === 'admin'}\n <a\n href=\"/teams/{team.id}\"\n class=\"font-medium text-foreground hover:text-primary transition-colors\"\n >\n {team.name}\n </a>\n {:else}\n <span class=\"font-medium text-foreground\">\n {team.name}\n </span>\n {/if}\n <p class=\"text-sm text-muted-foreground\">\n {team.role ? roleLabels[team.role] : 'Pending'}\n </p>\n </div>\n </div>\n {#if team.type === 'team'}\n <div class=\"flex items-center space-x-2 text-sm text-muted-foreground\">\n <UserIcon class=\"w-4 h-4\" />\n <span class=\"font-medium\">\n {team.members} member{team.members !== 1 ? 's' : ''}\n </span>\n </div>\n {:else if team.type === 'membership'}\n <div class=\"flex items-center\">\n <form method=\"POST\" action=\"?/leaveTeam\">\n <input type=\"hidden\" name=\"team_id\" value={team.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">\n <LogOutIcon class=\"w-4 h-4\" />\n Leave team\n </Button>\n </form>\n </div>\n {:else if team.type === 'invite'}\n <div class=\"flex items-center\">\n <form method=\"POST\" action=\"?/acceptInvite\">\n <input type=\"hidden\" name=\"invite_id\" value={team.invite_id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">\n <UserPlusIcon class=\"w-4 h-4\" />\n Accept invitation\n </Button>\n </form>\n </div>\n {/if}\n </div>\n {/each}\n </div>\n {:else}\n <div class=\"text-center py-8\">\n <div\n class=\"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4\"\n >\n <UserIcon class=\"w-6 h-6 text-muted-foreground\" />\n </div>\n <h3 class=\"text-lg font-medium text-foreground mb-2\">No teams yet</h3>\n <p class=\"text-muted-foreground mb-4\">Get started by creating your first team</p>\n </div>\n {/if}\n </Card.Content>\n <Card.Footer class=\"flex justify-between items-center pt-4 border-t\">\n <div class=\"text-sm text-muted-foreground\">\n {data.teams?.length || 0} team{(data.teams?.length || 0) !== 1 ? 's' : ''}\n </div>\n <Button size=\"sm\" href=\"/teams/new\" class=\"ml-auto\">Create new team</Button>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n</section>\n\n{@render children?.()}\n", lf = "import { error, fail } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\n\nexport const actions = {\n acceptInvite: async ({ locals, request, cookies }) => {\n const user = locals.pb.authStore.record!;\n const form = await request.formData();\n const inviteId = form.get(\"invite_id\") as string;\n if (!inviteId) {\n return fail(400, { error: \"Invite ID is required\" });\n }\n\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invites\").getOne(inviteId);\n } catch {\n return error(404, { message: \"Invite not found\" });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: invite.team,\n role: \"member\",\n });\n\n await locals.admin.collection(\"team_invites\").delete(invite.id);\n\n redirect(303, `/teams`, { type: \"toast\", message: \"Joined team\" }, cookies);\n },\n leaveTeam: async ({ locals, request, cookies }) => {\n const user = locals.pb.authStore.record!;\n const form = await request.formData();\n const teamId = form.get(\"team_id\") as string;\n if (!teamId) {\n return fail(400, { error: \"Team ID is required\" });\n }\n\n let teamMembership;\n try {\n teamMembership = await locals.pb\n .collection(\"team_memberships\")\n .getFirstListItem(\n locals.pb.filter(\"team = {:team} && user = {:user}\", {\n team: teamId,\n user: user.id,\n }),\n );\n } catch {\n return error(404, { message: \"Team not found\" });\n }\n\n if (teamMembership.role === \"owner\") {\n return error(400, { message: \"You cannot leave a team you own\" });\n }\n\n await locals.pb.collection(\"team_memberships\").delete(teamMembership.id);\n\n redirect(303, `/teams`, { type: \"toast\", message: \"Left team\" }, cookies);\n },\n};\n", uf = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Teams'\n });\n\n return { ...data, pageMetaTags };\n};\n", df = "import { redirect } from \"@sveltejs/kit\";\nimport { superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamSchema } from \"$lib/schemas/team\";\n\nexport const load = async ({ params, locals, parent }) => {\n const { user, breadcrumbs } = await parent();\n const { id } = params;\n\n let team;\n try {\n team = await locals.pb.collection(\"teams\").getOne(id, {\n expand: \"team_invite_links_via_team\",\n });\n } catch {\n redirect(303, \"/teams\");\n }\n\n let userMembership;\n try {\n userMembership = await locals.pb.collection(\"team_users\").getFirstListItem(\n locals.pb.filter(\n 'team = {:team} && id = {:user} && (role = \"admin\" || role = \"owner\")',\n {\n team: id,\n user: user.id,\n },\n ),\n );\n } catch (error) {\n redirect(303, \"/teams\");\n }\n\n const role = userMembership.role;\n\n // Get all team members with their roles\n const teamMembers = await locals.pb.collection(\"team_users\").getFullList({\n filter: locals.pb.filter(\"team = {:team}\", { team: id }),\n });\n\n // Get pending invites for this team\n const pendingInvites = await locals.pb\n .collection(\"team_invites\")\n .getFullList({\n filter: locals.pb.filter(\"team = {:team}\", { team: id }),\n });\n\n const form = await superValidate(team, zod4(teamSchema));\n\n return {\n team,\n role,\n teamMembers,\n pendingInvites,\n inviteLink: team.expand?.team_invite_links_via_team,\n form,\n breadcrumbs: [\n ...breadcrumbs,\n { title: \"Teams\", url: \"/teams\" },\n { title: team.name, url: `/teams/${id}` },\n ],\n };\n};\n", ff = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Card from '$lib/components/ui/card';\n import { Button, buttonVariants } from '$lib/components/ui/button';\n import CrownIcon from '@lucide/svelte/icons/crown';\n import ShieldIcon from '@lucide/svelte/icons/shield';\n import UserCheckIcon from '@lucide/svelte/icons/user-check';\n import UserPlusIcon from '@lucide/svelte/icons/user-plus';\n import CopyIcon from '@lucide/svelte/icons/copy';\n import MailIcon from '@lucide/svelte/icons/mail';\n import ClockIcon from '@lucide/svelte/icons/clock';\n import * as Avatar from '$lib/components/ui/avatar';\n import { Badge } from '$lib/components/ui/badge';\n import * as Table from '$lib/components/ui/table';\n import { getAuthorization } from './authorization';\n import { toast } from 'svelte-sonner';\n import * as AlertDialog from '$lib/components/ui/alert-dialog';\n import * as Form from '$lib/components/ui/form';\n import TrashIcon from '@lucide/svelte/icons/trash-2';\n import { Input } from '$lib/components/ui/input';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamSchema } from '$lib/schemas/team';\n\n let { data, children } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamSchema),\n warnings: {\n duplicateId: false\n }\n }\n );\n\n const { form: formData } = form;\n\n function getRoleIcon(role: 'owner' | 'admin' | 'member') {\n switch (role) {\n case 'owner':\n return CrownIcon;\n case 'admin':\n return ShieldIcon;\n case 'member':\n return UserCheckIcon;\n }\n }\n\n function handleCopyLink(inviteStr: string) {\n const link = `${data.meta.appURL}/${inviteStr}`;\n navigator.clipboard.writeText(link);\n toast.success('Link copied to clipboard');\n }\n<\/script>\n\n<section data-slot=\"content\">\n {#if data.role === 'owner'}\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Settings</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Update your team name and manage basic team settings.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <form method=\"POST\" action=\"?/updateTeam\" class=\"space-y-4\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Team Name</Card.Title>\n <Card.Description>Update your team's display name</Card.Description>\n </Card.Header>\n <Card.Content>\n <div class=\"space-y-2\">\n <Form.Field {form} name=\"name\">\n <Form.Control>\n {#snippet children({ props })}\n <Input {...props} type=\"text\" bind:value={$formData.name} required />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </Card.Content>\n <Card.Footer class=\"flex justify-end pt-4 border-t\">\n <Button type=\"submit\" class=\"flex items-center\" size=\"sm\">Save changes</Button>\n </Card.Footer>\n </form>\n </Card.Root>\n </div>\n </div>\n {/if}\n\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Members</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Manage team members and their roles. Control access permissions and organize your team\n effectively.\n </p>\n <div class=\"mt-4 space-y-2\">\n <div class=\"flex items-center text-sm text-muted-foreground\">\n <div class=\"w-2 h-2 bg-muted-foreground rounded-full mr-2\"></div>\n <span>Owner - Full team control</span>\n </div>\n <div class=\"flex items-center text-sm text-muted-foreground\">\n <div class=\"w-2 h-2 bg-muted-foreground rounded-full mr-2\"></div>\n <span>Admin - Manage members</span>\n </div>\n <div class=\"flex items-center text-sm text-muted-foreground\">\n <div class=\"w-2 h-2 bg-muted-foreground rounded-full mr-2\"></div>\n <span>Member - Team access</span>\n </div>\n </div>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">{data.team.name} Members</Card.Title>\n <Card.Description>Manage team members and their roles</Card.Description>\n </Card.Header>\n <Card.Content>\n <Table.Root>\n <Table.Header>\n <Table.Row>\n <Table.Head>Member</Table.Head>\n <Table.Head>Role</Table.Head>\n <Table.Head></Table.Head>\n </Table.Row>\n </Table.Header>\n <Table.Body>\n <!-- Team Members -->\n {#each data.teamMembers as member}\n {@const { canRemove, canChangeRole } = getAuthorization({\n user: data.user,\n role: data.role,\n member\n })}\n <Table.Row>\n <Table.Cell>\n <div class=\"flex items-center space-x-3\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback\n class=\"rounded-lg bg-primary text-primary-foreground font-medium\"\n >\n {member.name?.charAt(0).toUpperCase() ||\n member.email.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n <div class=\"font-medium text-foreground\">\n {member.name || member.email}\n </div>\n <div class=\"text-sm text-muted-foreground\">\n {member.email}\n </div>\n </div>\n </div>\n </Table.Cell>\n <Table.Cell>\n <Badge variant=\"outline\" class=\"flex items-center space-x-1 w-fit\">\n {@const Icon = getRoleIcon(member.role)}\n <Icon class=\"w-3 h-3\" />\n <span class=\"capitalize\">{member.role}</span>\n </Badge>\n </Table.Cell>\n <Table.Cell>\n <div class=\"flex space-x-2 justify-end\">\n {#if canChangeRole}\n <Button\n href=\"/teams/{data.team.id}/member/{member.membership_id}\"\n variant=\"outline\"\n size=\"sm\"\n data-sveltekit-noscroll\n >\n Change Role\n </Button>\n {/if}\n {#if canRemove}\n <form method=\"POST\" action=\"?/removeMember\">\n <input type=\"hidden\" name=\"member_id\" value={member.membership_id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Remove</Button>\n </form>\n {/if}\n </div>\n </Table.Cell>\n </Table.Row>\n {/each}\n </Table.Body>\n </Table.Root>\n </Card.Content>\n <Card.Footer class=\"flex justify-between items-center pt-4 border-t\">\n <div class=\"text-sm text-muted-foreground\">\n {data.teamMembers?.length || 0} member{(data.teamMembers?.length || 0) !== 1 ? 's' : ''}\n total\n </div>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Invites</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Invitations that have been sent but not yet accepted. You can resend or cancel pending\n invites.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Invitations</Card.Title>\n <Card.Description>Manage pending team invitations</Card.Description>\n </Card.Header>\n <Card.Content>\n {#if data.pendingInvites && data.pendingInvites.length > 0}\n <Table.Root>\n <Table.Header>\n <Table.Row>\n <Table.Head>Email</Table.Head>\n <Table.Head>Status</Table.Head>\n <Table.Head></Table.Head>\n </Table.Row>\n </Table.Header>\n <Table.Body>\n {#each data.pendingInvites as invite}\n <Table.Row>\n <Table.Cell>\n <div class=\"flex items-center space-x-3\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback\n class=\"rounded-lg bg-muted text-muted-foreground font-medium\"\n >\n <MailIcon class=\"w-4 h-4\" />\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n <div class=\"font-medium text-foreground\">\n {invite.email}\n </div>\n <div class=\"text-sm text-muted-foreground\">Pending invitation</div>\n </div>\n </div>\n </Table.Cell>\n <Table.Cell>\n <Badge variant=\"outline\" class=\"flex items-center space-x-1 w-fit\">\n <ClockIcon class=\"w-3 h-3\" />\n <span>Pending</span>\n </Badge>\n </Table.Cell>\n <Table.Cell>\n <div class=\"flex space-x-2 justify-end\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onclick={() => handleCopyLink(`invite/${invite.id}`)}>Copy link</Button\n >\n <form method=\"POST\" action=\"?/resendInvite\">\n <input type=\"hidden\" name=\"invite_id\" value={invite.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Resend</Button>\n </form>\n <form method=\"POST\" action=\"?/cancelInvite\">\n <input type=\"hidden\" name=\"invite_id\" value={invite.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Cancel</Button>\n </form>\n </div>\n </Table.Cell>\n </Table.Row>\n {/each}\n </Table.Body>\n </Table.Root>\n {:else}\n <div class=\"text-center py-8\">\n <div\n class=\"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4\"\n >\n <MailIcon class=\"w-6 h-6 text-muted-foreground\" />\n </div>\n <h3 class=\"text-lg font-medium text-foreground mb-2\">No pending invites</h3>\n <p class=\"text-muted-foreground mb-4\">\n All invitations have been accepted or there are no pending invites\n </p>\n </div>\n {/if}\n </Card.Content>\n <Card.Footer class=\"flex justify-between items-center pt-4 border-t\">\n <div class=\"text-sm text-muted-foreground\">\n {#if data.inviteLink}\n <div class=\"text-sm text-muted-foreground\">\n {data.meta.appURL}/join/{data.inviteLink.id}\n </div>\n {/if}\n </div>\n <div class=\"flex items-center space-x-2\">\n {#if data.inviteLink}\n <Button\n variant=\"outline\"\n size=\"sm\"\n onclick={() => handleCopyLink(`join/${data.inviteLink.id}`)}\n >\n <CopyIcon class=\"w-4 h-4\" />\n Copy invite link\n </Button>\n {/if}\n\n <Button\n size=\"sm\"\n href=\"/teams/{data.team.id}/invite\"\n class=\"ml-auto\"\n data-sveltekit-noscroll\n >\n <UserPlusIcon class=\"w-4 h-4\" />\n Invite member\n </Button>\n </div>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n\n {#if data.role === 'owner'}\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Danger Zone</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Permanently delete this team and all associated data. This action cannot be undone.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Delete Team</Card.Title>\n <Card.Description>\n Remove this team and all associated data permanently\n </Card.Description>\n </Card.Header>\n <Card.Content>\n <div\n class=\"flex items-center space-x-3 p-4 bg-destructive/10 rounded-lg border border-destructive/20\"\n >\n <div class=\"flex-shrink-0\">\n <TrashIcon class=\"w-5 h-5 text-destructive\" />\n </div>\n <div class=\"flex-1\">\n <p class=\"text-sm font-medium text-destructive\">Delete this team</p>\n <p class=\"text-sm text-muted-foreground\">\n This will permanently delete the team, remove all members, and delete all\n associated data.\n </p>\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"flex justify-end pt-4 border-t\">\n <AlertDialog.Root>\n <AlertDialog.Trigger class={buttonVariants({ variant: 'destructive', size: 'sm' })}>\n <TrashIcon class=\"w-4 h-4\" />\n Delete team\n </AlertDialog.Trigger>\n <AlertDialog.Content>\n <AlertDialog.Header>\n <AlertDialog.Title>Delete Team</AlertDialog.Title>\n <AlertDialog.Description>\n Are you sure you want to delete \"{data.team.name}\"? This action cannot be\n undone. This will permanently delete the team, remove all members, and delete\n all associated data.\n </AlertDialog.Description>\n </AlertDialog.Header>\n <AlertDialog.Footer>\n <AlertDialog.Cancel>Cancel</AlertDialog.Cancel>\n <form method=\"POST\" action=\"?/deleteTeam\" class=\"inline\">\n <AlertDialog.Action>\n <TrashIcon class=\"w-4 h-4\" />\n Delete team\n </AlertDialog.Action>\n </form>\n </AlertDialog.Footer>\n </AlertDialog.Content>\n </AlertDialog.Root>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n {/if}\n</section>\n\n{@render children?.()}\n", pf = "import { error, fail } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { superValidate } from \"sveltekit-superforms\";\nimport { teamSchema } from \"$lib/schemas/team\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\n\nexport const actions = {\n updateTeam: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(teamSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb\n .collection(\"teams\")\n .update(params.id, { name: form.data.name });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n redirect(\n 303,\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Team updated\" },\n cookies,\n );\n },\n removeMember: async ({ locals, params, request, cookies }) => {\n const formData = await request.formData();\n const memberId = formData.get(\"member_id\") as string;\n if (!memberId) {\n return error(400, { message: \"Member ID is required\" });\n }\n\n try {\n await locals.pb.collection(\"team_memberships\").delete(memberId);\n } catch {\n return error(400, { message: \"Failed to remove member\" });\n }\n\n redirect(\n 303,\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Member removed\" },\n cookies,\n );\n },\n resendInvite: async ({ locals }) => {\n const user = locals.pb.authStore.record!;\n },\n cancelInvite: async ({ locals, params, request, cookies }) => {\n const formData = await request.formData();\n const inviteId = formData.get(\"invite_id\") as string;\n if (!inviteId) {\n return error(400, { message: \"Invite ID is required\" });\n }\n\n try {\n await locals.pb.collection(\"team_invites\").delete(inviteId);\n } catch {\n return error(400, { message: \"Failed to cancel invite\" });\n }\n\n redirect(\n 303,\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Invite cancelled\" },\n cookies,\n );\n },\n deleteTeam: async ({ locals, params, cookies }) => {\n try {\n await locals.pb.collection(\"teams\").delete(params.id);\n } catch {\n return error(400, { message: \"Failed to delete team\" });\n }\n\n const team = cookies.get(\"team\");\n if (team === params.id) {\n cookies.delete(\"team\", { path: \"/\" });\n }\n\n redirect(\n 303,\n `/teams`,\n { type: \"toast\", message: \"Team deleted successfully\" },\n cookies,\n );\n },\n};\n", mf = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Team'\n });\n\n return { ...data, pageMetaTags };\n};\n", hf = "type Role = \"owner\" | \"admin\" | \"member\";\n\ninterface User {\n id: string;\n}\n\ninterface Member {\n id: string;\n role: Role;\n}\n\nexport const getAuthorization = ({\n user,\n role,\n member,\n}: {\n user: User;\n role: Role;\n member?: Member;\n}) => {\n const isSelf = member ? user.id === member.id : false;\n const isOwner = role === \"owner\";\n const isAdmin = role === \"admin\";\n\n if (isSelf) {\n return {\n canRemove: false,\n canChangeRole: false,\n };\n } else if (isOwner) {\n return {\n canRemove: true,\n canChangeRole: true,\n };\n } else if (isAdmin) {\n if (member && member.role === \"member\") {\n return {\n canRemove: true,\n canChangeRole: false,\n };\n }\n\n return {\n canRemove: false,\n canChangeRole: false,\n };\n }\n\n return {\n canRemove: false,\n canChangeRole: false,\n };\n};\n", gf = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamInviteSchema } from \"$lib/schemas/teamInvite\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\n\nexport const load = async () => {\n const form = await superValidate(zod4(teamInviteSchema));\n return { form };\n};\n\nexport const actions = {\n default: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(teamInviteSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n const team = await locals.pb.collection(\"teams\").getOne(params.id);\n\n try {\n await locals.pb.collection(\"team_invites\").create({\n email: form.data.email,\n team: params.id,\n name: team.name,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n redirect(\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Invite sent\" },\n cookies,\n );\n },\n};\n", _f = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Input } from '$lib/components/ui/input';\n import { goto } from '$app/navigation';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamInviteSchema } from '$lib/schemas/teamInvite';\n import * as Form from '$lib/components/ui/form';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamInviteSchema)\n }\n );\n\n const { form: formData } = form;\n\n const handleOpenChange = (open: boolean) => {\n if (!open) {\n goto(`/teams/${data.team.id}`, { noScroll: true });\n }\n };\n<\/script>\n\n<Dialog.Root open onOpenChange={handleOpenChange}>\n <Dialog.Content>\n <form method=\"POST\">\n <Dialog.Header class=\"mb-4\">\n <Dialog.Title>Invite to Team</Dialog.Title>\n </Dialog.Header>\n <Form.Field {form} name=\"email\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input {...props} type=\"email\" bind:value={$formData.email} />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Dialog.Footer class=\"mt-4\">\n <Form.Button>Send Invite</Form.Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n</Dialog.Root>\n", vf = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Invite to team'\n });\n\n return { ...data, pageMetaTags };\n};\n", yf = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n team = await context.admin.collection(\"teams\").create({\n name: \"Test Team\",\n owner: context.user.id,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: context.user.id,\n role: \"owner\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/[id]/invite\", () => {\n it(\"authenticated user should be able to access invite page\", async (context) => {\n const response = await context.agent.get(\n `/teams/${team.id}/invite` satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/[id]/invite\", () => {\n it(\"owner should be able to create invite with valid email\", async (context) => {\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: inviteEmail,\n });\n\n const invites = await context.admin\n .collection(\"team_invites\")\n .getList(1, 1, {\n filter: `team = \"${team.id}\" && email = \"${inviteEmail}\"`,\n });\n expect(invites.items).toHaveLength(1);\n expect(invites.items[0].email).toBe(inviteEmail);\n expect(invites.items[0].team).toBe(team.id);\n });\n\n it(\"admin should be able to create invite with valid email\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: inviteEmail,\n });\n\n const invites = await context.admin\n .collection(\"team_invites\")\n .getList(1, 1, {\n filter: `team = \"${team.id}\" && email = \"${inviteEmail}\"`,\n });\n expect(invites.items).toHaveLength(1);\n expect(invites.items[0].email).toBe(inviteEmail);\n expect(invites.items[0].team).toBe(team.id);\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to create invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: inviteEmail,\n });\n\n const invites = await context.admin\n .collection(\"team_invites\")\n .getList(1, 1, {\n filter: `team = \"${team.id}\" && email = \"${inviteEmail}\"`,\n });\n expect(invites.items).toHaveLength(0);\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"should return 400 for invalid email\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: \"invalid-email\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for missing email\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for empty email\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: \"\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n});\n", bf = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamRoleSchema } from \"$lib/schemas/teamRole\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\n\nexport const load = async ({ locals, params }) => {\n const member = await locals.pb\n .collection(\"team_memberships\")\n .getOne(params.member_id);\n const form = await superValidate(member, zod4(teamRoleSchema));\n\n return { form };\n};\n\nexport const actions = {\n default: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(teamRoleSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb.collection(\"team_memberships\").update(params.member_id, {\n role: form.data.role,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n redirect(\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Role updated successfully\" },\n cookies,\n );\n },\n};\n", xf = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '$lib/components/ui/dialog';\n import { goto } from '$app/navigation';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamRoleSchema } from '$lib/schemas/teamRole';\n import * as Form from '$lib/components/ui/form';\n import * as Select from '$lib/components/ui/select';\n\n let { data } = $props();\n\n const roleLabels = {\n owner: {\n label: 'Owner',\n value: 'owner'\n },\n admin: {\n label: 'Admin',\n value: 'admin'\n },\n member: {\n label: 'Member',\n value: 'member'\n }\n } as const;\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamRoleSchema)\n }\n );\n\n const { form: formData } = form;\n\n const handleOpenChange = (open: boolean) => {\n if (!open) {\n goto(`/teams/${data.team.id}`, { noScroll: true });\n }\n };\n<\/script>\n\n<Dialog.Root open onOpenChange={handleOpenChange}>\n <Dialog.Content>\n <form method=\"POST\">\n <Dialog.Header class=\"mb-4\">\n <Dialog.Title>Change Role</Dialog.Title>\n </Dialog.Header>\n <Form.Field {form} name=\"role\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Role</Form.Label>\n <Select.Root type=\"single\" {...props} bind:value={$formData.role}>\n <Select.Trigger class=\"w-full\">\n {roleLabels[$formData.role].label}\n </Select.Trigger>\n <Select.Content>\n {#each Object.values(roleLabels) as role}\n <Select.Item value={role.value}>{role.label}</Select.Item>\n {/each}\n </Select.Content>\n </Select.Root>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Dialog.Footer class=\"mt-4\">\n <Form.Button>Update Role</Form.Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n</Dialog.Root>\n", Sf = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Team member'\n });\n\n return { ...data, pageMetaTags };\n};\n", Cf = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string };\nlet member: { id: string; user: string; role: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n team = await context.admin.collection(\"teams\").create({\n name: \"Test Team\",\n owner: context.user.id,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: context.user.id,\n role: \"owner\",\n });\n\n // Create a test member\n const memberUser = await context.admin.collection(\"users\").create({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: \"password\",\n passwordConfirm: \"password\",\n });\n\n member = await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/[id]/member/[member_id]\", () => {\n it(\"authenticated user should be able to access member page\", async (context) => {\n const response = await context.agent.get(\n `/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/[id]/member/[member_id]\", () => {\n it(\"owner should be able to update member role\", async (context) => {\n await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"admin\",\n });\n\n // Verify role was updated\n const updatedMember = await context.admin\n .collection(\"team_memberships\")\n .getOne(member.id);\n expect(updatedMember.role).toBe(\"admin\");\n });\n\n it(\"admin should be able to update member role\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"member\",\n });\n\n // Verify role was updated\n const updatedMember = await context.admin\n .collection(\"team_memberships\")\n .getOne(member.id);\n expect(updatedMember.role).toBe(\"member\");\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to update member role\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"admin\",\n });\n\n // Verify role was not updated\n const unchangedMember = await context.admin\n .collection(\"team_memberships\")\n .getOne(member.id);\n expect(unchangedMember.role).toBe(\"member\");\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"should return 400 for invalid role\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"invalid-role\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for empty role\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for invalid member ID\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/member/invalid-id` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"admin\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n});\n", wf = "import {\n describe,\n it,\n expect,\n beforeEach,\n afterEach,\n type TestContext,\n} from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n team = await context.admin.collection(\"teams\").create({\n name: \"Test Team\",\n owner: context.user.id,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: context.user.id,\n role: \"owner\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/[id]\", () => {\n it(\"authenticated user should be able to access a team page\", async (context) => {\n const response = await context.agent.get(\n `/teams/${team.id}` satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/[id]?/updateTeam\", () => {\n it(\"owner should be able to update team\", async (context) => {\n await context.agent\n .post(`/teams/${team.id}?/updateTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: \"Updated Team Name\",\n });\n\n const updatedTeam = await context.admin.collection(\"teams\").getOne(team.id);\n expect(updatedTeam.name).toBe(\"Updated Team Name\");\n });\n\n it(\"admin should not be able to update team\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/updateTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: \"Updated Team Name\",\n });\n\n const updatedTeam = await context.admin.collection(\"teams\").getOne(team.id);\n expect(updatedTeam.name).not.toBe(\"Updated Team Name\");\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n});\n\ndescribe(\"POST /teams/[id]?/removeMember\", () => {\n it(\"owner should be able to remove member\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n const member = await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent\n .post(`/teams/${team.id}?/removeMember` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n member_id: member.id,\n });\n\n await expect(\n context.admin.collection(\"team_memberships\").getOne(member.id),\n ).rejects.toThrow();\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"admin should be able to remove member\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n const memberUser = await context.admin.collection(\"users\").create({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/removeMember` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n member_id: memberUser.id,\n });\n\n await expect(\n context.admin.collection(\"team_memberships\").getOne(memberUser.id),\n ).rejects.toThrow();\n\n context.admin.collection(\"users\").delete(adminUser.id);\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"admin should not be able to remove owner\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/removeMember` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n member_id: context.user.id,\n });\n\n const teamMembership = await context.admin\n .collection(\"team_memberships\")\n .getFirstListItem(\n context.pb.filter(\"team = {:team} && user = {:user}\", {\n team: team.id,\n user: context.user.id,\n }),\n );\n expect(teamMembership.role).toBe(\"owner\");\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n});\n\ndescribe(\"POST /teams/[id]?/cancelInvite\", () => {\n it(\"owner should be able to cancel invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n const invite = await context.admin.collection(\"team_invites\").create({\n team: team.id,\n email,\n role: \"member\",\n });\n\n await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: invite.id,\n });\n\n await expect(\n context.admin.collection(\"team_invites\").getOne(invite.id),\n ).rejects.toThrow();\n });\n\n it(\"admin should be able to cancel invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const invite = await context.admin.collection(\"team_invites\").create({\n team: team.id,\n email: inviteEmail,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: invite.id,\n });\n\n await expect(\n context.admin.collection(\"team_invites\").getOne(invite.id),\n ).rejects.toThrow();\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to cancel invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const invite = await context.admin.collection(\"team_invites\").create({\n team: team.id,\n email: inviteEmail,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: memberUser.email,\n password,\n });\n\n const response = await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: invite.id,\n });\n\n expect(response.status).toBe(400);\n\n // Verify invite still exists\n const existingInvite = await context.admin\n .collection(\"team_invites\")\n .getOne(invite.id);\n expect(existingInvite).toBeDefined();\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"should return error for invalid invite ID\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: \"invalid-id\",\n });\n\n expect(response.status).toBe(400);\n });\n});\n\ndescribe(\"POST /teams/[id]?/deleteTeam\", () => {\n it(\"owner should be able to delete team\", async (context) => {\n await context.agent\n .post(`/teams/${team.id}?/deleteTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n await expect(\n context.admin.collection(\"teams\").getOne(team.id),\n ).rejects.toThrow();\n });\n\n it(\"admin should not be able to delete team\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n const response = await context.agent\n .post(`/teams/${team.id}?/deleteTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n expect(response.status).toBe(400);\n\n // Verify team still exists\n const existingTeam = await context.admin\n .collection(\"teams\")\n .getOne(team.id);\n expect(existingTeam).toBeDefined();\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to delete team\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: memberUser.email,\n password,\n });\n\n const response = await context.agent\n .post(`/teams/${team.id}?/deleteTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n expect(response.status).toBe(400);\n\n // Verify team still exists\n const existingTeam = await context.admin\n .collection(\"teams\")\n .getOne(team.id);\n expect(existingTeam).toBeDefined();\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n});\n", Tf = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamSchema } from \"$lib/schemas/team\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\n\nexport const load = async () => {\n const form = await superValidate(zod4(teamSchema));\n return { form };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies }) => {\n const user = locals.pb.authStore.record!;\n const form = await superValidate(request, zod4(teamSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n let team;\n\n try {\n team = await locals.pb.collection(\"teams\").create({\n name: form.data.name,\n owner: user.id,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: team.id,\n role: \"owner\",\n });\n\n await locals.admin.collection(\"team_invite_links\").create({\n team: team.id,\n name: team.name,\n });\n\n redirect(\"/teams\", { type: \"toast\", message: \"Team created\" }, cookies);\n },\n};\n", Ef = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Input } from '$lib/components/ui/input';\n import { goto } from '$app/navigation';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamSchema } from '$lib/schemas/team';\n import * as Form from '$lib/components/ui/form';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamSchema)\n }\n );\n\n const { form: formData } = form;\n\n const handleOpenChange = (open: boolean) => {\n if (!open) {\n goto('/teams', { noScroll: true });\n }\n };\n<\/script>\n\n<Dialog.Root open onOpenChange={handleOpenChange}>\n <Dialog.Content>\n <form method=\"POST\">\n <Dialog.Header class=\"mb-4\">\n <Dialog.Title>Create Team</Dialog.Title>\n </Dialog.Header>\n <Form.Field {form} name=\"name\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Team Name</Form.Label>\n <Input {...props} type=\"text\" bind:value={$formData.name} />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Dialog.Footer class=\"mt-4\">\n <Form.Button>Create</Form.Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n</Dialog.Root>\n", Df = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'New team'\n });\n\n return { ...data, pageMetaTags };\n};\n", Of = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string; owner: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/new\", () => {\n it(\"authenticated user should be able to access new team page\", async (context) => {\n const response = await context.agent.get(\n \"/teams/new\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/new\", () => {\n it(\"authenticated user should be able to create team with valid name\", async (context) => {\n const teamName = `Test Team ${Math.random().toString(36).slice(2)}`;\n\n await context.agent\n .post(\"/teams/new\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: teamName,\n });\n\n // Verify team was created\n const teams = await context.admin.collection(\"teams\").getList(1, 1, {\n filter: `owner = \"${context.user.id}\" && name = \"${teamName}\"`,\n });\n expect(teams.items).toHaveLength(1);\n team = teams.items[0];\n expect(team.name).toBe(teamName);\n expect(team.owner).toBe(context.user.id);\n\n // Verify team membership was created\n const memberships = await context.admin\n .collection(\"team_memberships\")\n .getList(1, 1, {\n filter: `user = \"${context.user.id}\" && team = \"${team.id}\"`,\n });\n expect(memberships.items).toHaveLength(1);\n expect(memberships.items[0].role).toBe(\"owner\");\n });\n\n it(\"should return 400 for empty name\", async (context) => {\n const response = await context.agent\n .post(\"/teams/new\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: \"\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for missing name\", async (context) => {\n const response = await context.agent\n .post(\"/teams/new\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n});\n", kf = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /teams\", () => {\n it(\"authenticated user should be able to access the teams page\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\"/teams\" satisfies Match<RouteId>);\n expect(response.status).toBe(200);\n });\n});\n", Af = "import { error, redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/environment\";\n\nexport const load = async ({ params, cookies, url, locals }) => {\n const { id } = params;\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n\n try {\n await locals.pb.collection(\"teams\").getOne(id);\n } catch {\n return error(404, { message: \"Team not found\" });\n }\n\n cookies.set(\"team\", id, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n return redirect(303, redirectUrl);\n};\n", jf = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string; owner: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n // Create a test team for the user\n const teamName = `Test Team ${Math.random().toString(36).slice(2)}`;\n team = await context.admin.collection(\"teams\").create({\n name: teamName,\n owner: context.user.id,\n });\n\n // Create team membership\n await context.admin.collection(\"team_memberships\").create({\n user: context.user.id,\n team: team.id,\n role: \"owner\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/switch/[id]\", () => {\n it(\"should set team cookie and redirect to dashboard for valid team\", async (context) => {\n const response = await context.agent.get(\n `/teams/switch/${team.id}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/dashboard\");\n\n // Check that the team cookie is set\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeDefined();\n expect(cookies).toContain(`team=${team.id}`);\n });\n\n it(\"should redirect to custom redirect URL when provided\", async (context) => {\n const customRedirect = \"/teams\";\n const response = await context.agent.get(\n `/teams/switch/${team.id}?redirect=${encodeURIComponent(customRedirect)}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(customRedirect);\n\n // Check that the team cookie is still set\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeDefined();\n expect(cookies).toContain(\"team=\" + team.id);\n });\n\n it(\"should return 404 error for non-existent team\", async (context) => {\n const nonExistentTeamId = \"non-existent-team-id\";\n const response = await context.agent.get(\n `/teams/switch/${nonExistentTeamId}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(404);\n\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeUndefined();\n });\n\n it(\"should return 404 error for invalid team ID format\", async (context) => {\n const invalidTeamId = \"invalid-id-format\";\n const response = await context.agent.get(\n `/teams/switch/${invalidTeamId}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(404);\n\n // Check that no team cookie is set\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeUndefined();\n });\n});\n", Mf = /* #__PURE__ */ Object.assign({
|
|
5953
|
-
"./creates/src/lib/components/team-switcher.svelte":
|
|
5954
|
-
"./creates/src/lib/schemas/team.ts":
|
|
5955
|
-
"./creates/src/lib/schemas/teamInvite.ts":
|
|
5956
|
-
"./creates/src/lib/schemas/teamRole.ts":
|
|
5957
|
-
"./creates/src/routes/(app)/invite/[id]/+layout@.svelte":
|
|
5958
|
-
"./creates/src/routes/(app)/invite/[id]/+page.server.ts":
|
|
5959
|
-
"./creates/src/routes/(app)/invite/[id]/+page.svelte":
|
|
5960
|
-
"./creates/src/routes/(app)/invite/[id]/+page.ts":
|
|
5961
|
-
"./creates/src/routes/(app)/join/[id]/+layout@.svelte":
|
|
5962
|
-
"./creates/src/routes/(app)/join/[id]/+page.server.ts":
|
|
5963
|
-
"./creates/src/routes/(app)/join/[id]/+page.svelte":
|
|
5964
|
-
"./creates/src/routes/(app)/join/[id]/+page.ts":
|
|
5965
|
-
"./creates/src/routes/(app)/teams/+layout.server.ts":
|
|
5966
|
-
"./creates/src/routes/(app)/teams/+layout.svelte":
|
|
5967
|
-
"./creates/src/routes/(app)/teams/+page.server.ts":
|
|
5965
|
+
generate: Xd
|
|
5966
|
+
}, Qd = "<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';\n import * as Sidebar from '$lib/components/ui/sidebar/index.js';\n import { useSidebar } from '$lib/components/ui/sidebar/index.js';\n import PlusIcon from '@lucide/svelte/icons/plus';\n import UsersIcon from '@lucide/svelte/icons/users';\n import { page } from '$app/state';\n import { goto, invalidate } from '$app/navigation';\n\n let { teams, children }: { teams: { id: string; name: string }[] } & { children: Snippet } =\n $props();\n\n const switchTeam = async (teamId: string) => {\n await goto(`/teams/switch/${teamId}?redirect=${encodeURIComponent(page.url.pathname)}`);\n invalidate('app:team');\n };\n\n const sidebar = useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n {...props}\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n >\n {@render children?.()}\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n align=\"start\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"text-muted-foreground text-xs\">Teams</DropdownMenu.Label>\n {#each teams as team (team.name)}\n <DropdownMenu.Item onSelect={() => switchTeam(team.id)} class=\"gap-2 p-2\">\n <div class=\"flex size-6 items-center justify-center rounded-md border\">\n <UsersIcon class=\"size-3.5 shrink-0\" />\n </div>\n {team.name}\n </DropdownMenu.Item>\n {/each}\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"gap-2 p-2\">\n <div class=\"flex size-6 items-center justify-center rounded-md border bg-transparent\">\n <PlusIcon class=\"size-4\" />\n </div>\n <a href=\"/teams/new\" class=\"text-muted-foreground font-medium\">Add team</a>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", $d = "import { z } from \"zod\";\n\nexport const teamSchema = z.object({\n name: z.string(),\n});\n", ef = "import { z } from \"zod\";\n\nexport const teamInviteSchema = z.object({\n email: z.email(),\n});\n", tf = "import { z } from \"zod\";\n\nexport const teamRoleSchema = z.object({\n role: z.enum([\"owner\", \"admin\", \"member\"]),\n});\n", nf = "<script lang=\"ts\">\n import RootLayout from '../../../(public)/root-layout.svelte';\n\n let { data, children } = $props();\n<\/script>\n\n<RootLayout {data}>\n {@render children?.()}\n</RootLayout>\n", rf = "import { error } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\n\nexport const load = async ({ params, locals }) => {\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invites\").getOne(params.id, {\n expand: \"team\",\n });\n } catch {\n return error(404, { message: \"Invite not found\" });\n }\n\n return { invite };\n};\n\nexport const actions = {\n default: async ({ locals, params, cookies }) => {\n const user = locals.pb.authStore.record!;\n\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invites\").getOne(params.id);\n } catch {\n return error(404, { message: \"Invite not found\" });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: invite.team,\n role: \"member\",\n });\n\n await locals.admin.collection(\"team_invites\").delete(invite.id);\n\n redirect(\n 303,\n `/dashboard`,\n { type: \"toast\", message: \"Joined team\" },\n cookies,\n );\n },\n};\n", af = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\"\n >{data.invite.expand?.team.name} invited you to join their team</Card.Title\n >\n <Card.Description>Accept the invite to join the team</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Button type=\"submit\" class=\"w-full\">Accept Invite</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", of = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Invitation'\n });\n\n return { ...data, pageMetaTags };\n};\n", sf = "<script lang=\"ts\">\n import RootLayout from '../../../(public)/root-layout.svelte';\n\n let { data, children } = $props();\n<\/script>\n\n<RootLayout {data}>\n {@render children?.()}\n</RootLayout>\n", cf = "import { error } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\n\nexport const load = async ({ params, locals }) => {\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invite_links\").getOne(params.id, {\n expand: \"team\",\n });\n } catch {\n return error(404, { message: \"Invite link not found\" });\n }\n\n return { invite };\n};\n\nexport const actions = {\n default: async ({ locals, params, cookies }) => {\n const user = locals.pb.authStore.record!;\n\n let invite;\n try {\n invite = await locals.pb\n .collection(\"team_invite_links\")\n .getOne(params.id, {\n expand: \"team\",\n });\n } catch {\n return error(404, { message: \"Invite link not found\" });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: invite.team,\n role: \"member\",\n });\n\n redirect(\n 303,\n `/dashboard`,\n { type: \"toast\", message: \"Joined team\" },\n cookies,\n );\n },\n};\n", lf = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\"\n >{data.invite.expand?.team.name} invited you to join their team</Card.Title\n >\n <Card.Description>Accept the invite to join the team</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Button type=\"submit\" class=\"w-full\">Accept Invite</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", uf = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Join team'\n });\n\n return { ...data, pageMetaTags };\n};\n", df = "export const load = async ({ locals, parent }) => {\n const { user, breadcrumbs } = await parent();\n\n const ownedTeams = await locals.pb.collection(\"teams\").getFullList({\n filter: locals.pb.filter(\"owner = {:owner}\", { owner: user.id }),\n expand: \"team_users_via_team\",\n });\n\n const memberships = await locals.pb\n .collection(\"team_memberships\")\n .getFullList({\n filter: locals.pb.filter(\"user = {:user}\", { user: user.id }),\n expand: \"team\",\n });\n\n const pendingInvites = await locals.pb\n .collection(\"team_invites\")\n .getFullList({\n filter: locals.pb.filter(\"email = {:email}\", { email: user.email }),\n expand: \"team\",\n });\n\n const teams = [\n ...ownedTeams.map((team) => ({\n type: \"team\" as const,\n id: team.id,\n name: team.name,\n role: \"owner\" as const,\n members: team.expand?.team_users_via_team?.length || 0,\n })),\n ...memberships\n .filter((membership) => membership.expand?.team.owner !== membership.user)\n .map((membership) => ({\n type: \"membership\" as const,\n id: membership.team,\n name: membership.expand?.team.name,\n role: membership.role,\n })),\n ...pendingInvites.map((invite) => ({\n type: \"invite\" as const,\n id: invite.team,\n name: invite.expand?.team.name,\n role: null,\n invite_id: invite.id,\n })),\n ];\n\n return {\n teams,\n breadcrumbs: [...breadcrumbs, { title: \"Teams\", url: \"/teams\" }],\n };\n};\n", ff = "<script lang=\"ts\">\n import * as Card from '$lib/components/ui/card';\n import { Button } from '$lib/components/ui/button';\n import UserIcon from '@lucide/svelte/icons/user';\n import UserPlusIcon from '@lucide/svelte/icons/user-plus';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import * as Avatar from '$lib/components/ui/avatar';\n\n const roleLabels = {\n owner: 'Owner',\n admin: 'Admin',\n member: 'Member'\n };\n\n let { data, children } = $props();\n<\/script>\n\n<section data-slot=\"content\">\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Management</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Organize your workspace with teams. Collaborate with members, manage permissions, and\n streamline your workflow.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Your Teams</Card.Title>\n <Card.Description>Manage and view your team memberships</Card.Description>\n </Card.Header>\n <Card.Content class=\"space-y-4\">\n {#if data.teams && data.teams.length > 0}\n <div class=\"grid gap-3\">\n {#each data.teams as team}\n <div\n class=\"flex items-center justify-between p-4 border rounded-lg hover:bg-muted/50 transition-colors\"\n >\n <div class=\"flex items-center space-x-3\">\n <Avatar.Root class=\"size-10 rounded-lg\">\n <Avatar.Fallback\n class=\"rounded-lg bg-primary text-primary-foreground font-medium\"\n >\n {team.name?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n {#if team.role === 'owner' || team.role === 'admin'}\n <a\n href=\"/teams/{team.id}\"\n class=\"font-medium text-foreground hover:text-primary transition-colors\"\n >\n {team.name}\n </a>\n {:else}\n <span class=\"font-medium text-foreground\">\n {team.name}\n </span>\n {/if}\n <p class=\"text-sm text-muted-foreground\">\n {team.role ? roleLabels[team.role] : 'Pending'}\n </p>\n </div>\n </div>\n {#if team.type === 'team'}\n <div class=\"flex items-center space-x-2 text-sm text-muted-foreground\">\n <UserIcon class=\"w-4 h-4\" />\n <span class=\"font-medium\">\n {team.members} member{team.members !== 1 ? 's' : ''}\n </span>\n </div>\n {:else if team.type === 'membership'}\n <div class=\"flex items-center\">\n <form method=\"POST\" action=\"?/leaveTeam\">\n <input type=\"hidden\" name=\"team_id\" value={team.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">\n <LogOutIcon class=\"w-4 h-4\" />\n Leave team\n </Button>\n </form>\n </div>\n {:else if team.type === 'invite'}\n <div class=\"flex items-center\">\n <form method=\"POST\" action=\"?/acceptInvite\">\n <input type=\"hidden\" name=\"invite_id\" value={team.invite_id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">\n <UserPlusIcon class=\"w-4 h-4\" />\n Accept invitation\n </Button>\n </form>\n </div>\n {/if}\n </div>\n {/each}\n </div>\n {:else}\n <div class=\"text-center py-8\">\n <div\n class=\"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4\"\n >\n <UserIcon class=\"w-6 h-6 text-muted-foreground\" />\n </div>\n <h3 class=\"text-lg font-medium text-foreground mb-2\">No teams yet</h3>\n <p class=\"text-muted-foreground mb-4\">Get started by creating your first team</p>\n </div>\n {/if}\n </Card.Content>\n <Card.Footer class=\"flex justify-between items-center pt-4 border-t\">\n <div class=\"text-sm text-muted-foreground\">\n {data.teams?.length || 0} team{(data.teams?.length || 0) !== 1 ? 's' : ''}\n </div>\n <Button size=\"sm\" href=\"/teams/new\" class=\"ml-auto\">Create new team</Button>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n</section>\n\n{@render children?.()}\n", pf = "import { error, fail } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\n\nexport const actions = {\n acceptInvite: async ({ locals, request, cookies }) => {\n const user = locals.pb.authStore.record!;\n const form = await request.formData();\n const inviteId = form.get(\"invite_id\") as string;\n if (!inviteId) {\n return fail(400, { error: \"Invite ID is required\" });\n }\n\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invites\").getOne(inviteId);\n } catch {\n return error(404, { message: \"Invite not found\" });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: invite.team,\n role: \"member\",\n });\n\n await locals.admin.collection(\"team_invites\").delete(invite.id);\n\n redirect(303, `/teams`, { type: \"toast\", message: \"Joined team\" }, cookies);\n },\n leaveTeam: async ({ locals, request, cookies }) => {\n const user = locals.pb.authStore.record!;\n const form = await request.formData();\n const teamId = form.get(\"team_id\") as string;\n if (!teamId) {\n return fail(400, { error: \"Team ID is required\" });\n }\n\n let teamMembership;\n try {\n teamMembership = await locals.pb\n .collection(\"team_memberships\")\n .getFirstListItem(\n locals.pb.filter(\"team = {:team} && user = {:user}\", {\n team: teamId,\n user: user.id,\n }),\n );\n } catch {\n return error(404, { message: \"Team not found\" });\n }\n\n if (teamMembership.role === \"owner\") {\n return error(400, { message: \"You cannot leave a team you own\" });\n }\n\n await locals.pb.collection(\"team_memberships\").delete(teamMembership.id);\n\n redirect(303, `/teams`, { type: \"toast\", message: \"Left team\" }, cookies);\n },\n};\n", mf = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Teams'\n });\n\n return { pageMetaTags };\n};\n", hf = "import { redirect } from \"@sveltejs/kit\";\nimport { superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamSchema } from \"$lib/schemas/team\";\n\nexport const load = async ({ params, locals, parent }) => {\n const { user, breadcrumbs } = await parent();\n const { id } = params;\n\n let team;\n try {\n team = await locals.pb.collection(\"teams\").getOne(id, {\n expand: \"team_invite_links_via_team\",\n });\n } catch {\n redirect(303, \"/teams\");\n }\n\n let userMembership;\n try {\n userMembership = await locals.pb.collection(\"team_users\").getFirstListItem(\n locals.pb.filter(\n 'team = {:team} && id = {:user} && (role = \"admin\" || role = \"owner\")',\n {\n team: id,\n user: user.id,\n },\n ),\n );\n } catch (error) {\n redirect(303, \"/teams\");\n }\n\n const role = userMembership.role;\n\n // Get all team members with their roles\n const teamMembers = await locals.pb.collection(\"team_users\").getFullList({\n filter: locals.pb.filter(\"team = {:team}\", { team: id }),\n });\n\n // Get pending invites for this team\n const pendingInvites = await locals.pb\n .collection(\"team_invites\")\n .getFullList({\n filter: locals.pb.filter(\"team = {:team}\", { team: id }),\n });\n\n const form = await superValidate(team, zod4(teamSchema));\n\n return {\n team,\n role,\n teamMembers,\n pendingInvites,\n inviteLink: team.expand?.team_invite_links_via_team,\n form,\n breadcrumbs: [\n ...breadcrumbs,\n { title: \"Teams\", url: \"/teams\" },\n { title: team.name, url: `/teams/${id}` },\n ],\n };\n};\n", gf = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Card from '$lib/components/ui/card';\n import { Button, buttonVariants } from '$lib/components/ui/button';\n import CrownIcon from '@lucide/svelte/icons/crown';\n import ShieldIcon from '@lucide/svelte/icons/shield';\n import UserCheckIcon from '@lucide/svelte/icons/user-check';\n import UserPlusIcon from '@lucide/svelte/icons/user-plus';\n import CopyIcon from '@lucide/svelte/icons/copy';\n import MailIcon from '@lucide/svelte/icons/mail';\n import ClockIcon from '@lucide/svelte/icons/clock';\n import * as Avatar from '$lib/components/ui/avatar';\n import { Badge } from '$lib/components/ui/badge';\n import * as Table from '$lib/components/ui/table';\n import { getAuthorization } from './authorization';\n import { toast } from 'svelte-sonner';\n import * as AlertDialog from '$lib/components/ui/alert-dialog';\n import * as Form from '$lib/components/ui/form';\n import TrashIcon from '@lucide/svelte/icons/trash-2';\n import { Input } from '$lib/components/ui/input';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamSchema } from '$lib/schemas/team';\n\n let { data, children } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamSchema),\n warnings: {\n duplicateId: false\n }\n }\n );\n\n const { form: formData } = form;\n\n function getRoleIcon(role: 'owner' | 'admin' | 'member') {\n switch (role) {\n case 'owner':\n return CrownIcon;\n case 'admin':\n return ShieldIcon;\n case 'member':\n return UserCheckIcon;\n }\n }\n\n function handleCopyLink(inviteStr: string) {\n const link = `${data.meta.appURL}/${inviteStr}`;\n navigator.clipboard.writeText(link);\n toast.success('Link copied to clipboard');\n }\n<\/script>\n\n<section data-slot=\"content\">\n {#if data.role === 'owner'}\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Settings</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Update your team name and manage basic team settings.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <form method=\"POST\" action=\"?/updateTeam\" class=\"space-y-4\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Team Name</Card.Title>\n <Card.Description>Update your team's display name</Card.Description>\n </Card.Header>\n <Card.Content>\n <div class=\"space-y-2\">\n <Form.Field {form} name=\"name\">\n <Form.Control>\n {#snippet children({ props })}\n <Input {...props} type=\"text\" bind:value={$formData.name} required />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </Card.Content>\n <Card.Footer class=\"flex justify-end pt-4 border-t\">\n <Button type=\"submit\" class=\"flex items-center\" size=\"sm\">Save changes</Button>\n </Card.Footer>\n </form>\n </Card.Root>\n </div>\n </div>\n {/if}\n\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Members</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Manage team members and their roles. Control access permissions and organize your team\n effectively.\n </p>\n <div class=\"mt-4 space-y-2\">\n <div class=\"flex items-center text-sm text-muted-foreground\">\n <div class=\"w-2 h-2 bg-muted-foreground rounded-full mr-2\"></div>\n <span>Owner - Full team control</span>\n </div>\n <div class=\"flex items-center text-sm text-muted-foreground\">\n <div class=\"w-2 h-2 bg-muted-foreground rounded-full mr-2\"></div>\n <span>Admin - Manage members</span>\n </div>\n <div class=\"flex items-center text-sm text-muted-foreground\">\n <div class=\"w-2 h-2 bg-muted-foreground rounded-full mr-2\"></div>\n <span>Member - Team access</span>\n </div>\n </div>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">{data.team.name} Members</Card.Title>\n <Card.Description>Manage team members and their roles</Card.Description>\n </Card.Header>\n <Card.Content>\n <Table.Root>\n <Table.Header>\n <Table.Row>\n <Table.Head>Member</Table.Head>\n <Table.Head>Role</Table.Head>\n <Table.Head></Table.Head>\n </Table.Row>\n </Table.Header>\n <Table.Body>\n <!-- Team Members -->\n {#each data.teamMembers as member}\n {@const { canRemove, canChangeRole } = getAuthorization({\n user: data.user,\n role: data.role,\n member\n })}\n <Table.Row>\n <Table.Cell>\n <div class=\"flex items-center space-x-3\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback\n class=\"rounded-lg bg-primary text-primary-foreground font-medium\"\n >\n {member.name?.charAt(0).toUpperCase() ||\n member.email.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n <div class=\"font-medium text-foreground\">\n {member.name || member.email}\n </div>\n <div class=\"text-sm text-muted-foreground\">\n {member.email}\n </div>\n </div>\n </div>\n </Table.Cell>\n <Table.Cell>\n <Badge variant=\"outline\" class=\"flex items-center space-x-1 w-fit\">\n {@const Icon = getRoleIcon(member.role)}\n <Icon class=\"w-3 h-3\" />\n <span class=\"capitalize\">{member.role}</span>\n </Badge>\n </Table.Cell>\n <Table.Cell>\n <div class=\"flex space-x-2 justify-end\">\n {#if canChangeRole}\n <Button\n href=\"/teams/{data.team.id}/member/{member.membership_id}\"\n variant=\"outline\"\n size=\"sm\"\n data-sveltekit-noscroll\n >\n Change Role\n </Button>\n {/if}\n {#if canRemove}\n <form method=\"POST\" action=\"?/removeMember\">\n <input type=\"hidden\" name=\"member_id\" value={member.membership_id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Remove</Button>\n </form>\n {/if}\n </div>\n </Table.Cell>\n </Table.Row>\n {/each}\n </Table.Body>\n </Table.Root>\n </Card.Content>\n <Card.Footer class=\"flex justify-between items-center pt-4 border-t\">\n <div class=\"text-sm text-muted-foreground\">\n {data.teamMembers?.length || 0} member{(data.teamMembers?.length || 0) !== 1 ? 's' : ''}\n total\n </div>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Invites</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Invitations that have been sent but not yet accepted. You can resend or cancel pending\n invites.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Invitations</Card.Title>\n <Card.Description>Manage pending team invitations</Card.Description>\n </Card.Header>\n <Card.Content>\n {#if data.pendingInvites && data.pendingInvites.length > 0}\n <Table.Root>\n <Table.Header>\n <Table.Row>\n <Table.Head>Email</Table.Head>\n <Table.Head>Status</Table.Head>\n <Table.Head></Table.Head>\n </Table.Row>\n </Table.Header>\n <Table.Body>\n {#each data.pendingInvites as invite}\n <Table.Row>\n <Table.Cell>\n <div class=\"flex items-center space-x-3\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback\n class=\"rounded-lg bg-muted text-muted-foreground font-medium\"\n >\n <MailIcon class=\"w-4 h-4\" />\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n <div class=\"font-medium text-foreground\">\n {invite.email}\n </div>\n <div class=\"text-sm text-muted-foreground\">Pending invitation</div>\n </div>\n </div>\n </Table.Cell>\n <Table.Cell>\n <Badge variant=\"outline\" class=\"flex items-center space-x-1 w-fit\">\n <ClockIcon class=\"w-3 h-3\" />\n <span>Pending</span>\n </Badge>\n </Table.Cell>\n <Table.Cell>\n <div class=\"flex space-x-2 justify-end\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onclick={() => handleCopyLink(`invite/${invite.id}`)}>Copy link</Button\n >\n <form method=\"POST\" action=\"?/resendInvite\">\n <input type=\"hidden\" name=\"invite_id\" value={invite.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Resend</Button>\n </form>\n <form method=\"POST\" action=\"?/cancelInvite\">\n <input type=\"hidden\" name=\"invite_id\" value={invite.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Cancel</Button>\n </form>\n </div>\n </Table.Cell>\n </Table.Row>\n {/each}\n </Table.Body>\n </Table.Root>\n {:else}\n <div class=\"text-center py-8\">\n <div\n class=\"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4\"\n >\n <MailIcon class=\"w-6 h-6 text-muted-foreground\" />\n </div>\n <h3 class=\"text-lg font-medium text-foreground mb-2\">No pending invites</h3>\n <p class=\"text-muted-foreground mb-4\">\n All invitations have been accepted or there are no pending invites\n </p>\n </div>\n {/if}\n </Card.Content>\n <Card.Footer class=\"flex justify-between items-center pt-4 border-t\">\n <div class=\"text-sm text-muted-foreground\">\n {#if data.inviteLink}\n <div class=\"text-sm text-muted-foreground\">\n {data.meta.appURL}/join/{data.inviteLink.id}\n </div>\n {/if}\n </div>\n <div class=\"flex items-center space-x-2\">\n {#if data.inviteLink}\n <Button\n variant=\"outline\"\n size=\"sm\"\n onclick={() => handleCopyLink(`join/${data.inviteLink.id}`)}\n >\n <CopyIcon class=\"w-4 h-4\" />\n Copy invite link\n </Button>\n {/if}\n\n <Button\n size=\"sm\"\n href=\"/teams/{data.team.id}/invite\"\n class=\"ml-auto\"\n data-sveltekit-noscroll\n >\n <UserPlusIcon class=\"w-4 h-4\" />\n Invite member\n </Button>\n </div>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n\n {#if data.role === 'owner'}\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Danger Zone</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Permanently delete this team and all associated data. This action cannot be undone.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Delete Team</Card.Title>\n <Card.Description>\n Remove this team and all associated data permanently\n </Card.Description>\n </Card.Header>\n <Card.Content>\n <div\n class=\"flex items-center space-x-3 p-4 bg-destructive/10 rounded-lg border border-destructive/20\"\n >\n <div class=\"flex-shrink-0\">\n <TrashIcon class=\"w-5 h-5 text-destructive\" />\n </div>\n <div class=\"flex-1\">\n <p class=\"text-sm font-medium text-destructive\">Delete this team</p>\n <p class=\"text-sm text-muted-foreground\">\n This will permanently delete the team, remove all members, and delete all\n associated data.\n </p>\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"flex justify-end pt-4 border-t\">\n <AlertDialog.Root>\n <AlertDialog.Trigger class={buttonVariants({ variant: 'destructive', size: 'sm' })}>\n <TrashIcon class=\"w-4 h-4\" />\n Delete team\n </AlertDialog.Trigger>\n <AlertDialog.Content>\n <AlertDialog.Header>\n <AlertDialog.Title>Delete Team</AlertDialog.Title>\n <AlertDialog.Description>\n Are you sure you want to delete \"{data.team.name}\"? This action cannot be\n undone. This will permanently delete the team, remove all members, and delete\n all associated data.\n </AlertDialog.Description>\n </AlertDialog.Header>\n <AlertDialog.Footer>\n <AlertDialog.Cancel>Cancel</AlertDialog.Cancel>\n <form method=\"POST\" action=\"?/deleteTeam\" class=\"inline\">\n <AlertDialog.Action>\n <TrashIcon class=\"w-4 h-4\" />\n Delete team\n </AlertDialog.Action>\n </form>\n </AlertDialog.Footer>\n </AlertDialog.Content>\n </AlertDialog.Root>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n {/if}\n</section>\n\n{@render children?.()}\n", _f = "import { error, fail } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { superValidate } from \"sveltekit-superforms\";\nimport { teamSchema } from \"$lib/schemas/team\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\n\nexport const actions = {\n updateTeam: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(teamSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb\n .collection(\"teams\")\n .update(params.id, { name: form.data.name });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n redirect(\n 303,\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Team updated\" },\n cookies,\n );\n },\n removeMember: async ({ locals, params, request, cookies }) => {\n const formData = await request.formData();\n const memberId = formData.get(\"member_id\") as string;\n if (!memberId) {\n return error(400, { message: \"Member ID is required\" });\n }\n\n try {\n await locals.pb.collection(\"team_memberships\").delete(memberId);\n } catch {\n return error(400, { message: \"Failed to remove member\" });\n }\n\n redirect(\n 303,\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Member removed\" },\n cookies,\n );\n },\n resendInvite: async () => {\n // TODO: re-send the invite email once mail delivery is wired up.\n },\n cancelInvite: async ({ locals, params, request, cookies }) => {\n const formData = await request.formData();\n const inviteId = formData.get(\"invite_id\") as string;\n if (!inviteId) {\n return error(400, { message: \"Invite ID is required\" });\n }\n\n try {\n await locals.pb.collection(\"team_invites\").delete(inviteId);\n } catch {\n return error(400, { message: \"Failed to cancel invite\" });\n }\n\n redirect(\n 303,\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Invite cancelled\" },\n cookies,\n );\n },\n deleteTeam: async ({ locals, params, cookies }) => {\n try {\n await locals.pb.collection(\"teams\").delete(params.id);\n } catch {\n return error(400, { message: \"Failed to delete team\" });\n }\n\n const team = cookies.get(\"team\");\n if (team === params.id) {\n cookies.delete(\"team\", { path: \"/\" });\n }\n\n redirect(\n 303,\n `/teams`,\n { type: \"toast\", message: \"Team deleted successfully\" },\n cookies,\n );\n },\n};\n", vf = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Team'\n });\n\n return { pageMetaTags };\n};\n", yf = "type Role = \"owner\" | \"admin\" | \"member\";\n\ninterface User {\n id: string;\n}\n\ninterface Member {\n id: string;\n role: Role;\n}\n\nexport const getAuthorization = ({\n user,\n role,\n member,\n}: {\n user: User;\n role: Role;\n member?: Member;\n}) => {\n const isSelf = member ? user.id === member.id : false;\n const isOwner = role === \"owner\";\n const isAdmin = role === \"admin\";\n\n if (isSelf) {\n return {\n canRemove: false,\n canChangeRole: false,\n };\n } else if (isOwner) {\n return {\n canRemove: true,\n canChangeRole: true,\n };\n } else if (isAdmin) {\n if (member && member.role === \"member\") {\n return {\n canRemove: true,\n canChangeRole: false,\n };\n }\n\n return {\n canRemove: false,\n canChangeRole: false,\n };\n }\n\n return {\n canRemove: false,\n canChangeRole: false,\n };\n};\n", bf = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamInviteSchema } from \"$lib/schemas/teamInvite\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\n\nexport const load = async () => {\n const form = await superValidate(zod4(teamInviteSchema));\n return { form };\n};\n\nexport const actions = {\n default: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(teamInviteSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n const team = await locals.pb.collection(\"teams\").getOne(params.id);\n\n try {\n await locals.pb.collection(\"team_invites\").create({\n email: form.data.email,\n team: params.id,\n name: team.name,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n redirect(\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Invite sent\" },\n cookies,\n );\n },\n};\n", xf = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Input } from '$lib/components/ui/input';\n import { goto } from '$app/navigation';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamInviteSchema } from '$lib/schemas/teamInvite';\n import * as Form from '$lib/components/ui/form';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamInviteSchema)\n }\n );\n\n const { form: formData } = form;\n\n const handleOpenChange = (open: boolean) => {\n if (!open) {\n goto(`/teams/${data.team.id}`, { noScroll: true });\n }\n };\n<\/script>\n\n<Dialog.Root open onOpenChange={handleOpenChange}>\n <Dialog.Content>\n <form method=\"POST\">\n <Dialog.Header class=\"mb-4\">\n <Dialog.Title>Invite to Team</Dialog.Title>\n </Dialog.Header>\n <Form.Field {form} name=\"email\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input {...props} type=\"email\" bind:value={$formData.email} />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Dialog.Footer class=\"mt-4\">\n <Form.Button>Send Invite</Form.Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n</Dialog.Root>\n", Sf = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Invite to team'\n });\n\n return { ...data, pageMetaTags };\n};\n", Cf = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n team = await context.admin.collection(\"teams\").create({\n name: \"Test Team\",\n owner: context.user.id,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: context.user.id,\n role: \"owner\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/[id]/invite\", () => {\n it(\"authenticated user should be able to access invite page\", async (context) => {\n const response = await context.agent.get(\n `/teams/${team.id}/invite` satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/[id]/invite\", () => {\n it(\"owner should be able to create invite with valid email\", async (context) => {\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: inviteEmail,\n });\n\n const invites = await context.admin\n .collection(\"team_invites\")\n .getList(1, 1, {\n filter: `team = \"${team.id}\" && email = \"${inviteEmail}\"`,\n });\n expect(invites.items).toHaveLength(1);\n expect(invites.items[0].email).toBe(inviteEmail);\n expect(invites.items[0].team).toBe(team.id);\n });\n\n it(\"admin should be able to create invite with valid email\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: inviteEmail,\n });\n\n const invites = await context.admin\n .collection(\"team_invites\")\n .getList(1, 1, {\n filter: `team = \"${team.id}\" && email = \"${inviteEmail}\"`,\n });\n expect(invites.items).toHaveLength(1);\n expect(invites.items[0].email).toBe(inviteEmail);\n expect(invites.items[0].team).toBe(team.id);\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to create invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: inviteEmail,\n });\n\n const invites = await context.admin\n .collection(\"team_invites\")\n .getList(1, 1, {\n filter: `team = \"${team.id}\" && email = \"${inviteEmail}\"`,\n });\n expect(invites.items).toHaveLength(0);\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"should return 400 for invalid email\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: \"invalid-email\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for missing email\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for empty email\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: \"\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n});\n", wf = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamRoleSchema } from \"$lib/schemas/teamRole\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\n\nexport const load = async ({ locals, params }) => {\n const member = await locals.pb\n .collection(\"team_memberships\")\n .getOne(params.member_id);\n const form = await superValidate(member, zod4(teamRoleSchema));\n\n return { form };\n};\n\nexport const actions = {\n default: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(teamRoleSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb.collection(\"team_memberships\").update(params.member_id, {\n role: form.data.role,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n redirect(\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Role updated successfully\" },\n cookies,\n );\n },\n};\n", Tf = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '$lib/components/ui/dialog';\n import { goto } from '$app/navigation';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamRoleSchema } from '$lib/schemas/teamRole';\n import * as Form from '$lib/components/ui/form';\n import * as Select from '$lib/components/ui/select';\n\n let { data } = $props();\n\n const roleLabels = {\n owner: {\n label: 'Owner',\n value: 'owner'\n },\n admin: {\n label: 'Admin',\n value: 'admin'\n },\n member: {\n label: 'Member',\n value: 'member'\n }\n } as const;\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamRoleSchema)\n }\n );\n\n const { form: formData } = form;\n\n const handleOpenChange = (open: boolean) => {\n if (!open) {\n goto(`/teams/${data.team.id}`, { noScroll: true });\n }\n };\n<\/script>\n\n<Dialog.Root open onOpenChange={handleOpenChange}>\n <Dialog.Content>\n <form method=\"POST\">\n <Dialog.Header class=\"mb-4\">\n <Dialog.Title>Change Role</Dialog.Title>\n </Dialog.Header>\n <Form.Field {form} name=\"role\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Role</Form.Label>\n <Select.Root type=\"single\" {...props} bind:value={$formData.role}>\n <Select.Trigger class=\"w-full\">\n {roleLabels[$formData.role].label}\n </Select.Trigger>\n <Select.Content>\n {#each Object.values(roleLabels) as role}\n <Select.Item value={role.value}>{role.label}</Select.Item>\n {/each}\n </Select.Content>\n </Select.Root>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Dialog.Footer class=\"mt-4\">\n <Form.Button>Update Role</Form.Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n</Dialog.Root>\n", Ef = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Team member'\n });\n\n return { ...data, pageMetaTags };\n};\n", Df = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string };\nlet member: { id: string; user: string; role: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n team = await context.admin.collection(\"teams\").create({\n name: \"Test Team\",\n owner: context.user.id,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: context.user.id,\n role: \"owner\",\n });\n\n // Create a test member\n const memberUser = await context.admin.collection(\"users\").create({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: \"password\",\n passwordConfirm: \"password\",\n });\n\n member = await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/[id]/member/[member_id]\", () => {\n it(\"authenticated user should be able to access member page\", async (context) => {\n const response = await context.agent.get(\n `/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/[id]/member/[member_id]\", () => {\n it(\"owner should be able to update member role\", async (context) => {\n await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"admin\",\n });\n\n // Verify role was updated\n const updatedMember = await context.admin\n .collection(\"team_memberships\")\n .getOne(member.id);\n expect(updatedMember.role).toBe(\"admin\");\n });\n\n it(\"admin should be able to update member role\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"member\",\n });\n\n // Verify role was updated\n const updatedMember = await context.admin\n .collection(\"team_memberships\")\n .getOne(member.id);\n expect(updatedMember.role).toBe(\"member\");\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to update member role\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"admin\",\n });\n\n // Verify role was not updated\n const unchangedMember = await context.admin\n .collection(\"team_memberships\")\n .getOne(member.id);\n expect(unchangedMember.role).toBe(\"member\");\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"should return 400 for invalid role\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"invalid-role\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for empty role\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for invalid member ID\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/member/invalid-id` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"admin\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n});\n", Of = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n team = await context.admin.collection(\"teams\").create({\n name: \"Test Team\",\n owner: context.user.id,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: context.user.id,\n role: \"owner\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/[id]\", () => {\n it(\"authenticated user should be able to access a team page\", async (context) => {\n const response = await context.agent.get(\n `/teams/${team.id}` satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/[id]?/updateTeam\", () => {\n it(\"owner should be able to update team\", async (context) => {\n await context.agent\n .post(`/teams/${team.id}?/updateTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: \"Updated Team Name\",\n });\n\n const updatedTeam = await context.admin.collection(\"teams\").getOne(team.id);\n expect(updatedTeam.name).toBe(\"Updated Team Name\");\n });\n\n it(\"admin should not be able to update team\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/updateTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: \"Updated Team Name\",\n });\n\n const updatedTeam = await context.admin.collection(\"teams\").getOne(team.id);\n expect(updatedTeam.name).not.toBe(\"Updated Team Name\");\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n});\n\ndescribe(\"POST /teams/[id]?/removeMember\", () => {\n it(\"owner should be able to remove member\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n const member = await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent\n .post(`/teams/${team.id}?/removeMember` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n member_id: member.id,\n });\n\n await expect(\n context.admin.collection(\"team_memberships\").getOne(member.id),\n ).rejects.toThrow();\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"admin should be able to remove member\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n const memberUser = await context.admin.collection(\"users\").create({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/removeMember` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n member_id: memberUser.id,\n });\n\n await expect(\n context.admin.collection(\"team_memberships\").getOne(memberUser.id),\n ).rejects.toThrow();\n\n context.admin.collection(\"users\").delete(adminUser.id);\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"admin should not be able to remove owner\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/removeMember` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n member_id: context.user.id,\n });\n\n const teamMembership = await context.admin\n .collection(\"team_memberships\")\n .getFirstListItem(\n context.pb.filter(\"team = {:team} && user = {:user}\", {\n team: team.id,\n user: context.user.id,\n }),\n );\n expect(teamMembership.role).toBe(\"owner\");\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n});\n\ndescribe(\"POST /teams/[id]?/cancelInvite\", () => {\n it(\"owner should be able to cancel invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n const invite = await context.admin.collection(\"team_invites\").create({\n team: team.id,\n email,\n role: \"member\",\n });\n\n await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: invite.id,\n });\n\n await expect(\n context.admin.collection(\"team_invites\").getOne(invite.id),\n ).rejects.toThrow();\n });\n\n it(\"admin should be able to cancel invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const invite = await context.admin.collection(\"team_invites\").create({\n team: team.id,\n email: inviteEmail,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: invite.id,\n });\n\n await expect(\n context.admin.collection(\"team_invites\").getOne(invite.id),\n ).rejects.toThrow();\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to cancel invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const invite = await context.admin.collection(\"team_invites\").create({\n team: team.id,\n email: inviteEmail,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: memberUser.email,\n password,\n });\n\n const response = await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: invite.id,\n });\n\n expect(response.status).toBe(400);\n\n // Verify invite still exists\n const existingInvite = await context.admin\n .collection(\"team_invites\")\n .getOne(invite.id);\n expect(existingInvite).toBeDefined();\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"should return error for invalid invite ID\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: \"invalid-id\",\n });\n\n expect(response.status).toBe(400);\n });\n});\n\ndescribe(\"POST /teams/[id]?/deleteTeam\", () => {\n it(\"owner should be able to delete team\", async (context) => {\n await context.agent\n .post(`/teams/${team.id}?/deleteTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n await expect(\n context.admin.collection(\"teams\").getOne(team.id),\n ).rejects.toThrow();\n });\n\n it(\"admin should not be able to delete team\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n const response = await context.agent\n .post(`/teams/${team.id}?/deleteTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n expect(response.status).toBe(400);\n\n // Verify team still exists\n const existingTeam = await context.admin\n .collection(\"teams\")\n .getOne(team.id);\n expect(existingTeam).toBeDefined();\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to delete team\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: memberUser.email,\n password,\n });\n\n const response = await context.agent\n .post(`/teams/${team.id}?/deleteTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n expect(response.status).toBe(400);\n\n // Verify team still exists\n const existingTeam = await context.admin\n .collection(\"teams\")\n .getOne(team.id);\n expect(existingTeam).toBeDefined();\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n});\n", kf = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamSchema } from \"$lib/schemas/team\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\n\nexport const load = async () => {\n const form = await superValidate(zod4(teamSchema));\n return { form };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies }) => {\n const user = locals.pb.authStore.record!;\n const form = await superValidate(request, zod4(teamSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n let team;\n\n try {\n team = await locals.pb.collection(\"teams\").create({\n name: form.data.name,\n owner: user.id,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: team.id,\n role: \"owner\",\n });\n\n await locals.admin.collection(\"team_invite_links\").create({\n team: team.id,\n name: team.name,\n });\n\n redirect(\"/teams\", { type: \"toast\", message: \"Team created\" }, cookies);\n },\n};\n", Af = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Input } from '$lib/components/ui/input';\n import { goto } from '$app/navigation';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamSchema } from '$lib/schemas/team';\n import * as Form from '$lib/components/ui/form';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamSchema)\n }\n );\n\n const { form: formData } = form;\n\n const handleOpenChange = (open: boolean) => {\n if (!open) {\n goto('/teams', { noScroll: true });\n }\n };\n<\/script>\n\n<Dialog.Root open onOpenChange={handleOpenChange}>\n <Dialog.Content>\n <form method=\"POST\">\n <Dialog.Header class=\"mb-4\">\n <Dialog.Title>Create Team</Dialog.Title>\n </Dialog.Header>\n <Form.Field {form} name=\"name\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Team Name</Form.Label>\n <Input {...props} type=\"text\" bind:value={$formData.name} />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Dialog.Footer class=\"mt-4\">\n <Form.Button>Create</Form.Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n</Dialog.Root>\n", jf = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'New team'\n });\n\n return { ...data, pageMetaTags };\n};\n", Mf = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string; owner: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/new\", () => {\n it(\"authenticated user should be able to access new team page\", async (context) => {\n const response = await context.agent.get(\n \"/teams/new\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/new\", () => {\n it(\"authenticated user should be able to create team with valid name\", async (context) => {\n const teamName = `Test Team ${Math.random().toString(36).slice(2)}`;\n\n await context.agent\n .post(\"/teams/new\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: teamName,\n });\n\n // Verify team was created\n const teams = await context.admin.collection(\"teams\").getList(1, 1, {\n filter: `owner = \"${context.user.id}\" && name = \"${teamName}\"`,\n });\n expect(teams.items).toHaveLength(1);\n team = teams.items[0];\n expect(team.name).toBe(teamName);\n expect(team.owner).toBe(context.user.id);\n\n // Verify team membership was created\n const memberships = await context.admin\n .collection(\"team_memberships\")\n .getList(1, 1, {\n filter: `user = \"${context.user.id}\" && team = \"${team.id}\"`,\n });\n expect(memberships.items).toHaveLength(1);\n expect(memberships.items[0].role).toBe(\"owner\");\n });\n\n it(\"should return 400 for empty name\", async (context) => {\n const response = await context.agent\n .post(\"/teams/new\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: \"\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for missing name\", async (context) => {\n const response = await context.agent\n .post(\"/teams/new\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n});\n", Nf = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /teams\", () => {\n it(\"authenticated user should be able to access the teams page\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\"/teams\" satisfies Match<RouteId>);\n expect(response.status).toBe(200);\n });\n});\n", Pf = "import { error, redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/environment\";\n\nexport const load = async ({ params, cookies, url, locals }) => {\n const { id } = params;\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n\n try {\n await locals.pb.collection(\"teams\").getOne(id);\n } catch {\n return error(404, { message: \"Team not found\" });\n }\n\n cookies.set(\"team\", id, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n return redirect(303, redirectUrl);\n};\n", Ff = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string; owner: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n // Create a test team for the user\n const teamName = `Test Team ${Math.random().toString(36).slice(2)}`;\n team = await context.admin.collection(\"teams\").create({\n name: teamName,\n owner: context.user.id,\n });\n\n // Create team membership\n await context.admin.collection(\"team_memberships\").create({\n user: context.user.id,\n team: team.id,\n role: \"owner\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/switch/[id]\", () => {\n it(\"should set team cookie and redirect to dashboard for valid team\", async (context) => {\n const response = await context.agent.get(\n `/teams/switch/${team.id}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/dashboard\");\n\n // Check that the team cookie is set\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeDefined();\n expect(cookies).toContain(`team=${team.id}`);\n });\n\n it(\"should redirect to custom redirect URL when provided\", async (context) => {\n const customRedirect = \"/teams\";\n const response = await context.agent.get(\n `/teams/switch/${team.id}?redirect=${encodeURIComponent(customRedirect)}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(customRedirect);\n\n // Check that the team cookie is still set\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeDefined();\n expect(cookies).toContain(\"team=\" + team.id);\n });\n\n it(\"should return 404 error for non-existent team\", async (context) => {\n const nonExistentTeamId = \"non-existent-team-id\";\n const response = await context.agent.get(\n `/teams/switch/${nonExistentTeamId}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(404);\n\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeUndefined();\n });\n\n it(\"should return 404 error for invalid team ID format\", async (context) => {\n const invalidTeamId = \"invalid-id-format\";\n const response = await context.agent.get(\n `/teams/switch/${invalidTeamId}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(404);\n\n // Check that no team cookie is set\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeUndefined();\n });\n});\n", If = /* #__PURE__ */ Object.assign({
|
|
5967
|
+
"./creates/src/lib/components/team-switcher.svelte": Qd,
|
|
5968
|
+
"./creates/src/lib/schemas/team.ts": $d,
|
|
5969
|
+
"./creates/src/lib/schemas/teamInvite.ts": ef,
|
|
5970
|
+
"./creates/src/lib/schemas/teamRole.ts": tf,
|
|
5971
|
+
"./creates/src/routes/(app)/invite/[id]/+layout@.svelte": nf,
|
|
5972
|
+
"./creates/src/routes/(app)/invite/[id]/+page.server.ts": rf,
|
|
5973
|
+
"./creates/src/routes/(app)/invite/[id]/+page.svelte": af,
|
|
5974
|
+
"./creates/src/routes/(app)/invite/[id]/+page.ts": of,
|
|
5975
|
+
"./creates/src/routes/(app)/join/[id]/+layout@.svelte": sf,
|
|
5976
|
+
"./creates/src/routes/(app)/join/[id]/+page.server.ts": cf,
|
|
5977
|
+
"./creates/src/routes/(app)/join/[id]/+page.svelte": lf,
|
|
5978
|
+
"./creates/src/routes/(app)/join/[id]/+page.ts": uf,
|
|
5979
|
+
"./creates/src/routes/(app)/teams/+layout.server.ts": df,
|
|
5980
|
+
"./creates/src/routes/(app)/teams/+layout.svelte": ff,
|
|
5981
|
+
"./creates/src/routes/(app)/teams/+page.server.ts": pf,
|
|
5968
5982
|
"./creates/src/routes/(app)/teams/+page.svelte": "",
|
|
5969
|
-
"./creates/src/routes/(app)/teams/+page.ts":
|
|
5970
|
-
"./creates/src/routes/(app)/teams/[id]/+layout.server.ts":
|
|
5971
|
-
"./creates/src/routes/(app)/teams/[id]/+layout@(app).svelte":
|
|
5972
|
-
"./creates/src/routes/(app)/teams/[id]/+page.server.ts":
|
|
5983
|
+
"./creates/src/routes/(app)/teams/+page.ts": mf,
|
|
5984
|
+
"./creates/src/routes/(app)/teams/[id]/+layout.server.ts": hf,
|
|
5985
|
+
"./creates/src/routes/(app)/teams/[id]/+layout@(app).svelte": gf,
|
|
5986
|
+
"./creates/src/routes/(app)/teams/[id]/+page.server.ts": _f,
|
|
5973
5987
|
"./creates/src/routes/(app)/teams/[id]/+page.svelte": "",
|
|
5974
|
-
"./creates/src/routes/(app)/teams/[id]/+page.ts":
|
|
5975
|
-
"./creates/src/routes/(app)/teams/[id]/authorization.ts":
|
|
5976
|
-
"./creates/src/routes/(app)/teams/[id]/invite/+page.server.ts":
|
|
5977
|
-
"./creates/src/routes/(app)/teams/[id]/invite/+page.svelte":
|
|
5978
|
-
"./creates/src/routes/(app)/teams/[id]/invite/+page.ts":
|
|
5979
|
-
"./creates/src/routes/(app)/teams/[id]/invite/server.test.ts":
|
|
5980
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts":
|
|
5981
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte":
|
|
5982
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts":
|
|
5983
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts":
|
|
5984
|
-
"./creates/src/routes/(app)/teams/[id]/server.test.ts":
|
|
5985
|
-
"./creates/src/routes/(app)/teams/new/+page.server.ts":
|
|
5986
|
-
"./creates/src/routes/(app)/teams/new/+page.svelte":
|
|
5987
|
-
"./creates/src/routes/(app)/teams/new/+page.ts":
|
|
5988
|
-
"./creates/src/routes/(app)/teams/new/server.test.ts":
|
|
5989
|
-
"./creates/src/routes/(app)/teams/server.test.ts":
|
|
5990
|
-
"./creates/src/routes/(app)/teams/switch/[id]/+page.server.ts":
|
|
5991
|
-
"./creates/src/routes/(app)/teams/switch/[id]/server.test.ts":
|
|
5992
|
-
}),
|
|
5993
|
-
async function
|
|
5988
|
+
"./creates/src/routes/(app)/teams/[id]/+page.ts": vf,
|
|
5989
|
+
"./creates/src/routes/(app)/teams/[id]/authorization.ts": yf,
|
|
5990
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.server.ts": bf,
|
|
5991
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.svelte": xf,
|
|
5992
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.ts": Sf,
|
|
5993
|
+
"./creates/src/routes/(app)/teams/[id]/invite/server.test.ts": Cf,
|
|
5994
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts": wf,
|
|
5995
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte": Tf,
|
|
5996
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts": Ef,
|
|
5997
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts": Df,
|
|
5998
|
+
"./creates/src/routes/(app)/teams/[id]/server.test.ts": Of,
|
|
5999
|
+
"./creates/src/routes/(app)/teams/new/+page.server.ts": kf,
|
|
6000
|
+
"./creates/src/routes/(app)/teams/new/+page.svelte": Af,
|
|
6001
|
+
"./creates/src/routes/(app)/teams/new/+page.ts": jf,
|
|
6002
|
+
"./creates/src/routes/(app)/teams/new/server.test.ts": Mf,
|
|
6003
|
+
"./creates/src/routes/(app)/teams/server.test.ts": Nf,
|
|
6004
|
+
"./creates/src/routes/(app)/teams/switch/[id]/+page.server.ts": Pf,
|
|
6005
|
+
"./creates/src/routes/(app)/teams/switch/[id]/server.test.ts": Ff
|
|
6006
|
+
}), Lf = "./creates/";
|
|
6007
|
+
async function Rf(e) {
|
|
5994
6008
|
return {
|
|
5995
|
-
creates: Object.entries(
|
|
5996
|
-
let r = o(e,
|
|
6009
|
+
creates: Object.entries(If).map(([e, t]) => {
|
|
6010
|
+
let r = o(e, Lf);
|
|
5997
6011
|
return {
|
|
5998
6012
|
path: r,
|
|
5999
6013
|
language: n(r),
|
|
@@ -6024,7 +6038,7 @@ async function Pf(e) {
|
|
|
6024
6038
|
}
|
|
6025
6039
|
//#endregion
|
|
6026
6040
|
//#region src/patterns/enable/teams/preview-modifies/src/lib/components/app-sidebar.svelte?raw
|
|
6027
|
-
var
|
|
6041
|
+
var zf = "<script lang=\"ts\">\n import favicon from '$lib/assets/favicon.svg';\n\n import type { ComponentProps } from 'svelte';\n import HomeIcon from '@lucide/svelte/icons/home';\n import * as Sidebar from '$lib/components/ui/sidebar';\n import NavMain from './nav-main.svelte';\n import NavUser from './nav-user.svelte';\n // [!code highlight:3]\n import TeamSwitcher from '$lib/components/team-switcher.svelte';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import * as Avatar from '$lib/components/ui/avatar';\n\n let data = {\n navMain: [\n {\n title: 'Dashboard',\n url: '/dashboard',\n icon: HomeIcon\n }\n ]\n };\n\n let {\n user,\n meta,\n team,\n teams = [],\n ref = $bindable(null),\n ...restProps\n }: ComponentProps<typeof Sidebar.Root> & {\n user: any;\n meta: any;\n team?: string | undefined;\n teams?: { id: string; name: string }[];\n } = $props();\n<\/script>\n\n<Sidebar.Root bind:ref variant=\"inset\" {...restProps}>\n <Sidebar.Header>\n <Sidebar.Menu>\n <TeamSwitcher {teams}>\n {#snippet children()}\n {@const activeTeam = teams.find((t) => t.id === team)}\n {#if activeTeam}\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback class=\"rounded-lg bg-primary text-primary-foreground font-medium\">\n {activeTeam.name?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">\n {activeTeam.name}\n </span>\n </div>\n {:else}\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{meta.appName}</span>\n </div>\n {/if}\n <ChevronsUpDownIcon class=\"ml-auto\" />\n {/snippet}\n </TeamSwitcher>\n </Sidebar.Menu>\n </Sidebar.Header>\n <Sidebar.Content>\n <NavMain items={data.navMain} />\n </Sidebar.Content>\n <Sidebar.Footer>\n <NavUser {user} />\n </Sidebar.Footer>\n</Sidebar.Root>\n", Bf = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n // [!code highlight:1]\n import UsersIcon from '@lucide/svelte/icons/users';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import * as Avatar from '$lib/components/ui/avatar';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import * as Sidebar from '$lib/components/ui/sidebar';\n\n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n },\n // [!code highlight:5]\n {\n title: 'Teams',\n url: '/teams',\n icon: UsersIcon\n }\n ]\n };\n\n let {\n user\n }: {\n user: {\n id: string;\n name: string;\n email: string;\n avatar: string;\n };\n } = $props();\n\n const sidebar = Sidebar.useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n {...props}\n >\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.name?.charAt(0).toUpperCase() || user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name || user.email}</span>\n </div>\n <ChevronsUpDownIcon class=\"ml-auto size-4\" />\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n align=\"end\"\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"p-0 font-normal\">\n <div class=\"flex items-center gap-2 px-1 py-1.5 text-left text-sm\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.name?.charAt(0).toUpperCase() || user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name || user.email}</span>\n </div>\n </div>\n </DropdownMenu.Label>\n <DropdownMenu.Separator />\n <DropdownMenu.Group>\n <DropdownMenu.Item onclick={toggleMode}>\n {#if mode.current === 'dark'}\n <SunIcon />\n Light mode\n {:else}\n <MoonIcon />\n Dark mode\n {/if}\n </DropdownMenu.Item>\n {#each data.navUser as item}\n <DropdownMenu.Item class=\"p-0\">\n <a href={item.url} class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <item.icon />\n {item.title}\n </a>\n </DropdownMenu.Item>\n {/each}\n </DropdownMenu.Group>\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <form action=\"/logout\" method=\"post\" class=\"w-full\">\n <button type=\"submit\" class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <LogOutIcon />\n Log out\n </button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", Vf = "export const load = async ({ locals, depends }) => {\n const user = locals.pb.authStore.record!;\n // [!code highlight:3]\n const team = locals.team;\n const teams = await locals.pb.collection(\"teams\").getFullList();\n depends(\"app:team\");\n\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n\n return { user, team, teams, breadcrumbs };\n};\n", Hf = "<script lang=\"ts\">\n import * as Sidebar from '$lib/components/ui/sidebar';\n import { Separator } from '$lib/components/ui/separator';\n import AppSidebar from '$lib/components/app-sidebar.svelte';\n import * as Breadcrumb from '$lib/components/ui/breadcrumb';\n import { page } from '$app/state';\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as { title: string; url: string }[];\n let { data, children } = $props();\n<\/script>\n\n<div class=\"min-h-dvh dashboard\">\n <Sidebar.Provider>\n <!-- [!code highlight:1] -->\n <AppSidebar user={data.user} meta={data.meta} team={data.team} teams={data.teams ?? []} />\n <Sidebar.Inset>\n <header class=\"flex h-16 shrink-0 items-center gap-2\">\n <div class=\"flex items-center gap-2 px-4\">\n <Sidebar.Trigger class=\"-ml-1\" />\n <Separator orientation=\"vertical\" class=\"mr-2 data-[orientation=vertical]:h-4\" />\n {#if breadcrumbs.length > 0}\n <Breadcrumb.Root>\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}>{breadcrumb.title}</Breadcrumb.Link>\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n {/if}\n </div>\n </header>\n <div class=\"flex flex-1 flex-col p-4 pt-0\">\n {@render children?.()}\n </div>\n </Sidebar.Inset>\n </Sidebar.Provider>\n</div>\n\n<style>\n :global(body:has(div.dashboard)) {\n background-color: var(--color-sidebar);\n }\n</style>\n", Uf = "users", Wf = "teams", Gf = "team_memberships";
|
|
6028
6042
|
function $(e) {
|
|
6029
6043
|
let t = pe.find((t) => t.collectionName === e);
|
|
6030
6044
|
if (!t) throw Error(`teams: missing TEAM_RULE_PATCHES entry for "${e}"`);
|
|
@@ -6036,7 +6050,7 @@ function $(e) {
|
|
|
6036
6050
|
deleteRule: t.deleteRule
|
|
6037
6051
|
};
|
|
6038
6052
|
}
|
|
6039
|
-
var
|
|
6053
|
+
var Kf = [
|
|
6040
6054
|
{
|
|
6041
6055
|
name: "teams",
|
|
6042
6056
|
type: "base",
|
|
@@ -6061,7 +6075,7 @@ var Hf = [
|
|
|
6061
6075
|
name: "owner",
|
|
6062
6076
|
type: "relation",
|
|
6063
6077
|
cascadeDelete: !1,
|
|
6064
|
-
collectionId:
|
|
6078
|
+
collectionId: Uf,
|
|
6065
6079
|
maxSelect: 1,
|
|
6066
6080
|
minSelect: 0,
|
|
6067
6081
|
required: !0
|
|
@@ -6098,7 +6112,7 @@ var Hf = [
|
|
|
6098
6112
|
{
|
|
6099
6113
|
name: "team",
|
|
6100
6114
|
cascadeDelete: !0,
|
|
6101
|
-
collectionId:
|
|
6115
|
+
collectionId: Wf,
|
|
6102
6116
|
maxSelect: 1,
|
|
6103
6117
|
minSelect: 0,
|
|
6104
6118
|
required: !0,
|
|
@@ -6107,7 +6121,7 @@ var Hf = [
|
|
|
6107
6121
|
{
|
|
6108
6122
|
name: "user",
|
|
6109
6123
|
cascadeDelete: !0,
|
|
6110
|
-
collectionId:
|
|
6124
|
+
collectionId: Uf,
|
|
6111
6125
|
maxSelect: 1,
|
|
6112
6126
|
minSelect: 0,
|
|
6113
6127
|
required: !0,
|
|
@@ -6167,7 +6181,7 @@ var Hf = [
|
|
|
6167
6181
|
{
|
|
6168
6182
|
name: "membership_id",
|
|
6169
6183
|
cascadeDelete: !1,
|
|
6170
|
-
collectionId:
|
|
6184
|
+
collectionId: Gf,
|
|
6171
6185
|
maxSelect: 1,
|
|
6172
6186
|
minSelect: 0,
|
|
6173
6187
|
required: !1,
|
|
@@ -6176,7 +6190,7 @@ var Hf = [
|
|
|
6176
6190
|
{
|
|
6177
6191
|
name: "team",
|
|
6178
6192
|
cascadeDelete: !0,
|
|
6179
|
-
collectionId:
|
|
6193
|
+
collectionId: Wf,
|
|
6180
6194
|
maxSelect: 1,
|
|
6181
6195
|
minSelect: 0,
|
|
6182
6196
|
required: !0,
|
|
@@ -6214,7 +6228,7 @@ var Hf = [
|
|
|
6214
6228
|
name: "team",
|
|
6215
6229
|
type: "relation",
|
|
6216
6230
|
cascadeDelete: !0,
|
|
6217
|
-
collectionId:
|
|
6231
|
+
collectionId: Wf,
|
|
6218
6232
|
maxSelect: 1,
|
|
6219
6233
|
minSelect: 0,
|
|
6220
6234
|
required: !0
|
|
@@ -6257,7 +6271,7 @@ var Hf = [
|
|
|
6257
6271
|
{
|
|
6258
6272
|
name: "team",
|
|
6259
6273
|
cascadeDelete: !0,
|
|
6260
|
-
collectionId:
|
|
6274
|
+
collectionId: Wf,
|
|
6261
6275
|
maxSelect: 1,
|
|
6262
6276
|
minSelect: 0,
|
|
6263
6277
|
required: !0,
|
|
@@ -6277,17 +6291,17 @@ var Hf = [
|
|
|
6277
6291
|
}
|
|
6278
6292
|
]
|
|
6279
6293
|
}
|
|
6280
|
-
],
|
|
6281
|
-
"./preview-modifies/src/lib/components/app-sidebar.svelte":
|
|
6282
|
-
"./preview-modifies/src/lib/components/nav-user.svelte":
|
|
6283
|
-
"./preview-modifies/src/routes/(app)/+layout.server.ts":
|
|
6284
|
-
"./preview-modifies/src/routes/(app)/+layout.svelte":
|
|
6285
|
-
}),
|
|
6286
|
-
async function
|
|
6294
|
+
], qf = /* #__PURE__ */ Object.assign({
|
|
6295
|
+
"./preview-modifies/src/lib/components/app-sidebar.svelte": zf,
|
|
6296
|
+
"./preview-modifies/src/lib/components/nav-user.svelte": Bf,
|
|
6297
|
+
"./preview-modifies/src/routes/(app)/+layout.server.ts": Vf,
|
|
6298
|
+
"./preview-modifies/src/routes/(app)/+layout.svelte": Hf
|
|
6299
|
+
}), Jf = "./preview-modifies/";
|
|
6300
|
+
async function Yf(e) {
|
|
6287
6301
|
return {
|
|
6288
6302
|
creates: [],
|
|
6289
|
-
modifies: Object.entries(
|
|
6290
|
-
let r = o(e,
|
|
6303
|
+
modifies: Object.entries(qf).map(([e, t]) => {
|
|
6304
|
+
let r = o(e, Jf);
|
|
6291
6305
|
return {
|
|
6292
6306
|
path: r,
|
|
6293
6307
|
language: n(r),
|
|
@@ -6298,28 +6312,28 @@ async function Gf(e) {
|
|
|
6298
6312
|
deletes: [],
|
|
6299
6313
|
components: [],
|
|
6300
6314
|
packages: [],
|
|
6301
|
-
collections:
|
|
6315
|
+
collections: Kf,
|
|
6302
6316
|
collectionPatches: [],
|
|
6303
6317
|
collectionDrops: []
|
|
6304
6318
|
};
|
|
6305
6319
|
}
|
|
6306
6320
|
//#endregion
|
|
6307
6321
|
//#region src/patterns/enable/teams/index.ts
|
|
6308
|
-
var
|
|
6309
|
-
async function
|
|
6310
|
-
let t = await
|
|
6322
|
+
var Xf = "enable-teams", Zf = "1.0.0", Qf = "src/patterns/enable/teams", $f = "/enable/teams";
|
|
6323
|
+
async function ep(e) {
|
|
6324
|
+
let t = await Rf(e);
|
|
6311
6325
|
if (e.env === "preview") {
|
|
6312
|
-
let n = await
|
|
6326
|
+
let n = await Yf(e);
|
|
6313
6327
|
return m(i([t, n]), e);
|
|
6314
6328
|
}
|
|
6315
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
6329
|
+
let { generate: n } = await import("./chunks/generate.runtime-QmFJI7G1.js"), r = await n(e), { writeResult: a } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
6316
6330
|
return a(await m(i([t, r]), e), e);
|
|
6317
6331
|
}
|
|
6318
|
-
var
|
|
6319
|
-
version:
|
|
6320
|
-
slug:
|
|
6321
|
-
source:
|
|
6322
|
-
docs:
|
|
6332
|
+
var tp = {
|
|
6333
|
+
version: Zf,
|
|
6334
|
+
slug: Xf,
|
|
6335
|
+
source: Qf,
|
|
6336
|
+
docs: $f,
|
|
6323
6337
|
plan: "pro",
|
|
6324
6338
|
title: "Enable teams",
|
|
6325
6339
|
summary: "Adds multi-tenant teams with memberships, invites, and a sidebar team switcher.",
|
|
@@ -6352,11 +6366,11 @@ var Zf = {
|
|
|
6352
6366
|
examples: [],
|
|
6353
6367
|
tests: 36,
|
|
6354
6368
|
baseline: "velastack",
|
|
6355
|
-
generate:
|
|
6369
|
+
generate: ep
|
|
6356
6370
|
};
|
|
6357
6371
|
//#endregion
|
|
6358
6372
|
//#region src/patterns/destroy/schema/generate.ts
|
|
6359
|
-
async function
|
|
6373
|
+
async function np(e) {
|
|
6360
6374
|
let [r] = e.argv;
|
|
6361
6375
|
if (!r) throw new t("Invalid command arguments. Expected: <model>");
|
|
6362
6376
|
let i = `src/lib/schemas/${A(r).name}.ts`;
|
|
@@ -6378,18 +6392,18 @@ async function Qf(e) {
|
|
|
6378
6392
|
}
|
|
6379
6393
|
//#endregion
|
|
6380
6394
|
//#region src/patterns/destroy/schema/index.ts
|
|
6381
|
-
var
|
|
6382
|
-
async function
|
|
6383
|
-
let t = await
|
|
6395
|
+
var rp = "destroy-schema", ip = "1.0.0", ap = "src/patterns/destroy/schema", op = "/destroy/schema";
|
|
6396
|
+
async function sp(e) {
|
|
6397
|
+
let t = await np(e), n = await m(t, e);
|
|
6384
6398
|
if (e.env !== "runtime" || e.input.destructive !== !0) return n;
|
|
6385
|
-
let { writeResult: r } = await import("./chunks/write-result-
|
|
6399
|
+
let { writeResult: r } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
6386
6400
|
return r(n, e);
|
|
6387
6401
|
}
|
|
6388
|
-
var
|
|
6389
|
-
version:
|
|
6390
|
-
slug:
|
|
6391
|
-
source:
|
|
6392
|
-
docs:
|
|
6402
|
+
var cp = {
|
|
6403
|
+
version: ip,
|
|
6404
|
+
slug: rp,
|
|
6405
|
+
source: ap,
|
|
6406
|
+
docs: op,
|
|
6393
6407
|
plan: "open",
|
|
6394
6408
|
title: "Destroy a schema",
|
|
6395
6409
|
summary: "Removes the zod schema file created by generate-schema.",
|
|
@@ -6422,9 +6436,9 @@ var ip = {
|
|
|
6422
6436
|
}],
|
|
6423
6437
|
tests: 0,
|
|
6424
6438
|
baseline: "velastack",
|
|
6425
|
-
generate:
|
|
6426
|
-
},
|
|
6427
|
-
async function
|
|
6439
|
+
generate: sp
|
|
6440
|
+
}, lp = "destroy-form", up = "1.0.0", dp = "src/patterns/destroy/form", fp = "/destroy/form";
|
|
6441
|
+
async function pp(e) {
|
|
6428
6442
|
let [n] = e.argv;
|
|
6429
6443
|
if (!n) throw new t("Invalid command arguments. Expected: <model>");
|
|
6430
6444
|
let r = A(n), i = M(e.input.route, r, e, "form").fileBase, a = `src/lib/schemas/${r.name}.ts`, o = {
|
|
@@ -6438,14 +6452,14 @@ async function lp(e) {
|
|
|
6438
6452
|
collectionDrops: []
|
|
6439
6453
|
}, s = await m(o, e);
|
|
6440
6454
|
if (e.env !== "runtime" || e.input.destructive !== !0) return s;
|
|
6441
|
-
let { writeResult: c } = await import("./chunks/write-result-
|
|
6455
|
+
let { writeResult: c } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
6442
6456
|
return c(s, e);
|
|
6443
6457
|
}
|
|
6444
|
-
var
|
|
6445
|
-
version:
|
|
6446
|
-
slug:
|
|
6447
|
-
source:
|
|
6448
|
-
docs:
|
|
6458
|
+
var mp = {
|
|
6459
|
+
version: up,
|
|
6460
|
+
slug: lp,
|
|
6461
|
+
source: dp,
|
|
6462
|
+
docs: fp,
|
|
6449
6463
|
plan: "open",
|
|
6450
6464
|
title: "Destroy a form",
|
|
6451
6465
|
summary: "Removes the route directory and schema file created by generate-form.",
|
|
@@ -6481,9 +6495,9 @@ var up = {
|
|
|
6481
6495
|
}],
|
|
6482
6496
|
tests: 0,
|
|
6483
6497
|
baseline: "velastack",
|
|
6484
|
-
generate:
|
|
6485
|
-
},
|
|
6486
|
-
async function
|
|
6498
|
+
generate: pp
|
|
6499
|
+
}, hp = "destroy-resource", gp = "1.0.0", _p = "src/patterns/destroy/resource", vp = "/destroy/resource";
|
|
6500
|
+
async function yp(e) {
|
|
6487
6501
|
let [n] = e.argv;
|
|
6488
6502
|
if (!n) throw new t("Invalid command arguments. Expected: <model>");
|
|
6489
6503
|
let r = A(n), i = `src/lib/schemas/${r.name}.ts`, a = await me([r.tableName], e), o = {
|
|
@@ -6497,14 +6511,14 @@ async function hp(e) {
|
|
|
6497
6511
|
collectionDrops: a
|
|
6498
6512
|
}, s = await m(o, e);
|
|
6499
6513
|
if (e.env !== "runtime" || e.input.destructive !== !0) return s;
|
|
6500
|
-
let { writeResult: c } = await import("./chunks/write-result-
|
|
6514
|
+
let { writeResult: c } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
6501
6515
|
return c(s, e);
|
|
6502
6516
|
}
|
|
6503
|
-
var
|
|
6504
|
-
version:
|
|
6505
|
-
slug:
|
|
6506
|
-
source:
|
|
6507
|
-
docs:
|
|
6517
|
+
var bp = {
|
|
6518
|
+
version: gp,
|
|
6519
|
+
slug: hp,
|
|
6520
|
+
source: _p,
|
|
6521
|
+
docs: vp,
|
|
6508
6522
|
plan: "open",
|
|
6509
6523
|
title: "Destroy a resource",
|
|
6510
6524
|
summary: "Drops the collection and removes the schema file created by generate-resource.",
|
|
@@ -6537,9 +6551,9 @@ var gp = {
|
|
|
6537
6551
|
}],
|
|
6538
6552
|
tests: 0,
|
|
6539
6553
|
baseline: "velastack",
|
|
6540
|
-
generate:
|
|
6541
|
-
},
|
|
6542
|
-
async function
|
|
6554
|
+
generate: yp
|
|
6555
|
+
}, xp = "destroy-scaffold", Sp = "1.0.0", Cp = "src/patterns/destroy/scaffold", wp = "/destroy/scaffold";
|
|
6556
|
+
async function Tp(e) {
|
|
6543
6557
|
let [n] = e.argv;
|
|
6544
6558
|
if (!n) throw new t("Invalid command arguments. Expected: <model>");
|
|
6545
6559
|
let r = A(n), i = Ct(M(e.input.route, r, e, "scaffold")), a = `src/lib/schemas/${r.name}.ts`, o = await me([r.tableName], e), s = {
|
|
@@ -6553,14 +6567,14 @@ async function xp(e) {
|
|
|
6553
6567
|
collectionDrops: o
|
|
6554
6568
|
}, c = await m(s, e);
|
|
6555
6569
|
if (e.env !== "runtime" || e.input.destructive !== !0) return c;
|
|
6556
|
-
let { writeResult: l } = await import("./chunks/write-result-
|
|
6570
|
+
let { writeResult: l } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
6557
6571
|
return l(c, e);
|
|
6558
6572
|
}
|
|
6559
|
-
var
|
|
6560
|
-
version:
|
|
6561
|
-
slug:
|
|
6562
|
-
source:
|
|
6563
|
-
docs:
|
|
6573
|
+
var Ep = {
|
|
6574
|
+
version: Sp,
|
|
6575
|
+
slug: xp,
|
|
6576
|
+
source: Cp,
|
|
6577
|
+
docs: wp,
|
|
6564
6578
|
plan: "open",
|
|
6565
6579
|
title: "Destroy a scaffold",
|
|
6566
6580
|
summary: "Removes the route directory and schema file created by generate-scaffold and drops the collection. Retains shadcn components.",
|
|
@@ -6597,14 +6611,14 @@ var Sp = {
|
|
|
6597
6611
|
}],
|
|
6598
6612
|
tests: 0,
|
|
6599
6613
|
baseline: "velastack",
|
|
6600
|
-
generate:
|
|
6601
|
-
},
|
|
6602
|
-
async function
|
|
6614
|
+
generate: Tp
|
|
6615
|
+
}, Dp = /* #__PURE__ */ Object.assign({ "../../enable/api/creates/src/routes/api/server.test.ts": Ns }), Op = "../../enable/api/creates/";
|
|
6616
|
+
async function kp(e) {
|
|
6603
6617
|
return {
|
|
6604
6618
|
creates: [],
|
|
6605
6619
|
modifies: [],
|
|
6606
|
-
deletes: Object.keys(
|
|
6607
|
-
let t = o(e,
|
|
6620
|
+
deletes: Object.keys(Dp).map((e) => {
|
|
6621
|
+
let t = o(e, Op);
|
|
6608
6622
|
return {
|
|
6609
6623
|
path: t,
|
|
6610
6624
|
language: n(t),
|
|
@@ -6621,20 +6635,20 @@ async function Tp(e) {
|
|
|
6621
6635
|
}
|
|
6622
6636
|
//#endregion
|
|
6623
6637
|
//#region src/patterns/disable/api/index.ts
|
|
6624
|
-
var
|
|
6625
|
-
async function
|
|
6626
|
-
let t = await
|
|
6638
|
+
var Ap = "disable-api", jp = "1.0.0", Mp = "src/patterns/disable/api", Np = "/disable/api";
|
|
6639
|
+
async function Pp(e) {
|
|
6640
|
+
let t = await kp(e);
|
|
6627
6641
|
if (e.env !== "runtime") return m(t, e);
|
|
6628
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
6642
|
+
let { generate: n } = await import("./chunks/generate.runtime-fSDNxfGG.js"), r = await n(e), a = await m(i([t, r]), e);
|
|
6629
6643
|
if (e.input.destructive !== !0) return a;
|
|
6630
|
-
let { writeResult: o } = await import("./chunks/write-result-
|
|
6644
|
+
let { writeResult: o } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
6631
6645
|
return o(a, e);
|
|
6632
6646
|
}
|
|
6633
|
-
var
|
|
6634
|
-
version:
|
|
6635
|
-
slug:
|
|
6636
|
-
source:
|
|
6637
|
-
docs:
|
|
6647
|
+
var Fp = {
|
|
6648
|
+
version: jp,
|
|
6649
|
+
slug: Ap,
|
|
6650
|
+
source: Mp,
|
|
6651
|
+
docs: Np,
|
|
6638
6652
|
plan: "open",
|
|
6639
6653
|
title: "Disable API",
|
|
6640
6654
|
summary: "Disables the PocketBase API handler.",
|
|
@@ -6667,8 +6681,8 @@ var jp = {
|
|
|
6667
6681
|
examples: [],
|
|
6668
6682
|
tests: 0,
|
|
6669
6683
|
baseline: "velastack",
|
|
6670
|
-
generate:
|
|
6671
|
-
},
|
|
6684
|
+
generate: Pp
|
|
6685
|
+
}, Ip = /* #__PURE__ */ Object.assign({
|
|
6672
6686
|
"../../enable/api-keys/creates/src/lib/schemas/apiKey.ts": Ks,
|
|
6673
6687
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/+layout.server.ts": qs,
|
|
6674
6688
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/+layout.svelte": Js,
|
|
@@ -6681,13 +6695,13 @@ var jp = {
|
|
|
6681
6695
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/new/create-api-key.ts": ec,
|
|
6682
6696
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/new/server.test.ts": tc,
|
|
6683
6697
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/server.test.ts": nc
|
|
6684
|
-
}),
|
|
6685
|
-
async function
|
|
6698
|
+
}), Lp = "../../enable/api-keys/creates/";
|
|
6699
|
+
async function Rp(e) {
|
|
6686
6700
|
return {
|
|
6687
6701
|
creates: [],
|
|
6688
6702
|
modifies: [],
|
|
6689
|
-
deletes: Object.keys(
|
|
6690
|
-
let t = o(e,
|
|
6703
|
+
deletes: Object.keys(Ip).map((e) => {
|
|
6704
|
+
let t = o(e, Lp);
|
|
6691
6705
|
return {
|
|
6692
6706
|
path: t,
|
|
6693
6707
|
language: n(t),
|
|
@@ -6704,20 +6718,20 @@ async function Pp(e) {
|
|
|
6704
6718
|
}
|
|
6705
6719
|
//#endregion
|
|
6706
6720
|
//#region src/patterns/disable/api-keys/index.ts
|
|
6707
|
-
var
|
|
6708
|
-
async function
|
|
6709
|
-
let t = await
|
|
6721
|
+
var zp = "disable-api-keys", Bp = "1.0.0", Vp = "src/patterns/disable/api-keys", Hp = "/disable/api-keys";
|
|
6722
|
+
async function Up(e) {
|
|
6723
|
+
let t = await Rp(e);
|
|
6710
6724
|
if (e.env !== "runtime") return m(t, e);
|
|
6711
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
6725
|
+
let { generate: n } = await import("./chunks/generate.runtime-kH6XaWQz.js"), r = await n(e), a = await m(i([t, r]), e);
|
|
6712
6726
|
if (e.input.destructive !== !0) return a;
|
|
6713
|
-
let { writeResult: o } = await import("./chunks/write-result-
|
|
6727
|
+
let { writeResult: o } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
6714
6728
|
return o(a, e);
|
|
6715
6729
|
}
|
|
6716
|
-
var
|
|
6717
|
-
version:
|
|
6718
|
-
slug:
|
|
6719
|
-
source:
|
|
6720
|
-
docs:
|
|
6730
|
+
var Wp = {
|
|
6731
|
+
version: Bp,
|
|
6732
|
+
slug: zp,
|
|
6733
|
+
source: Vp,
|
|
6734
|
+
docs: Hp,
|
|
6721
6735
|
plan: "open",
|
|
6722
6736
|
title: "Disable API keys",
|
|
6723
6737
|
summary: "Removes API key management: drops the api_keys collection, reverts hooks.server and nav-user, deletes generated API key routes.",
|
|
@@ -6750,8 +6764,8 @@ var Bp = {
|
|
|
6750
6764
|
examples: [],
|
|
6751
6765
|
tests: 0,
|
|
6752
6766
|
baseline: "velastack",
|
|
6753
|
-
generate:
|
|
6754
|
-
},
|
|
6767
|
+
generate: Up
|
|
6768
|
+
}, Gp = /* #__PURE__ */ Object.assign({
|
|
6755
6769
|
"../../enable/auth/creates/src/lib/components/app-sidebar.svelte": ua,
|
|
6756
6770
|
"../../enable/auth/creates/src/lib/components/nav-main.svelte": da,
|
|
6757
6771
|
"../../enable/auth/creates/src/lib/components/nav-user.svelte": fa,
|
|
@@ -6801,7 +6815,7 @@ var Bp = {
|
|
|
6801
6815
|
"../../enable/auth/creates/src/routes/(public)/(auth)/signup/+page.svelte": to,
|
|
6802
6816
|
"../../enable/auth/creates/src/routes/(public)/(auth)/signup/+page.ts": no,
|
|
6803
6817
|
"../../enable/auth/creates/src/routes/(public)/(auth)/signup/server.test.ts": ro
|
|
6804
|
-
}),
|
|
6818
|
+
}), Kp = /* #__PURE__ */ Object.assign({
|
|
6805
6819
|
"../../enable/auth-remote/creates/src/lib/components/app-sidebar.svelte": bo,
|
|
6806
6820
|
"../../enable/auth-remote/creates/src/lib/components/nav-main.svelte": xo,
|
|
6807
6821
|
"../../enable/auth-remote/creates/src/lib/components/nav-user.svelte": So,
|
|
@@ -6858,11 +6872,11 @@ var Bp = {
|
|
|
6858
6872
|
"../../enable/auth-remote/creates/src/routes/(public)/(auth)/signup/+page.ts": vs,
|
|
6859
6873
|
"../../enable/auth-remote/creates/src/routes/(public)/(auth)/signup/form.remote.ts": ys,
|
|
6860
6874
|
"../../enable/auth-remote/creates/src/routes/(public)/(auth)/signup/server.test.ts": bs
|
|
6861
|
-
}),
|
|
6862
|
-
async function
|
|
6875
|
+
}), qp = "../../enable/auth/creates/", Jp = "../../enable/auth-remote/creates/";
|
|
6876
|
+
async function Yp(e) {
|
|
6863
6877
|
let t = /* @__PURE__ */ new Set();
|
|
6864
|
-
for (let e of Object.keys(
|
|
6865
|
-
for (let e of Object.keys(
|
|
6878
|
+
for (let e of Object.keys(Gp)) t.add(o(e, qp));
|
|
6879
|
+
for (let e of Object.keys(Kp)) t.add(o(e, Jp));
|
|
6866
6880
|
return {
|
|
6867
6881
|
creates: [],
|
|
6868
6882
|
modifies: [],
|
|
@@ -6881,20 +6895,20 @@ async function Gp(e) {
|
|
|
6881
6895
|
}
|
|
6882
6896
|
//#endregion
|
|
6883
6897
|
//#region src/patterns/disable/auth/index.ts
|
|
6884
|
-
var
|
|
6885
|
-
async function
|
|
6886
|
-
let t = await
|
|
6898
|
+
var Xp = "disable-auth", Zp = "1.0.0", Qp = "src/patterns/disable/auth", $p = "/disable/auth";
|
|
6899
|
+
async function em(e) {
|
|
6900
|
+
let t = await Yp(e);
|
|
6887
6901
|
if (e.env !== "runtime") return m(t, e);
|
|
6888
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
6902
|
+
let { generate: n } = await import("./chunks/generate.runtime-lqPPXQyS.js"), r = await n(e), a = await m(i([t, r]), e);
|
|
6889
6903
|
if (e.input.destructive !== !0) return a;
|
|
6890
|
-
let { writeResult: o } = await import("./chunks/write-result-
|
|
6904
|
+
let { writeResult: o } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
6891
6905
|
return o(a, e);
|
|
6892
6906
|
}
|
|
6893
|
-
var
|
|
6894
|
-
version:
|
|
6895
|
-
slug:
|
|
6896
|
-
source:
|
|
6897
|
-
docs:
|
|
6907
|
+
var tm = {
|
|
6908
|
+
version: Zp,
|
|
6909
|
+
slug: Xp,
|
|
6910
|
+
source: Qp,
|
|
6911
|
+
docs: $p,
|
|
6898
6912
|
plan: "open",
|
|
6899
6913
|
title: "Disable auth",
|
|
6900
6914
|
summary: "Reverts auth integration (including the remote-functions variant): removes auth routes, reverts layout/hooks edits, drops oauth_accounts. Does NOT delete the users collection or user data.",
|
|
@@ -6925,19 +6939,19 @@ var Zp = {
|
|
|
6925
6939
|
examples: [],
|
|
6926
6940
|
tests: 0,
|
|
6927
6941
|
baseline: "velastack-auth",
|
|
6928
|
-
generate:
|
|
6929
|
-
},
|
|
6942
|
+
generate: em
|
|
6943
|
+
}, nm = /* #__PURE__ */ Object.assign({
|
|
6930
6944
|
"../../enable/backend/creates/data/fixtures/README.md": gc,
|
|
6931
6945
|
"../../enable/backend/creates/data/hooks/README.md": _c,
|
|
6932
6946
|
"../../enable/backend/creates/data/seeds/README.md": vc,
|
|
6933
6947
|
"../../enable/backend/creates/src/hooks.server.ts": yc
|
|
6934
|
-
}),
|
|
6935
|
-
async function
|
|
6948
|
+
}), rm = "../../enable/backend/creates/";
|
|
6949
|
+
async function im(e) {
|
|
6936
6950
|
return {
|
|
6937
6951
|
creates: [],
|
|
6938
6952
|
modifies: [],
|
|
6939
|
-
deletes: Object.keys(
|
|
6940
|
-
let t = o(e,
|
|
6953
|
+
deletes: Object.keys(nm).map((e) => {
|
|
6954
|
+
let t = o(e, rm);
|
|
6941
6955
|
return {
|
|
6942
6956
|
path: t,
|
|
6943
6957
|
language: n(t),
|
|
@@ -6959,20 +6973,20 @@ async function em(e) {
|
|
|
6959
6973
|
}
|
|
6960
6974
|
//#endregion
|
|
6961
6975
|
//#region src/patterns/disable/backend/index.ts
|
|
6962
|
-
var
|
|
6963
|
-
async function
|
|
6964
|
-
let t = await
|
|
6976
|
+
var am = "disable-backend", om = "1.0.0", sm = "src/patterns/disable/backend", cm = "/disable/backend";
|
|
6977
|
+
async function lm(e) {
|
|
6978
|
+
let t = await im(e);
|
|
6965
6979
|
if (e.env !== "runtime") return m(t, e);
|
|
6966
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
6980
|
+
let { generate: n } = await import("./chunks/generate.runtime-CGkVUKvz.js"), r = await n(e), a = await m(i([t, r]), e);
|
|
6967
6981
|
if (e.input.destructive !== !0) return a;
|
|
6968
|
-
let { writeResult: o } = await import("./chunks/write-result-
|
|
6982
|
+
let { writeResult: o } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
6969
6983
|
return o(a, e);
|
|
6970
6984
|
}
|
|
6971
|
-
var
|
|
6972
|
-
version:
|
|
6973
|
-
slug:
|
|
6974
|
-
source:
|
|
6975
|
-
docs:
|
|
6985
|
+
var um = {
|
|
6986
|
+
version: om,
|
|
6987
|
+
slug: am,
|
|
6988
|
+
source: sm,
|
|
6989
|
+
docs: cm,
|
|
6976
6990
|
plan: "open",
|
|
6977
6991
|
title: "Disable Backend",
|
|
6978
6992
|
summary: "Removes the PocketBase backend wiring: deletes hooks.server.ts and the data/ scaffold, switches the SvelteKit adapter back to static with SPA fallback, and reverts test/setup.ts. Leaves @velastack/pocketbase and pocketbase-sveltekit installed; uninstall manually.",
|
|
@@ -7003,28 +7017,27 @@ var om = {
|
|
|
7003
7017
|
examples: [],
|
|
7004
7018
|
tests: 0,
|
|
7005
7019
|
baseline: "velastack",
|
|
7006
|
-
generate:
|
|
7007
|
-
},
|
|
7020
|
+
generate: lm
|
|
7021
|
+
}, dm = /* #__PURE__ */ Object.assign({
|
|
7008
7022
|
"../../enable/content-negotiation/creates/src/lib/negotiate.ts": wl,
|
|
7009
7023
|
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.server.ts": Tl,
|
|
7010
7024
|
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.svelte": El,
|
|
7011
7025
|
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.ts": Dl
|
|
7012
|
-
}),
|
|
7013
|
-
async function
|
|
7026
|
+
}), fm = /* #__PURE__ */ Object.assign({ "../../enable/content-negotiation/creates-with-blog/src/routes/(public)/blog/[slug]/+page.server.ts": Ol }), pm = "../../enable/content-negotiation/creates/", mm = "../../enable/content-negotiation/creates-with-blog/";
|
|
7027
|
+
async function hm(e) {
|
|
7028
|
+
let t = [...Object.keys(dm).map((e) => o(e, pm)), ...Object.keys(fm).map((e) => o(e, mm))];
|
|
7014
7029
|
return {
|
|
7015
7030
|
creates: [],
|
|
7016
7031
|
modifies: [],
|
|
7017
|
-
deletes:
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
status: "success"
|
|
7024
|
-
};
|
|
7025
|
-
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
7032
|
+
deletes: [...new Set(t)].map((e) => ({
|
|
7033
|
+
path: e,
|
|
7034
|
+
language: n(e),
|
|
7035
|
+
content: "",
|
|
7036
|
+
status: "success"
|
|
7037
|
+
})).sort((e, t) => e.path.localeCompare(t.path)),
|
|
7026
7038
|
components: [],
|
|
7027
7039
|
packages: [],
|
|
7040
|
+
uninstalls: ["sveltekit-negotiate"],
|
|
7028
7041
|
collections: [],
|
|
7029
7042
|
collectionPatches: [],
|
|
7030
7043
|
collectionDrops: []
|
|
@@ -7032,20 +7045,20 @@ async function lm(e) {
|
|
|
7032
7045
|
}
|
|
7033
7046
|
//#endregion
|
|
7034
7047
|
//#region src/patterns/disable/content-negotiation/index.ts
|
|
7035
|
-
var
|
|
7036
|
-
async function
|
|
7037
|
-
let t = await
|
|
7048
|
+
var gm = "disable-content-negotiation", _m = "1.0.0", vm = "src/patterns/disable/content-negotiation", ym = "/disable/content-negotiation";
|
|
7049
|
+
async function bm(e) {
|
|
7050
|
+
let t = await hm(e);
|
|
7038
7051
|
if (e.env !== "runtime") return m(t, e);
|
|
7039
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
7052
|
+
let { generate: n } = await import("./chunks/generate.runtime-BjULAL3h.js"), r = await n(e), a = await m(i([t, r]), e);
|
|
7040
7053
|
if (e.input.destructive !== !0) return a;
|
|
7041
|
-
let { writeResult: o } = await import("./chunks/write-result-
|
|
7054
|
+
let { writeResult: o } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
7042
7055
|
return o(a, e);
|
|
7043
7056
|
}
|
|
7044
|
-
var
|
|
7045
|
-
version:
|
|
7046
|
-
slug:
|
|
7047
|
-
source:
|
|
7048
|
-
docs:
|
|
7057
|
+
var xm = {
|
|
7058
|
+
version: _m,
|
|
7059
|
+
slug: gm,
|
|
7060
|
+
source: vm,
|
|
7061
|
+
docs: ym,
|
|
7049
7062
|
plan: "open",
|
|
7050
7063
|
title: "Disable content negotiation",
|
|
7051
7064
|
summary: "Removes sveltekit-negotiate wiring: deletes creates, unwraps hooks.server handle, reverts reroute (preserving i18n compose), removes <Negotiate /> from the root layout.",
|
|
@@ -7077,19 +7090,19 @@ var hm = {
|
|
|
7077
7090
|
examples: [],
|
|
7078
7091
|
tests: 0,
|
|
7079
7092
|
baseline: "velastack",
|
|
7080
|
-
generate:
|
|
7081
|
-
},
|
|
7093
|
+
generate: bm
|
|
7094
|
+
}, Sm = /* #__PURE__ */ Object.assign({
|
|
7082
7095
|
"../../enable/i18n/creates/src/hooks.ts": Wl,
|
|
7083
7096
|
"../../enable/i18n/creates/src/lib/components/language-select.svelte": Gl,
|
|
7084
7097
|
"../../enable/i18n/creates/src/lib/url.ts": Kl,
|
|
7085
7098
|
"../../enable/i18n/creates/wuchale.config.js": ql
|
|
7086
|
-
}),
|
|
7087
|
-
async function
|
|
7099
|
+
}), Cm = "../../enable/i18n/creates/";
|
|
7100
|
+
async function wm(e) {
|
|
7088
7101
|
return {
|
|
7089
7102
|
creates: [],
|
|
7090
7103
|
modifies: [],
|
|
7091
|
-
deletes: Object.keys(
|
|
7092
|
-
let t = o(e,
|
|
7104
|
+
deletes: Object.keys(Sm).map((e) => {
|
|
7105
|
+
let t = o(e, Cm);
|
|
7093
7106
|
return {
|
|
7094
7107
|
path: t,
|
|
7095
7108
|
language: n(t),
|
|
@@ -7099,6 +7112,7 @@ async function vm(e) {
|
|
|
7099
7112
|
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
7100
7113
|
components: [],
|
|
7101
7114
|
packages: [],
|
|
7115
|
+
uninstalls: ["wuchale", "@wuchale/svelte"],
|
|
7102
7116
|
collections: [],
|
|
7103
7117
|
collectionPatches: [],
|
|
7104
7118
|
collectionDrops: []
|
|
@@ -7106,20 +7120,20 @@ async function vm(e) {
|
|
|
7106
7120
|
}
|
|
7107
7121
|
//#endregion
|
|
7108
7122
|
//#region src/patterns/disable/i18n/index.ts
|
|
7109
|
-
var
|
|
7110
|
-
async function
|
|
7111
|
-
let t = await
|
|
7123
|
+
var Tm = "disable-i18n", Em = "1.0.0", Dm = "src/patterns/disable/i18n", Om = "/disable/i18n";
|
|
7124
|
+
async function km(e) {
|
|
7125
|
+
let t = await wm(e);
|
|
7112
7126
|
if (e.env !== "runtime") return m(t, e);
|
|
7113
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
7127
|
+
let { generate: n } = await import("./chunks/generate.runtime-Dc98DCsh.js"), r = await n(e), a = await m(i([t, r]), e);
|
|
7114
7128
|
if (e.input.destructive !== !0) return a;
|
|
7115
|
-
let { writeResult: o } = await import("./chunks/write-result-
|
|
7129
|
+
let { writeResult: o } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
7116
7130
|
return o(a, e);
|
|
7117
7131
|
}
|
|
7118
|
-
var
|
|
7119
|
-
version:
|
|
7120
|
-
slug:
|
|
7121
|
-
source:
|
|
7122
|
-
docs:
|
|
7132
|
+
var Am = {
|
|
7133
|
+
version: Em,
|
|
7134
|
+
slug: Tm,
|
|
7135
|
+
source: Dm,
|
|
7136
|
+
docs: Om,
|
|
7123
7137
|
plan: "open",
|
|
7124
7138
|
title: "Disable i18n",
|
|
7125
7139
|
summary: "Removes i18n scaffolding files and the Wuchale .gitignore block. vite.config, svelte.config, hooks.server, app.html, and +layout.ts must be reverted manually.",
|
|
@@ -7151,54 +7165,127 @@ var wm = {
|
|
|
7151
7165
|
examples: [],
|
|
7152
7166
|
tests: 0,
|
|
7153
7167
|
baseline: "velastack",
|
|
7154
|
-
generate:
|
|
7155
|
-
},
|
|
7156
|
-
"../../enable/
|
|
7157
|
-
"../../enable/
|
|
7158
|
-
"../../enable/
|
|
7159
|
-
"../../enable/
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7168
|
+
generate: km
|
|
7169
|
+
}, jm = /* #__PURE__ */ Object.assign({
|
|
7170
|
+
"../../enable/notifications/creates/src/lib/components/notifications-bell.svelte": ou,
|
|
7171
|
+
"../../enable/notifications/creates/src/lib/server/notifications.ts": su,
|
|
7172
|
+
"../../enable/notifications/creates/src/routes/(app)/notifications/+page.server.ts": cu,
|
|
7173
|
+
"../../enable/notifications/creates/src/routes/(app)/notifications/+page.svelte": lu
|
|
7174
|
+
}), Mm = "../../enable/notifications/creates/";
|
|
7175
|
+
async function Nm(e) {
|
|
7176
|
+
return {
|
|
7177
|
+
creates: [],
|
|
7178
|
+
modifies: [],
|
|
7179
|
+
deletes: Object.keys(jm).map((e) => {
|
|
7180
|
+
let t = o(e, Mm);
|
|
7181
|
+
return {
|
|
7182
|
+
path: t,
|
|
7183
|
+
language: n(t),
|
|
7184
|
+
content: "",
|
|
7185
|
+
status: "success"
|
|
7186
|
+
};
|
|
7187
|
+
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
7188
|
+
components: [],
|
|
7189
|
+
packages: [],
|
|
7190
|
+
collections: [],
|
|
7191
|
+
collectionPatches: [],
|
|
7192
|
+
collectionDrops: []
|
|
7193
|
+
};
|
|
7194
|
+
}
|
|
7195
|
+
//#endregion
|
|
7196
|
+
//#region src/patterns/disable/notifications/index.ts
|
|
7197
|
+
var Pm = "disable-notifications", Fm = "1.0.0", Im = "src/patterns/disable/notifications", Lm = "/disable/notifications";
|
|
7198
|
+
async function Rm(e) {
|
|
7199
|
+
let t = await Nm(e);
|
|
7200
|
+
if (e.env !== "runtime") return m(t, e);
|
|
7201
|
+
let { generate: n } = await import("./chunks/generate.runtime-BdTCMGGB.js"), r = await n(e), a = await m(i([t, r]), e);
|
|
7202
|
+
if (e.input.destructive !== !0) return a;
|
|
7203
|
+
let { writeResult: o } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
7204
|
+
return o(a, e);
|
|
7205
|
+
}
|
|
7206
|
+
var zm = {
|
|
7207
|
+
version: Fm,
|
|
7208
|
+
slug: Pm,
|
|
7209
|
+
source: Im,
|
|
7210
|
+
docs: Lm,
|
|
7211
|
+
plan: "open",
|
|
7212
|
+
title: "Disable notifications",
|
|
7213
|
+
summary: "Drops the notifications collection, deletes the bell component, server helpers and /notifications page, and takes the bell and its loader out of the (app) layout.",
|
|
7214
|
+
requires: {
|
|
7215
|
+
auth: !0,
|
|
7216
|
+
api: !1,
|
|
7217
|
+
apiKeys: !1,
|
|
7218
|
+
backend: !0,
|
|
7219
|
+
i18n: !1,
|
|
7220
|
+
teams: !1,
|
|
7221
|
+
payments: !1,
|
|
7222
|
+
blog: !1,
|
|
7223
|
+
contentNegotiation: !1,
|
|
7224
|
+
cms: !1
|
|
7225
|
+
},
|
|
7226
|
+
category: "auth",
|
|
7227
|
+
tags: [
|
|
7228
|
+
"sveltekit",
|
|
7229
|
+
"notifications",
|
|
7230
|
+
"pocketbase",
|
|
7231
|
+
"velastack"
|
|
7232
|
+
],
|
|
7233
|
+
command: {
|
|
7234
|
+
raw: "vela disable notifications",
|
|
7235
|
+
base: "vela disable notifications",
|
|
7236
|
+
argv: []
|
|
7237
|
+
},
|
|
7238
|
+
examples: [],
|
|
7239
|
+
tests: 0,
|
|
7240
|
+
baseline: "velastack-auth",
|
|
7241
|
+
generate: Rm
|
|
7242
|
+
}, Bm = /* #__PURE__ */ Object.assign({
|
|
7243
|
+
"../../enable/teams/creates/src/lib/components/team-switcher.svelte": Qd,
|
|
7244
|
+
"../../enable/teams/creates/src/lib/schemas/team.ts": $d,
|
|
7245
|
+
"../../enable/teams/creates/src/lib/schemas/teamInvite.ts": ef,
|
|
7246
|
+
"../../enable/teams/creates/src/lib/schemas/teamRole.ts": tf,
|
|
7247
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+layout@.svelte": nf,
|
|
7248
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.server.ts": rf,
|
|
7249
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.svelte": af,
|
|
7250
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.ts": of,
|
|
7251
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+layout@.svelte": sf,
|
|
7252
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.server.ts": cf,
|
|
7253
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.svelte": lf,
|
|
7254
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.ts": uf,
|
|
7255
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+layout.server.ts": df,
|
|
7256
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+layout.svelte": ff,
|
|
7257
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+page.server.ts": pf,
|
|
7171
7258
|
"../../enable/teams/creates/src/routes/(app)/teams/+page.svelte": "",
|
|
7172
|
-
"../../enable/teams/creates/src/routes/(app)/teams/+page.ts":
|
|
7173
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout.server.ts":
|
|
7174
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout@(app).svelte":
|
|
7175
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.server.ts":
|
|
7259
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+page.ts": mf,
|
|
7260
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout.server.ts": hf,
|
|
7261
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout@(app).svelte": gf,
|
|
7262
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.server.ts": _f,
|
|
7176
7263
|
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.svelte": "",
|
|
7177
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.ts":
|
|
7178
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/authorization.ts":
|
|
7179
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.server.ts":
|
|
7180
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.svelte":
|
|
7181
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.ts":
|
|
7182
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/server.test.ts":
|
|
7183
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts":
|
|
7184
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte":
|
|
7185
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts":
|
|
7186
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts":
|
|
7187
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/server.test.ts":
|
|
7188
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.server.ts":
|
|
7189
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.svelte":
|
|
7190
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.ts":
|
|
7191
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/server.test.ts":
|
|
7192
|
-
"../../enable/teams/creates/src/routes/(app)/teams/server.test.ts":
|
|
7193
|
-
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/+page.server.ts":
|
|
7194
|
-
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/server.test.ts":
|
|
7195
|
-
}),
|
|
7196
|
-
async function
|
|
7264
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.ts": vf,
|
|
7265
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/authorization.ts": yf,
|
|
7266
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.server.ts": bf,
|
|
7267
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.svelte": xf,
|
|
7268
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.ts": Sf,
|
|
7269
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/server.test.ts": Cf,
|
|
7270
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts": wf,
|
|
7271
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte": Tf,
|
|
7272
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts": Ef,
|
|
7273
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts": Df,
|
|
7274
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/server.test.ts": Of,
|
|
7275
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.server.ts": kf,
|
|
7276
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.svelte": Af,
|
|
7277
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.ts": jf,
|
|
7278
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/server.test.ts": Mf,
|
|
7279
|
+
"../../enable/teams/creates/src/routes/(app)/teams/server.test.ts": Nf,
|
|
7280
|
+
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/+page.server.ts": Pf,
|
|
7281
|
+
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/server.test.ts": Ff
|
|
7282
|
+
}), Vm = "../../enable/teams/creates/";
|
|
7283
|
+
async function Hm(e) {
|
|
7197
7284
|
return {
|
|
7198
7285
|
creates: [],
|
|
7199
7286
|
modifies: [],
|
|
7200
|
-
deletes: Object.keys(
|
|
7201
|
-
let t = o(e,
|
|
7287
|
+
deletes: Object.keys(Bm).map((e) => {
|
|
7288
|
+
let t = o(e, Vm);
|
|
7202
7289
|
return {
|
|
7203
7290
|
path: t,
|
|
7204
7291
|
language: n(t),
|
|
@@ -7215,23 +7302,23 @@ async function Dm(e) {
|
|
|
7215
7302
|
}
|
|
7216
7303
|
//#endregion
|
|
7217
7304
|
//#region src/patterns/disable/teams/index.ts
|
|
7218
|
-
var
|
|
7219
|
-
async function
|
|
7220
|
-
let t = await
|
|
7305
|
+
var Um = "disable-teams", Wm = "1.0.0", Gm = "src/patterns/disable/teams", Km = "/disable/teams";
|
|
7306
|
+
async function qm(e) {
|
|
7307
|
+
let t = await Hm(e);
|
|
7221
7308
|
if (e.env !== "runtime") return m(t, e);
|
|
7222
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
7309
|
+
let { generate: n } = await import("./chunks/generate.runtime-DWeiewRj.js"), r = await n(e), a = await m(i([t, r]), e);
|
|
7223
7310
|
if (e.input.destructive !== !0) return a;
|
|
7224
|
-
let { writeResult: o } = await import("./chunks/write-result-
|
|
7311
|
+
let { writeResult: o } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
7225
7312
|
return o(a, e);
|
|
7226
7313
|
}
|
|
7227
|
-
var
|
|
7228
|
-
version:
|
|
7229
|
-
slug:
|
|
7230
|
-
source:
|
|
7231
|
-
docs:
|
|
7314
|
+
var Jm = {
|
|
7315
|
+
version: Wm,
|
|
7316
|
+
slug: Um,
|
|
7317
|
+
source: Gm,
|
|
7318
|
+
docs: Km,
|
|
7232
7319
|
plan: "pro",
|
|
7233
7320
|
title: "Disable teams",
|
|
7234
|
-
summary: "Removes teams collections
|
|
7321
|
+
summary: "Removes the teams collections and routes, and reverts the Teams nav item, the team switcher in app-sidebar, the team props in the (app) layout, and the team loader in its +layout.server.ts.",
|
|
7235
7322
|
requires: {
|
|
7236
7323
|
auth: !0,
|
|
7237
7324
|
api: !1,
|
|
@@ -7259,47 +7346,47 @@ var Nm = {
|
|
|
7259
7346
|
examples: [],
|
|
7260
7347
|
tests: 0,
|
|
7261
7348
|
baseline: "velastack-auth",
|
|
7262
|
-
generate:
|
|
7263
|
-
},
|
|
7264
|
-
"../../enable/payments/creates/data/hooks/stripe.pb.js":
|
|
7265
|
-
"../../enable/payments/creates/data/hooks/utils.js":
|
|
7266
|
-
"../../enable/payments/creates/src/lib/components/payments/confirm-dialog.svelte":
|
|
7267
|
-
"../../enable/payments/creates/src/lib/components/payments/payment-button.svelte":
|
|
7268
|
-
"../../enable/payments/creates/src/lib/components/payments/payment-dialog.svelte":
|
|
7269
|
-
"../../enable/payments/creates/src/lib/components/payments/stripe-constants.ts":
|
|
7270
|
-
"../../enable/payments/creates/src/lib/components/payments/stripe-payment-form.svelte":
|
|
7271
|
-
"../../enable/payments/creates/src/lib/components/payments/use-payment-intent.svelte.ts":
|
|
7272
|
-
"../../enable/payments/creates/src/lib/components/payments/use-stripe.svelte.ts":
|
|
7273
|
-
"../../enable/payments/creates/src/lib/stripe.ts":
|
|
7274
|
-
"../../enable/payments/creates/src/routes/api/stripe/payment-intent/+server.ts":
|
|
7275
|
-
"../../enable/payments/creates/src/routes/api/stripe/payment-intent/server.test.ts":
|
|
7276
|
-
"../../enable/payments/creates/src/routes/api/stripe/sync/prices/+server.ts":
|
|
7277
|
-
"../../enable/payments/creates/src/routes/api/stripe/sync/products/+server.ts":
|
|
7278
|
-
"../../enable/payments/creates/src/routes/webhooks/stripe/+server.ts":
|
|
7279
|
-
"../../enable/payments/creates/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts":
|
|
7280
|
-
"../../enable/payments/creates/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts":
|
|
7281
|
-
"../../enable/payments/creates/src/routes/webhooks/stripe/server.test.ts":
|
|
7282
|
-
}),
|
|
7283
|
-
"../../enable/payments/creates-app-mode/data/hooks/stripe.pb.js":
|
|
7284
|
-
"../../enable/payments/creates-app-mode/data/hooks/utils.js":
|
|
7285
|
-
"../../enable/payments/creates-app-mode/src/lib/components/payments/setup-button.svelte":
|
|
7286
|
-
"../../enable/payments/creates-app-mode/src/lib/components/payments/setup-dialog.svelte":
|
|
7287
|
-
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+layout.server.ts":
|
|
7349
|
+
generate: qm
|
|
7350
|
+
}, Ym = /* #__PURE__ */ Object.assign({
|
|
7351
|
+
"../../enable/payments/creates/data/hooks/stripe.pb.js": Eu,
|
|
7352
|
+
"../../enable/payments/creates/data/hooks/utils.js": Du,
|
|
7353
|
+
"../../enable/payments/creates/src/lib/components/payments/confirm-dialog.svelte": Ou,
|
|
7354
|
+
"../../enable/payments/creates/src/lib/components/payments/payment-button.svelte": ku,
|
|
7355
|
+
"../../enable/payments/creates/src/lib/components/payments/payment-dialog.svelte": Au,
|
|
7356
|
+
"../../enable/payments/creates/src/lib/components/payments/stripe-constants.ts": ju,
|
|
7357
|
+
"../../enable/payments/creates/src/lib/components/payments/stripe-payment-form.svelte": Mu,
|
|
7358
|
+
"../../enable/payments/creates/src/lib/components/payments/use-payment-intent.svelte.ts": Nu,
|
|
7359
|
+
"../../enable/payments/creates/src/lib/components/payments/use-stripe.svelte.ts": Pu,
|
|
7360
|
+
"../../enable/payments/creates/src/lib/stripe.ts": Fu,
|
|
7361
|
+
"../../enable/payments/creates/src/routes/api/stripe/payment-intent/+server.ts": Iu,
|
|
7362
|
+
"../../enable/payments/creates/src/routes/api/stripe/payment-intent/server.test.ts": Lu,
|
|
7363
|
+
"../../enable/payments/creates/src/routes/api/stripe/sync/prices/+server.ts": Ru,
|
|
7364
|
+
"../../enable/payments/creates/src/routes/api/stripe/sync/products/+server.ts": zu,
|
|
7365
|
+
"../../enable/payments/creates/src/routes/webhooks/stripe/+server.ts": Bu,
|
|
7366
|
+
"../../enable/payments/creates/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": Vu,
|
|
7367
|
+
"../../enable/payments/creates/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": Hu,
|
|
7368
|
+
"../../enable/payments/creates/src/routes/webhooks/stripe/server.test.ts": Uu
|
|
7369
|
+
}), Xm = /* #__PURE__ */ Object.assign({
|
|
7370
|
+
"../../enable/payments/creates-app-mode/data/hooks/stripe.pb.js": Wu,
|
|
7371
|
+
"../../enable/payments/creates-app-mode/data/hooks/utils.js": Gu,
|
|
7372
|
+
"../../enable/payments/creates-app-mode/src/lib/components/payments/setup-button.svelte": Ku,
|
|
7373
|
+
"../../enable/payments/creates-app-mode/src/lib/components/payments/setup-dialog.svelte": qu,
|
|
7374
|
+
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+layout.server.ts": Ju,
|
|
7288
7375
|
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+page.server.ts": re,
|
|
7289
7376
|
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+page.svelte": ne,
|
|
7290
|
-
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/README.md":
|
|
7291
|
-
"../../enable/payments/creates-app-mode/src/routes/api/stripe/payment-intent/+server.ts":
|
|
7292
|
-
"../../enable/payments/creates-app-mode/src/routes/api/stripe/payment-intent/server.test.ts":
|
|
7293
|
-
"../../enable/payments/creates-app-mode/src/routes/api/stripe/setup-intent/+server.ts":
|
|
7294
|
-
"../../enable/payments/creates-app-mode/src/routes/api/stripe/setup-intent/server.test.ts":
|
|
7295
|
-
"../../enable/payments/creates-app-mode/src/routes/api/stripe/sync/customers/+server.ts":
|
|
7296
|
-
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/+server.ts":
|
|
7297
|
-
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts":
|
|
7298
|
-
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts":
|
|
7299
|
-
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/attached.ts":
|
|
7300
|
-
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts":
|
|
7301
|
-
}),
|
|
7302
|
-
function
|
|
7377
|
+
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/README.md": Yu,
|
|
7378
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/payment-intent/+server.ts": Xu,
|
|
7379
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/payment-intent/server.test.ts": Zu,
|
|
7380
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/setup-intent/+server.ts": Qu,
|
|
7381
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/setup-intent/server.test.ts": $u,
|
|
7382
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/sync/customers/+server.ts": ed,
|
|
7383
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/+server.ts": td,
|
|
7384
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": nd,
|
|
7385
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": rd,
|
|
7386
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/attached.ts": id,
|
|
7387
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts": ad
|
|
7388
|
+
}), Zm = "../../enable/payments/creates/", Qm = "../../enable/payments/creates-app-mode/";
|
|
7389
|
+
function $m(e, t) {
|
|
7303
7390
|
let r = {};
|
|
7304
7391
|
for (let i of Object.keys(e)) {
|
|
7305
7392
|
let e = o(i, t);
|
|
@@ -7312,10 +7399,10 @@ function Rm(e, t) {
|
|
|
7312
7399
|
}
|
|
7313
7400
|
return r;
|
|
7314
7401
|
}
|
|
7315
|
-
async function
|
|
7316
|
-
let t = e.features.auth, n = {
|
|
7402
|
+
async function eh(e) {
|
|
7403
|
+
let t = e.features.auth, n = { ...$m(Ym, Zm) };
|
|
7317
7404
|
if (t) {
|
|
7318
|
-
let e =
|
|
7405
|
+
let e = $m(Xm, Qm);
|
|
7319
7406
|
Object.assign(n, e);
|
|
7320
7407
|
}
|
|
7321
7408
|
return {
|
|
@@ -7331,20 +7418,20 @@ async function zm(e) {
|
|
|
7331
7418
|
}
|
|
7332
7419
|
//#endregion
|
|
7333
7420
|
//#region src/patterns/disable/payments/index.ts
|
|
7334
|
-
var
|
|
7335
|
-
async function
|
|
7336
|
-
let t = await
|
|
7421
|
+
var th = "disable-payments", nh = "1.0.0", rh = "src/patterns/disable/payments", ih = "/disable/payments";
|
|
7422
|
+
async function ah(e) {
|
|
7423
|
+
let t = await eh(e);
|
|
7337
7424
|
if (e.env !== "runtime") return m(t, e);
|
|
7338
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
7425
|
+
let { generate: n } = await import("./chunks/generate.runtime-Wssys8A0.js"), r = await n(e), a = await m(i([t, r]), e);
|
|
7339
7426
|
if (e.input.destructive !== !0) return a;
|
|
7340
|
-
let o = await
|
|
7427
|
+
let o = await oh(e), s = {
|
|
7341
7428
|
...a,
|
|
7342
7429
|
creates: [...a.creates, ...o]
|
|
7343
|
-
}, { writeResult: c } = await import("./chunks/write-result-
|
|
7430
|
+
}, { writeResult: c } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
7344
7431
|
return c(s, e);
|
|
7345
7432
|
}
|
|
7346
|
-
async function
|
|
7347
|
-
let { withPocketbase: t } = await import("./chunks/pocketbase-059B1oot.js"), { applyCollectionFieldsPatches: n } = await import("./chunks/collections-
|
|
7433
|
+
async function oh(e) {
|
|
7434
|
+
let { withPocketbase: t } = await import("./chunks/pocketbase-059B1oot.js"), { applyCollectionFieldsPatches: n } = await import("./chunks/collections-B3lAtPlQ.js"), r = b(e), i = [];
|
|
7348
7435
|
return await t(e.root, async (t) => {
|
|
7349
7436
|
let a;
|
|
7350
7437
|
try {
|
|
@@ -7362,11 +7449,11 @@ async function Gm(e) {
|
|
|
7362
7449
|
}], e, r));
|
|
7363
7450
|
}), i;
|
|
7364
7451
|
}
|
|
7365
|
-
var
|
|
7366
|
-
version:
|
|
7367
|
-
slug:
|
|
7368
|
-
source:
|
|
7369
|
-
docs:
|
|
7452
|
+
var sh = {
|
|
7453
|
+
version: nh,
|
|
7454
|
+
slug: th,
|
|
7455
|
+
source: rh,
|
|
7456
|
+
docs: ih,
|
|
7370
7457
|
plan: "pro",
|
|
7371
7458
|
title: "Disable payments",
|
|
7372
7459
|
summary: "Drops Stripe collections, strips Stripe env credentials, reverts nav/signup edits, and deletes generated payment files. Does NOT delete Stripe products/prices in the Stripe dashboard, or uninstall stripe/@stripe/stripe-js packages.",
|
|
@@ -7399,20 +7486,20 @@ var Km = {
|
|
|
7399
7486
|
examples: [],
|
|
7400
7487
|
tests: 0,
|
|
7401
7488
|
baseline: "velastack",
|
|
7402
|
-
generate:
|
|
7403
|
-
},
|
|
7404
|
-
"../../enable/subscriptions/creates/src/routes/api/stripe/sync/subscriptions/+server.ts":
|
|
7405
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/created.ts":
|
|
7406
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts":
|
|
7407
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts":
|
|
7408
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts":
|
|
7409
|
-
}),
|
|
7410
|
-
async function
|
|
7489
|
+
generate: ah
|
|
7490
|
+
}, ch = /* #__PURE__ */ Object.assign({
|
|
7491
|
+
"../../enable/subscriptions/creates/src/routes/api/stripe/sync/subscriptions/+server.ts": Pd,
|
|
7492
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/created.ts": Fd,
|
|
7493
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts": Id,
|
|
7494
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts": Ld,
|
|
7495
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts": Rd
|
|
7496
|
+
}), lh = "../../enable/subscriptions/creates/";
|
|
7497
|
+
async function uh(e) {
|
|
7411
7498
|
return {
|
|
7412
7499
|
creates: [],
|
|
7413
7500
|
modifies: [],
|
|
7414
|
-
deletes: Object.keys(
|
|
7415
|
-
let t = o(e,
|
|
7501
|
+
deletes: Object.keys(ch).map((e) => {
|
|
7502
|
+
let t = o(e, lh);
|
|
7416
7503
|
return {
|
|
7417
7504
|
path: t,
|
|
7418
7505
|
language: n(t),
|
|
@@ -7429,20 +7516,20 @@ async function Ym(e) {
|
|
|
7429
7516
|
}
|
|
7430
7517
|
//#endregion
|
|
7431
7518
|
//#region src/patterns/disable/subscriptions/index.ts
|
|
7432
|
-
var
|
|
7433
|
-
async function
|
|
7434
|
-
let t = await
|
|
7519
|
+
var dh = "disable-subscriptions", fh = "1.0.0", ph = "src/patterns/disable/subscriptions", mh = "/disable/subscriptions";
|
|
7520
|
+
async function hh(e) {
|
|
7521
|
+
let t = await uh(e);
|
|
7435
7522
|
if (e.env !== "runtime") return m(t, e);
|
|
7436
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
7523
|
+
let { generate: n } = await import("./chunks/generate.runtime-DKJaYtVZ.js"), r = await n(e), a = await m(i([t, r]), e);
|
|
7437
7524
|
if (e.input.destructive !== !0) return a;
|
|
7438
|
-
let { writeResult: o } = await import("./chunks/write-result-
|
|
7525
|
+
let { writeResult: o } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
7439
7526
|
return o(a, e);
|
|
7440
7527
|
}
|
|
7441
|
-
var
|
|
7442
|
-
version:
|
|
7443
|
-
slug:
|
|
7444
|
-
source:
|
|
7445
|
-
docs:
|
|
7528
|
+
var gh = {
|
|
7529
|
+
version: fh,
|
|
7530
|
+
slug: dh,
|
|
7531
|
+
source: ph,
|
|
7532
|
+
docs: mh,
|
|
7446
7533
|
plan: "pro",
|
|
7447
7534
|
title: "Disable subscriptions",
|
|
7448
7535
|
summary: "Drops the stripe_subscriptions collection, reverts billing / layout / nav edits, and removes subscription webhook handlers and sync endpoint. Leaves the payments pattern intact.",
|
|
@@ -7476,8 +7563,8 @@ var th = {
|
|
|
7476
7563
|
examples: [],
|
|
7477
7564
|
tests: 0,
|
|
7478
7565
|
baseline: "velastack",
|
|
7479
|
-
generate:
|
|
7480
|
-
},
|
|
7566
|
+
generate: hh
|
|
7567
|
+
}, _h = Te.version, vh = [
|
|
7481
7568
|
jn,
|
|
7482
7569
|
lr,
|
|
7483
7570
|
br,
|
|
@@ -7495,48 +7582,49 @@ var th = {
|
|
|
7495
7582
|
Cl,
|
|
7496
7583
|
Ul,
|
|
7497
7584
|
au,
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7585
|
+
Tu,
|
|
7586
|
+
Nd,
|
|
7587
|
+
Zd,
|
|
7588
|
+
tp,
|
|
7589
|
+
cp,
|
|
7590
|
+
mp,
|
|
7591
|
+
bp,
|
|
7592
|
+
Ep,
|
|
7593
|
+
Fp,
|
|
7594
|
+
Wp,
|
|
7595
|
+
tm,
|
|
7596
|
+
um,
|
|
7597
|
+
xm,
|
|
7598
|
+
Am,
|
|
7599
|
+
zm,
|
|
7600
|
+
Jm,
|
|
7601
|
+
sh,
|
|
7602
|
+
gh
|
|
7603
|
+
], yh = Object.fromEntries(vh.map((e) => [e.slug, e])), bh = vh.reduce((e, t) => {
|
|
7516
7604
|
let n = t.category;
|
|
7517
7605
|
return e[n] ??= [], e[n].push(t), e;
|
|
7518
7606
|
}, {});
|
|
7519
|
-
async function
|
|
7520
|
-
let { installComponents: n } = await import("./chunks/write-result-
|
|
7607
|
+
async function xh(e, t) {
|
|
7608
|
+
let { installComponents: n } = await import("./chunks/write-result-BN7Ff0rF.js");
|
|
7521
7609
|
return n(e, t);
|
|
7522
7610
|
}
|
|
7523
|
-
async function
|
|
7524
|
-
let { listComponents: n } = await import("./chunks/ui-
|
|
7611
|
+
async function Sh(e, t) {
|
|
7612
|
+
let { listComponents: n } = await import("./chunks/ui-BsG60gQg.js");
|
|
7525
7613
|
return n(e, t);
|
|
7526
7614
|
}
|
|
7527
|
-
async function
|
|
7528
|
-
let { switchStyle: n } = await import("./chunks/ui-
|
|
7615
|
+
async function Ch(e, t) {
|
|
7616
|
+
let { switchStyle: n } = await import("./chunks/ui-BsG60gQg.js");
|
|
7529
7617
|
return n(e, t);
|
|
7530
7618
|
}
|
|
7531
|
-
async function
|
|
7532
|
-
let { applyBaseColor: n } = await import("./chunks/ui-
|
|
7619
|
+
async function wh(e, t) {
|
|
7620
|
+
let { applyBaseColor: n } = await import("./chunks/ui-BsG60gQg.js");
|
|
7533
7621
|
return n(e, t);
|
|
7534
7622
|
}
|
|
7535
|
-
async function
|
|
7536
|
-
let { applyTheme: n } = await import("./chunks/ui-
|
|
7623
|
+
async function Th(e, t) {
|
|
7624
|
+
let { applyTheme: n } = await import("./chunks/ui-BsG60gQg.js");
|
|
7537
7625
|
return n(e, t);
|
|
7538
7626
|
}
|
|
7539
7627
|
//#endregion
|
|
7540
|
-
export { t as InvalidArgumentError, e as RegistryUnavailableError,
|
|
7628
|
+
export { t as InvalidArgumentError, e as RegistryUnavailableError, wh as applyBaseColor, Th as applyTheme, bh as byCategory, yh as bySlug, xh as installComponents, Sh as listComponents, vh as patterns, s as providerFromArgv, u as resolveProvider, Ch as switchStyle, f as unknownProviderMessage, _h as version };
|
|
7541
7629
|
|
|
7542
7630
|
//# sourceMappingURL=index.js.map
|