prismic 1.1.0 → 1.2.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.
Files changed (48) hide show
  1. package/dist/{builders-hKD4IrLX-ClhMQQkN.mjs → builders-hKD4IrLX-BrpqCAS2.mjs} +1 -1
  2. package/dist/index.mjs +115 -101
  3. package/dist/nextjs-HiDO_p-p.mjs +318 -0
  4. package/dist/nuxt-CDrqbn0o.mjs +59 -0
  5. package/dist/string-BUjs_2AH.mjs +7 -0
  6. package/dist/{sveltekit-BMDXAfYz.mjs → sveltekit-Qx8xJZOd.mjs} +45 -35
  7. package/package.json +1 -1
  8. package/src/adapters/index.ts +177 -0
  9. package/src/{frameworks → adapters}/nextjs.templates.ts +102 -102
  10. package/src/adapters/nextjs.ts +211 -0
  11. package/src/adapters/nuxt.ts +232 -0
  12. package/src/adapters/sveltekit.ts +226 -0
  13. package/src/clients/core.ts +104 -0
  14. package/src/clients/wroom.ts +111 -0
  15. package/src/commands/init.ts +57 -69
  16. package/src/commands/login.ts +12 -29
  17. package/src/commands/logout.ts +8 -28
  18. package/src/commands/preview-add.ts +57 -0
  19. package/src/commands/preview-list.ts +54 -0
  20. package/src/commands/preview-remove.ts +51 -0
  21. package/src/commands/preview-set-simulator.ts +60 -0
  22. package/src/commands/preview.ts +28 -0
  23. package/src/commands/sync.ts +49 -87
  24. package/src/commands/webhook-create.ts +89 -0
  25. package/src/commands/webhook-disable.ts +60 -0
  26. package/src/commands/webhook-enable.ts +60 -0
  27. package/src/commands/webhook-list.ts +43 -0
  28. package/src/commands/webhook-remove.ts +52 -0
  29. package/src/commands/webhook-set-triggers.ts +93 -0
  30. package/src/commands/webhook-view.ts +65 -0
  31. package/src/commands/webhook.ts +43 -0
  32. package/src/commands/whoami.ts +7 -28
  33. package/src/config.ts +2 -11
  34. package/src/index.ts +122 -105
  35. package/src/lib/command.ts +188 -0
  36. package/src/lib/file.ts +13 -1
  37. package/src/lib/packageJson.ts +70 -1
  38. package/src/lib/segment.ts +26 -30
  39. package/src/project.ts +54 -0
  40. package/dist/frameworks-DtGBrEuY.mjs +0 -17
  41. package/dist/nextjs-2qjzSaQI.mjs +0 -312
  42. package/dist/nuxt-DKsgbqpV.mjs +0 -59
  43. package/src/frameworks/index.ts +0 -398
  44. package/src/frameworks/nextjs.ts +0 -211
  45. package/src/frameworks/nuxt.ts +0 -252
  46. package/src/frameworks/sveltekit.ts +0 -234
  47. /package/src/{frameworks → adapters}/nuxt.templates.ts +0 -0
  48. /package/src/{frameworks → adapters}/sveltekit.templates.ts +0 -0
@@ -0,0 +1,188 @@
1
+ import type { ParseArgsOptionDescriptor } from "node:util";
2
+
3
+ import { parseArgs } from "node:util";
4
+
5
+ import { dedent } from "./string";
6
+
7
+ export type CommandConfig = {
8
+ name: string;
9
+ description: string;
10
+ sections?: Record<string, string>;
11
+ positionals?: Record<string, { description: string }>;
12
+ options?: Record<string, ParseArgsOptionDescriptor & { description: string }>;
13
+ };
14
+
15
+ type CommandHandlerArgs<T extends CommandConfig> = ReturnType<
16
+ typeof parseArgs<T & { allowPositionals: T["positionals"] extends undefined ? false : true }>
17
+ >;
18
+
19
+ export function createCommand<T extends CommandConfig>(
20
+ config: T,
21
+ handler: (args: CommandHandlerArgs<T>) => Promise<void>,
22
+ ): () => Promise<void> {
23
+ return async function () {
24
+ const { positionals = {}, options } = config;
25
+
26
+ const depth = config.name.split(" ").length;
27
+ const args = process.argv.slice(1 + depth);
28
+ const allowPositionals = Object.keys(positionals).length > 0;
29
+
30
+ const result = parseArgs({
31
+ args,
32
+ options: {
33
+ ...options,
34
+ help: { type: "boolean", short: "h" },
35
+ },
36
+ allowPositionals,
37
+ strict: true,
38
+ });
39
+
40
+ if (result.values.help) {
41
+ console.info(buildCommandHelp(config));
42
+ return;
43
+ }
44
+
45
+ await handler(result as CommandHandlerArgs<T>);
46
+ };
47
+ }
48
+
49
+ function buildCommandHelp(config: CommandConfig): string {
50
+ const { description, sections, positionals = {}, options } = config;
51
+
52
+ const positionalNames = Object.keys(positionals);
53
+
54
+ const lines = [dedent(description)];
55
+
56
+ lines.push("");
57
+ lines.push("USAGE");
58
+ let usage = ` ${config.name}`;
59
+ if (positionalNames.length > 0) {
60
+ usage += " " + positionalNames.map((positionalName) => `<${positionalName}>`).join(" ");
61
+ }
62
+ usage += " [options]";
63
+ lines.push(usage);
64
+
65
+ if (positionalNames.length > 0) {
66
+ lines.push("");
67
+ lines.push("ARGUMENTS");
68
+ const maxNameLength = Math.max(
69
+ ...positionalNames.map((positionalName) => `<${positionalName}>`.length),
70
+ );
71
+ for (const positionalName in positionals) {
72
+ const formattedName = `<${positionalName}>`;
73
+ const paddedName = formattedName.padEnd(maxNameLength);
74
+ const description = positionals[positionalName].description;
75
+ lines.push(` ${paddedName} ${description}`);
76
+ }
77
+ }
78
+
79
+ lines.push("");
80
+ lines.push("OPTIONS");
81
+ const optionEntries: { left: string; description: string }[] = [];
82
+ if (options) {
83
+ const optionNames = Object.keys(options);
84
+ for (const optionName of optionNames) {
85
+ const option = options[optionName];
86
+ const shortPart = option.short ? `-${option.short}, ` : " ";
87
+ const typeSuffix = option.type === "string" ? " string" : "";
88
+ const left = `${shortPart}--${optionName}${typeSuffix}`;
89
+ optionEntries.push({ left, description: option.description });
90
+ }
91
+ }
92
+ optionEntries.push({ left: "-h, --help", description: "Show help for command" });
93
+ const maxOptionLength = Math.max(...optionEntries.map((optionEntry) => optionEntry.left.length));
94
+ for (const optionEntry of optionEntries) {
95
+ const paddedLeft = optionEntry.left.padEnd(maxOptionLength);
96
+ lines.push(` ${paddedLeft} ${optionEntry.description}`);
97
+ }
98
+
99
+ if (sections) {
100
+ for (const sectionName in sections) {
101
+ const content = dedent(sections[sectionName]);
102
+ lines.push("");
103
+ lines.push(sectionName);
104
+ for (const line of content.split("\n")) {
105
+ lines.push(line ? ` ${line}` : "");
106
+ }
107
+ }
108
+ }
109
+
110
+ lines.push("");
111
+ lines.push("LEARN MORE");
112
+ const bin = config.name.split(" ")[0];
113
+ lines.push(` Use \`${bin} <command> --help\` for more information about a command.`);
114
+
115
+ return lines.join("\n");
116
+ }
117
+
118
+ type CreateCommandRouterConfig = {
119
+ name: string;
120
+ description: string;
121
+ commands: Record<string, RouterCommand>;
122
+ };
123
+ type RouterCommand = { handler: () => Promise<void>; description: string };
124
+
125
+ export function createCommandRouter(config: CreateCommandRouterConfig): () => Promise<void> {
126
+ const { name, description, commands } = config;
127
+
128
+ const depth = name.split(" ").length;
129
+
130
+ return async function () {
131
+ const args = process.argv.slice(1 + depth);
132
+
133
+ const {
134
+ positionals: [subcommand],
135
+ } = parseArgs({
136
+ args,
137
+ options: { help: { type: "boolean", short: "h" } },
138
+ allowPositionals: true,
139
+ strict: false,
140
+ });
141
+
142
+ const entry = subcommand ? config.commands[subcommand] : undefined;
143
+ if (entry) {
144
+ await entry.handler();
145
+ return;
146
+ }
147
+
148
+ if (subcommand) {
149
+ throw new CommandError(`Unknown command: ${subcommand}`);
150
+ }
151
+
152
+ console.info(buildRouterHelp({ name, description, commands }));
153
+ };
154
+ }
155
+
156
+ function buildRouterHelp(config: CreateCommandRouterConfig): string {
157
+ const { name, description, commands } = config;
158
+
159
+ const lines = [description];
160
+
161
+ lines.push("");
162
+ lines.push("USAGE");
163
+ lines.push(` ${name} <command> [options]`);
164
+
165
+ lines.push("");
166
+ lines.push("COMMANDS");
167
+ const commandNames = Object.keys(commands);
168
+ const maxNameLength = Math.max(...commandNames.map((commandName) => commandName.length));
169
+ for (const commandName of commandNames) {
170
+ const paddedName = commandName.padEnd(maxNameLength);
171
+ const description = commands[commandName].description;
172
+ lines.push(` ${paddedName} ${description}`);
173
+ }
174
+
175
+ lines.push("");
176
+ lines.push("OPTIONS");
177
+ lines.push(" -h, --help Show help for command");
178
+
179
+ lines.push("");
180
+ lines.push("LEARN MORE");
181
+ lines.push(` Use \`${name} <command> --help\` for more information about a command.`);
182
+
183
+ return lines.join("\n");
184
+ }
185
+
186
+ export class CommandError extends Error {
187
+ name = "CommandError";
188
+ }
package/src/lib/file.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { access, mkdir, writeFile } from "node:fs/promises";
1
+ import { access, mkdir, readFile, writeFile } from "node:fs/promises";
2
2
  import { pathToFileURL } from "node:url";
3
+ import * as z from "zod/mini";
3
4
 
4
5
  import { appendTrailingSlash } from "./url";
5
6
 
@@ -56,3 +57,14 @@ export async function writeFileRecursive(
56
57
  await mkdir(dirname, { recursive: true });
57
58
  await writeFile(path, data);
58
59
  }
60
+
61
+ export async function readJsonFile<T = unknown>(
62
+ path: URL,
63
+ options: { schema?: z.ZodMiniType<T> } = {},
64
+ ): Promise<T> {
65
+ const { schema } = options;
66
+ const file = await readFile(path, "utf8");
67
+ const json = JSON.parse(file);
68
+ if (schema) return z.parse(schema, json);
69
+ return json;
70
+ }
@@ -1,7 +1,24 @@
1
1
  import detectIndent from "detect-indent";
2
2
  import { readFile, writeFile } from "node:fs/promises";
3
+ import { fileURLToPath } from "node:url";
4
+ import { x } from "tinyexec";
5
+ import { z } from "zod/mini";
3
6
 
4
- import { findUpward } from "./file";
7
+ import { exists, findUpward, readJsonFile } from "./file";
8
+
9
+ const PackageJsonSchema = z.object({
10
+ dependencies: z.optional(z.record(z.string(), z.string())),
11
+ devDependencies: z.optional(z.record(z.string(), z.string())),
12
+ peerDependencies: z.optional(z.record(z.string(), z.string())),
13
+ packageManager: z.optional(z.string()),
14
+ });
15
+ type PackageJson = z.infer<typeof PackageJsonSchema>;
16
+
17
+ export async function readPackageJson(): Promise<PackageJson> {
18
+ const packageJsonPath = await findPackageJson();
19
+ const packageJson = await readJsonFile(packageJsonPath, { schema: PackageJsonSchema });
20
+ return packageJson;
21
+ }
5
22
 
6
23
  export async function findPackageJson(): Promise<URL> {
7
24
  const packageJsonPath = await findUpward("package.json");
@@ -35,3 +52,55 @@ export async function getNpmPackageVersion(name: string, tag = "latest"): Promis
35
52
  const { version } = await res.json();
36
53
  return version;
37
54
  }
55
+
56
+ const INSTALL_COMMANDS = {
57
+ npm: ["npm", "install"],
58
+ yarn: ["yarn", "install"],
59
+ pnpm: ["pnpm", "install"],
60
+ bun: ["bun", "install"],
61
+ };
62
+
63
+ export async function installDependencies(): Promise<void> {
64
+ const packageJsonPath = await findPackageJson();
65
+ const cwd = new URL(".", packageJsonPath);
66
+ const packageManager = await detectPackageManager();
67
+ const [command, ...args] = INSTALL_COMMANDS[packageManager];
68
+ await x(command, args, {
69
+ nodeOptions: { cwd: fileURLToPath(cwd), stdio: "inherit" },
70
+ throwOnError: true,
71
+ });
72
+ }
73
+
74
+ const PACKAGE_MANAGER_LOCKFILES: Record<string, keyof typeof INSTALL_COMMANDS> = {
75
+ "bun.lock": "bun",
76
+ "bun.lockb": "bun",
77
+ "pnpm-lock.yaml": "pnpm",
78
+ "yarn.lock": "yarn",
79
+ "package-lock.json": "npm",
80
+ };
81
+
82
+ async function detectPackageManager(): Promise<keyof typeof INSTALL_COMMANDS> {
83
+ const packageManager = await readPackageManager();
84
+ if (packageManager) return packageManager;
85
+
86
+ const packageJsonPath = await findPackageJson();
87
+ for (const file in PACKAGE_MANAGER_LOCKFILES) {
88
+ const packageManager = PACKAGE_MANAGER_LOCKFILES[file];
89
+ const hasLockfile = await exists(new URL(file, packageJsonPath));
90
+ if (hasLockfile) return packageManager;
91
+ }
92
+
93
+ return "npm";
94
+ }
95
+
96
+ async function readPackageManager(): Promise<keyof typeof INSTALL_COMMANDS | undefined> {
97
+ try {
98
+ const packageJson = await readPackageJson();
99
+ if (!packageJson.packageManager) return;
100
+ const packageManager = packageJson.packageManager.split("@")[0];
101
+ if (packageManager in INSTALL_COMMANDS) return packageManager as keyof typeof INSTALL_COMMANDS;
102
+ return undefined;
103
+ } catch {
104
+ return undefined;
105
+ }
106
+ }
@@ -18,7 +18,7 @@ let enabled = false;
18
18
  let anonymousId = "";
19
19
  let authorization = "";
20
20
  let userId: string | undefined;
21
- let repository: string | undefined;
21
+ let globalRepository: string | undefined;
22
22
  const appContext = { app: { name: packageJson.name, version: packageJson.version } };
23
23
  const trackQueue: Array<{
24
24
  event: string;
@@ -47,52 +47,50 @@ export async function initSegment(): Promise<void> {
47
47
 
48
48
  export type TrackContext = { repository?: string; watch?: boolean };
49
49
 
50
- export function segmentTrackStart(command: string, ctx?: TrackContext): void {
51
- if (!enabled) {
52
- return;
53
- }
50
+ export function segmentTrackStart(command: string, context: TrackContext = {}): void {
51
+ if (!enabled) return;
52
+
53
+ const { repository = globalRepository, watch } = context;
54
54
 
55
- const repo = ctx?.repository ?? repository;
56
55
  const properties: Record<string, unknown> = {
57
56
  commandType: command,
58
57
  fullCommand: process.argv.join(" "),
59
58
  };
60
- if (repo) {
61
- properties.repository = repo;
62
- }
59
+ if (repository) properties.repository = repository;
60
+ if (watch !== undefined) properties.watch = watch;
63
61
 
64
- trackQueue.push({ event: "Prismic CLI Start", properties, context: buildContext(repo) });
62
+ trackQueue.push({
63
+ event: "Prismic CLI Start",
64
+ properties,
65
+ context: buildContext(repository),
66
+ });
65
67
  }
66
68
 
67
69
  export function segmentTrackEnd(
68
70
  command: string,
69
- success: boolean,
70
- error?: unknown,
71
- ctx?: TrackContext,
71
+ context: TrackContext & { success?: boolean; error?: unknown } = {},
72
72
  ): void {
73
- if (!enabled) {
74
- return;
75
- }
73
+ if (!enabled) return;
74
+
75
+ const { success = !process.exitCode, error, repository = globalRepository, watch } = context;
76
76
 
77
- const repo = ctx?.repository ?? repository;
78
77
  const properties: Record<string, unknown> = {
79
78
  commandType: command,
80
79
  fullCommand: process.argv.join(" "),
81
80
  success,
82
81
  };
83
- if (repo) {
84
- properties.repository = repo;
85
- }
86
- if (ctx?.watch !== undefined) {
87
- properties.watch = ctx.watch;
88
- }
89
-
82
+ if (repository) properties.repository = repository;
83
+ if (watch !== undefined) properties.watch = watch;
90
84
  if (error !== undefined) {
91
85
  const message = error instanceof Error ? error.message : String(error);
92
86
  properties.error = message.slice(0, 512);
93
87
  }
94
88
 
95
- trackQueue.push({ event: "Prismic CLI End", properties, context: buildContext(repo) });
89
+ trackQueue.push({
90
+ event: "Prismic CLI End",
91
+ properties,
92
+ context: buildContext(repository),
93
+ });
96
94
  }
97
95
 
98
96
  export function segmentIdentify(profile: { shortId: string; intercomHash: string }): void {
@@ -112,14 +110,12 @@ export function segmentIdentify(profile: { shortId: string; intercomHash: string
112
110
  }
113
111
 
114
112
  export function segmentSetRepository(repo: string): void {
115
- repository = repo;
113
+ globalRepository = repo;
116
114
  }
117
115
 
118
- function buildContext(repo: string | undefined): Record<string, unknown> {
116
+ function buildContext(repository: string | undefined): Record<string, unknown> {
119
117
  const context: Record<string, unknown> = { ...appContext };
120
- if (repo) {
121
- context.groupId = { Repository: repo };
122
- }
118
+ if (repository) context.groupId = { Repository: repository };
123
119
  return context;
124
120
  }
125
121
 
package/src/project.ts ADDED
@@ -0,0 +1,54 @@
1
+ import {
2
+ findConfigPath,
3
+ findSuggestedConfigPath,
4
+ MissingPrismicConfig,
5
+ readConfig,
6
+ } from "./config";
7
+ import { exists } from "./lib/file";
8
+ import { appendTrailingSlash } from "./lib/url";
9
+
10
+ export async function findProjectRoot(): Promise<URL> {
11
+ let configPath;
12
+ try {
13
+ configPath = await findConfigPath();
14
+ } catch (error) {
15
+ if (error instanceof MissingPrismicConfig) {
16
+ configPath = await findSuggestedConfigPath();
17
+ } else {
18
+ throw error;
19
+ }
20
+ }
21
+ const projectRoot = new URL(".", configPath);
22
+ return projectRoot;
23
+ }
24
+
25
+ export async function safeGetRepositoryName(): Promise<string | undefined> {
26
+ try {
27
+ return await getRepositoryName();
28
+ } catch {
29
+ return undefined;
30
+ }
31
+ }
32
+
33
+ export async function getRepositoryName(): Promise<string> {
34
+ const config = await readConfig();
35
+ return config.repositoryName;
36
+ }
37
+
38
+ export async function getLibraries(): Promise<URL[] | undefined> {
39
+ const config = await readConfig();
40
+ const rawLibraries = config.libraries;
41
+ if (!rawLibraries || rawLibraries.length < 1) return;
42
+ const projectRoot = await findProjectRoot();
43
+ const libraries = rawLibraries.map((library) =>
44
+ appendTrailingSlash(new URL(library.replace(/^\//, ""), projectRoot)),
45
+ );
46
+ return libraries;
47
+ }
48
+
49
+ export async function checkIsTypeScriptProject(): Promise<boolean> {
50
+ const projectRoot = await findProjectRoot();
51
+ const tsconfigPath = new URL("tsconfig.json", projectRoot);
52
+ const isTypeScriptProject = await exists(tsconfigPath);
53
+ return isTypeScriptProject;
54
+ }
@@ -1,17 +0,0 @@
1
- import{createRequire as e}from"node:module";import{access as t,mkdir as n,readFile as r,rename as i,rm as a,writeFile as o}from"node:fs/promises";import{fileURLToPath as s,pathToFileURL as c}from"node:url";import{relative as l}from"node:path";import*as u from"fs";import d from"fs";import f,{basename as p,dirname as m,normalize as h,posix as g,relative as ee,resolve as _,sep as v}from"path";import{fileURLToPath as y}from"url";import{createRequire as b}from"module";var x=Object.create,S=Object.defineProperty,C=Object.getOwnPropertyDescriptor,w=Object.getOwnPropertyNames,T=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty,D=(e,t)=>()=>(e&&(t=e(e=0)),t),O=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),k=(e,t)=>{let n={};for(var r in e)S(n,r,{get:e[r],enumerable:!0});return t&&S(n,Symbol.toStringTag,{value:`Module`}),n},te=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=w(t),a=0,o=i.length,s;a<o;a++)s=i[a],!E.call(e,s)&&s!==n&&S(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=C(t,s))||r.enumerable});return e},A=(e,t,n)=>(n=e==null?{}:x(T(e)),te(t||!e||!e.__esModule?S(n,`default`,{value:e,enumerable:!0}):n,e)),j=e=>E.call(e,`module.exports`)?e[`module.exports`]:te(S({},`__esModule`,{value:!0}),e),ne=e(import.meta.url);Object.freeze({status:`aborted`});function M(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var N=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};const P={};function F(e){return e&&Object.assign(P,e),P}function I(e,t){return typeof t==`bigint`?t.toString():t}function L(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function R(e){return e==null}function z(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}const B=Symbol(`evaluating`);function V(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==B)return r===void 0&&(r=B,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}const H=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function W(e){if(U(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(U(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function re(e){return W(e)?{...e}:Array.isArray(e)?[...e]:e}function G(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function K(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function q(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}-Number.MAX_VALUE,Number.MAX_VALUE;function J(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Y(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ie(e){return typeof e==`string`?e:e?.message}function ae(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=ie(e.inst?._zod.def?.error?.(e))??ie(t?.error?.(e))??ie(n.customError?.(e))??ie(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function oe(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}const se=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,I,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},ce=M(`$ZodError`,se),le=M(`$ZodError`,se,{Parent:Error}),ue=(e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new N;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>ae(e,a,F())));throw H(t,i?.callee),t}return o.value})(le),de=(e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>ae(e,a,F())));throw H(t,i?.callee),t}return o.value})(le),fe=(e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new N;return a.issues.length?{success:!1,error:new(e??ce)(a.issues.map(e=>ae(e,i,F())))}:{success:!0,data:a.value}})(le),pe=(e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>ae(e,i,F())))}:{success:!0,data:a.value}})(le),me=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,he=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},ge=/^-?\d+(?:\.\d+)?$/,_e=/^(?:true|false)$/i,ve=M(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ye=M(`$ZodCheckMinLength`,(e,t)=>{var n;ve.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!R(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=oe(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),be=M(`$ZodCheckStringFormat`,(e,t)=>{var n,r;ve.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),xe={major:4,minor:3,patch:6},X=M(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=xe;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=J(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new N;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=J(e,t))});else{if(e.issues.length===t)continue;r||=J(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(J(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new N;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new N;return o.then(e=>t(e,r,a))}return t(o,r,a)}}V(e,`~standard`,()=>({validate:t=>{try{let n=fe(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return pe(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Se=M(`$ZodString`,(e,t)=>{X.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??he(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Ce=M(`$ZodStringFormat`,(e,t)=>{be.init(e,t),Se.init(e,t)}),we=M(`$ZodURL`,(e,t)=>{Ce.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Te=M(`$ZodBoolean`,(e,t)=>{X.init(e,t),e._zod.pattern=_e,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}});function Ee(e,t,n){e.issues.length&&t.issues.push(...Y(n,e.issues)),t.value[n]=e.value}const De=M(`$ZodArray`,(e,t)=>{X.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Ee(t,n,e))):Ee(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Oe(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...Y(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function ke(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=q(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ae(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Oe(e,n,i,t,u))):Oe(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const je=M(`$ZodObject`,(e,t)=>{if(X.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=L(()=>ke(t));V(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=U,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>Oe(n,t,e,s,r))):Oe(i,t,e,s,r)}return i?Ae(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Me=M(`$ZodRecord`,(e,t)=>{X.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!W(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Y(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Y(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&ge.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>ae(e,r,F())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Y(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Y(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}});function Ne(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Pe=M(`$ZodOptional`,(e,t)=>{X.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,V(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),V(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${z(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Ne(t,e.value)):Ne(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Fe=M(`$ZodDefault`,(e,t)=>{X.init(e,t),e._zod.optin=`optional`,V(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ie(e,t)):Ie(r,t)}});function Ie(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Le=M(`$ZodPipe`,(e,t)=>{X.init(e,t),V(e._zod,`values`,()=>t.in._zod.values),V(e._zod,`optin`,()=>t.in._zod.optin),V(e._zod,`optout`,()=>t.out._zod.optout),V(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Re(e,t.in,n)):Re(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Re(e,t.out,n)):Re(r,t.out,n)}});function Re(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const ze=M(`$ZodCodec`,(e,t)=>{X.init(e,t),V(e._zod,`values`,()=>t.in._zod.values),V(e._zod,`optin`,()=>t.in._zod.optin),V(e._zod,`optout`,()=>t.out._zod.optout),V(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if((n.direction||`forward`)===`forward`){let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Be(e,t,n)):Be(r,t,n)}else{let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Be(e,t,n)):Be(r,t,n)}}});function Be(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||`forward`)===`forward`){let r=t.transform(e.value,e);return r instanceof Promise?r.then(r=>Ve(e,r,t.out,n)):Ve(e,r,t.out,n)}else{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(r=>Ve(e,r,t.in,n)):Ve(e,r,t.in,n)}}function Ve(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}var He,Ue=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function We(){return new Ue}(He=globalThis).__zod_globalRegistry??(He.__zod_globalRegistry=We()),globalThis.__zod_globalRegistry;function Ge(e,t){return new e({type:`string`,...K(t)})}function Ke(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...K(t)})}function qe(e,t){return new ye({check:`min_length`,...K(t),minimum:e})}function Je(e,t){let n=K(t),r=n.truthy??[`true`,`1`,`yes`,`on`,`y`,`enabled`],i=n.falsy??[`false`,`0`,`no`,`off`,`n`,`disabled`];n.case!==`sensitive`&&(r=r.map(e=>typeof e==`string`?e.toLowerCase():e),i=i.map(e=>typeof e==`string`?e.toLowerCase():e));let a=new Set(r),o=new Set(i),s=e.Codec??ze,c=e.Boolean??Te,l=new s({type:`pipe`,in:new(e.String??Se)({type:`string`,error:n.error}),out:new c({type:`boolean`,error:n.error}),transform:((e,t)=>{let r=e;return n.case!==`sensitive`&&(r=r.toLowerCase()),a.has(r)?!0:o.has(r)?!1:(t.issues.push({code:`invalid_value`,expected:`stringbool`,values:[...a,...o],input:t.value,inst:l,continue:!1}),{})}),reverseTransform:((e,t)=>e===!0?r[0]||`true`:i[0]||`false`),error:n.error});return l}const Z=M(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);X.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>ue(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>fe(e,t,n),e.parseAsync=async(t,n)=>de(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>pe(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0}),e.with=e.check,e.clone=(t,n)=>G(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),Ye=M(`ZodMiniString`,(e,t)=>{Se.init(e,t),Z.init(e,t)});function Q(e){return Ge(Ye,e)}const Xe=M(`ZodMiniStringFormat`,(e,t)=>{Ce.init(e,t),Ye.init(e,t)}),Ze=M(`ZodMiniURL`,(e,t)=>{we.init(e,t),Xe.init(e,t)});function Qe(e){return Ke(Ze,{protocol:/^https?$/,hostname:me,...K(e)})}const $e=M(`ZodMiniBoolean`,(e,t)=>{Te.init(e,t),Z.init(e,t)}),et=M(`ZodMiniArray`,(e,t)=>{De.init(e,t),Z.init(e,t)});function tt(e,t){return new et({type:`array`,element:e,...K(t)})}const nt=M(`ZodMiniObject`,(e,t)=>{je.init(e,t),Z.init(e,t),V(e,`shape`,()=>t.shape)});function rt(e,t){return new nt({type:`object`,shape:e??{},...K(t)})}const it=M(`ZodMiniRecord`,(e,t)=>{Me.init(e,t),Z.init(e,t)});function at(e,t,n){return new it({type:`record`,keyType:e,valueType:t,...K(n)})}const ot=M(`ZodMiniOptional`,(e,t)=>{Pe.init(e,t),Z.init(e,t)});function st(e){return new ot({type:`optional`,innerType:e})}const ct=M(`ZodMiniDefault`,(e,t)=>{Fe.init(e,t),Z.init(e,t)});function lt(e,t){return new ct({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():re(t)}})}const ut=M(`ZodMiniPipe`,(e,t)=>{Le.init(e,t),Z.init(e,t)}),dt=M(`ZodMiniCodec`,(e,t)=>{ut.init(e,t),ze.init(e,t)}),ft=(...e)=>Je({Codec:dt,Boolean:$e,String:Ye},...e);function pt(e){let t=new URL(e);return t.pathname.endsWith(`/`)||(t.pathname+=`/`),t}async function mt(e,n={}){let{start:r=c(process.cwd()),stop:i}=n,a=pt(r);for(;;){let n=new URL(e,a);try{return await t(n),n}catch{}if(typeof i==`string`){let e=new URL(i,a);try{await t(e);return}catch{}}else if(i instanceof URL&&i.href===a.href)return;let r=new URL(`..`,a);if(r.href===a.href)return;a=r}}async function ht(e){try{return await t(e),!0}catch{return!1}}async function gt(e,t){await n(new URL(`.`,e),{recursive:!0}),await o(e,t)}function _t(e){return JSON.stringify(e,null,2)}const vt=/^(?:( )+|\t+)/,$=`space`;function yt(e,t,n){return e&&t===$&&n===1}function bt(e,t){let n=new Map,r=0,i,a;for(let o of e.split(/\n/g)){if(!o)continue;let e=o.match(vt);if(e===null)r=0,i=``;else{let o=e[0].length,s=e[1]?$:`tab`;if(yt(t,s,o))continue;s!==i&&(r=0),i=s;let c=1,l=0,u=o-r;if(r=o,u===0)c=0,l=1;else{let e=Math.abs(u);if(yt(t,s,e))continue;a=xt(s,e)}let d=n.get(a);n.set(a,d===void 0?[1,0]:[d[0]+c,d[1]+l])}}return n}function xt(e,t){return(e===$?`s`:`t`)+String(t)}function St(e){return{type:e[0]===`s`?$:`tab`,amount:Number(e.slice(1))}}function Ct(e){let t,n=0,r=0;for(let[i,[a,o]]of e)(a>n||a===n&&o>r)&&(n=a,r=o,t=i);return t}function wt(e,t){return(e===$?` `:` `).repeat(t)}function Tt(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);let t=bt(e,!0);t.size===0&&(t=bt(e,!1));let n=Ct(t),r,i=0,a=``;return n!==void 0&&({type:r,amount:i}=St(n),a=wt(r,i)),{amount:i,type:r,indent:a}}async function Et(){let e=await mt(`package.json`);if(!e)throw new Dt;return e}var Dt=class extends Error{name=`MissingPackageJson`;message=`Could not find a package.json file.`};async function Ot(e){let t=await Et(),n=await r(t,`utf8`),i=Tt(n).indent||` `,a=JSON.parse(n);a.dependencies=Object.fromEntries(Object.entries({...a.dependencies,...e}).sort(([e],[t])=>e.localeCompare(t))),await o(t,JSON.stringify(a,null,i)+`
2
- `)}async function kt(e,t=`latest`){let n=new URL(`${e}/${t}`,`https://registry.npmjs.org/`),{version:r}=await(await fetch(n)).json();return r}const At=`prismic.config.json`,jt=`slicemachine.config.json`,Mt=rt({repositoryName:Q(),libraries:st(tt(Q()))}),Nt=rt({repositoryName:Q(),libraries:st(tt(Q()))});async function Pt(e){let t=await Vt();return await o(t,_t(e)),t}async function Ft(){try{return(await It()).repositoryName}catch{return}}async function It(){let e=await zt();try{let t=await r(e,`utf8`);return ue(Mt,JSON.parse(t))}catch(e){throw e instanceof ce?new Lt(e.issues):new Lt}}var Lt=class extends Error{name=`InvalidPrismicConfig`;message=`${At} is invalid.`;issues;constructor(e=[]){super(),this.issues=e}};async function Rt(e){let t=await zt(),n={...await It(),...e};return await o(t,_t(n)),n}async function zt(){let e=await mt(At,{stop:`package.json`});if(!e)throw new Bt;return e}var Bt=class extends Error{name=`MissingPrismicConfig`;message=`Could not find a ${At} file.`};async function Vt(){try{let e=await Et();return new URL(At,e)}catch(e){throw e instanceof Dt?new Ht(void 0,{cause:e}):e}}var Ht=class extends Error{name=`UnknownProjectRoot`};async function Ut(){let e=await Kt();try{let t=await r(e,`utf8`);return ue(Nt,JSON.parse(t))}catch(e){throw e instanceof ce?new Wt(e.issues):new Wt}}var Wt=class extends Error{name=`InvalidLegacySliceMachineConfig`;message=`${jt} is invalid.`;issues;constructor(e=[]){super(),this.issues=e}};async function Gt(){await a(await Kt())}async function Kt(){let e=await mt(jt,{stop:`package.json`});if(!e)throw new qt;return e}var qt=class extends Error{name=`MissingLegacySliceMachineConfig`;message=`Could not find a ${jt} file.`};const Jt=/([\p{Ll}\d])(\p{Lu})/gu,Yt=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,Xt=/(\d)\p{Ll}|(\p{L})\d/u,Zt=/[^\p{L}\d]+/giu,Qt=`$1\0$2`;function $t(e){let t=e.trim();t=t.replace(Jt,Qt).replace(Yt,Qt),t=t.replace(Zt,`\0`);let n=0,r=t.length;for(;t.charAt(n)===`\0`;)n++;if(n===r)return[];for(;t.charAt(r-1)===`\0`;)r--;return t.slice(n,r).split(/\0/g)}function en(e){let t=$t(e);for(let e=0;e<t.length;e++){let n=t[e],r=Xt.exec(n);if(r){let i=r.index+(r[1]??r[2]).length;t.splice(e,1,n.slice(0,i),n.slice(i))}}return t}function tn(e,t){let[n,r,i]=sn(e,t),a=nn(t?.locale),o=rn(t?.locale),s=t?.mergeAmbiguousCharacters?an(a,o):on(a,o);return n+r.map(s).join(t?.delimiter??``)+i}function nn(e){return e===!1?e=>e.toLowerCase():t=>t.toLocaleLowerCase(e)}function rn(e){return e===!1?e=>e.toUpperCase():t=>t.toLocaleUpperCase(e)}function an(e,t){return n=>`${t(n[0])}${e(n.slice(1))}`}function on(e,t){return(n,r)=>{let i=n[0];return(r>0&&i>=`0`&&i<=`9`?`_`+i:t(i))+e(n.slice(1))}}function sn(e,t={}){let n=t.split??(t.separateNumbers?en:$t),r=t.prefixCharacters??``,i=t.suffixCharacters??``,a=0,o=e.length;for(;a<e.length;){let t=e.charAt(a);if(!r.includes(t))break;a++}for(;o>a;){let t=o-1,n=e.charAt(t);if(!i.includes(n))break;o=t}return[e.slice(0,a),n(e.slice(a,o)),e.slice(o)]}var cn=b(import.meta.url);function ln(e){let t=h(e);return t.length>1&&t[t.length-1]===v&&(t=t.substring(0,t.length-1)),t}const un=/[\\/]/g;function dn(e,t){return e.replace(un,t)}const fn=/^[a-z]:[\\/]$/i;function pn(e){return e===`/`||fn.test(e)}function mn(e,t){let{resolvePaths:n,normalizePath:r,pathSeparator:i}=t,a=process.platform===`win32`&&e.includes(`/`)||e.startsWith(`.`);return n&&(e=_(e)),(r||a)&&(e=ln(e)),e===`.`?``:dn(e[e.length-1]===i?e:e+i,i)}function hn(e,t){return t+e}function gn(e,t){return function(n,r){return r.startsWith(e)?r.slice(e.length)+n:dn(ee(e,r),t.pathSeparator)+t.pathSeparator+n}}function _n(e){return e}function vn(e,t,n){return t+e+n}function yn(e,t){let{relativePaths:n,includeBasePath:r}=t;return n&&e?gn(e,t):r?hn:_n}function bn(e){return function(t,n){n.push(t.substring(e.length)||`.`)}}function xn(e){return function(t,n,r){let i=t.substring(e.length)||`.`;r.every(e=>e(i,!0))&&n.push(i)}}const Sn=(e,t)=>{t.push(e||`.`)},Cn=(e,t,n)=>{let r=e||`.`;n.every(e=>e(r,!0))&&t.push(r)},wn=()=>{};function Tn(e,t){let{includeDirs:n,filters:r,relativePaths:i}=t;return n?i?r&&r.length?xn(e):bn(e):r&&r.length?Cn:Sn:wn}const En=(e,t,n,r)=>{r.every(t=>t(e,!1))&&n.files++},Dn=(e,t,n,r)=>{r.every(t=>t(e,!1))&&t.push(e)},On=(e,t,n,r)=>{n.files++},kn=(e,t)=>{t.push(e)},An=()=>{};function jn(e){let{excludeFiles:t,filters:n,onlyCounts:r}=e;return t?An:n&&n.length?r?En:Dn:r?On:kn}const Mn=e=>e,Nn=()=>[``].slice(0,0);function Pn(e){return e.group?Nn:Mn}const Fn=(e,t,n)=>{e.push({directory:t,files:n,dir:t})},In=()=>{};function Ln(e){return e.group?Fn:In}const Rn=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue(),i.realpath(e,(o,s)=>{if(o)return r.dequeue(a?null:o,t);i.stat(s,(i,o)=>{if(i)return r.dequeue(a?null:i,t);if(o.isDirectory()&&Vn(e,s,t))return r.dequeue(null,t);n(o,s),r.dequeue(null,t)})})},zn=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue();try{let r=i.realpathSync(e),a=i.statSync(r);if(a.isDirectory()&&Vn(e,r,t))return;n(a,r)}catch(e){if(!a)throw e}};function Bn(e,t){return!e.resolveSymlinks||e.excludeSymlinks?null:t?zn:Rn}function Vn(e,t,n){if(n.options.useRealPaths)return Hn(t,n);let r=m(e),i=1;for(;r!==n.root&&i<2;){let e=n.symlinks.get(r);e&&(e===t||e.startsWith(t)||t.startsWith(e))?i++:r=m(r)}return n.symlinks.set(e,t),i>1}function Hn(e,t){return t.visited.includes(e+t.options.pathSeparator)}const Un=e=>e.counts,Wn=e=>e.groups,Gn=e=>e.paths,Kn=e=>e.paths.slice(0,e.options.maxFiles),qn=(e,t,n)=>(Zn(t,n,e.counts,e.options.suppressErrors),null),Jn=(e,t,n)=>(Zn(t,n,e.paths,e.options.suppressErrors),null),Yn=(e,t,n)=>(Zn(t,n,e.paths.slice(0,e.options.maxFiles),e.options.suppressErrors),null),Xn=(e,t,n)=>(Zn(t,n,e.groups,e.options.suppressErrors),null);function Zn(e,t,n,r){t(e&&!r?e:null,n)}function Qn(e,t){let{onlyCounts:n,group:r,maxFiles:i}=e;return n?t?Un:qn:r?t?Wn:Xn:i?t?Kn:Yn:t?Gn:Jn}const $n={withFileTypes:!0},er=(e,t,n,r,i)=>{if(e.queue.enqueue(),r<0)return e.queue.dequeue(null,e);let{fs:a}=e;e.visited.push(t),e.counts.directories++,a.readdir(t||`.`,$n,(t,a=[])=>{i(a,n,r),e.queue.dequeue(e.options.suppressErrors?null:t,e)})},tr=(e,t,n,r,i)=>{let{fs:a}=e;if(r<0)return;e.visited.push(t),e.counts.directories++;let o=[];try{o=a.readdirSync(t||`.`,$n)}catch(t){if(!e.options.suppressErrors)throw t}i(o,n,r)};function nr(e){return e?tr:er}var rr=class{count=0;constructor(e){this.onQueueEmpty=e}enqueue(){return this.count++,this.count}dequeue(e,t){this.onQueueEmpty&&(--this.count<=0||e)&&(this.onQueueEmpty(e,t),e&&(t.controller.abort(),this.onQueueEmpty=void 0))}},ir=class{_files=0;_directories=0;set files(e){this._files=e}get files(){return this._files}set directories(e){this._directories=e}get directories(){return this._directories}get dirs(){return this._directories}},ar=class{aborted=!1;abort(){this.aborted=!0}},or=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(e,t,n){this.isSynchronous=!n,this.callbackInvoker=Qn(t,this.isSynchronous),this.root=mn(e,t),this.state={root:pn(this.root)?this.root:this.root.slice(0,-1),paths:[``].slice(0,0),groups:[],counts:new ir,options:t,queue:new rr((e,t)=>this.callbackInvoker(t,e,n)),symlinks:new Map,visited:[``].slice(0,0),controller:new ar,fs:t.fs||u},this.joinPath=yn(this.root,t),this.pushDirectory=Tn(this.root,t),this.pushFile=jn(t),this.getArray=Pn(t),this.groupFiles=Ln(t),this.resolveSymlink=Bn(t,this.isSynchronous),this.walkDirectory=nr(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(e,t,n)=>{let{paths:r,options:{filters:i,resolveSymlinks:a,excludeSymlinks:o,exclude:s,maxFiles:c,signal:l,useRealPaths:u,pathSeparator:d},controller:f}=this.state;if(f.aborted||l&&l.aborted||c&&r.length>c)return;let h=this.getArray(this.state.paths);for(let c=0;c<e.length;++c){let l=e[c];if(l.isFile()||l.isSymbolicLink()&&!a&&!o){let e=this.joinPath(l.name,t);this.pushFile(e,h,this.state.counts,i)}else if(l.isDirectory()){let e=vn(l.name,t,this.state.options.pathSeparator);if(s&&s(l.name,e))continue;this.pushDirectory(e,r,i),this.walkDirectory(this.state,e,e,n-1,this.walk)}else if(this.resolveSymlink&&l.isSymbolicLink()){let e=hn(l.name,t);this.resolveSymlink(e,this.state,(t,r)=>{if(t.isDirectory()){if(r=mn(r,this.state.options),s&&s(l.name,u?r:e+d))return;this.walkDirectory(this.state,r,u?r:e+d,n-1,this.walk)}else{r=u?r:e;let t=p(r),n=mn(m(r),this.state.options);r=this.joinPath(t,n),this.pushFile(r,h,this.state.counts,i)}})}}this.groupFiles(this.state.groups,t,h)}};function sr(e,t){return new Promise((n,r)=>{cr(e,t,(e,t)=>{if(e)return r(e);n(t)})})}function cr(e,t,n){new or(e,t,n).start()}function lr(e,t){return new or(e,t).start()}var ur=class{constructor(e,t){this.root=e,this.options=t}withPromise(){return sr(this.root,this.options)}withCallback(e){cr(this.root,this.options,e)}sync(){return lr(this.root,this.options)}};let dr=null;try{cn.resolve(`picomatch`),dr=cn(`picomatch`)}catch{}var fr=class{globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:v,filters:[]};globFunction;constructor(e){this.options={...this.options,...e},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator(e){return this.options.pathSeparator=e,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth(e){return this.options.maxDepth=e,this}withMaxFiles(e){return this.options.maxFiles=e,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:e=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=e,this.withFullPaths()}withAbortSignal(e){return this.options.signal=e,this}normalize(){return this.options.normalizePath=!0,this}filter(e){return this.options.filters.push(e),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude(e){return this.options.exclude=e,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl(e){return new ur(e||`.`,this.options)}withGlobFunction(e){return this.globFunction=e,this}crawlWithOptions(e,t){return this.options={...this.options,...t},new ur(e||`.`,this.options)}glob(...e){return this.globFunction?this.globWithOptions(e):this.globWithOptions(e,{dot:!0})}globWithOptions(e,...t){let n=this.globFunction||dr;if(!n)throw Error(`Please specify a glob function to use glob matching.`);var r=this.globCache[e.join(`\0`)];return r||(r=n(e,...t),this.globCache[e.join(`\0`)]=r),this.options.filters.push(e=>r(e)),this}},pr=O(((e,t)=>{let n=`[^\\\\/]`,r=`[^/]`,i=`(?:\\/|$)`,a=`(?:^|\\/)`,o=`\\.{1,2}${i}`,s={DOT_LITERAL:`\\.`,PLUS_LITERAL:`\\+`,QMARK_LITERAL:`\\?`,SLASH_LITERAL:`\\/`,ONE_CHAR:`(?=.)`,QMARK:r,END_ANCHOR:i,DOTS_SLASH:o,NO_DOT:`(?!\\.)`,NO_DOTS:`(?!${a}${o})`,NO_DOT_SLASH:`(?!\\.{0,1}${i})`,NO_DOTS_SLASH:`(?!${o})`,QMARK_NO_DOT:`[^.\\/]`,STAR:`${r}*?`,START_ANCHOR:a,SEP:`/`},c={...s,SLASH_LITERAL:`[\\\\/]`,QMARK:n,STAR:`${n}*?`,DOTS_SLASH:`\\.{1,2}(?:[\\\\/]|$)`,NO_DOT:`(?!\\.)`,NO_DOTS:`(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))`,NO_DOT_SLASH:`(?!\\.{0,1}(?:[\\\\/]|$))`,NO_DOTS_SLASH:`(?!\\.{1,2}(?:[\\\\/]|$))`,QMARK_NO_DOT:`[^.\\\\/]`,START_ANCHOR:`(?:^|[\\\\/])`,END_ANCHOR:`(?:[\\\\/]|$)`,SEP:`\\`};t.exports={MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:{alnum:`a-zA-Z0-9`,alpha:`a-zA-Z`,ascii:`\\x00-\\x7F`,blank:` \\t`,cntrl:`\\x00-\\x1F\\x7F`,digit:`0-9`,graph:`\\x21-\\x7E`,lower:`a-z`,print:`\\x20-\\x7E `,punct:`\\-!"#$%&'()\\*+,./:;<=>?@[\\]^_\`{|}~`,space:` \\t\\r\\n\\v\\f`,upper:`A-Z`,word:`A-Za-z0-9_`,xdigit:`A-Fa-f0-9`},REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":`*`,"**/**":`**`,"**/**/**":`**`},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(e){return{"!":{type:`negate`,open:`(?:(?!(?:`,close:`))${e.STAR})`},"?":{type:`qmark`,open:`(?:`,close:`)?`},"+":{type:`plus`,open:`(?:`,close:`)+`},"*":{type:`star`,open:`(?:`,close:`)*`},"@":{type:`at`,open:`(?:`,close:`)`}}},globChars(e){return e===!0?c:s}}})),mr=O((e=>{let{REGEX_BACKSLASH:t,REGEX_REMOVE_BACKSLASH:n,REGEX_SPECIAL_CHARS:r,REGEX_SPECIAL_CHARS_GLOBAL:i}=pr();e.isObject=e=>typeof e==`object`&&!!e&&!Array.isArray(e),e.hasRegexChars=e=>r.test(e),e.isRegexChar=t=>t.length===1&&e.hasRegexChars(t),e.escapeRegex=e=>e.replace(i,`\\$1`),e.toPosixSlashes=e=>e.replace(t,`/`),e.isWindows=()=>{if(typeof navigator<`u`&&navigator.platform){let e=navigator.platform.toLowerCase();return e===`win32`||e===`windows`}return typeof process<`u`&&process.platform?process.platform===`win32`:!1},e.removeBackslashes=e=>e.replace(n,e=>e===`\\`?``:e),e.escapeLast=(t,n,r)=>{let i=t.lastIndexOf(n,r);return i===-1?t:t[i-1]===`\\`?e.escapeLast(t,n,i-1):`${t.slice(0,i)}\\${t.slice(i)}`},e.removePrefix=(e,t={})=>{let n=e;return n.startsWith(`./`)&&(n=n.slice(2),t.prefix=`./`),n},e.wrapOutput=(e,t={},n={})=>{let r=`${n.contains?``:`^`}(?:${e})${n.contains?``:`$`}`;return t.negated===!0&&(r=`(?:^(?!${r}).*$)`),r},e.basename=(e,{windows:t}={})=>{let n=e.split(t?/[\\/]/:`/`),r=n[n.length-1];return r===``?n[n.length-2]:r}})),hr=O(((e,t)=>{let n=mr(),{CHAR_ASTERISK:r,CHAR_AT:i,CHAR_BACKWARD_SLASH:a,CHAR_COMMA:o,CHAR_DOT:s,CHAR_EXCLAMATION_MARK:c,CHAR_FORWARD_SLASH:l,CHAR_LEFT_CURLY_BRACE:u,CHAR_LEFT_PARENTHESES:d,CHAR_LEFT_SQUARE_BRACKET:f,CHAR_PLUS:p,CHAR_QUESTION_MARK:m,CHAR_RIGHT_CURLY_BRACE:h,CHAR_RIGHT_PARENTHESES:g,CHAR_RIGHT_SQUARE_BRACKET:ee}=pr(),_=e=>e===l||e===a,v=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)};t.exports=(e,t)=>{let y=t||{},b=e.length-1,x=y.parts===!0||y.scanToEnd===!0,S=[],C=[],w=[],T=e,E=-1,D=0,O=0,k=!1,te=!1,A=!1,j=!1,ne=!1,M=!1,N=!1,P=!1,F=!1,I=!1,L=0,R,z,B={value:``,depth:0,isGlob:!1},V=()=>E>=b,H=()=>T.charCodeAt(E+1),U=()=>(R=z,T.charCodeAt(++E));for(;E<b;){z=U();let e;if(z===a){N=B.backslashes=!0,z=U(),z===u&&(M=!0);continue}if(M===!0||z===u){for(L++;V()!==!0&&(z=U());){if(z===a){N=B.backslashes=!0,U();continue}if(z===u){L++;continue}if(M!==!0&&z===s&&(z=U())===s){if(k=B.isBrace=!0,A=B.isGlob=!0,I=!0,x===!0)continue;break}if(M!==!0&&z===o){if(k=B.isBrace=!0,A=B.isGlob=!0,I=!0,x===!0)continue;break}if(z===h&&(L--,L===0)){M=!1,k=B.isBrace=!0,I=!0;break}}if(x===!0)continue;break}if(z===l){if(S.push(E),C.push(B),B={value:``,depth:0,isGlob:!1},I===!0)continue;if(R===s&&E===D+1){D+=2;continue}O=E+1;continue}if(y.noext!==!0&&(z===p||z===i||z===r||z===m||z===c)&&H()===d){if(A=B.isGlob=!0,j=B.isExtglob=!0,I=!0,z===c&&E===D&&(F=!0),x===!0){for(;V()!==!0&&(z=U());){if(z===a){N=B.backslashes=!0,z=U();continue}if(z===g){A=B.isGlob=!0,I=!0;break}}continue}break}if(z===r){if(R===r&&(ne=B.isGlobstar=!0),A=B.isGlob=!0,I=!0,x===!0)continue;break}if(z===m){if(A=B.isGlob=!0,I=!0,x===!0)continue;break}if(z===f){for(;V()!==!0&&(e=U());){if(e===a){N=B.backslashes=!0,U();continue}if(e===ee){te=B.isBracket=!0,A=B.isGlob=!0,I=!0;break}}if(x===!0)continue;break}if(y.nonegate!==!0&&z===c&&E===D){P=B.negated=!0,D++;continue}if(y.noparen!==!0&&z===d){if(A=B.isGlob=!0,x===!0){for(;V()!==!0&&(z=U());){if(z===d){N=B.backslashes=!0,z=U();continue}if(z===g){I=!0;break}}continue}break}if(A===!0){if(I=!0,x===!0)continue;break}}y.noext===!0&&(j=!1,A=!1);let W=T,re=``,G=``;D>0&&(re=T.slice(0,D),T=T.slice(D),O-=D),W&&A===!0&&O>0?(W=T.slice(0,O),G=T.slice(O)):A===!0?(W=``,G=T):W=T,W&&W!==``&&W!==`/`&&W!==T&&_(W.charCodeAt(W.length-1))&&(W=W.slice(0,-1)),y.unescape===!0&&(G&&=n.removeBackslashes(G),W&&N===!0&&(W=n.removeBackslashes(W)));let K={prefix:re,input:e,start:D,base:W,glob:G,isBrace:k,isBracket:te,isGlob:A,isExtglob:j,isGlobstar:ne,negated:P,negatedExtglob:F};if(y.tokens===!0&&(K.maxDepth=0,_(z)||C.push(B),K.tokens=C),y.parts===!0||y.tokens===!0){let t;for(let n=0;n<S.length;n++){let r=t?t+1:D,i=S[n],a=e.slice(r,i);y.tokens&&(n===0&&D!==0?(C[n].isPrefix=!0,C[n].value=re):C[n].value=a,v(C[n]),K.maxDepth+=C[n].depth),(n!==0||a!==``)&&w.push(a),t=i}if(t&&t+1<e.length){let n=e.slice(t+1);w.push(n),y.tokens&&(C[C.length-1].value=n,v(C[C.length-1]),K.maxDepth+=C[C.length-1].depth)}K.slashes=S,K.parts=w}return K}})),gr=O(((e,t)=>{let n=pr(),r=mr(),{MAX_LENGTH:i,POSIX_REGEX_SOURCE:a,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:s,REPLACEMENTS:c}=n,l=(e,t)=>{if(typeof t.expandRange==`function`)return t.expandRange(...e,t);e.sort();let n=`[${e.join(`-`)}]`;try{new RegExp(n)}catch{return e.map(e=>r.escapeRegex(e)).join(`..`)}return n},u=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,d=(e,t)=>{if(typeof e!=`string`)throw TypeError(`Expected a string`);e=c[e]||e;let f={...t},p=typeof f.maxLength==`number`?Math.min(i,f.maxLength):i,m=e.length;if(m>p)throw SyntaxError(`Input length: ${m}, exceeds maximum allowed length: ${p}`);let h={type:`bos`,value:``,output:f.prepend||``},g=[h],ee=f.capture?``:`?:`,_=n.globChars(f.windows),v=n.extglobChars(_),{DOT_LITERAL:y,PLUS_LITERAL:b,SLASH_LITERAL:x,ONE_CHAR:S,DOTS_SLASH:C,NO_DOT:w,NO_DOT_SLASH:T,NO_DOTS_SLASH:E,QMARK:D,QMARK_NO_DOT:O,STAR:k,START_ANCHOR:te}=_,A=e=>`(${ee}(?:(?!${te}${e.dot?C:y}).)*?)`,j=f.dot?``:w,ne=f.dot?D:O,M=f.bash===!0?A(f):k;f.capture&&(M=`(${M})`),typeof f.noext==`boolean`&&(f.noextglob=f.noext);let N={input:e,index:-1,start:0,dot:f.dot===!0,consumed:``,output:``,prefix:``,backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:g};e=r.removePrefix(e,N),m=e.length;let P=[],F=[],I=[],L=h,R,z=()=>N.index===m-1,B=N.peek=(t=1)=>e[N.index+t],V=N.advance=()=>e[++N.index]||``,H=()=>e.slice(N.index+1),U=(e=``,t=0)=>{N.consumed+=e,N.index+=t},W=e=>{N.output+=e.output==null?e.value:e.output,U(e.value)},re=()=>{let e=1;for(;B()===`!`&&(B(2)!==`(`||B(3)===`?`);)V(),N.start++,e++;return e%2==0?!1:(N.negated=!0,N.start++,!0)},G=e=>{N[e]++,I.push(e)},K=e=>{N[e]--,I.pop()},q=e=>{if(L.type===`globstar`){let t=N.braces>0&&(e.type===`comma`||e.type===`brace`),n=e.extglob===!0||P.length&&(e.type===`pipe`||e.type===`paren`);e.type!==`slash`&&e.type!==`paren`&&!t&&!n&&(N.output=N.output.slice(0,-L.output.length),L.type=`star`,L.value=`*`,L.output=M,N.output+=L.output)}if(P.length&&e.type!==`paren`&&(P[P.length-1].inner+=e.value),(e.value||e.output)&&W(e),L&&L.type===`text`&&e.type===`text`){L.output=(L.output||L.value)+e.value,L.value+=e.value;return}e.prev=L,g.push(e),L=e},J=(e,t)=>{let n={...v[t],conditions:1,inner:``};n.prev=L,n.parens=N.parens,n.output=N.output;let r=(f.capture?`(`:``)+n.open;G(`parens`),q({type:e,value:t,output:N.output?``:S}),q({type:`paren`,extglob:!0,value:V(),output:r}),P.push(n)},Y=e=>{let n=e.close+(f.capture?`)`:``),r;if(e.type===`negate`){let i=M;e.inner&&e.inner.length>1&&e.inner.includes(`/`)&&(i=A(f)),(i!==M||z()||/^\)+$/.test(H()))&&(n=e.close=`)$))${i}`),e.inner.includes(`*`)&&(r=H())&&/^\.[^\\/.]+$/.test(r)&&(n=e.close=`)${d(r,{...t,fastpaths:!1}).output})${i})`),e.prev.type===`bos`&&(N.negatedExtglob=!0)}q({type:`paren`,extglob:!0,value:R,output:n}),K(`parens`)};if(f.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let n=!1,i=e.replace(s,(e,t,r,i,a,o)=>i===`\\`?(n=!0,e):i===`?`?t?t+i+(a?D.repeat(a.length):``):o===0?ne+(a?D.repeat(a.length):``):D.repeat(r.length):i===`.`?y.repeat(r.length):i===`*`?t?t+i+(a?M:``):M:t?e:`\\${e}`);return n===!0&&(i=f.unescape===!0?i.replace(/\\/g,``):i.replace(/\\+/g,e=>e.length%2==0?`\\\\`:e?`\\`:``)),i===e&&f.contains===!0?(N.output=e,N):(N.output=r.wrapOutput(i,N,t),N)}for(;!z();){if(R=V(),R===`\0`)continue;if(R===`\\`){let e=B();if(e===`/`&&f.bash!==!0||e===`.`||e===`;`)continue;if(!e){R+=`\\`,q({type:`text`,value:R});continue}let t=/^\\+/.exec(H()),n=0;if(t&&t[0].length>2&&(n=t[0].length,N.index+=n,n%2!=0&&(R+=`\\`)),f.unescape===!0?R=V():R+=V(),N.brackets===0){q({type:`text`,value:R});continue}}if(N.brackets>0&&(R!==`]`||L.value===`[`||L.value===`[^`)){if(f.posix!==!1&&R===`:`){let e=L.value.slice(1);if(e.includes(`[`)&&(L.posix=!0,e.includes(`:`))){let e=L.value.lastIndexOf(`[`),t=L.value.slice(0,e),n=a[L.value.slice(e+2)];if(n){L.value=t+n,N.backtrack=!0,V(),!h.output&&g.indexOf(L)===1&&(h.output=S);continue}}}(R===`[`&&B()!==`:`||R===`-`&&B()===`]`)&&(R=`\\${R}`),R===`]`&&(L.value===`[`||L.value===`[^`)&&(R=`\\${R}`),f.posix===!0&&R===`!`&&L.value===`[`&&(R=`^`),L.value+=R,W({value:R});continue}if(N.quotes===1&&R!==`"`){R=r.escapeRegex(R),L.value+=R,W({value:R});continue}if(R===`"`){N.quotes=N.quotes===1?0:1,f.keepQuotes===!0&&q({type:`text`,value:R});continue}if(R===`(`){G(`parens`),q({type:`paren`,value:R});continue}if(R===`)`){if(N.parens===0&&f.strictBrackets===!0)throw SyntaxError(u(`opening`,`(`));let e=P[P.length-1];if(e&&N.parens===e.parens+1){Y(P.pop());continue}q({type:`paren`,value:R,output:N.parens?`)`:`\\)`}),K(`parens`);continue}if(R===`[`){if(f.nobracket===!0||!H().includes(`]`)){if(f.nobracket!==!0&&f.strictBrackets===!0)throw SyntaxError(u(`closing`,`]`));R=`\\${R}`}else G(`brackets`);q({type:`bracket`,value:R});continue}if(R===`]`){if(f.nobracket===!0||L&&L.type===`bracket`&&L.value.length===1){q({type:`text`,value:R,output:`\\${R}`});continue}if(N.brackets===0){if(f.strictBrackets===!0)throw SyntaxError(u(`opening`,`[`));q({type:`text`,value:R,output:`\\${R}`});continue}K(`brackets`);let e=L.value.slice(1);if(L.posix!==!0&&e[0]===`^`&&!e.includes(`/`)&&(R=`/${R}`),L.value+=R,W({value:R}),f.literalBrackets===!1||r.hasRegexChars(e))continue;let t=r.escapeRegex(L.value);if(N.output=N.output.slice(0,-L.value.length),f.literalBrackets===!0){N.output+=t,L.value=t;continue}L.value=`(${ee}${t}|${L.value})`,N.output+=L.value;continue}if(R===`{`&&f.nobrace!==!0){G(`braces`);let e={type:`brace`,value:R,output:`(`,outputIndex:N.output.length,tokensIndex:N.tokens.length};F.push(e),q(e);continue}if(R===`}`){let e=F[F.length-1];if(f.nobrace===!0||!e){q({type:`text`,value:R,output:R});continue}let t=`)`;if(e.dots===!0){let e=g.slice(),n=[];for(let t=e.length-1;t>=0&&(g.pop(),e[t].type!==`brace`);t--)e[t].type!==`dots`&&n.unshift(e[t].value);t=l(n,f),N.backtrack=!0}if(e.comma!==!0&&e.dots!==!0){let n=N.output.slice(0,e.outputIndex),r=N.tokens.slice(e.tokensIndex);e.value=e.output=`\\{`,R=t=`\\}`,N.output=n;for(let e of r)N.output+=e.output||e.value}q({type:`brace`,value:R,output:t}),K(`braces`),F.pop();continue}if(R===`|`){P.length>0&&P[P.length-1].conditions++,q({type:`text`,value:R});continue}if(R===`,`){let e=R,t=F[F.length-1];t&&I[I.length-1]===`braces`&&(t.comma=!0,e=`|`),q({type:`comma`,value:R,output:e});continue}if(R===`/`){if(L.type===`dot`&&N.index===N.start+1){N.start=N.index+1,N.consumed=``,N.output=``,g.pop(),L=h;continue}q({type:`slash`,value:R,output:x});continue}if(R===`.`){if(N.braces>0&&L.type===`dot`){L.value===`.`&&(L.output=y);let e=F[F.length-1];L.type=`dots`,L.output+=R,L.value+=R,e.dots=!0;continue}if(N.braces+N.parens===0&&L.type!==`bos`&&L.type!==`slash`){q({type:`text`,value:R,output:y});continue}q({type:`dot`,value:R,output:y});continue}if(R===`?`){if(!(L&&L.value===`(`)&&f.noextglob!==!0&&B()===`(`&&B(2)!==`?`){J(`qmark`,R);continue}if(L&&L.type===`paren`){let e=B(),t=R;(L.value===`(`&&!/[!=<:]/.test(e)||e===`<`&&!/<([!=]|\w+>)/.test(H()))&&(t=`\\${R}`),q({type:`text`,value:R,output:t});continue}if(f.dot!==!0&&(L.type===`slash`||L.type===`bos`)){q({type:`qmark`,value:R,output:O});continue}q({type:`qmark`,value:R,output:D});continue}if(R===`!`){if(f.noextglob!==!0&&B()===`(`&&(B(2)!==`?`||!/[!=<:]/.test(B(3)))){J(`negate`,R);continue}if(f.nonegate!==!0&&N.index===0){re();continue}}if(R===`+`){if(f.noextglob!==!0&&B()===`(`&&B(2)!==`?`){J(`plus`,R);continue}if(L&&L.value===`(`||f.regex===!1){q({type:`plus`,value:R,output:b});continue}if(L&&(L.type===`bracket`||L.type===`paren`||L.type===`brace`)||N.parens>0){q({type:`plus`,value:R});continue}q({type:`plus`,value:b});continue}if(R===`@`){if(f.noextglob!==!0&&B()===`(`&&B(2)!==`?`){q({type:`at`,extglob:!0,value:R,output:``});continue}q({type:`text`,value:R});continue}if(R!==`*`){(R===`$`||R===`^`)&&(R=`\\${R}`);let e=o.exec(H());e&&(R+=e[0],N.index+=e[0].length),q({type:`text`,value:R});continue}if(L&&(L.type===`globstar`||L.star===!0)){L.type=`star`,L.star=!0,L.value+=R,L.output=M,N.backtrack=!0,N.globstar=!0,U(R);continue}let t=H();if(f.noextglob!==!0&&/^\([^?]/.test(t)){J(`star`,R);continue}if(L.type===`star`){if(f.noglobstar===!0){U(R);continue}let n=L.prev,r=n.prev,i=n.type===`slash`||n.type===`bos`,a=r&&(r.type===`star`||r.type===`globstar`);if(f.bash===!0&&(!i||t[0]&&t[0]!==`/`)){q({type:`star`,value:R,output:``});continue}let o=N.braces>0&&(n.type===`comma`||n.type===`brace`),s=P.length&&(n.type===`pipe`||n.type===`paren`);if(!i&&n.type!==`paren`&&!o&&!s){q({type:`star`,value:R,output:``});continue}for(;t.slice(0,3)===`/**`;){let n=e[N.index+4];if(n&&n!==`/`)break;t=t.slice(3),U(`/**`,3)}if(n.type===`bos`&&z()){L.type=`globstar`,L.value+=R,L.output=A(f),N.output=L.output,N.globstar=!0,U(R);continue}if(n.type===`slash`&&n.prev.type!==`bos`&&!a&&z()){N.output=N.output.slice(0,-(n.output+L.output).length),n.output=`(?:${n.output}`,L.type=`globstar`,L.output=A(f)+(f.strictSlashes?`)`:`|$)`),L.value+=R,N.globstar=!0,N.output+=n.output+L.output,U(R);continue}if(n.type===`slash`&&n.prev.type!==`bos`&&t[0]===`/`){let e=t[1]===void 0?``:`|$`;N.output=N.output.slice(0,-(n.output+L.output).length),n.output=`(?:${n.output}`,L.type=`globstar`,L.output=`${A(f)}${x}|${x}${e})`,L.value+=R,N.output+=n.output+L.output,N.globstar=!0,U(R+V()),q({type:`slash`,value:`/`,output:``});continue}if(n.type===`bos`&&t[0]===`/`){L.type=`globstar`,L.value+=R,L.output=`(?:^|${x}|${A(f)}${x})`,N.output=L.output,N.globstar=!0,U(R+V()),q({type:`slash`,value:`/`,output:``});continue}N.output=N.output.slice(0,-L.output.length),L.type=`globstar`,L.output=A(f),L.value+=R,N.output+=L.output,N.globstar=!0,U(R);continue}let n={type:`star`,value:R,output:M};if(f.bash===!0){n.output=`.*?`,(L.type===`bos`||L.type===`slash`)&&(n.output=j+n.output),q(n);continue}if(L&&(L.type===`bracket`||L.type===`paren`)&&f.regex===!0){n.output=R,q(n);continue}(N.index===N.start||L.type===`slash`||L.type===`dot`)&&(L.type===`dot`?(N.output+=T,L.output+=T):f.dot===!0?(N.output+=E,L.output+=E):(N.output+=j,L.output+=j),B()!==`*`&&(N.output+=S,L.output+=S)),q(n)}for(;N.brackets>0;){if(f.strictBrackets===!0)throw SyntaxError(u(`closing`,`]`));N.output=r.escapeLast(N.output,`[`),K(`brackets`)}for(;N.parens>0;){if(f.strictBrackets===!0)throw SyntaxError(u(`closing`,`)`));N.output=r.escapeLast(N.output,`(`),K(`parens`)}for(;N.braces>0;){if(f.strictBrackets===!0)throw SyntaxError(u(`closing`,`}`));N.output=r.escapeLast(N.output,`{`),K(`braces`)}if(f.strictSlashes!==!0&&(L.type===`star`||L.type===`bracket`)&&q({type:`maybe_slash`,value:``,output:`${x}?`}),N.backtrack===!0){N.output=``;for(let e of N.tokens)N.output+=e.output==null?e.value:e.output,e.suffix&&(N.output+=e.suffix)}return N};d.fastpaths=(e,t)=>{let a={...t},o=typeof a.maxLength==`number`?Math.min(i,a.maxLength):i,s=e.length;if(s>o)throw SyntaxError(`Input length: ${s}, exceeds maximum allowed length: ${o}`);e=c[e]||e;let{DOT_LITERAL:l,SLASH_LITERAL:u,ONE_CHAR:d,DOTS_SLASH:f,NO_DOT:p,NO_DOTS:m,NO_DOTS_SLASH:h,STAR:g,START_ANCHOR:ee}=n.globChars(a.windows),_=a.dot?m:p,v=a.dot?h:p,y=a.capture?``:`?:`,b={negated:!1,prefix:``},x=a.bash===!0?`.*?`:g;a.capture&&(x=`(${x})`);let S=e=>e.noglobstar===!0?x:`(${y}(?:(?!${ee}${e.dot?f:l}).)*?)`,C=e=>{switch(e){case`*`:return`${_}${d}${x}`;case`.*`:return`${l}${d}${x}`;case`*.*`:return`${_}${x}${l}${d}${x}`;case`*/*`:return`${_}${x}${u}${d}${v}${x}`;case`**`:return _+S(a);case`**/*`:return`(?:${_}${S(a)}${u})?${v}${d}${x}`;case`**/*.*`:return`(?:${_}${S(a)}${u})?${v}${x}${l}${d}${x}`;case`**/.*`:return`(?:${_}${S(a)}${u})?${l}${d}${x}`;default:{let t=/^(.*?)\.(\w+)$/.exec(e);if(!t)return;let n=C(t[1]);return n?n+l+t[2]:void 0}}},w=C(r.removePrefix(e,b));return w&&a.strictSlashes!==!0&&(w+=`${u}?`),w},t.exports=d})),_r=O(((e,t)=>{let n=hr(),r=gr(),i=mr(),a=pr(),o=e=>e&&typeof e==`object`&&!Array.isArray(e),s=(e,t,n=!1)=>{if(Array.isArray(e)){let r=e.map(e=>s(e,t,n));return e=>{for(let t of r){let n=t(e);if(n)return n}return!1}}let r=o(e)&&e.tokens&&e.input;if(e===``||typeof e!=`string`&&!r)throw TypeError(`Expected pattern to be a non-empty string`);let i=t||{},a=i.windows,c=r?s.compileRe(e,t):s.makeRe(e,t,!1,!0),l=c.state;delete c.state;let u=()=>!1;if(i.ignore){let e={...t,ignore:null,onMatch:null,onResult:null};u=s(i.ignore,e,n)}let d=(n,r=!1)=>{let{isMatch:o,match:d,output:f}=s.test(n,c,t,{glob:e,posix:a}),p={glob:e,state:l,regex:c,posix:a,input:n,output:f,match:d,isMatch:o};return typeof i.onResult==`function`&&i.onResult(p),o===!1?(p.isMatch=!1,r?p:!1):u(n)?(typeof i.onIgnore==`function`&&i.onIgnore(p),p.isMatch=!1,r?p:!1):(typeof i.onMatch==`function`&&i.onMatch(p),r?p:!0)};return n&&(d.state=l),d};s.test=(e,t,n,{glob:r,posix:a}={})=>{if(typeof e!=`string`)throw TypeError(`Expected input to be a string`);if(e===``)return{isMatch:!1,output:``};let o=n||{},c=o.format||(a?i.toPosixSlashes:null),l=e===r,u=l&&c?c(e):e;return l===!1&&(u=c?c(e):e,l=u===r),(l===!1||o.capture===!0)&&(l=o.matchBase===!0||o.basename===!0?s.matchBase(e,t,n,a):t.exec(u)),{isMatch:!!l,match:l,output:u}},s.matchBase=(e,t,n)=>(t instanceof RegExp?t:s.makeRe(t,n)).test(i.basename(e)),s.isMatch=(e,t,n)=>s(t,n)(e),s.parse=(e,t)=>Array.isArray(e)?e.map(e=>s.parse(e,t)):r(e,{...t,fastpaths:!1}),s.scan=(e,t)=>n(e,t),s.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let i=t||{},a=i.contains?``:`^`,o=i.contains?``:`$`,c=`${a}(?:${e.output})${o}`;e&&e.negated===!0&&(c=`^(?!${c}).*$`);let l=s.toRegex(c,t);return r===!0&&(l.state=e),l},s.makeRe=(e,t={},n=!1,i=!1)=>{if(!e||typeof e!=`string`)throw TypeError(`Expected a non-empty string`);let a={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]===`.`||e[0]===`*`)&&(a.output=r.fastpaths(e,t)),a.output||(a=r(e,t)),s.compileRe(a,t,n,i)},s.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?`i`:``))}catch(e){if(t&&t.debug===!0)throw e;return/$^/}},s.constants=a,t.exports=s})),vr=A(O(((e,t)=>{let n=_r(),r=mr();function i(e,t,i=!1){return t&&(t.windows===null||t.windows===void 0)&&(t={...t,windows:r.isWindows()}),n(e,t,i)}Object.assign(i,n),t.exports=i}))(),1);const yr=Array.isArray,br=process.platform===`win32`,xr=/^(\/?\.\.)+$/;function Sr(e,t={}){let n=e.length,r=Array(n),i=Array(n),a=!t.noglobstar;for(let a=0;a<n;a++){let n=Or(e[a]);r[a]=n;let o=n.length,s=Array(o);for(let e=0;e<o;e++)s[e]=(0,vr.default)(n[e],t);i[a]=s}return t=>{let n=t.split(`/`);if(n[0]===`..`&&xr.test(t))return!0;for(let t=0;t<e.length;t++){let e=r[t],o=i[t],s=n.length,c=Math.min(s,e.length),l=0;for(;l<c;){let t=e[l];if(t.includes(`/`))return!0;if(!o[l](n[l]))break;if(a&&t===`**`)return!0;l++}if(l===s)return!0}return!1}}const Cr=/^[A-Z]:\/$/i,wr=br?e=>Cr.test(e):e=>e===`/`;function Tr(e,t,n){if(e===t||t.startsWith(`${e}/`)){if(n){let t=wr(e)?e.length:e.length+1;return(e,n)=>e.slice(t,n?-1:void 0)||`.`}let r=t.slice(e.length+1);return r?(e,t)=>{if(e===`.`)return r;let n=`${r}/${e}`;return t?n.slice(0,-1):n}:(e,t)=>t&&e!==`.`?e.slice(0,-1):e}return n?t=>g.relative(e,t)||`.`:n=>g.relative(e,`${t}/${n}`)||`.`}function Er(e,t){if(t.startsWith(`${e}/`)){let n=t.slice(e.length+1);return e=>`${n}/${e}`}return n=>{let r=g.relative(e,`${t}/${n}`);return n.endsWith(`/`)&&r!==``?`${r}/`:r||`.`}}const Dr={parts:!0};function Or(e){let t=vr.default.scan(e,Dr);return t.parts?.length?t.parts:[e]}const kr=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,Ar=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,jr=br?e=>e.replace(Ar,`\\$&`):e=>e.replace(kr,`\\$&`);function Mr(e,t){if(t?.caseSensitiveMatch===!1)return!0;let n=vr.default.scan(e);return n.isGlob||n.negated}function Nr(...e){console.log(`[tinyglobby ${new Date().toLocaleTimeString(`es`)}]`,...e)}const Pr=/^(\/?\.\.)+/,Fr=/\\(?=[()[\]{}!*+?@|])/g,Ir=/\\/g;function Lr(e,t,n,r,i){let a=e;e.endsWith(`/`)&&(a=e.slice(0,-1)),!a.endsWith(`*`)&&t&&(a+=`/**`);let o=jr(n);a=f.isAbsolute(a.replace(Fr,``))?g.relative(o,a):g.normalize(a);let s=Pr.exec(a),c=Or(a);if(s?.[0]){let e=(s[0].length+1)/3,t=0,i=o.split(`/`);for(;t<e&&c[t+e]===i[i.length+t-e];)a=a.slice(0,(e-t-1)*3)+a.slice((e-t)*3+c[t+e].length+1)||`.`,t++;let l=g.join(n,s[0].slice(t*3));!l.startsWith(`.`)&&r.root.length>l.length&&(r.root=l,r.depthOffset=-e+t)}if(!i&&r.depthOffset>=0){r.commonPath??=c;let e=[],t=Math.min(r.commonPath.length,c.length);for(let n=0;n<t;n++){let t=c[n];if(t===`**`&&!c[n+1]){e.pop();break}if(t!==r.commonPath[n]||Mr(t)||n===c.length-1)break;e.push(t)}r.depthOffset=e.length,r.commonPath=e,r.root=e.length>0?g.join(n,...e):n}return a}function Rr({patterns:e=[`**/*`],ignore:t=[],expandDirectories:n=!0},r,i){typeof e==`string`&&(e=[e]),typeof t==`string`&&(t=[t]);let a=[],o=[];for(let e of t)e&&(e[0]!==`!`||e[1]===`(`)&&o.push(Lr(e,n,r,i,!0));for(let t of e)t&&(t[0]!==`!`||t[1]===`(`?a.push(Lr(t,n,r,i,!1)):(t[1]!==`!`||t[2]===`(`)&&o.push(Lr(t.slice(1),n,r,i,!0)));return{match:a,ignore:o}}function zr(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];e[n]=t(r)}return e}function Br(e){return e?e instanceof URL?y(e).replace(Ir,`/`):f.resolve(e).replace(Ir,`/`):process.cwd().replace(Ir,`/`)}function Vr(e,t={}){let n=process.env.TINYGLOBBY_DEBUG?{...t,debug:!0}:t,r=Br(n.cwd);if(n.debug&&Nr(`globbing with:`,{patterns:e,options:n,cwd:r}),Array.isArray(e)&&e.length===0)return[{sync:()=>[],withPromise:async()=>[]},!1];let i={root:r,commonPath:null,depthOffset:0},a=Rr({...n,patterns:e},r,i);n.debug&&Nr(`internal processing patterns:`,a);let o={dot:n.dot,nobrace:n.braceExpansion===!1,nocase:n.caseSensitiveMatch===!1,noextglob:n.extglob===!1,noglobstar:n.globstar===!1,posix:!0},s=(0,vr.default)(a.match,{...o,ignore:a.ignore}),c=(0,vr.default)(a.ignore,o),l=Sr(a.match,o),u=Tr(r,i.root,n.absolute),f=n.absolute?u:Tr(r,i.root,!0),p={filters:[n.debug?(e,t)=>{let n=u(e,t),r=s(n);return r&&Nr(`matched ${n}`),r}:(e,t)=>s(u(e,t))],exclude:n.debug?(e,t)=>{let n=f(t,!0),r=n!==`.`&&!l(n)||c(n);return Nr(r?`skipped ${t}`:`crawling ${t}`),r}:(e,t)=>{let n=f(t,!0);return n!==`.`&&!l(n)||c(n)},fs:n.fs?{readdir:n.fs.readdir||d.readdir,readdirSync:n.fs.readdirSync||d.readdirSync,realpath:n.fs.realpath||d.realpath,realpathSync:n.fs.realpathSync||d.realpathSync,stat:n.fs.stat||d.stat,statSync:n.fs.statSync||d.statSync}:void 0,pathSeparator:`/`,relativePaths:!0,resolveSymlinks:!0,signal:n.signal};n.deep!==void 0&&(p.maxDepth=Math.round(n.deep-i.depthOffset)),n.absolute&&(p.relativePaths=!1,p.resolvePaths=!0,p.includeBasePath=!0),n.followSymbolicLinks===!1&&(p.resolveSymlinks=!1,p.excludeSymlinks=!0),n.onlyDirectories?(p.excludeFiles=!0,p.includeDirs=!0):n.onlyFiles===!1&&(p.includeDirs=!0),i.root=i.root.replace(Ir,``);let m=i.root;n.debug&&Nr(`internal properties:`,i);let h=r!==m&&!n.absolute&&Er(r,i.root);return[new fr(p).crawl(m),h]}async function Hr(e,t){if(e&&t?.patterns)throw Error(`Cannot pass patterns as both an argument and an option`);let n=yr(e)||typeof e==`string`,r=n?t:e,[i,a]=Vr(n?e:e.patterns,r);return a?zr(await i.withPromise(),a):i.withPromise()}function Ur(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Wr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ur(Object(n),!0).forEach(function(t){Gr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ur(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Gr(e,t,n){return t=Kr(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Kr(e){var t=qr(e,`string`);return typeof t==`symbol`?t:String(t)}function qr(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Jr=Yr({});function Yr(e){return t.withOptions=t=>Yr(Wr(Wr({},e),t)),t;function t(t,...n){let r=typeof t==`string`?[t]:t.raw,{alignValues:i=!1,escapeSpecialCharacters:a=Array.isArray(t),trimWhitespace:o=!0}=e,s=``;for(let e=0;e<r.length;e++){let t=r[e];if(a&&(t=t.replace(/\\\n[ \t]*/g,``).replace(/\\`/g,"`").replace(/\\\$/g,`$`).replace(/\\\{/g,`{`)),s+=t,e<n.length){let t=i?Xr(n[e],s):n[e];s+=t}}let c=s.split(`
3
- `),l=null;for(let e of c){let t=e.match(/^(\s+)\S+/);if(t){let e=t[1].length;l=l?Math.min(l,e):e}}if(l!==null){let e=l;s=c.map(t=>t[0]===` `||t[0]===` `?t.slice(e):t).join(`
4
- `)}return o&&(s=s.trim()),a&&(s=s.replace(/\\n/g,`
5
- `).replace(/\\t/g,` `).replace(/\\r/g,`\r`).replace(/\\v/g,`\v`).replace(/\\b/g,`\b`).replace(/\\f/g,`\f`).replace(/\\0/g,`\0`).replace(/\\x([\da-fA-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/\\u\{([\da-fA-F]{1,6})\}/g,(e,t)=>String.fromCodePoint(parseInt(t,16))).replace(/\\u([\da-fA-F]{4})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))),typeof Bun<`u`&&(s=s.replace(/\\u(?:\{([\da-fA-F]{1,6})\}|([\da-fA-F]{4}))/g,(e,t,n)=>{let r=t??n??``;return String.fromCodePoint(parseInt(r,16))})),s}}function Xr(e,t){if(typeof e!=`string`||!e.includes(`
6
- `))return e;let n=t.slice(t.lastIndexOf(`
7
- `)+1).match(/^(\s+)/);if(n){let t=n[1];return e.replace(/\n/g,`\n${t}`)}return e}const Zr=Jr.withOptions({alignValues:!0});var Qr=class{async initProject(){await Ot(await this.getDependencies());let e=await this.#r();for(let t of e)await this.#i(t)}async createSlice(e,t){let{modelPath:n}=await this.#t(e,t),r=await this.#n(e.name,t),{componentPath:i}=await this.createSliceComponent(e,r),{indexPath:a}=await this.#i(t);return{modelPath:n,componentPath:i,indexPath:a}}async readSlice(e){return(await this.#e(e)).model}async updateSlice(e){let t=await this.#e(e.id),{modelPath:n}=await this.#t(e,t.library),{indexPath:r}=await this.#i(t.library);return{modelPath:n,indexPath:r}}async renameSlice(e){let t=await this.#e(e.id),n=await this.#n(e.name,t.library);await i(t.directory,n);let{modelPath:r}=await this.#t(e,t.library),{indexPath:a}=await this.#i(t.library);return{modelPath:r,indexPath:a}}async deleteSlice(e){let t=await this.#e(e);await a(t.directory,{recursive:!0});let{indexPath:n}=await this.#i(t.library);return{sliceDirectory:t.directory,indexPath:n}}async getSlices(e){let t=e?[e]:await this.#r(),n=[];for(let e of t){let t=new URL(`*/model.json`,e),i=Array.from(await Hr(s(t),{absolute:!0}),e=>c(e)),a=await Promise.all(i.map(async t=>{let n=new URL(`.`,t),i=await r(t,`utf8`);return{library:e,directory:n,model:JSON.parse(i)}}));n.push(...a)}return n.sort((e,t)=>e.model.id.toLowerCase().localeCompare(t.model.id.toLowerCase()))}async getDefaultSliceLibrary(){return(await this.#r())[0]}async createCustomType(e){let{modelPath:t}=await this.#a(e);return{modelPath:t}}async readCustomType(e){let t=await this.#o(e),n=await r(new URL(`index.json`,t),`utf8`);return JSON.parse(n)}async updateCustomType(e){let{modelPath:t}=await this.#a(e);return{modelPath:t}}async renameCustomType(e){await i(await this.#o(e.id),await this.#o(e.id));let{modelPath:t}=await this.#a(e);return{modelPath:t}}async deleteCustomType(e){let t=await this.#o(e);return await a(t,{recursive:!0}),{customTypeDirectory:t}}async getCustomTypes(){let e=await this.#s(),t=new URL(`*/index.json`,e),n=Array.from(await Hr(s(t),{absolute:!0}),e=>c(e));return(await Promise.all(n.map(async e=>{let t=new URL(`.`,e),n=await r(e,`utf8`);return{directory:t,model:JSON.parse(n)}}))).sort((e,t)=>e.model.id.toLowerCase().localeCompare(t.model.id.toLowerCase()))}async getProjectRoot(){let e=await mt(`package.json`);if(!e)throw Error(`No package.json found`);return new URL(`./`,e)}async checkIsTypeScriptProject(){let e=await this.getProjectRoot();return await ht(new URL(`tsconfig.json`,e))}async getJsFileExtension(){return await this.checkIsTypeScriptProject()?`ts`:`js`}async#e(e){let t=(await this.getSlices()).find(t=>t.model.id===e);if(!t)throw Error(`No slice found with ID: ${e}`);return t}async#t(e,t){let n=await this.#n(e.name,t),r=new URL(`model.json`,n);return await gt(r,this.#c(e)),{modelPath:r}}async#n(e,t){let n=tn(e);return pt(new URL(n,t))}async#r(){let e=await this.getProjectRoot(),t=(await It()).libraries??[];return t.length<1?[await this.getDefaultSliceLibraryPath(e)]:t.map(t=>{let n=t.replace(/^\//,``);return pt(new URL(n,e))})}async#i(e){let t=await this.getSlices(e),n=await this.generateSliceLibraryIndexContents(t),r=`index.${await this.getJsFileExtension()}`,i=new URL(r,e);return await gt(i,n),{indexPath:i}}async generateSliceLibraryIndexContents(e){let t=e.map(e=>{let t=tn(e.model.name),n=l(s(e.library),s(e.directory));return`import ${t} from "${this.getSliceImportPath(n)}";`}),n=e.map(e=>{let t=tn(e.model.name);return`${e.model.id}: ${t}`});return Zr`
8
- // Code generated by Prismic. DO NOT EDIT.
9
-
10
- ${t.join(`
11
- `)}
12
-
13
- export const components = {
14
- ${n.join(`,
15
- `)}
16
- };
17
- `}async#a(e){let t=await this.#o(e.id),n=new URL(`index.json`,t);return await gt(n,this.#c(e)),{modelPath:n}}async#o(e){let t=await this.#s(),n=e;return pt(new URL(n,t))}async#s(){let e=await this.getProjectRoot();return new URL(`customtypes/`,e)}#c(e){return _t(e)}};const $r=rt({dependencies:st(at(Q(),Q())),devDependencies:st(at(Q(),Q()))});async function ei(){let e=await ni();if(!e)throw new ti;return e}var ti=class extends Error{message=`No supported framework found (Next.js, Nuxt, or SvelteKit required)`};async function ni(){switch(await ri()){case`next`:{let{NextJsFramework:e}=await import(`./nextjs-2qjzSaQI.mjs`);return new e}case`nuxt`:{let{NuxtFramework:e}=await import(`./nuxt-DKsgbqpV.mjs`);return new e}case`sveltekit`:{let{SvelteKitFramework:e}=await import(`./sveltekit-BMDXAfYz.mjs`);return new e}default:return}}async function ri(){let e=await mt(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={},devDependencies:i={}}=ue($r,JSON.parse(t)),a={...n,...i};if(`next`in a)return`next`;if(`nuxt`in a)return`nuxt`;if(`@sveltejs/kit`in a)return`sveltekit`}catch{}}export{ue as A,tt as C,Q as D,st as E,j as F,A as I,D as M,k as N,ft as O,ne as P,lt as S,rt as T,kt as _,Zr as a,gt as b,Lt as c,Pt as d,Gt as f,Rt as g,Ft as h,ei as i,O as j,qe as k,Bt as l,Ut as m,ti as n,tn as o,It as p,ni as r,Wt as s,Qr as t,Ht as u,_t as v,Qe as w,pt as x,ht as y};