@nswds/app 1.45.2 → 1.46.0
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/globals.css +95 -4
- package/dist/index.cjs +602 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -1
- package/dist/index.d.ts +66 -1
- package/dist/index.js +592 -77
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/styles.css +102 -4
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,9 +6,9 @@ import { cva } from 'class-variance-authority';
|
|
|
6
6
|
import * as AspectRatioPrimitive from '@radix-ui/react-aspect-ratio';
|
|
7
7
|
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
8
8
|
import * as Headless4 from '@headlessui/react';
|
|
9
|
-
import { PopoverGroup, Popover as Popover$1, PopoverButton, PopoverPanel } from '@headlessui/react';
|
|
9
|
+
import { PopoverGroup, Popover as Popover$1, PopoverButton, PopoverPanel, Dialog as Dialog$1, DialogPanel } from '@headlessui/react';
|
|
10
10
|
import * as React16 from 'react';
|
|
11
|
-
import React16__default, { forwardRef, useEffect, createContext, useRef, useState, Suspense, useId, useMemo, useContext, Fragment as Fragment$1,
|
|
11
|
+
import React16__default, { forwardRef, useEffect, createContext, useRef, useState, Suspense, useId, useMemo, useContext, Fragment as Fragment$1, useCallback, useLayoutEffect, useInsertionEffect, createElement, Component } from 'react';
|
|
12
12
|
import Link10 from 'next/link';
|
|
13
13
|
import * as culori from 'culori';
|
|
14
14
|
import { Slot } from '@radix-ui/react-slot';
|
|
@@ -32,7 +32,7 @@ import { useCopyToClipboard } from '@uidotdev/usehooks';
|
|
|
32
32
|
import { Toaster as Toaster$1, toast } from 'sonner';
|
|
33
33
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
34
34
|
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
35
|
-
import { CircleIcon, ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon, ArrowLeft, ArrowRight, MinusIcon } from 'lucide-react';
|
|
35
|
+
import { CircleIcon, ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon, ArrowLeft, ArrowRight, MinusIcon, Layers, Hash } from 'lucide-react';
|
|
36
36
|
import * as TabsPrimitive2 from '@radix-ui/react-tabs';
|
|
37
37
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
38
38
|
import { Command as Command$1 } from 'cmdk';
|
|
@@ -57,16 +57,28 @@ import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
|
|
57
57
|
import { getDefaultClassNames, DayPicker } from 'react-day-picker';
|
|
58
58
|
import useEmblaCarousel from 'embla-carousel-react';
|
|
59
59
|
import { OTPInput, OTPInputContext } from 'input-otp';
|
|
60
|
+
import NextAuth from 'next-auth';
|
|
61
|
+
import MicrosoftEntraID from 'next-auth/providers/microsoft-entra-id';
|
|
62
|
+
import { and, eq } from 'drizzle-orm';
|
|
63
|
+
import { DrizzleAdapter } from '@auth/drizzle-adapter';
|
|
64
|
+
import { drizzle } from 'drizzle-orm/libsql';
|
|
65
|
+
import { createClient } from '@libsql/client';
|
|
66
|
+
import { sqliteTable, text, integer, primaryKey } from 'drizzle-orm/sqlite-core';
|
|
60
67
|
import { slugifyWithCounter } from '@sindresorhus/slugify';
|
|
61
68
|
import { create } from 'zustand';
|
|
62
69
|
import { persist, createJSONStorage } from 'zustand/middleware';
|
|
63
70
|
|
|
71
|
+
var __defProp = Object.defineProperty;
|
|
64
72
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
65
73
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
66
74
|
}) : x)(function(x) {
|
|
67
75
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
68
76
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
69
77
|
});
|
|
78
|
+
var __export = (target, all) => {
|
|
79
|
+
for (var name in all)
|
|
80
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
81
|
+
};
|
|
70
82
|
var Icons = {
|
|
71
83
|
account_circle: (props) => /* @__PURE__ */ jsx("svg", { fill: "currentColor", "data-slot": "icon", viewBox: "0 -960 960 960", ...props, children: /* @__PURE__ */ jsx("path", { d: "M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z" }) }),
|
|
72
84
|
add: (props) => /* @__PURE__ */ jsx("svg", { fill: "currentColor", "data-slot": "icon", viewBox: "0 -960 960 960", ...props, children: /* @__PURE__ */ jsx("path", { d: "M440-440H240q-17 0-28.5-11.5T200-480q0-17 11.5-28.5T240-520h200v-200q0-17 11.5-28.5T480-760q17 0 28.5 11.5T520-720v200h200q17 0 28.5 11.5T760-480q0 17-11.5 28.5T720-440H520v200q0 17-11.5 28.5T480-200q-17 0-28.5-11.5T440-240v-200Z" }) }),
|
|
@@ -175,11 +187,11 @@ var Icons = {
|
|
|
175
187
|
function cn(...inputs) {
|
|
176
188
|
return twMerge(clsx(inputs));
|
|
177
189
|
}
|
|
178
|
-
function truncate(
|
|
179
|
-
if (
|
|
180
|
-
return
|
|
190
|
+
function truncate(text4, maxLength) {
|
|
191
|
+
if (text4.length <= maxLength) {
|
|
192
|
+
return text4;
|
|
181
193
|
}
|
|
182
|
-
return
|
|
194
|
+
return text4.slice(0, maxLength) + "...";
|
|
183
195
|
}
|
|
184
196
|
function kebabCase(str) {
|
|
185
197
|
return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
@@ -643,7 +655,7 @@ var styles = {
|
|
|
643
655
|
default: "px-[calc(--spacing(5)-1px)] py-[calc(--spacing(4)-1px)] sm:px-[calc(--spacing(4.5)-1px)] sm:py-[calc(--spacing(3)-1px)]",
|
|
644
656
|
sm: "px-[calc(--spacing(4)-1px)] py-[calc(--spacing(3)-1px)] sm:px-[calc(--spacing(3.5)-1px)] sm:py-[calc(--spacing(2)-1px)]",
|
|
645
657
|
lg: "px-[calc(--spacing(6)-1px)] py-[calc(--spacing(5)-1px)] sm:px-[calc(--spacing(5.5)-1px)] sm:py-[calc(--spacing(4)-1px)]",
|
|
646
|
-
icon: "
|
|
658
|
+
icon: "w-10 h-10 flex-none"
|
|
647
659
|
}
|
|
648
660
|
};
|
|
649
661
|
var buttonVariants = cva(styles.base, {
|
|
@@ -4570,7 +4582,7 @@ var colors = {
|
|
|
4570
4582
|
hex: "#c99ac2",
|
|
4571
4583
|
rgb: "rgb(201, 154, 194)",
|
|
4572
4584
|
hsl: "hsl(308.94, 30.32%, 69.61%)",
|
|
4573
|
-
name: "Lilli
|
|
4585
|
+
name: "Lilli Pilli Purple"
|
|
4574
4586
|
},
|
|
4575
4587
|
{
|
|
4576
4588
|
token: "nsw-aboriginal-purple-450",
|
|
@@ -5910,7 +5922,6 @@ function ThemeSelectorContent({
|
|
|
5910
5922
|
availableAccentColors,
|
|
5911
5923
|
colorThemes: colorThemes2
|
|
5912
5924
|
}) {
|
|
5913
|
-
const searchParams = useSearchParams();
|
|
5914
5925
|
const [, copyToClipboardRaw] = useCopyToClipboard();
|
|
5915
5926
|
const [copied, setCopied] = useState(false);
|
|
5916
5927
|
const updateUrlParams = useCallback(
|
|
@@ -5923,60 +5934,6 @@ function ThemeSelectorContent({
|
|
|
5923
5934
|
},
|
|
5924
5935
|
[]
|
|
5925
5936
|
);
|
|
5926
|
-
useEffect(() => {
|
|
5927
|
-
const themeParam = searchParams.get("theme");
|
|
5928
|
-
const primaryParam = searchParams.get("primary");
|
|
5929
|
-
const accentParam = searchParams.get("accent");
|
|
5930
|
-
let shouldUpdateUrl = false;
|
|
5931
|
-
let newCategory = themeCategory;
|
|
5932
|
-
let newPrimary = primaryColor;
|
|
5933
|
-
let newAccent = accentColor;
|
|
5934
|
-
if (themeParam && (themeParam === "brand" || themeParam === "aboriginal")) {
|
|
5935
|
-
if (themeParam !== themeCategory) {
|
|
5936
|
-
newCategory = themeParam;
|
|
5937
|
-
shouldUpdateUrl = true;
|
|
5938
|
-
const neutral = findGreyKey(colorThemes2[themeParam]);
|
|
5939
|
-
if (neutral && neutral !== greyColor) {
|
|
5940
|
-
setGreyColor(neutral);
|
|
5941
|
-
}
|
|
5942
|
-
}
|
|
5943
|
-
}
|
|
5944
|
-
const availableColors = Object.keys(colorThemes2[newCategory]);
|
|
5945
|
-
if (primaryParam && availableColors.includes(primaryParam)) {
|
|
5946
|
-
if (primaryParam !== primaryColor) {
|
|
5947
|
-
newPrimary = primaryParam;
|
|
5948
|
-
shouldUpdateUrl = true;
|
|
5949
|
-
}
|
|
5950
|
-
}
|
|
5951
|
-
if (accentParam && availableColors.includes(accentParam) && accentParam !== newPrimary) {
|
|
5952
|
-
if (accentParam !== accentColor) {
|
|
5953
|
-
newAccent = accentParam;
|
|
5954
|
-
shouldUpdateUrl = true;
|
|
5955
|
-
}
|
|
5956
|
-
} else {
|
|
5957
|
-
const newAccentColor = availableColors.find((color2) => color2 !== newPrimary);
|
|
5958
|
-
if (newAccentColor && newAccentColor !== accentColor) {
|
|
5959
|
-
newAccent = newAccentColor;
|
|
5960
|
-
shouldUpdateUrl = true;
|
|
5961
|
-
}
|
|
5962
|
-
}
|
|
5963
|
-
if (shouldUpdateUrl) {
|
|
5964
|
-
if (newCategory !== themeCategory) setThemeCategory(newCategory);
|
|
5965
|
-
if (newPrimary !== primaryColor) setPrimaryColor(newPrimary);
|
|
5966
|
-
if (newAccent !== accentColor) setAccentColor(newAccent);
|
|
5967
|
-
}
|
|
5968
|
-
}, [
|
|
5969
|
-
searchParams,
|
|
5970
|
-
themeCategory,
|
|
5971
|
-
primaryColor,
|
|
5972
|
-
accentColor,
|
|
5973
|
-
greyColor,
|
|
5974
|
-
colorThemes2,
|
|
5975
|
-
setThemeCategory,
|
|
5976
|
-
setPrimaryColor,
|
|
5977
|
-
setAccentColor,
|
|
5978
|
-
setGreyColor
|
|
5979
|
-
]);
|
|
5980
5937
|
const handleCategoryChange = (newCategory) => {
|
|
5981
5938
|
setThemeCategory(newCategory);
|
|
5982
5939
|
const availableColors = Object.keys(colorThemes2[newCategory]);
|
|
@@ -6187,6 +6144,7 @@ function CodeDemoContent({ data, hide = {} }) {
|
|
|
6187
6144
|
const themeParam = searchParams.get("theme");
|
|
6188
6145
|
const primaryParam = searchParams.get("primary");
|
|
6189
6146
|
const accentParam = searchParams.get("accent");
|
|
6147
|
+
const hasUrlParams = themeParam || primaryParam || accentParam;
|
|
6190
6148
|
let newCategory = themeCategory;
|
|
6191
6149
|
let newPrimary = primaryColor;
|
|
6192
6150
|
let newAccent = accentColor;
|
|
@@ -6205,12 +6163,20 @@ function CodeDemoContent({ data, hide = {} }) {
|
|
|
6205
6163
|
if (accentParam && availableColors.includes(accentParam) && accentParam !== newPrimary) {
|
|
6206
6164
|
newAccent = accentParam;
|
|
6207
6165
|
setAccentColor(accentParam);
|
|
6208
|
-
} else {
|
|
6166
|
+
} else if (hasUrlParams) {
|
|
6209
6167
|
const newAccentColor = availableColors.find((color2) => color2 !== newPrimary);
|
|
6210
6168
|
if (newAccentColor) {
|
|
6211
6169
|
newAccent = newAccentColor;
|
|
6212
6170
|
setAccentColor(newAccent);
|
|
6213
6171
|
}
|
|
6172
|
+
} else {
|
|
6173
|
+
if (!availableColors.includes(newAccent) || newAccent === newPrimary) {
|
|
6174
|
+
const newAccentColor = availableColors.find((color2) => color2 !== newPrimary);
|
|
6175
|
+
if (newAccentColor) {
|
|
6176
|
+
newAccent = newAccentColor;
|
|
6177
|
+
setAccentColor(newAccent);
|
|
6178
|
+
}
|
|
6179
|
+
}
|
|
6214
6180
|
}
|
|
6215
6181
|
const neutralKey = Object.keys(colorThemes[newCategory]).find(
|
|
6216
6182
|
(k) => k.toLowerCase().includes("grey")
|
|
@@ -6308,6 +6274,27 @@ function CodeDemoContent({ data, hide = {} }) {
|
|
|
6308
6274
|
const explicit = data.labels ?? {};
|
|
6309
6275
|
return Object.fromEntries(variants.map((v) => [v, explicit[v] ?? humaniseVariant(v)]));
|
|
6310
6276
|
}, [variants, data]);
|
|
6277
|
+
useEffect(() => {
|
|
6278
|
+
if (!isThemeInitialized) return;
|
|
6279
|
+
const neutralKey = Object.keys(colorThemes[themeCategory]).find((k) => k.toLowerCase().includes("grey")) ?? "";
|
|
6280
|
+
if (neutralKey && neutralKey !== greyColor) {
|
|
6281
|
+
setGreyColor(neutralKey);
|
|
6282
|
+
}
|
|
6283
|
+
const availableColors = Object.keys(colorThemes[themeCategory]);
|
|
6284
|
+
if (!availableColors.includes(primaryColor)) {
|
|
6285
|
+
setPrimaryColor(availableColors[0]);
|
|
6286
|
+
if (availableColors.length > 1) {
|
|
6287
|
+
setAccentColor(availableColors[1]);
|
|
6288
|
+
}
|
|
6289
|
+
return;
|
|
6290
|
+
}
|
|
6291
|
+
if (accentColor === primaryColor || !availableColors.includes(accentColor)) {
|
|
6292
|
+
const newAccentColor = availableColors.find((color2) => color2 !== primaryColor);
|
|
6293
|
+
if (newAccentColor) {
|
|
6294
|
+
setAccentColor(newAccentColor);
|
|
6295
|
+
}
|
|
6296
|
+
}
|
|
6297
|
+
}, [themeCategory, primaryColor, accentColor, greyColor, isThemeInitialized]);
|
|
6311
6298
|
return /* @__PURE__ */ jsxs("div", { className: "mt-8", children: [
|
|
6312
6299
|
/* @__PURE__ */ jsx("div", { className: "border-grey-200 bg-grey-50 dark:border-grey-600 dark:bg-grey-700 w-full rounded-t-xl border p-4", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 sm:grid-cols-3", children: [
|
|
6313
6300
|
/* @__PURE__ */ jsx(EditOnGithubButton, { githubSlug: data.githubSlug }),
|
|
@@ -7756,7 +7743,7 @@ function Heading({
|
|
|
7756
7743
|
|
|
7757
7744
|
// package.json
|
|
7758
7745
|
var package_default = {
|
|
7759
|
-
version: "1.
|
|
7746
|
+
version: "1.45.1"};
|
|
7760
7747
|
function Logo(props) {
|
|
7761
7748
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7762
7749
|
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "NSW Government" }),
|
|
@@ -7900,7 +7887,7 @@ function Header2({
|
|
|
7900
7887
|
"data-scrolled": isScrolled,
|
|
7901
7888
|
id: "nsw-header",
|
|
7902
7889
|
className: clsx21(
|
|
7903
|
-
"sticky top-0 z-50 flex flex-none flex-wrap items-center justify-between bg-white px-4 py-5 transition duration-500 sm:px-6 lg:px-12",
|
|
7890
|
+
"sticky top-0 z-50 flex hidden flex-none flex-wrap items-center justify-between bg-white px-4 py-5 transition duration-500 sm:px-6 lg:flex lg:px-12",
|
|
7904
7891
|
shadow && "shadow-md shadow-slate-900/5 dark:shadow-none",
|
|
7905
7892
|
isScrolled ? "dark:bg-slate-900/95 dark:backdrop-blur-sm dark:[@supports(backdrop-filter:blur(0))]:bg-slate-900/75" : "dark:bg-transparent"
|
|
7906
7893
|
),
|
|
@@ -13292,7 +13279,7 @@ function distance2D(a, b) {
|
|
|
13292
13279
|
|
|
13293
13280
|
// node_modules/framer-motion/dist/es/gestures/pan/PanSession.mjs
|
|
13294
13281
|
var PanSession = class {
|
|
13295
|
-
constructor(event,
|
|
13282
|
+
constructor(event, handlers2, { transformPagePoint, contextWindow, dragSnapToOrigin = false } = {}) {
|
|
13296
13283
|
this.startEvent = null;
|
|
13297
13284
|
this.lastMoveEvent = null;
|
|
13298
13285
|
this.lastMoveEventInfo = null;
|
|
@@ -13337,7 +13324,7 @@ var PanSession = class {
|
|
|
13337
13324
|
if (!isPrimaryPointer(event))
|
|
13338
13325
|
return;
|
|
13339
13326
|
this.dragSnapToOrigin = dragSnapToOrigin;
|
|
13340
|
-
this.handlers =
|
|
13327
|
+
this.handlers = handlers2;
|
|
13341
13328
|
this.transformPagePoint = transformPagePoint;
|
|
13342
13329
|
this.contextWindow = contextWindow || window;
|
|
13343
13330
|
const info = extractEventInfo(event);
|
|
@@ -13345,12 +13332,12 @@ var PanSession = class {
|
|
|
13345
13332
|
const { point } = initialInfo;
|
|
13346
13333
|
const { timestamp } = frameData;
|
|
13347
13334
|
this.history = [{ ...point, timestamp }];
|
|
13348
|
-
const { onSessionStart } =
|
|
13335
|
+
const { onSessionStart } = handlers2;
|
|
13349
13336
|
onSessionStart && onSessionStart(event, getPanInfo(initialInfo, this.history));
|
|
13350
13337
|
this.removeListeners = pipe(addPointerEvent(this.contextWindow, "pointermove", this.handlePointerMove), addPointerEvent(this.contextWindow, "pointerup", this.handlePointerUp), addPointerEvent(this.contextWindow, "pointercancel", this.handlePointerUp));
|
|
13351
13338
|
}
|
|
13352
|
-
updateHandlers(
|
|
13353
|
-
this.handlers =
|
|
13339
|
+
updateHandlers(handlers2) {
|
|
13340
|
+
this.handlers = handlers2;
|
|
13354
13341
|
}
|
|
13355
13342
|
end() {
|
|
13356
13343
|
this.removeListeners && this.removeListeners();
|
|
@@ -22981,6 +22968,534 @@ function DescriptionDetails({ className, ...props }) {
|
|
|
22981
22968
|
}
|
|
22982
22969
|
);
|
|
22983
22970
|
}
|
|
22971
|
+
function generateLevelId() {
|
|
22972
|
+
return `level-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
|
|
22973
|
+
}
|
|
22974
|
+
function getMaxDepth(items, currentDepth = 1) {
|
|
22975
|
+
if (!items || !Array.isArray(items) || items.length === 0) {
|
|
22976
|
+
return currentDepth;
|
|
22977
|
+
}
|
|
22978
|
+
let maxDepth2 = currentDepth;
|
|
22979
|
+
for (const item of items) {
|
|
22980
|
+
if (item && item.links && Array.isArray(item.links) && item.links.length > 0) {
|
|
22981
|
+
const itemDepth = getMaxDepth(item.links, currentDepth + 1);
|
|
22982
|
+
maxDepth2 = Math.max(maxDepth2, itemDepth);
|
|
22983
|
+
}
|
|
22984
|
+
}
|
|
22985
|
+
return maxDepth2;
|
|
22986
|
+
}
|
|
22987
|
+
function findItemById(items, id3) {
|
|
22988
|
+
if (!items || !Array.isArray(items)) {
|
|
22989
|
+
return null;
|
|
22990
|
+
}
|
|
22991
|
+
for (const item of items) {
|
|
22992
|
+
if (!item) continue;
|
|
22993
|
+
if (item.id === id3) {
|
|
22994
|
+
return item;
|
|
22995
|
+
}
|
|
22996
|
+
if (item.links && Array.isArray(item.links)) {
|
|
22997
|
+
const found = findItemById(item.links, id3);
|
|
22998
|
+
if (found) return found;
|
|
22999
|
+
}
|
|
23000
|
+
}
|
|
23001
|
+
return null;
|
|
23002
|
+
}
|
|
23003
|
+
function findPathToItem(items, targetId, path = []) {
|
|
23004
|
+
if (!items || !Array.isArray(items)) {
|
|
23005
|
+
return null;
|
|
23006
|
+
}
|
|
23007
|
+
for (const item of items) {
|
|
23008
|
+
if (!item) continue;
|
|
23009
|
+
const currentPath = [...path, item];
|
|
23010
|
+
if (item.id === targetId) {
|
|
23011
|
+
return currentPath;
|
|
23012
|
+
}
|
|
23013
|
+
if (item.links && Array.isArray(item.links)) {
|
|
23014
|
+
const found = findPathToItem(item.links, targetId, currentPath);
|
|
23015
|
+
if (found) return found;
|
|
23016
|
+
}
|
|
23017
|
+
}
|
|
23018
|
+
return null;
|
|
23019
|
+
}
|
|
23020
|
+
function getTotalItemCount(items) {
|
|
23021
|
+
if (!items || !Array.isArray(items)) {
|
|
23022
|
+
return 0;
|
|
23023
|
+
}
|
|
23024
|
+
let count = items.length;
|
|
23025
|
+
for (const item of items) {
|
|
23026
|
+
if (item && item.links && Array.isArray(item.links)) {
|
|
23027
|
+
count += getTotalItemCount(item.links);
|
|
23028
|
+
}
|
|
23029
|
+
}
|
|
23030
|
+
return count;
|
|
23031
|
+
}
|
|
23032
|
+
function generateBreadcrumb(levels, maxLength = 50) {
|
|
23033
|
+
if (levels.length <= 1) return levels[0]?.title || "Menu";
|
|
23034
|
+
const breadcrumb = levels.map((level) => level.title).join(" \u203A ");
|
|
23035
|
+
if (breadcrumb.length <= maxLength) {
|
|
23036
|
+
return breadcrumb;
|
|
23037
|
+
}
|
|
23038
|
+
if (levels.length > 3) {
|
|
23039
|
+
const first = levels[0].title;
|
|
23040
|
+
const last = levels[levels.length - 1].title;
|
|
23041
|
+
const secondLast = levels[levels.length - 2].title;
|
|
23042
|
+
return `${first} \u203A ... \u203A ${secondLast} \u203A ${last}`;
|
|
23043
|
+
}
|
|
23044
|
+
return breadcrumb.substring(0, maxLength - 3) + "...";
|
|
23045
|
+
}
|
|
23046
|
+
function MultiLevelPushMenu({
|
|
23047
|
+
navigation,
|
|
23048
|
+
onItemClick,
|
|
23049
|
+
onNavigate,
|
|
23050
|
+
onClose,
|
|
23051
|
+
className = "",
|
|
23052
|
+
showHeader = true,
|
|
23053
|
+
showFooter = true,
|
|
23054
|
+
showBreadcrumbs = true,
|
|
23055
|
+
showStats = true,
|
|
23056
|
+
showBackButton = true,
|
|
23057
|
+
initialTitle = "Menu"
|
|
23058
|
+
}) {
|
|
23059
|
+
const pathname = usePathname();
|
|
23060
|
+
const [navigationHistory, setNavigationHistory] = useState([
|
|
23061
|
+
{ items: navigation || [], title: initialTitle, depth: 1, id: generateLevelId() }
|
|
23062
|
+
]);
|
|
23063
|
+
const [animationState, setAnimationState] = useState("idle");
|
|
23064
|
+
const [isAnimationStarted, setIsAnimationStarted] = useState(false);
|
|
23065
|
+
const containerRef = useRef(null);
|
|
23066
|
+
const breadcrumb = useMemo(() => {
|
|
23067
|
+
const levels = navigationHistory.map((level) => ({ title: level.title, depth: level.depth }));
|
|
23068
|
+
return generateBreadcrumb(levels);
|
|
23069
|
+
}, [navigationHistory]);
|
|
23070
|
+
const navigateToSubmenu = useCallback(
|
|
23071
|
+
(item) => {
|
|
23072
|
+
if (item.links && item.links.length > 0 && animationState === "idle") {
|
|
23073
|
+
const newLevel = {
|
|
23074
|
+
items: item.links,
|
|
23075
|
+
title: item.title,
|
|
23076
|
+
parentItem: item,
|
|
23077
|
+
depth: navigationHistory[navigationHistory.length - 1].depth + 1,
|
|
23078
|
+
id: generateLevelId()
|
|
23079
|
+
};
|
|
23080
|
+
const newHistory = [...navigationHistory, newLevel];
|
|
23081
|
+
setNavigationHistory(newHistory);
|
|
23082
|
+
setAnimationState("sliding-forward");
|
|
23083
|
+
setIsAnimationStarted(false);
|
|
23084
|
+
requestAnimationFrame(() => {
|
|
23085
|
+
setIsAnimationStarted(true);
|
|
23086
|
+
});
|
|
23087
|
+
setTimeout(() => {
|
|
23088
|
+
setAnimationState("idle");
|
|
23089
|
+
setIsAnimationStarted(false);
|
|
23090
|
+
onNavigate?.(newLevel, newHistory);
|
|
23091
|
+
}, 300);
|
|
23092
|
+
}
|
|
23093
|
+
},
|
|
23094
|
+
[navigationHistory, animationState, onNavigate]
|
|
23095
|
+
);
|
|
23096
|
+
const navigateBack = useCallback(() => {
|
|
23097
|
+
if (navigationHistory.length > 1 && animationState === "idle") {
|
|
23098
|
+
setAnimationState("sliding-backward");
|
|
23099
|
+
setTimeout(() => {
|
|
23100
|
+
const newHistory = navigationHistory.slice(0, -1);
|
|
23101
|
+
setNavigationHistory(newHistory);
|
|
23102
|
+
setAnimationState("idle");
|
|
23103
|
+
onNavigate?.(newHistory[newHistory.length - 1], newHistory);
|
|
23104
|
+
}, 300);
|
|
23105
|
+
}
|
|
23106
|
+
}, [navigationHistory, animationState, onNavigate]);
|
|
23107
|
+
const handleItemClick = useCallback(
|
|
23108
|
+
(item, event) => {
|
|
23109
|
+
if (item.links && item.links.length > 0) {
|
|
23110
|
+
event?.preventDefault();
|
|
23111
|
+
navigateToSubmenu(item);
|
|
23112
|
+
} else {
|
|
23113
|
+
if (!item.href) {
|
|
23114
|
+
event?.preventDefault();
|
|
23115
|
+
}
|
|
23116
|
+
onItemClick?.(item);
|
|
23117
|
+
}
|
|
23118
|
+
},
|
|
23119
|
+
[navigateToSubmenu, onItemClick]
|
|
23120
|
+
);
|
|
23121
|
+
const currentLevel = navigationHistory[navigationHistory.length - 1];
|
|
23122
|
+
if (!currentLevel || !currentLevel.items) {
|
|
23123
|
+
return /* @__PURE__ */ jsx("div", { className: `flex items-center justify-center p-8 ${className}`, children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
23124
|
+
/* @__PURE__ */ jsx("h3", { className: "mb-2 text-lg font-semibold", children: "Navigation Error" }),
|
|
23125
|
+
/* @__PURE__ */ jsx("p", { className: "text-grey-800 text-sm", children: "Unable to load navigation data." })
|
|
23126
|
+
] }) });
|
|
23127
|
+
}
|
|
23128
|
+
const shouldShowBackButton = showBackButton && navigationHistory.length > 1;
|
|
23129
|
+
const isAnimating = animationState !== "idle";
|
|
23130
|
+
return /* @__PURE__ */ jsx("div", { ref: containerRef, className: `relative h-full overflow-hidden ${className}`, children: /* @__PURE__ */ jsx("div", { className: "relative h-full", children: navigationHistory.map((level, index) => {
|
|
23131
|
+
const isCurrentLevel = index === navigationHistory.length - 1;
|
|
23132
|
+
let translateX = 0;
|
|
23133
|
+
if (animationState === "sliding-forward") {
|
|
23134
|
+
if (isCurrentLevel) {
|
|
23135
|
+
translateX = isAnimationStarted ? 0 : 100;
|
|
23136
|
+
} else {
|
|
23137
|
+
translateX = 0;
|
|
23138
|
+
}
|
|
23139
|
+
} else if (animationState === "sliding-backward") {
|
|
23140
|
+
if (isCurrentLevel) {
|
|
23141
|
+
translateX = 100;
|
|
23142
|
+
} else {
|
|
23143
|
+
translateX = 0;
|
|
23144
|
+
}
|
|
23145
|
+
} else {
|
|
23146
|
+
translateX = 0;
|
|
23147
|
+
}
|
|
23148
|
+
return /* @__PURE__ */ jsx(
|
|
23149
|
+
"div",
|
|
23150
|
+
{
|
|
23151
|
+
className: `absolute inset-0 h-full w-full will-change-transform`,
|
|
23152
|
+
style: {
|
|
23153
|
+
transform: `translateX(${translateX}%)`,
|
|
23154
|
+
transition: animationState === "sliding-forward" && isAnimationStarted ? "transform 300ms ease-out" : animationState === "sliding-backward" ? "transform 300ms ease-out" : "none",
|
|
23155
|
+
zIndex: index + 1
|
|
23156
|
+
},
|
|
23157
|
+
"data-level-id": level.id,
|
|
23158
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col bg-white", children: [
|
|
23159
|
+
shouldShowBackButton && !showHeader && /* @__PURE__ */ jsx("div", { className: "flex items-center bg-white px-4 py-2", children: /* @__PURE__ */ jsxs(Button2, { variant: "ghost", onClick: navigateBack, disabled: isAnimating, children: [
|
|
23160
|
+
/* @__PURE__ */ jsx(Icons.west, {}),
|
|
23161
|
+
"Back"
|
|
23162
|
+
] }) }),
|
|
23163
|
+
showHeader && /* @__PURE__ */ jsx("div", { className: "border-grey-200 flex items-center justify-between border-b bg-white px-4 py-2", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
|
|
23164
|
+
shouldShowBackButton && /* @__PURE__ */ jsxs(Button2, { variant: "ghost", onClick: navigateBack, disabled: isAnimating, children: [
|
|
23165
|
+
/* @__PURE__ */ jsx(Icons.west, {}),
|
|
23166
|
+
"Back"
|
|
23167
|
+
] }),
|
|
23168
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
23169
|
+
navigationHistory.length === 1 && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx(Heading, { level: 2, size: 6, className: "truncate p-2 font-semibold", children: initialTitle }) }),
|
|
23170
|
+
navigationHistory.length > 1 && /* @__PURE__ */ jsxs(Button2, { variant: "ghost", size: "icon", onClick: onClose, children: [
|
|
23171
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close panel" }),
|
|
23172
|
+
/* @__PURE__ */ jsx(Icons.close, { "aria-hidden": "true", className: "h-6 w-6" })
|
|
23173
|
+
] })
|
|
23174
|
+
] })
|
|
23175
|
+
] }) }),
|
|
23176
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden bg-white", children: /* @__PURE__ */ jsx("div", { className: "h-full overflow-y-auto", children: level.items.map((item) => /* @__PURE__ */ jsx(
|
|
23177
|
+
"div",
|
|
23178
|
+
{
|
|
23179
|
+
className: "divide-grey-200 ring-grey-200 divide-y overflow-hidden bg-white ring-1",
|
|
23180
|
+
children: /* @__PURE__ */ jsxs(
|
|
23181
|
+
"button",
|
|
23182
|
+
{
|
|
23183
|
+
...item.href && !item.links?.length ? { href: item.href } : {},
|
|
23184
|
+
onClick: (event) => handleItemClick(item, event),
|
|
23185
|
+
disabled: isAnimating,
|
|
23186
|
+
className: clsx21(
|
|
23187
|
+
"hover:bg-primary-800/10 hover:border-primary-800 relative flex w-full cursor-pointer items-center justify-between gap-x-6 border-l p-4 transition-colors",
|
|
23188
|
+
pathname === item.href ? "text-primary-800 bg-primary-800/10 border-primary-800 font-semibold" : "text-grey-800 border-transparent",
|
|
23189
|
+
isAnimating && "pointer-events-none"
|
|
23190
|
+
),
|
|
23191
|
+
children: [
|
|
23192
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: item.title }) }) }),
|
|
23193
|
+
item.links && item.links.length > 0 && /* @__PURE__ */ jsx(Icons.chevron_right, { className: "h-5 w-5" })
|
|
23194
|
+
]
|
|
23195
|
+
}
|
|
23196
|
+
)
|
|
23197
|
+
},
|
|
23198
|
+
item.id
|
|
23199
|
+
)) }) }),
|
|
23200
|
+
showFooter && /* @__PURE__ */ jsxs("div", { className: "border-grey-100 border-t bg-white px-4 py-2", children: [
|
|
23201
|
+
/* @__PURE__ */ jsxs("div", { className: "text-grey-800 flex items-center justify-between text-xs", children: [
|
|
23202
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
23203
|
+
/* @__PURE__ */ jsx(Layers, { className: "h-4 w-4" }),
|
|
23204
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
23205
|
+
"Level ",
|
|
23206
|
+
level.depth
|
|
23207
|
+
] }),
|
|
23208
|
+
isAnimating && /* @__PURE__ */ jsx("span", { className: "text-primary-800 animate-pulse", children: "\u2022" })
|
|
23209
|
+
] }),
|
|
23210
|
+
showStats && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
23211
|
+
/* @__PURE__ */ jsx(Hash, { className: "h-3 w-3" }),
|
|
23212
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
23213
|
+
level.items.length,
|
|
23214
|
+
" items"
|
|
23215
|
+
] })
|
|
23216
|
+
] })
|
|
23217
|
+
] }),
|
|
23218
|
+
level.depth > 1 && /* @__PURE__ */ jsxs("div", { className: "mt-1", children: [
|
|
23219
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
|
|
23220
|
+
Array.from({ length: Math.min(level.depth, 10) }, (_, i) => /* @__PURE__ */ jsx(
|
|
23221
|
+
"div",
|
|
23222
|
+
{
|
|
23223
|
+
className: `bg-primary-800 h-1 w-2 rounded-full transition-colors duration-300`
|
|
23224
|
+
},
|
|
23225
|
+
i
|
|
23226
|
+
)),
|
|
23227
|
+
level.depth > 10 && /* @__PURE__ */ jsxs("span", { className: "text-grey-800 ml-1 text-xs", children: [
|
|
23228
|
+
"+",
|
|
23229
|
+
level.depth - 10
|
|
23230
|
+
] })
|
|
23231
|
+
] }),
|
|
23232
|
+
showBreadcrumbs && navigationHistory.length > 1 && /* @__PURE__ */ jsx("div", { className: "mt-1 flex items-center justify-end gap-2", children: /* @__PURE__ */ jsx("p", { className: "text-grey-800 truncate text-xs", children: breadcrumb }) })
|
|
23233
|
+
] })
|
|
23234
|
+
] })
|
|
23235
|
+
] })
|
|
23236
|
+
},
|
|
23237
|
+
level.id
|
|
23238
|
+
);
|
|
23239
|
+
}) }) });
|
|
23240
|
+
}
|
|
23241
|
+
function MobileSearch({ navigation }) {
|
|
23242
|
+
const [open, setOpen] = React16.useState(false);
|
|
23243
|
+
const router = useRouter();
|
|
23244
|
+
React16.useEffect(() => {
|
|
23245
|
+
const down = (e) => {
|
|
23246
|
+
if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
|
|
23247
|
+
e.preventDefault();
|
|
23248
|
+
setOpen((open2) => !open2);
|
|
23249
|
+
}
|
|
23250
|
+
};
|
|
23251
|
+
document.addEventListener("keydown", down);
|
|
23252
|
+
return () => document.removeEventListener("keydown", down);
|
|
23253
|
+
}, []);
|
|
23254
|
+
const runCommand = React16.useCallback((command) => {
|
|
23255
|
+
setOpen(false);
|
|
23256
|
+
command();
|
|
23257
|
+
}, []);
|
|
23258
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
23259
|
+
/* @__PURE__ */ jsx(
|
|
23260
|
+
Button2,
|
|
23261
|
+
{
|
|
23262
|
+
variant: "ghost",
|
|
23263
|
+
size: "icon",
|
|
23264
|
+
className: "relative m-4 h-10 w-10",
|
|
23265
|
+
onClick: () => setOpen(true),
|
|
23266
|
+
"aria-label": "Search site",
|
|
23267
|
+
children: /* @__PURE__ */ jsx(Icons.search, { "aria-hidden": "true" })
|
|
23268
|
+
}
|
|
23269
|
+
),
|
|
23270
|
+
/* @__PURE__ */ jsxs(CommandDialog, { open, onOpenChange: setOpen, children: [
|
|
23271
|
+
/* @__PURE__ */ jsx(CommandInput, { placeholder: "Type to search across the site..." }),
|
|
23272
|
+
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
23273
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: "No results found." }),
|
|
23274
|
+
navigation.map((page, index) => /* @__PURE__ */ jsx(CommandGroup, { heading: page.title, children: page.links && page.links.filter((link) => link.href && link.title).map((link) => /* @__PURE__ */ jsx(
|
|
23275
|
+
CommandItem,
|
|
23276
|
+
{
|
|
23277
|
+
onSelect: () => runCommand(() => router.push(link.href)),
|
|
23278
|
+
children: /* @__PURE__ */ jsx("span", { children: link.title })
|
|
23279
|
+
},
|
|
23280
|
+
link.href
|
|
23281
|
+
)) }, index))
|
|
23282
|
+
] })
|
|
23283
|
+
] })
|
|
23284
|
+
] });
|
|
23285
|
+
}
|
|
23286
|
+
function MobileHeader({
|
|
23287
|
+
sitename,
|
|
23288
|
+
navigation,
|
|
23289
|
+
version = false,
|
|
23290
|
+
hide = {}
|
|
23291
|
+
}) {
|
|
23292
|
+
const [open, setOpen] = useState(false);
|
|
23293
|
+
const { search = true } = hide;
|
|
23294
|
+
return /* @__PURE__ */ jsxs("div", { className: "lg:hidden", children: [
|
|
23295
|
+
/* @__PURE__ */ jsxs("div", { className: "relative flex w-full items-center justify-between", children: [
|
|
23296
|
+
/* @__PURE__ */ jsxs(Button2, { variant: "ghost", size: "icon", onClick: () => setOpen(true), className: "m-4", children: [
|
|
23297
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Main Navigation Menu" }),
|
|
23298
|
+
/* @__PURE__ */ jsx(Icons.menu, { "aria-hidden": "true" })
|
|
23299
|
+
] }),
|
|
23300
|
+
/* @__PURE__ */ jsx("div", { className: "relative flex items-center", children: /* @__PURE__ */ jsxs(
|
|
23301
|
+
Link10,
|
|
23302
|
+
{
|
|
23303
|
+
href: "/",
|
|
23304
|
+
"aria-label": "Home page",
|
|
23305
|
+
className: "flex flex-col items-center justify-between",
|
|
23306
|
+
children: [
|
|
23307
|
+
/* @__PURE__ */ jsx(Logo, { className: "m-2 h-12 w-auto transition-colors" }),
|
|
23308
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-center text-center", children: [
|
|
23309
|
+
/* @__PURE__ */ jsx(Heading, { level: 2, size: 6, className: "ml-6", children: sitename }),
|
|
23310
|
+
version && /* @__PURE__ */ jsx(Badge, { variant: "soft", color: "primary", className: "ml-2", children: package_default.version })
|
|
23311
|
+
] })
|
|
23312
|
+
]
|
|
23313
|
+
}
|
|
23314
|
+
) }),
|
|
23315
|
+
search && /* @__PURE__ */ jsx(MobileSearch, { navigation })
|
|
23316
|
+
] }),
|
|
23317
|
+
/* @__PURE__ */ jsxs(Dialog$1, { open, onClose: setOpen, className: "relative z-50", children: [
|
|
23318
|
+
/* @__PURE__ */ jsx("div", { className: "fixed inset-0" }),
|
|
23319
|
+
/* @__PURE__ */ jsx("div", { className: "fixed inset-0 overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "absolute inset-0 overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "pointer-events-none fixed inset-y-0 left-0 flex max-w-full pr-10 sm:pr-16", children: /* @__PURE__ */ jsx(
|
|
23320
|
+
DialogPanel,
|
|
23321
|
+
{
|
|
23322
|
+
transition: true,
|
|
23323
|
+
className: "pointer-events-auto w-screen max-w-md transform transition duration-500 ease-in-out data-[closed]:-translate-x-full sm:duration-300",
|
|
23324
|
+
children: /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col overflow-y-scroll bg-white shadow-xl", children: /* @__PURE__ */ jsx(
|
|
23325
|
+
MultiLevelPushMenu,
|
|
23326
|
+
{
|
|
23327
|
+
navigation,
|
|
23328
|
+
showHeader: true,
|
|
23329
|
+
onClose: () => {
|
|
23330
|
+
setOpen(false);
|
|
23331
|
+
}
|
|
23332
|
+
}
|
|
23333
|
+
) })
|
|
23334
|
+
}
|
|
23335
|
+
) }) }) })
|
|
23336
|
+
] })
|
|
23337
|
+
] });
|
|
23338
|
+
}
|
|
23339
|
+
|
|
23340
|
+
// src/db/schema/users.ts
|
|
23341
|
+
var users_exports = {};
|
|
23342
|
+
__export(users_exports, {
|
|
23343
|
+
users: () => users
|
|
23344
|
+
});
|
|
23345
|
+
var users = sqliteTable("user", {
|
|
23346
|
+
id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
23347
|
+
name: text("name"),
|
|
23348
|
+
email: text("email").unique(),
|
|
23349
|
+
emailVerified: integer("emailVerified", { mode: "timestamp_ms" }),
|
|
23350
|
+
image: text("image"),
|
|
23351
|
+
role: text("role", { enum: ["ADMIN", "USER"] }).default("USER")
|
|
23352
|
+
});
|
|
23353
|
+
|
|
23354
|
+
// src/db/schema/accounts.ts
|
|
23355
|
+
var accounts_exports = {};
|
|
23356
|
+
__export(accounts_exports, {
|
|
23357
|
+
accounts: () => accounts
|
|
23358
|
+
});
|
|
23359
|
+
var accounts = sqliteTable(
|
|
23360
|
+
"account",
|
|
23361
|
+
{
|
|
23362
|
+
userId: text("userId").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
23363
|
+
type: text("type").$type().notNull(),
|
|
23364
|
+
provider: text("provider").notNull(),
|
|
23365
|
+
providerAccountId: text("providerAccountId").notNull(),
|
|
23366
|
+
refresh_token: text("refresh_token"),
|
|
23367
|
+
access_token: text("access_token"),
|
|
23368
|
+
expires_at: integer("expires_at"),
|
|
23369
|
+
token_type: text("token_type"),
|
|
23370
|
+
scope: text("scope"),
|
|
23371
|
+
id_token: text("id_token"),
|
|
23372
|
+
session_state: text("session_state")
|
|
23373
|
+
},
|
|
23374
|
+
(table) => [
|
|
23375
|
+
primaryKey({
|
|
23376
|
+
columns: [table.provider, table.providerAccountId],
|
|
23377
|
+
name: "accounts_pk"
|
|
23378
|
+
})
|
|
23379
|
+
]
|
|
23380
|
+
);
|
|
23381
|
+
|
|
23382
|
+
// src/db/schema/sessions.ts
|
|
23383
|
+
var sessions_exports = {};
|
|
23384
|
+
__export(sessions_exports, {
|
|
23385
|
+
sessions: () => sessions
|
|
23386
|
+
});
|
|
23387
|
+
var sessions = sqliteTable("session", {
|
|
23388
|
+
sessionToken: text("sessionToken").primaryKey(),
|
|
23389
|
+
userId: text("userId").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
23390
|
+
expires: integer("expires", { mode: "timestamp_ms" }).notNull()
|
|
23391
|
+
});
|
|
23392
|
+
|
|
23393
|
+
// src/db/index.ts
|
|
23394
|
+
var client = createClient({
|
|
23395
|
+
url: process.env.TURSO_CONNECTION_URL,
|
|
23396
|
+
authToken: process.env.TURSO_AUTH_TOKEN
|
|
23397
|
+
});
|
|
23398
|
+
var db = drizzle(client, {
|
|
23399
|
+
schema: {
|
|
23400
|
+
...users_exports,
|
|
23401
|
+
...accounts_exports,
|
|
23402
|
+
...sessions_exports
|
|
23403
|
+
}
|
|
23404
|
+
});
|
|
23405
|
+
|
|
23406
|
+
// src/auth.ts
|
|
23407
|
+
var { handlers, signIn, signOut, auth } = NextAuth({
|
|
23408
|
+
adapter: DrizzleAdapter(db),
|
|
23409
|
+
providers: [
|
|
23410
|
+
MicrosoftEntraID({
|
|
23411
|
+
clientId: process.env.AUTH_MICROSOFT_ENTRA_ID_ID,
|
|
23412
|
+
clientSecret: process.env.AUTH_MICROSOFT_ENTRA_ID_SECRET,
|
|
23413
|
+
issuer: process.env.AUTH_MICROSOFT_ENTRA_ID_ISSUER,
|
|
23414
|
+
authorization: {
|
|
23415
|
+
params: {
|
|
23416
|
+
scope: "openid profile email User.Read offline_access",
|
|
23417
|
+
tenant: process.env.AUTH_MICROSOFT_ENTRA_ID_TENANT_ID
|
|
23418
|
+
}
|
|
23419
|
+
}
|
|
23420
|
+
})
|
|
23421
|
+
],
|
|
23422
|
+
callbacks: {
|
|
23423
|
+
authorized: async ({ auth: auth2, request }) => {
|
|
23424
|
+
if (request.nextUrl.pathname.startsWith("/")) {
|
|
23425
|
+
return true;
|
|
23426
|
+
}
|
|
23427
|
+
return !!auth2;
|
|
23428
|
+
},
|
|
23429
|
+
jwt({ token, user }) {
|
|
23430
|
+
if (user) {
|
|
23431
|
+
token.id = user.id;
|
|
23432
|
+
}
|
|
23433
|
+
return token;
|
|
23434
|
+
},
|
|
23435
|
+
async session({ session, user }) {
|
|
23436
|
+
session.user.id = user.id;
|
|
23437
|
+
const [microsoftAccount] = await db.select().from(accounts).where(and(eq(accounts.userId, user.id), eq(accounts.provider, "microsoft-entra-id"))).limit(1);
|
|
23438
|
+
if (microsoftAccount && microsoftAccount.expires_at && microsoftAccount.expires_at * 1e3 < Date.now()) {
|
|
23439
|
+
try {
|
|
23440
|
+
const tokenEndpoint = `https://login.microsoftonline.com/${process.env.AUTH_MICROSOFT_ENTRA_ID_TENANT_ID}/oauth2/v2.0/token`;
|
|
23441
|
+
const response = await fetch(tokenEndpoint, {
|
|
23442
|
+
method: "POST",
|
|
23443
|
+
headers: {
|
|
23444
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
23445
|
+
},
|
|
23446
|
+
body: new URLSearchParams({
|
|
23447
|
+
client_id: process.env.AUTH_MICROSOFT_ENTRA_ID_ID,
|
|
23448
|
+
client_secret: process.env.AUTH_MICROSOFT_ENTRA_ID_SECRET,
|
|
23449
|
+
grant_type: "refresh_token",
|
|
23450
|
+
refresh_token: microsoftAccount.refresh_token,
|
|
23451
|
+
scope: "openid profile email offline_access"
|
|
23452
|
+
})
|
|
23453
|
+
});
|
|
23454
|
+
const tokensOrError = await response.json();
|
|
23455
|
+
if (!response.ok) throw tokensOrError;
|
|
23456
|
+
const newTokens = tokensOrError;
|
|
23457
|
+
await db.update(accounts).set({
|
|
23458
|
+
access_token: newTokens.access_token,
|
|
23459
|
+
expires_at: Math.floor(Date.now() / 1e3 + newTokens.expires_in),
|
|
23460
|
+
refresh_token: newTokens.refresh_token ?? microsoftAccount.refresh_token,
|
|
23461
|
+
id_token: newTokens.id_token ?? microsoftAccount.id_token
|
|
23462
|
+
}).where(
|
|
23463
|
+
and(
|
|
23464
|
+
eq(accounts.provider, "microsoft-entra-id"),
|
|
23465
|
+
eq(accounts.providerAccountId, microsoftAccount.providerAccountId)
|
|
23466
|
+
)
|
|
23467
|
+
);
|
|
23468
|
+
} catch (error) {
|
|
23469
|
+
console.error("Error refreshing access_token", error);
|
|
23470
|
+
session.error = "RefreshTokenError";
|
|
23471
|
+
}
|
|
23472
|
+
}
|
|
23473
|
+
return session;
|
|
23474
|
+
}
|
|
23475
|
+
}
|
|
23476
|
+
});
|
|
23477
|
+
|
|
23478
|
+
// src/actions/auth-actions.ts
|
|
23479
|
+
async function signInWithEntra(formData) {
|
|
23480
|
+
const redirect = formData.get("redirect")?.toString() || "/dashboard";
|
|
23481
|
+
await signIn("microsoft-entra-id", { redirectTo: redirect });
|
|
23482
|
+
}
|
|
23483
|
+
async function signInGeneric(formData) {
|
|
23484
|
+
const redirect = formData.get("redirect")?.toString() || "/dashboard";
|
|
23485
|
+
await signIn(void 0, { redirectTo: redirect });
|
|
23486
|
+
}
|
|
23487
|
+
async function signOutAction() {
|
|
23488
|
+
await signOut();
|
|
23489
|
+
}
|
|
23490
|
+
function SignInButton() {
|
|
23491
|
+
return /* @__PURE__ */ jsx("form", { action: signInGeneric, children: /* @__PURE__ */ jsx(Button2, { type: "submit", variant: "outline", children: "Sign in" }) });
|
|
23492
|
+
}
|
|
23493
|
+
function SignOutButton() {
|
|
23494
|
+
return /* @__PURE__ */ jsx("form", { action: signOutAction, children: /* @__PURE__ */ jsx(Button2, { type: "submit", color: "danger", children: "Sign Out" }) });
|
|
23495
|
+
}
|
|
23496
|
+
function SignInWithEntraButton() {
|
|
23497
|
+
return /* @__PURE__ */ jsx("form", { action: signInWithEntra, children: /* @__PURE__ */ jsx(Button2, { type: "submit", children: "Sign in with Entra" }) });
|
|
23498
|
+
}
|
|
22984
23499
|
var MOBILE_BREAKPOINT = 768;
|
|
22985
23500
|
function useIsMobile() {
|
|
22986
23501
|
const [isMobile, setIsMobile] = React16.useState(void 0);
|
|
@@ -23011,15 +23526,15 @@ function useDisableToc() {
|
|
|
23011
23526
|
}, [setToc]);
|
|
23012
23527
|
}
|
|
23013
23528
|
function getNodeText(node) {
|
|
23014
|
-
let
|
|
23529
|
+
let text4 = "";
|
|
23015
23530
|
for (const child of node.children ?? []) {
|
|
23016
23531
|
if ("type" in child && child.type === "text") {
|
|
23017
|
-
|
|
23532
|
+
text4 += child.attributes?.content ?? "";
|
|
23018
23533
|
} else if (child instanceof HTMLElement) {
|
|
23019
|
-
|
|
23534
|
+
text4 += getNodeText(child);
|
|
23020
23535
|
}
|
|
23021
23536
|
}
|
|
23022
|
-
return
|
|
23537
|
+
return text4;
|
|
23023
23538
|
}
|
|
23024
23539
|
function domToSimple(node) {
|
|
23025
23540
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
@@ -23136,6 +23651,6 @@ var languages = [
|
|
|
23136
23651
|
"html"
|
|
23137
23652
|
];
|
|
23138
23653
|
|
|
23139
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AreaChart, AspectRatio, AuthLayout, AvailableChartColors, Avatar, AvatarFallback, AvatarImage, Badge, BadgeButton, BarChart, BarList, BaseColorSwatches, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Breadcrumbs, Button2 as Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, CategoryBar, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, Code, CodeDemo, CodeHighlight, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, ColorCard, ColorSwatches, ColourScale, ComboChart, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Description3 as Description, DescriptionDetails, DescriptionList, DescriptionTerm, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DonutChart, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DynamicFavicon, ErrorMessage, ExpandableSearch, ExpandableSearchField, Field2 as Field, FieldGroup, FieldLabel, Fieldset2 as Fieldset, Footer, FooterAcknowledgement, FooterLegalLinks, FooterSmallPrint, FooterSocialLink, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormatToggle, GenerateInterpolatedColors, Header2 as Header, Heading, HoverCard, HoverCardContent, HoverCardTrigger, Icons, Input, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Label3 as Label, Legend2 as Legend, LineChart, Link, _List as List, Listbox2 as Listbox, ListboxDescription, ListboxLabel, ListboxOption2 as ListboxOption, Logo, MainNavigation, Masthead, MegaMenu, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, Navbar, NavbarDivider, NavbarItem, NavbarLabel, NavbarSection, NavbarSpacer, Navigation, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PreWithCopy, PrevNextLinks, PrevNextLinksPageLink, Progress, ProgressBar, ProgressCircle, Prose, RadioGroup2 as RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator4 as Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SidebarLink, SidebarNavigation, SiteSearch, Skeleton, Slider, Social, SparkAreaChart, SparkBarChart, SparkLineChart, Spinner, StepIndicator, StepNavigation, Strong, Switch2 as Switch, SwitchField, SwitchGroup, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableOfContents, TableRow, Tabs2 as Tabs, TabsContent, TabsList, TabsTrigger, Text, TextLink, Textarea, ThemeColorPalette, ThemeProvider, ThemeSelector, ThemeSwitcher, Toaster, TocContext, TocProvider, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TopLevel, TouchTarget, Tracker, Tooltip5 as TremorTooltip, ViewToggle, aboriginal, addStartStopToColorArray, allPalettes, badgeVariants, brand, buttonVariants, camelCase, chartColors, cn, colorDataArray, colorThemes, colors, constructCategoryColors, createColorArray, createColorData, createFormStore, darkenColor, domToSimple, focusInput, focusRing, generateColorThemes, getColorClassName, getColorValue, getHeadings, getNodeText, getSurroundingColors, getYAxisDomain, hasErrorInput, hasOnlyOneValueForKey, humaniseVariant, interpolateColors, isLightColor, kebabCase, languages, lightenColor, navigationMenuTriggerStyle, oklchConverter, progressBarVariants, renderColorOutput, renderColorOutputToDTFM, semantic, shades, themeIndices, themeTokens, toggleVariants, truncate, useActiveSectionObserver, useDisableToc, useFormField, useIsMobile, useOnWindowResize, usePageHeadings, useSelectorHeight, useToc };
|
|
23654
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AreaChart, AspectRatio, AuthLayout, AvailableChartColors, Avatar, AvatarFallback, AvatarImage, Badge, BadgeButton, BarChart, BarList, BaseColorSwatches, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Breadcrumbs, Button2 as Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, CategoryBar, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, Code, CodeDemo, CodeHighlight, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, ColorCard, ColorSwatches, ColourScale, ComboChart, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Description3 as Description, DescriptionDetails, DescriptionList, DescriptionTerm, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DonutChart, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DynamicFavicon, ErrorMessage, ExpandableSearch, ExpandableSearchField, Field2 as Field, FieldGroup, FieldLabel, Fieldset2 as Fieldset, Footer, FooterAcknowledgement, FooterLegalLinks, FooterSmallPrint, FooterSocialLink, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormatToggle, GenerateInterpolatedColors, Header2 as Header, Heading, HoverCard, HoverCardContent, HoverCardTrigger, Icons, Input, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Label3 as Label, Legend2 as Legend, LineChart, Link, _List as List, Listbox2 as Listbox, ListboxDescription, ListboxLabel, ListboxOption2 as ListboxOption, Logo, MainNavigation, Masthead, MegaMenu, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, MobileHeader, MobileSearch, MultiLevelPushMenu, Navbar, NavbarDivider, NavbarItem, NavbarLabel, NavbarSection, NavbarSpacer, Navigation, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PreWithCopy, PrevNextLinks, PrevNextLinksPageLink, Progress, ProgressBar, ProgressCircle, Prose, RadioGroup2 as RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator4 as Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SidebarLink, SidebarNavigation, SignInButton, SignInWithEntraButton, SignOutButton, SiteSearch, Skeleton, Slider, Social, SparkAreaChart, SparkBarChart, SparkLineChart, Spinner, StepIndicator, StepNavigation, Strong, Switch2 as Switch, SwitchField, SwitchGroup, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableOfContents, TableRow, Tabs2 as Tabs, TabsContent, TabsList, TabsTrigger, Text, TextLink, Textarea, ThemeColorPalette, ThemeProvider, ThemeSelector, ThemeSwitcher, Toaster, TocContext, TocProvider, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TopLevel, TouchTarget, Tracker, Tooltip5 as TremorTooltip, ViewToggle, aboriginal, addStartStopToColorArray, allPalettes, badgeVariants, brand, buttonVariants, camelCase, chartColors, cn, colorDataArray, colorThemes, colors, constructCategoryColors, createColorArray, createColorData, createFormStore, darkenColor, domToSimple, findItemById, findPathToItem, focusInput, focusRing, generateBreadcrumb, generateColorThemes, generateLevelId, getColorClassName, getColorValue, getHeadings, getMaxDepth, getNodeText, getSurroundingColors, getTotalItemCount, getYAxisDomain, hasErrorInput, hasOnlyOneValueForKey, humaniseVariant, interpolateColors, isLightColor, kebabCase, languages, lightenColor, navigationMenuTriggerStyle, oklchConverter, progressBarVariants, renderColorOutput, renderColorOutputToDTFM, semantic, shades, themeIndices, themeTokens, toggleVariants, truncate, useActiveSectionObserver, useDisableToc, useFormField, useIsMobile, useOnWindowResize, usePageHeadings, useSelectorHeight, useToc };
|
|
23140
23655
|
//# sourceMappingURL=index.js.map
|
|
23141
23656
|
//# sourceMappingURL=index.js.map
|