@powerhousedao/shared 6.2.3-dev.30 → 6.2.3-dev.32

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 (53) hide show
  1. package/dist/clis/args/{connect-B6xK4YI_.mjs → connect-BG3HkYBk.mjs} +2 -2
  2. package/dist/clis/args/connect-BG3HkYBk.mjs.map +1 -0
  3. package/dist/clis/args/connect.mjs +1 -1
  4. package/dist/clis/args/{generate-10dooJ-D.mjs → generate-BOItUNvP.mjs} +2 -7
  5. package/dist/clis/args/generate-BOItUNvP.mjs.map +1 -0
  6. package/dist/clis/args/{generate-DmgiCzuf.d.mts → generate-BPBBLeUD.d.mts} +1 -4
  7. package/dist/clis/args/generate-BPBBLeUD.d.mts.map +1 -0
  8. package/dist/clis/args/generate.d.mts +1 -1
  9. package/dist/clis/args/generate.mjs +1 -1
  10. package/dist/clis/args/{help-yRmplJjW.mjs → help-DS1NlcJQ.mjs} +3 -3
  11. package/dist/clis/args/{help-yRmplJjW.mjs.map → help-DS1NlcJQ.mjs.map} +1 -1
  12. package/dist/clis/args/help.mjs +1 -1
  13. package/dist/clis/args/index.d.mts +1 -1
  14. package/dist/clis/args/index.mjs +3 -3
  15. package/dist/clis/build-pieces.d.mts +4 -5
  16. package/dist/clis/build-pieces.d.mts.map +1 -1
  17. package/dist/clis/build-pieces.mjs +18 -11
  18. package/dist/clis/build-pieces.mjs.map +1 -1
  19. package/dist/clis/constants.d.mts +1 -1
  20. package/dist/clis/index.d.mts +40 -7
  21. package/dist/clis/index.d.mts.map +1 -1
  22. package/dist/clis/index.mjs +30 -10
  23. package/dist/clis/index.mjs.map +1 -1
  24. package/dist/clis/{types-CMFHKrgv.d.mts → types-NHa-Kayi.d.mts} +12 -1
  25. package/dist/clis/{types-CMFHKrgv.d.mts.map → types-NHa-Kayi.d.mts.map} +1 -1
  26. package/dist/{config-loader-SYDWHtqk.js → config-loader-3oqy1hN4.js} +17 -4
  27. package/dist/config-loader-3oqy1hN4.js.map +1 -0
  28. package/dist/connect/config-loader.d.ts +8 -1
  29. package/dist/connect/config-loader.d.ts.map +1 -1
  30. package/dist/connect/config-loader.js +2 -2
  31. package/dist/connect/index.d.ts +30 -5
  32. package/dist/connect/index.d.ts.map +1 -1
  33. package/dist/connect/index.js +29 -4
  34. package/dist/connect/index.js.map +1 -1
  35. package/dist/document-drive/index.d.ts +4 -4
  36. package/dist/document-model/index.d.ts +2 -2
  37. package/dist/{index-CDDyUSHE.d.ts → index-BHdnKfWp.d.ts} +2 -2
  38. package/dist/{index-CDDyUSHE.d.ts.map → index-BHdnKfWp.d.ts.map} +1 -1
  39. package/dist/{index-D0JljlgO.d.ts → index-skEwkUNm.d.ts} +2 -2
  40. package/dist/{index-D0JljlgO.d.ts.map → index-skEwkUNm.d.ts.map} +1 -1
  41. package/dist/index.d.ts +4 -4
  42. package/dist/processors/index.d.ts +1 -1
  43. package/dist/registry/index.d.ts +2 -2
  44. package/dist/registry/manifest-slim.d.ts +2 -2
  45. package/dist/{types-xLPOHE23.d.ts → types-Dr6-2rMp.d.ts} +13 -2
  46. package/dist/{types-xLPOHE23.d.ts.map → types-Dr6-2rMp.d.ts.map} +1 -1
  47. package/dist/{types-VDHUeQnm.d.ts → types-DvE2gUGf.d.ts} +3 -3
  48. package/dist/{types-VDHUeQnm.d.ts.map → types-DvE2gUGf.d.ts.map} +1 -1
  49. package/package.json +1 -1
  50. package/dist/clis/args/connect-B6xK4YI_.mjs.map +0 -1
  51. package/dist/clis/args/generate-10dooJ-D.mjs.map +0 -1
  52. package/dist/clis/args/generate-DmgiCzuf.d.mts.map +0 -1
  53. package/dist/config-loader-SYDWHtqk.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../connect/dynamic-base.ts","../../connect/env-config.ts","../../connect/pwa-config.ts","../../connect/pwa-manifest.ts","../../connect/schema-fragments.ts","../../connect/shared-deps.ts"],"sourcesContent":["/**\n * The base a dynamic-base Connect build is compiled against. The build emits\n * this literal wherever a base-relative URL would go, and the serving layer\n * (the dynamic-base vite plugin at build time, the connect proxy at serve\n * time) rewrites it to the base the app is actually deployed under.\n *\n * It lives here, in the browser-safe shared package, rather than in\n * `@powerhousedao/builder-tools`, because both the node-only build toolchain\n * and Connect's own browser code need it. Importing builder-tools from app\n * code pulls the whole build toolchain (and its node-only `read-pkg`\n * dependency) into the browser graph.\n */\nexport const DYNAMIC_BASE_PLACEHOLDER = \"/__PH_DYNAMIC_BASE__/\";\n","import { z } from \"zod\";\n\n/**\n * Coerces string values to boolean.\n * Accepts: \"true\", \"false\", true, false\n */\nconst booleanString = z\n .union([z.boolean(), z.enum([\"true\", \"false\"])])\n .transform((val) => {\n if (typeof val === \"boolean\") return val;\n return val === \"true\";\n });\n\n// ============================================================================\n// Build-time Environment Variables\n// ============================================================================\n\n/**\n * Build-time configuration schema\n */\nconst buildEnvSchema = z.object({\n /**\n * Comma-separated list of package names to load\n * @example \"package1,package2\"\n */\n PH_PACKAGES: z.string().optional(),\n\n /**\n * Path to local package to load during development\n */\n PH_LOCAL_PACKAGE: z.string().optional(),\n\n /**\n * Sentry authentication token for uploading source maps\n */\n PH_SENTRY_AUTH_TOKEN: z.string().optional(),\n\n /**\n * Sentry organization slug\n */\n PH_SENTRY_ORG: z.string().optional(),\n\n /**\n * Sentry project slug\n */\n PH_SENTRY_PROJECT: z.string().optional(),\n});\n\n// ============================================================================\n// Application Configuration (build metadata only)\n// ============================================================================\n\n/**\n * Connect runtime values (anything in `PHConnectRuntimeConfig`) are NOT\n * settable from env vars. They live in `powerhouse.config.json` and are\n * overridden via `ph connect build --<field>` or `ph connect config\n * --<field>`.\n *\n * What stays env-driven below is non-runtime: build metadata, Sentry\n * credentials, analytics processor toggles, etc.\n */\nconst appConfigSchema = z.object({\n /**\n * Application version number (build metadata stamp)\n * @default \"unknown\"\n */\n PH_CONNECT_VERSION: z.string().default(\"unknown\"),\n\n /**\n * CLI version number (build metadata stamp)\n */\n PH_CONNECT_CLI_VERSION: z.string().optional(),\n});\n\n// ============================================================================\n// Analytics Processor Configuration\n// ============================================================================\n\n/**\n * Analytics processor configuration schema. These are non-runtime feature\n * toggles for the analytics subsystem — they don't live in the runtime\n * schema and stay env-driven.\n */\nconst processorsConfigSchema = z.object({\n /**\n * Enable diff analytics tracking\n * @default false\n */\n PH_CONNECT_DIFF_ANALYTICS_ENABLED: booleanString.default(false),\n\n /**\n * Enable drive analytics tracking\n * @default true\n */\n PH_CONNECT_DRIVE_ANALYTICS_ENABLED: booleanString.default(true),\n\n /**\n * Enable external analytics processors\n * @default true\n */\n PH_CONNECT_EXTERNAL_ANALYTICS_PROCESSORS_ENABLED: booleanString.default(true),\n});\n\n// ============================================================================\n// OpenPanel Configuration\n// ============================================================================\n\n/**\n * OpenPanel analytics configuration schema\n */\nconst openPanelConfigSchema = z.object({\n /**\n * OpenPanel client ID. When unset, the OpenPanel subsystem is a no-op.\n */\n PH_CONNECT_OPENPANEL_CLIENT_ID: z.string().optional(),\n\n /**\n * OpenPanel API URL override. Defaults to the OpenPanel cloud when unset.\n */\n PH_CONNECT_OPENPANEL_API_URL: z.string().optional(),\n\n /**\n * Track UI events via the useOpenPanel() hook\n * @default true\n */\n PH_CONNECT_OPENPANEL_TRACK_UI_EVENTS: booleanString.default(true),\n\n /**\n * Track document operations via the OpenPanel processor\n * @default true\n */\n PH_CONNECT_OPENPANEL_TRACK_OPERATIONS: booleanString.default(true),\n});\n\n// ============================================================================\n// Combined Schemas\n// ============================================================================\n\n/**\n * Complete runtime environment schema (all PH_CONNECT_* vars). Only\n * build-metadata + analytics-processor toggles live here; all Connect\n * runtime config lives in `powerhouse.config.json`.\n */\nexport const runtimeEnvSchema = appConfigSchema\n .extend(processorsConfigSchema.shape)\n .extend(openPanelConfigSchema.shape);\n\n/**\n * Complete environment schema (build + runtime)\n */\nexport const connectEnvSchema = buildEnvSchema.extend(runtimeEnvSchema.shape);\n\n/**\n * Inferred TypeScript types from schemas\n */\nexport type ConnectBuildEnv = z.infer<typeof buildEnvSchema>;\nexport type ConnectRuntimeEnv = z.infer<typeof runtimeEnvSchema>;\nexport type ConnectEnv = z.infer<typeof connectEnvSchema>;\n\n// ============================================================================\n// Environment Loading Functions\n// ============================================================================\n\n/**\n * Options for loading environment variables\n */\nexport interface LoadEnvOptions {\n /**\n * Environment variables from process.env (highest priority)\n */\n processEnv?: Record<string, string | undefined>;\n /**\n * Environment variables from .env file (lowest priority)\n */\n fileEnv?: Record<string, string | undefined>;\n}\n\n/**\n * Internal helper to merge environment sources with priority.\n * Validates each value and falls back to next priority if invalid.\n */\nfunction mergeEnvSources(\n options: LoadEnvOptions,\n keys: Set<string>,\n schema: z.ZodObject<Record<string, z.ZodTypeAny>>,\n): Record<string, unknown> {\n const { processEnv = {}, fileEnv = {} } = options;\n const merged: Record<string, unknown> = {};\n\n // Apply priority: fileEnv < processEnv\n for (const key of keys) {\n const sources = [\n { name: \"process.env\", value: processEnv[key] },\n { name: \"fileEnv\", value: fileEnv[key] },\n ];\n\n // Try each source in priority order\n for (const source of sources) {\n const value = source.value;\n if (value === undefined || value === \"\") continue;\n\n // Try to validate just this field\n try {\n const fieldSchema = schema.shape[key];\n if (fieldSchema) {\n fieldSchema.parse(value);\n merged[key] = value;\n break; // Successfully validated, use this value\n }\n // No schema for this key, accept it\n console.warn(`Unknown environment variable: '${key}'`);\n merged[key] = value;\n break;\n } catch {\n // Validation failed, log warning and try next source\n const valueStr =\n value === null\n ? \"null\"\n : typeof value === \"object\"\n ? JSON.stringify(value)\n : (value as string);\n console.warn(\n `Invalid value for ${key} from ${source.name}: ${valueStr}. Trying next source.`,\n );\n }\n }\n }\n\n return merged;\n}\n\n/**\n * Loads and validates environment variables with priority:\n * 1. process.env (highest)\n * 2. fileEnv\n * 3. defaults from schema (lowest)\n *\n * @param options - Environment sources in priority order\n * @returns Validated and typed environment configuration\n */\nexport function loadConnectEnv(options: LoadEnvOptions = {}): ConnectEnv {\n const allKeys = new Set([\n ...Object.keys(buildEnvSchema.shape),\n ...Object.keys(runtimeEnvSchema.shape),\n ]);\n\n const merged = mergeEnvSources(options, allKeys, connectEnvSchema);\n return connectEnvSchema.parse(merged);\n}\n\n/**\n * Loads only runtime environment variables (build metadata + Sentry +\n * analytics-processor toggles — everything in the Connect runtime schema\n * is sourced from powerhouse.config.json, not env).\n *\n * @param options - Environment sources in priority order\n * @returns Validated runtime environment configuration\n */\nexport function loadRuntimeEnv(\n options: LoadEnvOptions = {},\n): ConnectRuntimeEnv {\n const allKeys = new Set(Object.keys(runtimeEnvSchema.shape));\n const merged = mergeEnvSources(options, allKeys, runtimeEnvSchema);\n return runtimeEnvSchema.parse(merged);\n}\n\n/**\n * Safely sets Connect environment variables with validation.\n * Invalid values will log a warning and be skipped.\n *\n * @param values - Type-safe object with key-value pairs to set\n *\n * @example\n * ```ts\n * setConnectEnv({\n * PH_CONNECT_VERSION: \"1.2.3\",\n * PH_CONNECT_SENTRY_DSN: \"https://…\",\n * });\n * ```\n */\nexport function setConnectEnv(values: Partial<ConnectEnv>): void {\n for (const [key, value] of Object.entries(values)) {\n // Check if key exists in schema\n const fieldSchema =\n connectEnvSchema.shape[key as keyof typeof connectEnvSchema.shape];\n\n if (!fieldSchema) {\n console.warn(\n `Unknown environment variable: ${key}. Variable not set. Valid keys: ${Object.keys(connectEnvSchema.shape).join(\", \")}`,\n );\n continue;\n }\n\n try {\n // Validate the value\n fieldSchema.parse(value);\n\n // Set the value (convert to string for process.env compatibility)\n process.env[key] = String(value);\n } catch (error) {\n console.warn(\n `Invalid value for ${key}: ${String(value)}. Validation failed.`,\n error,\n );\n }\n }\n}\n\n/**\n * Normalizes a base path to ensure it:\n * - Starts with a forward slash (/)\n * - Ends with a forward slash (/)\n * - Has no relative path prefix (.)\n *\n * @param basePath - The base path to normalize\n * @returns The normalized base path\n *\n * @example\n * normalizeBasePath('/app') // '/app/'\n * normalizeBasePath('./app/') // '/app/'\n * normalizeBasePath('app') // '/app/'\n * normalizeBasePath('/') // '/'\n * normalizeBasePath('') // '/'\n */\nexport function normalizeBasePath(basePath: string): string {\n if (!basePath) {\n return \"/\";\n }\n\n let normalized = basePath;\n\n // Remove relative path prefix\n if (normalized.startsWith(\".\")) {\n normalized = normalized.slice(1);\n }\n\n // Ensure it starts with a forward slash\n if (!normalized.startsWith(\"/\")) {\n normalized = `/${normalized}`;\n }\n\n // Ensure it ends with a forward slash\n if (!normalized.endsWith(\"/\")) {\n normalized = `${normalized}/`;\n }\n\n return normalized;\n}\n\n/**\n * Base storage namespace for a Connect instance served at the root of an\n * origin. Kept as a literal so root deployments resolve to a byte-identical\n * value with no migration.\n */\nexport const ROOT_STORAGE_NAMESPACE = \"reactor\";\n\n/**\n * Derives the origin-scoped storage namespace from a Connect base path.\n *\n * Connect instances served under different path prefixes of the same origin\n * (e.g. behind a reverse proxy) otherwise share all origin-scoped browser\n * storage (PGlite data dirs, IndexedDB). This produces a deterministic,\n * collision-free namespace per distinct prefix that is valid as an\n * IndexedDB database name.\n *\n * - root base path (\"/\" or unset) -> \"reactor\" (byte-identical to the legacy\n * key, so existing root deployments keep their data with zero migration)\n * - any non-root base path -> \"reactor--<slug>\", e.g.\n * \"/reactor-project/vetra-studio/\" -> \"reactor--reactor-project-vetra-studio\"\n *\n * @param basePath - The Connect base path (env.PH_CONNECT_BASE_PATH ||\n * import.meta.env.BASE_URL); normalized internally.\n * @returns The storage namespace.\n *\n * @example\n * getStorageNamespace('/') // 'reactor'\n * getStorageNamespace('/reactor-project/vetra-studio/') // 'reactor--reactor-project-vetra-studio'\n */\nexport function getStorageNamespace(basePath: string): string {\n const normalized = normalizeBasePath(basePath);\n if (normalized === \"/\") {\n return ROOT_STORAGE_NAMESPACE;\n }\n const slug = normalized\n .slice(1, -1)\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n // A non-root base path whose slug normalizes to nothing (e.g. \"/-/\") must\n // not collapse into the root namespace and share its storage.\n return `${ROOT_STORAGE_NAMESPACE}--${slug || \"default\"}`;\n}\n","// Merging of Connect PWA override fragments.\n//\n// PWA config comes from several layers — Connect's hardcoded defaults, each\n// build-time-known package's `pwa` fragment, and the project's `connect.pwa`\n// block. A naive deep-merge is wrong here: runtime-caching rules and precache\n// globs are ADDITIVE (a later layer must not drop an earlier layer's offline\n// coverage), and the precache size ceiling must be the MAX so no contributor\n// can silently shrink another's limit. This module encodes those per-field\n// strategies: `mergePwaConfig(contributions)` folds an ordered list of\n// serialisable `PHConnectPwa` fragments (lowest precedence first) into one\n// effective fragment, warning when multiple packages set the same manifest\n// scalar to different values.\n//\n// Laying the effective fragment over Connect's hardcoded VitePWA base happens\n// in builder-tools (`connect-utils/vite-plugins/pwa-overrides.ts`), where\n// vite-plugin-pwa's manifest types are available.\n\nimport type {\n PHConnectPwa,\n PHConnectPwaManifest,\n PHConnectPwaUrlPattern,\n} from \"../clis/types.js\";\nimport { deepMerge } from \"./config-loader.js\";\n\n// Re-exported so the PWA override types are reachable from the same\n// `@powerhousedao/shared/connect` entry as the merge helpers that consume them.\nexport type {\n PHConnectPwa,\n PHConnectPwaCacheStrategy,\n PHConnectPwaFileHandler,\n PHConnectPwaIcon,\n PHConnectPwaManifest,\n PHConnectPwaRuntimeCaching,\n PHConnectPwaUrlPattern,\n} from \"../clis/types.js\";\n\n/** A labelled PWA fragment, so merge diagnostics can name the contributor. */\nexport type PwaContribution = {\n /** Human-readable origin (package name, or the project config file). */\n source: string;\n config: PHConnectPwa;\n};\n\n// Manifest scalar fields — the ones where \"two layers set it\" is a genuine\n// conflict (as opposed to the additive arrays, which never conflict).\nconst MANIFEST_SCALAR_KEYS: readonly (keyof PHConnectPwaManifest)[] = [\n \"name\",\n \"short_name\",\n \"description\",\n \"theme_color\",\n \"background_color\",\n \"display\",\n \"start_url\",\n \"scope\",\n \"launch_handler\",\n];\n\n// Manifest fields merged additively (concatenated/unioned across every layer),\n// never as scalar conflicts. Kept out of the deepMerge path, which replaces\n// arrays wholesale and would drop earlier contributions. `categories` is\n// derived (from the manifest `category` field) but merges the same additive way.\nconst ADDITIVE_MANIFEST_KEYS = new Set<keyof PHConnectPwaManifest>([\n \"icons\",\n \"file_handlers\",\n \"categories\",\n]);\n\n// Structural icon shape shared by PHConnectPwaIcon and vite-plugin-pwa's\n// IconResource (whose `purpose` may also be an array of purposes).\ntype IconLike = {\n src: string;\n sizes?: string;\n purpose?: string | readonly string[];\n};\n\nfunction iconKey(icon: IconLike): string {\n const purpose =\n typeof icon.purpose === \"string\"\n ? icon.purpose\n : (icon.purpose?.join(\",\") ?? \"\");\n return `${icon.src}|${icon.sizes ?? \"\"}|${purpose}`;\n}\n\n/** Concatenate, keeping the first occurrence per `key`. */\nfunction dedupeBy<T>(items: T[], key: (item: T) => string): T[] {\n const seen = new Set<string>();\n const result: T[] = [];\n for (const item of items) {\n const k = key(item);\n if (seen.has(k)) continue;\n seen.add(k);\n result.push(item);\n }\n return result;\n}\n\n/** Concatenate icons, keeping the first occurrence of each (src,sizes,purpose). */\nexport function dedupeIcons<T extends IconLike>(icons: T[]): T[] {\n return dedupeBy(icons, iconKey);\n}\n\n/** `JSON.stringify` with object keys sorted recursively, so two structurally\n * equal values always serialise identically (accept-map key order etc.). */\nfunction stableStringify(value: unknown): string {\n if (Array.isArray(value)) {\n return `[${value.map(stableStringify).join(\",\")}]`;\n }\n if (value !== null && typeof value === \"object\") {\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`);\n return `{${entries.join(\",\")}}`;\n }\n return JSON.stringify(value);\n}\n\n/**\n * Concatenate file handlers, keeping the first occurrence of each entry.\n * Deduped on the WHOLE entry (canonical JSON) rather than any single field:\n * every handler shares Connect's fixed action, and two handlers accepting\n * different file types are both real contributions — only the exact same\n * fragment arriving via two layers is a duplicate. Structural, so it also\n * works on the vite-plugin-pwa handler shape in builder-tools.\n */\nexport function dedupeFileHandlers<T extends object>(handlers: T[]): T[] {\n return dedupeBy(handlers, stableStringify);\n}\n\n/** Fold a manifest's top-level `category` string into a PWA config as a\n * `categories: [category]` entry. PWA `categories` is DERIVED from the\n * `category` field of every contributing `powerhouse.manifest.json` (never\n * authored under `pwa`); `mergePwaConfig`/`mergeManifest` then union them\n * across contributors. No-op when there is no usable category. */\nexport function withInferredCategory(\n config: PHConnectPwa,\n category: unknown,\n): PHConnectPwa {\n if (typeof category !== \"string\" || !category) return config;\n return {\n ...config,\n manifest: { ...config.manifest, categories: [category] },\n };\n}\n\n/** Order-preserving string union (used for the precache glob lists). */\nexport function unionStrings(\n base: string[] | undefined,\n extra: string[],\n): string[] {\n const result = [...(base ?? [])];\n for (const item of extra) if (!result.includes(item)) result.push(item);\n return result;\n}\n\nfunction patternKey(pattern: PHConnectPwaUrlPattern): string {\n return typeof pattern === \"string\"\n ? `s:${pattern}`\n : `r:${pattern.source}:${pattern.flags ?? \"\"}`;\n}\n\nfunction unionPatterns(\n base: PHConnectPwaUrlPattern[] | undefined,\n extra: PHConnectPwaUrlPattern[],\n): PHConnectPwaUrlPattern[] {\n const result = [...(base ?? [])];\n const seen = new Set(result.map(patternKey));\n for (const pattern of extra) {\n const key = patternKey(pattern);\n if (seen.has(key)) continue;\n seen.add(key);\n result.push(pattern);\n }\n return result;\n}\n\n/** Merge one fragment into `target` in place, applying the per-field\n * strategies (manifest scalars deep-merge and win; icons/file_handlers/globs/\n * rules/denylist are additive; size ceiling takes the max). */\nfunction mergeInto(target: PHConnectPwa, config: PHConnectPwa): void {\n if (config.manifest) {\n // The additive arrays are pulled out of the deepMerge path: deepMerge\n // replaces arrays wholesale, which would drop earlier contributions.\n const { icons, file_handlers, categories, ...scalars } = config.manifest;\n if (Object.keys(scalars).length > 0) {\n target.manifest = deepMerge(\n target.manifest ?? {},\n scalars as PHConnectPwaManifest,\n );\n }\n if (icons?.length) {\n target.manifest = {\n ...(target.manifest ?? {}),\n icons: dedupeIcons([...(target.manifest?.icons ?? []), ...icons]),\n };\n }\n if (file_handlers?.length) {\n target.manifest = {\n ...(target.manifest ?? {}),\n file_handlers: dedupeFileHandlers([\n ...(target.manifest?.file_handlers ?? []),\n ...file_handlers,\n ]),\n };\n }\n if (categories?.length) {\n target.manifest = {\n ...(target.manifest ?? {}),\n categories: unionStrings(target.manifest?.categories, categories),\n };\n }\n }\n if (config.globPatterns?.length) {\n target.globPatterns = unionStrings(\n target.globPatterns,\n config.globPatterns,\n );\n }\n if (config.globIgnores?.length) {\n target.globIgnores = unionStrings(target.globIgnores, config.globIgnores);\n }\n if (config.runtimeCaching?.length) {\n target.runtimeCaching = [\n ...(target.runtimeCaching ?? []),\n ...config.runtimeCaching,\n ];\n }\n if (config.navigateFallbackDenylist?.length) {\n target.navigateFallbackDenylist = unionPatterns(\n target.navigateFallbackDenylist,\n config.navigateFallbackDenylist,\n );\n }\n if (typeof config.maximumFileSizeToCacheInBytes === \"number\") {\n target.maximumFileSizeToCacheInBytes = Math.max(\n target.maximumFileSizeToCacheInBytes ?? 0,\n config.maximumFileSizeToCacheInBytes,\n );\n }\n}\n\n/**\n * Fold the build-time-known package PWA fragments and the project's\n * `connect.pwa` block into one effective fragment. Precedence is\n * `packageContributions (in order) < projectConfig` — the project config wins\n * scalar fields, while arrays (`icons`, globs, `runtimeCaching`,\n * `navigateFallbackDenylist`) are additive across every layer and the size\n * ceiling takes the max.\n *\n * `onWarn` fires when two or more PACKAGES set the same manifest scalar to\n * different values and the project config doesn't settle it — the winner is\n * otherwise decided silently by package load order. The operator resolves it\n * by setting that field in `connect.pwa`, which both wins and silences the\n * warning.\n */\nexport function mergePwaConfig(\n packageContributions: PwaContribution[],\n projectConfig?: PHConnectPwa,\n onWarn: (message: string) => void = () => {},\n): PHConnectPwa {\n const merged: PHConnectPwa = {};\n // Which packages set each manifest scalar, and to what (for the conflict\n // warning). The project config is deliberately excluded — it is the\n // authority, not a conflicting sibling.\n const packageScalarSetters: Partial<\n Record<string, { source: string; value: unknown }[]>\n > = {};\n\n for (const { source, config } of packageContributions) {\n mergeInto(merged, config);\n for (const [key, value] of Object.entries(config.manifest ?? {})) {\n if (ADDITIVE_MANIFEST_KEYS.has(key as keyof PHConnectPwaManifest)) {\n continue;\n }\n (packageScalarSetters[key] ??= []).push({ source, value });\n }\n }\n if (projectConfig) mergeInto(merged, projectConfig);\n\n const projectManifest = projectConfig?.manifest ?? {};\n for (const key of MANIFEST_SCALAR_KEYS) {\n const setters = packageScalarSetters[key];\n const projectSettles = projectManifest[key] !== undefined;\n if (!setters || setters.length < 2 || projectSettles) continue;\n // Same value from every package is agreement, not a conflict. Compared\n // via stableStringify, not by identity — launch_handler is object-valued,\n // and two packages sending equal objects (in any key order) must not read\n // as a conflict.\n const distinctValues = new Set(\n setters.map((s) => stableStringify(s.value)),\n );\n if (distinctValues.size < 2) continue;\n const sources = setters.map((s) => s.source);\n onWarn(\n `PWA config: manifest.${key} set by multiple packages (${sources.join(\n \", \",\n )}); '${sources[sources.length - 1]}' wins by load order. Set connect.pwa.manifest.${key} in the project config to make the winner explicit.`,\n );\n }\n\n return merged;\n}\n\n/** A serialisable URL pattern as Workbox consumes it: strings pass through\n * verbatim, `{ source, flags }` is rebuilt into a RegExp. */\nexport function toRegExpOrString(\n pattern: PHConnectPwaUrlPattern,\n): string | RegExp {\n return typeof pattern === \"string\"\n ? pattern\n : new RegExp(pattern.source, pattern.flags);\n}\n","// Building the effective web-app manifest from a base manifest plus a\n// `PHConnectPwaManifest` fragment. Pure JSON in / JSON out — no PWA-toolchain\n// or DOM dependency — so the SAME code path runs at build time (laying the\n// effective build-merged fragment over Connect's hardcoded base, see\n// applyPwaOverrides) and at runtime inside the service worker (laying a\n// dynamically-installed package's fragment over the build-embedded base to\n// serve the live manifest).\n//\n// Connect owns the \"where\" of every OS integration: file handlers open at the\n// app root, `web+…` protocol links and shared files route through fixed\n// in-scope endpoints. Contributors declare only WHAT they accept; the routes\n// below are injected here so a package can never point the OS at an arbitrary\n// URL. Injection is idempotent, so re-merging a manifest that already carries\n// the routes is a no-op.\n\nimport type {\n PHConnectPwaFileHandler,\n PHConnectPwaIcon,\n PHConnectPwaManifest,\n} from \"../clis/types.js\";\nimport { dedupeFileHandlers, dedupeIcons, unionStrings } from \"./pwa-config.js\";\n\n/**\n * The one route launched files open at, shared by the built-in handler and\n * injected into every contributed one. Not configurable: consuming launched\n * files takes runtime code that lives in Connect itself, and a relative \".\"\n * resolves against the manifest URL so it tracks any deploy base (the\n * webmanifest is served dynamically and never rewritten by the dynamic-base\n * plugin) — same trick as the base start_url/scope.\n */\nexport const PWA_FILE_HANDLER_ACTION = \".\";\n\n// IndexedDB schema for the page->service-worker PWA-fragment mirror. A SW can't\n// read localStorage (where the installed-package list lives), so the SPA\n// mirrors the merged fragment here and the SW reads it to serve a live\n// manifest. Both sides MUST agree, so the schema lives here as the single\n// source of truth (the SPA writer and the SW reader both import these) —\n// a rename or version bump can no longer desync one side silently.\nexport const PWA_IDB_NAME = \"ph-pwa\";\nexport const PWA_IDB_STORE = \"fragments\";\nexport const PWA_IDB_KEY = \"merged\";\nexport const PWA_IDB_VERSION = 1;\n\n/** The subset of a web-app manifest this module reads/writes, plus an index\n * signature so untouched fields (name, theme_color, launch_handler, …) pass\n * through verbatim. */\nexport interface PwaWebManifest {\n icons?: PHConnectPwaIcon[];\n file_handlers?: (PHConnectPwaFileHandler & { action?: string })[];\n categories?: string[];\n [key: string]: unknown;\n}\n\n/**\n * Lay a `PHConnectPwaManifest` fragment over a base web-manifest object.\n *\n * - **scalars** (name, theme_color, launch_handler, …): governed by\n * `scalarPolicy`. `\"fragment-wins\"` lets the fragment overwrite the base;\n * `\"base-wins\"` keeps the base and only fills fields it left unset. Keys\n * listed in `protectedScalars` always behave as base-wins even under a\n * fragment-wins policy — used at runtime to fragment-win cosmetic scalars\n * while still protecting navigation-critical ones (`start_url`/`scope`) from\n * an untrusted dynamically-installed package.\n * - **arrays** (icons, file_handlers): always additive, base entries first,\n * de-duplicated — so a package can extend but never displace a built-in\n * (Chromium is first-registered-wins per file extension, so `.phd`/`.phdm`\n * stay Connect's).\n * - **categories**: order-preserving string union (derived from the manifest\n * `category` field, not authored under `pwa`).\n *\n * The Connect-owned file-handler action is injected idempotently.\n */\nexport function mergeManifest(\n base: PwaWebManifest,\n fragment: PHConnectPwaManifest | undefined,\n opts?: {\n scalarPolicy?: \"base-wins\" | \"fragment-wins\";\n protectedScalars?: readonly string[];\n },\n): PwaWebManifest {\n const scalarPolicy = opts?.scalarPolicy ?? \"base-wins\";\n const protectedScalars = opts?.protectedScalars ?? [];\n const result: PwaWebManifest = { ...base };\n const { icons, file_handlers, categories, ...scalars } = fragment ?? {};\n\n const takeScalar = (key: string): boolean => {\n // Protected keys stay base-wins regardless of the policy.\n const policy = protectedScalars.includes(key) ? \"base-wins\" : scalarPolicy;\n return policy === \"fragment-wins\" || result[key] === undefined;\n };\n\n for (const [key, value] of Object.entries(scalars)) {\n if (takeScalar(key)) result[key] = value;\n }\n\n if (icons?.length) {\n result.icons = dedupeIcons([...(result.icons ?? []), ...icons]);\n }\n if (file_handlers?.length) {\n // Force the Connect-owned action (spread first, action last) so contributed\n // handlers match the base's already-injected shape and de-dupe correctly.\n const injected = file_handlers.map((handler) => ({\n ...handler,\n action: PWA_FILE_HANDLER_ACTION,\n }));\n result.file_handlers = dedupeFileHandlers([\n ...(result.file_handlers ?? []),\n ...injected,\n ]);\n }\n if (categories?.length) {\n result.categories = unionStrings(result.categories, categories);\n }\n\n // Idempotently (re-)assert the Connect-owned file-handler action across the\n // merged result, covering both fragment contributions and any base entries.\n if (result.file_handlers?.length) {\n result.file_handlers = result.file_handlers.map((handler) => ({\n ...handler,\n action: PWA_FILE_HANDLER_ACTION,\n }));\n }\n\n return result;\n}\n","// Single source of truth for JSON Schema shapes shared between the source\n// PowerhouseConfig schema (packages/shared/clis/source-config-schema.ts) and\n// the runtime RuntimePowerhouseConfig schema\n// (packages/builder-tools/connect-utils/runtime-config-schema.ts).\n//\n// When a shared shape changes, edit it here — both schemas pick it up.\n\nexport const powerhousePackageSchema = {\n type: \"object\",\n additionalProperties: false,\n required: [\"packageName\"],\n properties: {\n packageName: {\n type: \"string\",\n description: \"Fully qualified npm package name (e.g. @scope/name).\",\n },\n version: {\n type: \"string\",\n description: \"Exact version (registry providers) or omit to take latest.\",\n },\n provider: {\n type: \"string\",\n enum: [\"npm\", \"github\", \"local\", \"registry\"],\n description: \"Where Connect should resolve the package from at runtime.\",\n },\n url: {\n type: \"string\",\n description:\n \"Override URL for non-registry providers (e.g. github tarball).\",\n },\n },\n} as const;\n\n// Reusable shape for `connect.drives.sections.{remote,local}` — three\n// affirmative-named toggles per section. The legacy public+cloud sections\n// have been collapsed into a single `remote`.\nconst driveSectionSchema = {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Visibility and add/delete affordances for a drive section in the sidebar.\",\n properties: {\n enabled: {\n type: \"boolean\",\n description: \"When false, the section is hidden in the sidebar.\",\n default: true,\n },\n allowAdd: {\n type: \"boolean\",\n description:\n \"When false, the section's 'add drive' affordance is hidden.\",\n default: true,\n },\n allowDelete: {\n type: \"boolean\",\n description:\n \"When false, drives in this section cannot be deleted from the UI.\",\n default: true,\n },\n },\n} as const;\n\n// Reusable shape for a runtime-caching / denylist URL match. A string is\n// handed to Workbox verbatim; `{ source, flags }` is rebuilt into a RegExp at\n// build time. Function patterns aren't serialisable and can't be expressed\n// from config — only Connect's built-in rules use them (see the runtime-caching\n// rules in builder-tools' connect-utils/service-worker/service-worker.ts).\nconst pwaUrlPatternSchema = {\n description:\n \"URL match. A string is matched verbatim by Workbox; { source, flags } is rebuilt into a RegExp at build time.\",\n oneOf: [\n { type: \"string\" },\n {\n type: \"object\",\n additionalProperties: false,\n required: [\"source\"],\n properties: {\n source: { type: \"string\", description: \"RegExp source.\" },\n flags: { type: \"string\", description: \"RegExp flags (e.g. 'i').\" },\n },\n },\n ],\n} as const;\n\n// Reusable web-app-manifest icon shape (manifest.icons and file-handler icons).\nconst pwaIconSchema = {\n type: \"object\",\n additionalProperties: false,\n required: [\"src\"],\n properties: {\n src: { type: \"string\" },\n sizes: { type: \"string\" },\n type: { type: \"string\" },\n purpose: { type: \"string\" },\n },\n} as const;\n\nexport const phConnectRuntimeConfigSchema = {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Connect-specific UI customisations. All fields optional; omit the section entirely for default behaviour.\",\n properties: {\n branding: {\n type: \"object\",\n additionalProperties: false,\n description: \"App identity and visual branding.\",\n properties: {\n appName: {\n type: \"string\",\n description:\n \"Browser tab title and any in-app brand text. Defaults to 'Powerhouse Connect'.\",\n },\n homeBackground: {\n type: [\"string\", \"null\"],\n description:\n \"Hero image on the empty home screen. URL or path to override; null or omitted uses the bundled default image.\",\n },\n },\n },\n app: {\n type: \"object\",\n additionalProperties: false,\n description: \"Top-level Connect application behaviour.\",\n properties: {\n logLevel: {\n type: \"string\",\n enum: [\"debug\", \"info\", \"warn\", \"error\"],\n description:\n \"Log level applied by Connect's logger at boot. Affects browser-side output only.\",\n default: \"info\",\n },\n basePath: {\n type: \"string\",\n description:\n \"Base path Connect is mounted under (e.g. '/connect' for subpath deploys). Normalised at runtime to start and end with '/'. Defaults to the build-time BASE_URL.\",\n default: \"/\",\n },\n offline: {\n type: \"boolean\",\n description:\n \"When true (default), the build emits a precaching service worker so Connect's app shell works offline, and the SPA registers it at boot. Set false to opt this deployment out: no service worker is built, the SPA skips registration, and any previously-installed worker is unregistered.\",\n default: true,\n },\n studioMode: {\n type: \"boolean\",\n description:\n \"Studio mode. Enables builder-only capabilities: Connect loads the vetra package and exposes DocumentModel (and vetra spec types) as creatable documents. Forced on by `ph vetra` / `ph connect studio`; false by default.\",\n default: false,\n },\n workflowsEnabled: {\n type: \"boolean\",\n description:\n \"Powerhouse workflows in Connect. When true the tab loads the @powerhousedao/workflow package (workflow + connection documents, their editors and Workflow Studio) and the reactor worker registers its document models. Connect's counterpart to the reactor-side `workflows.enabled` / PH_WORKFLOWS_ENABLED; independent of studioMode. False by default.\",\n default: false,\n },\n },\n },\n ai: {\n type: \"object\",\n additionalProperties: false,\n description: \"AI assistant (chat) behaviour.\",\n properties: {\n assistantEnabled: {\n type: \"boolean\",\n description:\n \"When true, Connect mounts the in-browser AI assistant (bottom-right chat FAB that talks to a user-configured OpenAI-compatible endpoint and acts on the reactor). Disabled by default.\",\n default: false,\n },\n },\n },\n packages: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Runtime behaviour for the Connect package manager (separate from top-level `packages[]`, which lists which packages to load).\",\n properties: {\n externalEnabled: {\n type: \"boolean\",\n description:\n \"When false, Connect refuses to load any package that wasn't bundled at build time. Affirmative replacement for the legacy PH_CONNECT_EXTERNAL_PACKAGES_DISABLED env var.\",\n default: true,\n },\n liveReload: {\n type: \"boolean\",\n description:\n \"When true, Connect subscribes to the static-mode `/__packages` SSE channel so live publishes flow into the running tab without a page reload. Only works under hosting that serves this channel (e.g. ph-clint static mode).\",\n default: false,\n },\n },\n },\n drives: {\n type: \"object\",\n additionalProperties: false,\n description: \"Default-drive and add-drive UI behaviour.\",\n properties: {\n allowAddDrive: {\n type: \"boolean\",\n description:\n \"When false, the SPA hides the 'add drive' affordance entirely (top-level). Per-section overrides live in `sections.{remote,local}.allowAdd`.\",\n default: true,\n },\n defaultDrives: {\n type: \"array\",\n description:\n \"Drives the SPA auto-connects to on first load. Each entry is either a remote drive (a URL, with optional name/icon overrides) or a local drive (created locally on first boot, with a stable id and optional name/icon/app).\",\n default: [],\n items: {\n oneOf: [\n {\n type: \"object\",\n additionalProperties: false,\n required: [\"url\"],\n properties: {\n url: { type: \"string\" },\n name: { type: [\"string\", \"null\"] },\n icon: { type: [\"string\", \"null\"] },\n },\n },\n {\n type: \"object\",\n additionalProperties: false,\n required: [\"local\", \"id\"],\n properties: {\n local: {\n const: true,\n description:\n \"Discriminator: this entry is a local drive created on first boot.\",\n },\n id: {\n type: \"string\",\n description:\n \"Stable drive id. The drive is created with this id on first boot and is not re-created on later boots.\",\n },\n name: { type: [\"string\", \"null\"] },\n icon: { type: [\"string\", \"null\"] },\n app: {\n type: \"string\",\n description:\n \"Drive app (preferred editor) to open on the drive.\",\n },\n },\n },\n ],\n },\n },\n preserveStrategy: {\n type: \"string\",\n enum: [\"preserve-all\", \"preserve-by-url-and-detach\"],\n description:\n \"Strategy applied when defaultDrives change between deploys. 'preserve-all' keeps user-added drives untouched; 'preserve-by-url-and-detach' detaches removed default drives. No schema default — opt-in only.\",\n },\n sections: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Per-section visibility and affordance toggles. `remote` covers what was historically split into 'public' + 'cloud'; `local` is browser-local drives.\",\n properties: {\n remote: driveSectionSchema,\n local: driveSectionSchema,\n },\n },\n },\n },\n renown: {\n type: \"object\",\n additionalProperties: false,\n description: \"Renown identity / authentication coordinates.\",\n properties: {\n url: {\n type: \"string\",\n description: \"Renown auth service URL.\",\n default: \"https://www.renown.id\",\n },\n networkId: {\n type: \"string\",\n description: \"CAIP-2 network namespace (e.g. 'eip155').\",\n default: \"eip155\",\n },\n chainId: {\n type: \"number\",\n description: \"CAIP-2 chain reference within the network namespace.\",\n default: 1,\n },\n namespace: {\n type: \"string\",\n description:\n \"Renown localStorage namespace; share it across Connects to share login.\",\n },\n switchboardUrl: {\n type: \"string\",\n description:\n \"Switchboard GraphQL URL. When set, Connect enables in-page (no-redirect) Renown sign-in; otherwise it falls back to the redirect flow via `url`.\",\n },\n adapters: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Per-adapter wallet config for in-page auth. Presence of an adapter key enables it; omit or leave empty for redirect-only behaviour.\",\n properties: {\n rainbow: {\n type: \"object\",\n additionalProperties: false,\n description: \"wagmi + RainbowKit external-wallet adapter config.\",\n properties: {\n walletConnectProjectId: {\n type: \"string\",\n description:\n \"WalletConnect project id; required for this adapter to function.\",\n },\n infuraProjectId: {\n type: \"string\",\n description:\n \"Optional Infura project id used to build RPC transports.\",\n },\n },\n },\n privy: {\n type: \"object\",\n additionalProperties: false,\n description: \"Privy embedded/social adapter config.\",\n properties: {\n appId: {\n type: \"string\",\n description:\n \"Privy application id; required for this adapter to function.\",\n },\n clientId: {\n type: \"string\",\n description: \"Optional Privy client id.\",\n },\n methods: {\n type: \"array\",\n description:\n \"Login methods this adapter offers; default per adapter when omitted.\",\n items: { type: \"string\" },\n },\n },\n },\n },\n },\n },\n },\n sentry: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Sentry error-tracking coordinates. Set `dsn` to enable Sentry; leave `dsn` null to disable. The Sentry release tag stays build-time (stamped via Vite's `define` from WORKSPACE_VERSION) so it always matches the sourcemaps uploaded by CI.\",\n properties: {\n dsn: {\n type: [\"string\", \"null\"],\n description:\n \"Sentry DSN URL. `null` disables Sentry entirely; the SPA never loads the Sentry SDK chunk.\",\n default: null,\n },\n env: {\n type: \"string\",\n description:\n \"Sentry environment label, surfaced as the `environment` tag on every event.\",\n default: \"dev\",\n },\n tracing: {\n type: \"boolean\",\n description: \"Enable Sentry performance tracing.\",\n default: false,\n },\n },\n },\n instance: {\n type: \"object\",\n additionalProperties: false,\n required: [\"namespace\", \"reactorWorker\"],\n description:\n \"Per-instance identity. Lets one origin host multiple isolated Connect instances, each with its own storage + SharedWorker namespace.\",\n properties: {\n namespace: {\n type: [\"string\", \"null\"],\n description:\n \"Explicit storage/SharedWorker namespace for this instance. `null` derives it from the base path (and, later, the configured endpoint), so root deployments stay byte-identical.\",\n default: null,\n },\n reactorWorker: {\n type: \"boolean\",\n description:\n \"Host the reactor in a shared worker instead of on the main thread. Off by default; the main-thread reactor stays the proven path until cutover is verified.\",\n default: false,\n },\n },\n },\n reactor: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Settings for the reactor Connect runs in the browser, on the main thread or in the shared worker alike.\",\n properties: {\n featureFlags: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Enforcement flags. Each implies its predecessors, and the reactor refuses to boot on a set that names a later flag without an earlier one. These are consensus settings: a Connect syncing with a fleet must carry the same flags the fleet does, or the two reach different replay outcomes for the same history and diverge.\",\n properties: {\n documentDecisions: {\n type: \"boolean\",\n description:\n \"Decide writes from the document stream rather than the document meta cache, so a backdated deletion denies the operations that sort after it.\",\n default: false,\n },\n authEnforcement: {\n type: \"boolean\",\n description:\n \"Enforce the auth scope's policy at admission, replay, and read. Requires documentDecisions.\",\n default: false,\n },\n authGroups: {\n type: \"boolean\",\n description:\n \"Let `{ group }` principals match against the rosters of the group documents a policy names. Requires authEnforcement.\",\n default: false,\n },\n authConditions: {\n type: \"boolean\",\n description:\n \"Evaluate `where` and `match` conditions on grants. Requires authGroups. Do not enable on a fleet `preflight:auth` reports as crossing a reducer version.\",\n default: false,\n },\n },\n },\n createSignaturePolicy: {\n type: \"string\",\n enum: [\"legacy\", \"v2-required\"],\n description:\n \"What new documents are created as. `v2-required` documents accept only v2 action signatures and take content-addressed ids; set `legacy` while any peer Connect syncs with predates them. Existing documents keep their policy.\",\n default: \"v2-required\",\n },\n },\n },\n pwa: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Progressive-web-app / service-worker overrides, layered on Connect's built-in PWA defaults at build time. Scalar fields deep-merge (this layer wins); the array members (icons, file_handlers, globs, runtimeCaching and denylist patterns) are additive; maximumFileSizeToCacheInBytes takes the max across contributors. (categories is not set here — it is derived from the manifest's category field.) Only applied when connect.app.offline is true.\",\n properties: {\n manifest: {\n type: \"object\",\n additionalProperties: false,\n description: \"Web-app-manifest field overrides.\",\n properties: {\n name: { type: \"string\" },\n short_name: { type: \"string\" },\n description: { type: \"string\" },\n theme_color: { type: \"string\" },\n background_color: { type: \"string\" },\n display: {\n type: \"string\",\n enum: [\"fullscreen\", \"standalone\", \"minimal-ui\", \"browser\"],\n },\n start_url: { type: \"string\" },\n scope: { type: \"string\" },\n icons: {\n type: \"array\",\n description:\n \"Icons appended to the built-in set and de-duplicated by (src, sizes, purpose).\",\n items: pwaIconSchema,\n },\n file_handlers: {\n type: \"array\",\n description:\n \"File associations appended after Connect's built-in .phd/.phdm handler and de-duplicated on the whole entry. Entries only declare accepted types; there is no action field, because opening the files requires Connect's own runtime handling, so every handler opens at the app root.\",\n items: {\n type: \"object\",\n additionalProperties: false,\n required: [\"accept\"],\n properties: {\n accept: {\n type: \"object\",\n description:\n \"MIME type → file extensions. Each extension must start with '.'; browsers ignore entries without it.\",\n additionalProperties: {\n type: \"array\",\n items: { type: \"string\", pattern: \"^\\\\.\" },\n },\n },\n icons: {\n type: \"array\",\n description: \"OS-level file-type icons.\",\n items: pwaIconSchema,\n },\n launch_type: {\n type: \"string\",\n enum: [\"single-client\", \"multiple-clients\"],\n },\n },\n },\n },\n launch_handler: {\n type: \"object\",\n additionalProperties: false,\n required: [\"client_mode\"],\n description:\n \"How the OS launches the app for handled files/links. Connect defaults to focus-existing.\",\n properties: {\n client_mode: {\n type: \"string\",\n enum: [\n \"auto\",\n \"focus-existing\",\n \"navigate-existing\",\n \"navigate-new\",\n ],\n },\n },\n },\n },\n },\n globPatterns: {\n type: \"array\",\n items: { type: \"string\" },\n description:\n \"Extra Workbox precache globs, unioned with the built-ins.\",\n },\n globIgnores: {\n type: \"array\",\n items: { type: \"string\" },\n description:\n \"Extra precache ignore globs, unioned with the built-ins.\",\n },\n maximumFileSizeToCacheInBytes: {\n type: \"number\",\n description:\n \"Raise the precache file-size ceiling. The max across all contributors wins, so no contributor can shrink another's limit.\",\n },\n runtimeCaching: {\n type: \"array\",\n description:\n \"Runtime-caching rules appended after the built-in rules. Workbox is first-match-wins, so these cannot override a built-in rule matching the same URL.\",\n items: {\n type: \"object\",\n additionalProperties: false,\n required: [\"urlPattern\", \"handler\"],\n properties: {\n urlPattern: pwaUrlPatternSchema,\n handler: {\n type: \"string\",\n enum: [\n \"CacheFirst\",\n \"CacheOnly\",\n \"NetworkFirst\",\n \"NetworkOnly\",\n \"StaleWhileRevalidate\",\n ],\n },\n method: {\n type: \"string\",\n enum: [\"GET\", \"POST\", \"PUT\", \"DELETE\", \"HEAD\", \"PATCH\"],\n },\n options: {\n type: \"object\",\n additionalProperties: false,\n properties: {\n cacheName: { type: \"string\" },\n networkTimeoutSeconds: {\n type: \"number\",\n description:\n \"Seconds a NetworkFirst rule waits for the network before falling back to the cache.\",\n },\n expiration: {\n type: \"object\",\n additionalProperties: false,\n properties: {\n maxEntries: { type: \"number\" },\n maxAgeSeconds: { type: \"number\" },\n },\n },\n cacheableResponse: {\n type: \"object\",\n additionalProperties: false,\n properties: {\n statuses: { type: \"array\", items: { type: \"number\" } },\n headers: {\n type: \"object\",\n additionalProperties: { type: \"string\" },\n },\n },\n },\n },\n },\n },\n },\n },\n navigateFallbackDenylist: {\n type: \"array\",\n description:\n \"Extra SPA navigate-fallback denylist patterns, unioned with the built-ins.\",\n items: pwaUrlPatternSchema,\n },\n },\n },\n },\n} as const;\n","import { satisfies, validRange } from \"semver\";\n\nexport type SharedDep = { specifier: string; package: string };\n\n/**\n * The dependency set Connect and loaded packages share via the import map.\n * `@powerhousedao/connect` is deliberately absent: it is the Connect app\n * itself (no importable exports), so there is nothing to share.\n */\nexport const SHARED_DEPS: readonly SharedDep[] = [\n { specifier: \"document-model\", package: \"document-model\" },\n {\n specifier: \"@powerhousedao/document-engineering\",\n package: \"@powerhousedao/document-engineering\",\n },\n { specifier: \"@powerhousedao/shared\", package: \"@powerhousedao/shared\" },\n {\n specifier: \"@powerhousedao/shared/registry/urls\",\n package: \"@powerhousedao/shared\",\n },\n {\n specifier: \"@powerhousedao/design-system/connect\",\n package: \"@powerhousedao/design-system\",\n },\n {\n specifier: \"@powerhousedao/reactor-browser\",\n package: \"@powerhousedao/reactor-browser\",\n },\n // Connect already vendors zod (it is in DEFAULT_VENDOR_INCLUDE, so the\n // import map publishes an entry for it) and every generated project already\n // declares it as a peerDependency -- yet it was missing from this set, so\n // each package inlined a private copy anyway. It is the single biggest\n // dependency left in a minimal package.\n { specifier: \"zod\", package: \"zod\" },\n];\n\nexport const SHARED_DEP_SPECIFIERS: readonly string[] = SHARED_DEPS.map(\n (d) => d.specifier,\n);\n\n/**\n * The `@powerhousedao/shared` subpaths the production vendor bundles. The\n * bare root is deliberately absent: its type barrel references node-only\n * modules (`clis/`), which the current vite/rolldown cannot bundle for the\n * browser — vendoring the root fails the build (a pre-existing latent\n * issue). A package that imports the bare root is simply not shared; it\n * bundles its own copy.\n */\nexport const SHARED_SUBPATHS: readonly string[] = [\n \"connect\",\n \"document-model\",\n \"processors\",\n \"document-drive\",\n \"registry\",\n \"registry/urls\",\n \"registry/manifest-slim\",\n];\n\n/**\n * The specifiers a package build may safely externalize onto the host's\n * import map — i.e. the ones the vendor actually publishes an entry for.\n *\n * `@powerhousedao/shared` is narrowed to SHARED_SUBPATHS rather than taken as\n * a prefix: the bare root is never vendored (see SHARED_SUBPATHS), and\n * neither are its other subpaths (`analytics`, `constants`, `clis`, ...).\n * Externalizing those would leave a bare specifier in the package's output\n * that nothing in the import map resolves, so the package would fail to load\n * at runtime instead of simply bundling its own copy.\n */\nexport const EXTERNALIZABLE_SHARED_SPECIFIERS: readonly string[] = [\n ...new Set([\n ...SHARED_DEP_SPECIFIERS.filter((s) => s !== \"@powerhousedao/shared\"),\n ...SHARED_SUBPATHS.map((s) => `@powerhousedao/shared/${s}`),\n ]),\n];\n\n/** Split a specifier into its package name and subpath (\"\" for a root). */\nexport function parseDepSpec(spec: string): { pkg: string; sub: string } {\n if (spec.startsWith(\"@\")) {\n const parts = spec.split(\"/\");\n return { pkg: parts.slice(0, 2).join(\"/\"), sub: parts.slice(2).join(\"/\") };\n }\n const i = spec.indexOf(\"/\");\n return i === -1\n ? { pkg: spec, sub: \"\" }\n : { pkg: spec.slice(0, i), sub: spec.slice(i + 1) };\n}\n\nfunction isSharedSpecifier(spec: string, specs: readonly string[]): boolean {\n return specs.some((s) => spec === s || spec.startsWith(s + \"/\"));\n}\n\n/**\n * Return the import/export specifiers in `source` that are a shared\n * specifier (or a subpath of one), sorted. Heuristic: only statement\n * positions are scanned (`from \"x\"`, `import \"x\"`, `import(\"x\")`;\n * `export … from \"x\"` is covered by the `from` pattern), so import-like\n * text inside comments or strings can be reported too. That errs toward\n * over-reporting, which is the safe direction for the advisory build\n * warning.\n */\nexport function findSharedImports(\n source: string,\n specs: readonly string[] = SHARED_DEP_SPECIFIERS,\n): string[] {\n const found = new Set<string>();\n const patterns = [\n /\\bfrom\\s+[\"']([^\"'\\\\]+)[\"']/g,\n /\\bimport\\s+[\"']([^\"'\\\\]+)[\"']/g,\n /\\bimport\\s*\\(\\s*[\"']([^\"'\\\\]+)[\"']\\s*\\)/g,\n ];\n for (const re of patterns) {\n for (const m of source.matchAll(re)) {\n const spec = m[1];\n if (isSharedSpecifier(spec, specs)) found.add(spec);\n }\n }\n return [...found].sort();\n}\n\n/**\n * Rewrite a package source for blob import in a worker context (import maps\n * don't apply there): shared specifiers become their mapped URLs, and\n * relative (`./`, `../`) specifiers become absolute against `sourceUrl`\n * (a blob URL has no directory to resolve against). `#` subpath imports are\n * deliberately left alone: they resolve via the package's own\n * `package.json` \"imports\" field, which the rewrite cannot reproduce.\n * Returns the input unchanged when nothing matched.\n */\nexport function rewritePackageSource(\n source: string,\n sourceUrl: string,\n imports: Record<string, string>,\n): string {\n if (!Object.keys(imports).length) return source;\n const base = new URL(sourceUrl);\n const map = (spec: string): string | null => {\n const mapped = imports[spec];\n if (mapped) return mapped;\n if (spec.startsWith(\"./\") || spec.startsWith(\"../\")) {\n return new URL(spec, base).href;\n }\n return null;\n };\n let out = source;\n // The quote character is captured and reused: a source that quotes its\n // specifiers with ' would otherwise never match the replacement and be\n // left un-rewritten — silently, since the specifier still maps.\n for (const re of [\n /\\bfrom\\s+([\"'])([^\"'\\\\]+)\\1/g,\n /\\bimport\\s+([\"'])([^\"'\\\\]+)\\1/g,\n /\\bimport\\s*\\(\\s*([\"'])([^\"'\\\\]+)\\1\\s*\\)/g,\n ]) {\n out = out.replace(re, (match, quote: string, spec: string) => {\n // The match contains the quoted specifier exactly once and the\n // captured group has no quotes/backslashes ([^\"'\\\\]), so a literal\n // replace is safe.\n const mapped = map(spec);\n return mapped\n ? match.replace(`${quote}${spec}${quote}`, `${quote}${mapped}${quote}`)\n : match;\n });\n }\n return out;\n}\n\nexport type SharedDepMismatch = {\n package: string;\n required: string;\n provided: string;\n};\n\nexport type PackageDeps = {\n dependencies?: Record<string, unknown>;\n peerDependencies?: Record<string, unknown>;\n};\n\n/**\n * Compare a package's declared ranges against the host's version table.\n * `hostVersions` defines the checked set (only deps present in it are\n * checked). `*`, non-semver protocols (workspace:, file:, git:, npm:, URLs)\n * and unparseable ranges never mismatch.\n */\nexport function checkSharedDeps(\n pkgJson: PackageDeps,\n hostVersions: Record<string, string>,\n): SharedDepMismatch[] {\n const out: SharedDepMismatch[] = [];\n const entries = [\n ...Object.entries(pkgJson.dependencies ?? {}),\n ...Object.entries(pkgJson.peerDependencies ?? {}),\n ];\n for (const [dep, range] of entries) {\n const provided = hostVersions[dep];\n if (provided === undefined || typeof range !== \"string\") continue;\n if (range === \"*\" || /^[a-z]+:/i.test(range)) continue;\n if (!validRange(range)) continue;\n if (!satisfies(provided, range, { includePrerelease: true })) {\n out.push({ package: dep, required: range, provided });\n }\n }\n return out;\n}\n\nexport function formatSharedDepWarnings(\n mismatches: SharedDepMismatch[],\n): string[] {\n return mismatches.map(\n (m) =>\n `${m.package}: requires ${m.required}, Connect provides ${m.provided}`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,MAAa,2BAA2B;;;;;;;ACNxC,MAAM,gBAAgB,EACnB,MAAM,CAAC,EAAE,QAAQ,GAAG,EAAE,KAAK,CAAC,QAAQ,OAAO,CAAC,CAAC,CAAC,CAAC,CAC/C,WAAW,QAAQ;CAClB,IAAI,OAAO,QAAQ,WAAW,OAAO;CACrC,OAAO,QAAQ;AACjB,CAAC;;;;AASH,MAAM,iBAAiB,EAAE,OAAO;;;;;CAK9B,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;;;;CAKjC,kBAAkB,EAAE,OAAO,CAAC,CAAC,SAAS;;;;CAKtC,sBAAsB,EAAE,OAAO,CAAC,CAAC,SAAS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N,aACE;KACF,SAAS;IACX;IACA,YAAY;KACV,MAAM;KACN,aACE;KACF,SAAS;IACX;GACF;EACF;EACA,QAAQ;GACN,MAAM;GACN,sBAAsB;GACtB,aAAa;GACb,YAAY;IACV,eAAe;KACb,MAAM;KACN,aACE;KACF,SAAS;IACX;IACA,eAAe;KACb,MAAM;KACN,aACE;KACF,SAAS,CAAC;KACV,OAAO,EACL,OAAO,CACL;MACE,MAAM;MACN,sBAAsB;MACtB,UAAU,CAAC,KAAK;MAChB,YAAY;OACV,KAAK,EAAE,MAAM,SAAS;OACtB,MAAM,EAAE,MAAM,CAAC,UAAU,MAAM,EAAE;OACjC,MAAM,EAAE,MAAM,CAAC,UAAU,MAAM,EAAE;MACnC;KACF,GACA;MACE,MAAM;MACN,sBAAsB;MACtB,UAAU,CAAC,SAAS,IAAI;MACxB,YAAY;OACV,OAAO;QACL,OAAO;QACP,aACE;OACJ;OACA,IAAI;QACF,MAAM;QACN,aACE;OACJ;OACA,MAAM,EAAE,MAAM,CAAC,UAAU,MAAM,EAAE;OACjC,MAAM,EAAE,MAAM,CAAC,UAAU,MAAM,EAAE;OACjC,KAAK;QACH,MAAM;QACN,aACE;OACJ;MACF;KACF,CACF,EACF;IACF;IACA,kBAAkB;KAChB,MAAM;KACN,MAAM,CAAC,gBAAgB,4BAA4B;KACnD,aACE;IACJ;IACA,UAAU;KACR,MAAM;KACN,sBAAsB;KACtB,aACE;KACF,YAAY;MACV,QAAQ;MACR,OAAO;KACT;IACF;GACF;EACF;EACA,QAAQ;GACN,MAAM;GACN,sBAAsB;GACtB,aAAa;GACb,YAAY;IACV,KAAK;KACH,MAAM;KACN,aAAa;KACb,SAAS;IACX;IACA,WAAW;KACT,MAAM;KACN,aAAa;KACb,SAAS;IACX;IACA,SAAS;KACP,MAAM;KACN,aAAa;KACb,SAAS;IACX;IACA,WAAW;KACT,MAAM;KACN,aACE;IACJ;IACA,gBAAgB;KACd,MAAM;KACN,aACE;IACJ;IACA,UAAU;KACR,MAAM;KACN,sBAAsB;KACtB,aACE;KACF,YAAY;MACV,SAAS;OACP,MAAM;OACN,sBAAsB;OACtB,aAAa;OACb,YAAY;QACV,wBAAwB;SACtB,MAAM;SACN,aACE;QACJ;QACA,iBAAiB;SACf,MAAM;SACN,aACE;QACJ;OACF;MACF;MACA,OAAO;OACL,MAAM;OACN,sBAAsB;OACtB,aAAa;OACb,YAAY;QACV,OAAO;SACL,MAAM;SACN,aACE;QACJ;QACA,UAAU;SACR,MAAM;SACN,aAAa;QACf;QACA,SAAS;SACP,MAAM;SACN,aACE;SACF,OAAO,EAAE,MAAM,SAAS;QAC1B;OACF;MACF;KACF;IACF;GACF;EACF;EACA,QAAQ;GACN,MAAM;GACN,sBAAsB;GACtB,aACE;GACF,YAAY;IACV,KAAK;KACH,MAAM,CAAC,UAAU,MAAM;KACvB,aACE;KACF,SAAS;IACX;IACA,KAAK;KACH,MAAM;KACN,aACE;KACF,SAAS;IACX;IACA,SAAS;KACP,MAAM;KACN,aAAa;KACb,SAAS;IACX;GACF;EACF;EACA,UAAU;GACR,MAAM;GACN,sBAAsB;GACtB,UAAU,CAAC,aAAa,eAAe;GACvC,aACE;GACF,YAAY;IACV,WAAW;KACT,MAAM,CAAC,UAAU,MAAM;KACvB,aACE;KACF,SAAS;IACX;IACA,eAAe;KACb,MAAM;KACN,aACE;KACF,SAAS;IACX;GACF;EACF;EACA,SAAS;GACP,MAAM;GACN,sBAAsB;GACtB,aACE;GACF,YAAY;IACV,cAAc;KACZ,MAAM;KACN,sBAAsB;KACtB,aACE;KACF,YAAY;MACV,mBAAmB;OACjB,MAAM;OACN,aACE;OACF,SAAS;MACX;MACA,iBAAiB;OACf,MAAM;OACN,aACE;OACF,SAAS;MACX;MACA,YAAY;OACV,MAAM;OACN,aACE;OACF,SAAS;MACX;MACA,gBAAgB;OACd,MAAM;OACN,aACE;OACF,SAAS;MACX;KACF;IACF;IACA,uBAAuB;KACrB,MAAM;KACN,MAAM,CAAC,UAAU,aAAa;KAC9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OAAO;CACT;CACA,IAAI,MAAM;CAIV,KAAK,MAAM,MAAM;EACf;EACA;EACA;CACF,GACE,MAAM,IAAI,QAAQ,KAAK,OAAO,OAAe,SAAiB;EAI5D,MAAM,SAAS,IAAI,IAAI;EACvB,OAAO,SACH,MAAM,QAAQ,GAAG,QAAQ,OAAO,SAAS,GAAG,QAAQ,SAAS,OAAO,IACpE;CACN,CAAC;CAEH,OAAO;AACT;;;;;;;AAmBA,SAAgB,gBACd,SACA,cACqB;CACrB,MAAM,MAA2B,CAAC;CAClC,MAAM,UAAU,CACd,GAAG,OAAO,QAAQ,QAAQ,gBAAgB,CAAC,CAAC,GAC5C,GAAG,OAAO,QAAQ,QAAQ,oBAAoB,CAAC,CAAC,CAClD;CACA,KAAK,MAAM,CAAC,KAAK,UAAU,SAAS;EAClC,MAAM,WAAW,aAAa;EAC9B,IAAI,aAAa,KAAA,KAAa,OAAO,UAAU,UAAU;EACzD,IAAI,UAAU,OAAO,YAAY,KAAK,KAAK,GAAG;EAC9C,IAAI,CAAC,WAAW,KAAK,GAAG;EACxB,IAAI,CAAC,UAAU,UAAU,OAAO,EAAE,mBAAmB,KAAK,CAAC,GACzD,IAAI,KAAK;GAAE,SAAS;GAAK,UAAU;GAAO;EAAS,CAAC;CAExD;CACA,OAAO;AACT;AAEA,SAAgB,wBACd,YACU;CACV,OAAO,WAAW,KACf,MACC,GAAG,EAAE,QAAQ,aAAa,EAAE,SAAS,qBAAqB,EAAE,UAChE;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../connect/dynamic-base.ts","../../connect/env-config.ts","../../connect/pwa-config.ts","../../connect/pwa-manifest.ts","../../connect/schema-fragments.ts","../../connect/shared-deps.ts"],"sourcesContent":["/**\n * The base a dynamic-base Connect build is compiled against. The build emits\n * this literal wherever a base-relative URL would go, and the serving layer\n * (the dynamic-base vite plugin at build time, the connect proxy at serve\n * time) rewrites it to the base the app is actually deployed under.\n *\n * It lives here, in the browser-safe shared package, rather than in\n * `@powerhousedao/builder-tools`, because both the node-only build toolchain\n * and Connect's own browser code need it. Importing builder-tools from app\n * code pulls the whole build toolchain (and its node-only `read-pkg`\n * dependency) into the browser graph.\n */\nexport const DYNAMIC_BASE_PLACEHOLDER = \"/__PH_DYNAMIC_BASE__/\";\n","import { z } from \"zod\";\n\n/**\n * Coerces string values to boolean.\n * Accepts: \"true\", \"false\", true, false\n */\nconst booleanString = z\n .union([z.boolean(), z.enum([\"true\", \"false\"])])\n .transform((val) => {\n if (typeof val === \"boolean\") return val;\n return val === \"true\";\n });\n\n// ============================================================================\n// Build-time Environment Variables\n// ============================================================================\n\n/**\n * Build-time configuration schema\n */\nconst buildEnvSchema = z.object({\n /**\n * Comma-separated list of package names to load\n * @example \"package1,package2\"\n */\n PH_PACKAGES: z.string().optional(),\n\n /**\n * Path to local package to load during development\n */\n PH_LOCAL_PACKAGE: z.string().optional(),\n\n /**\n * Sentry authentication token for uploading source maps\n */\n PH_SENTRY_AUTH_TOKEN: z.string().optional(),\n\n /**\n * Sentry organization slug\n */\n PH_SENTRY_ORG: z.string().optional(),\n\n /**\n * Sentry project slug\n */\n PH_SENTRY_PROJECT: z.string().optional(),\n});\n\n// ============================================================================\n// Application Configuration (build metadata only)\n// ============================================================================\n\n/**\n * Connect runtime values (anything in `PHConnectRuntimeConfig`) are NOT\n * settable from env vars. They live in `powerhouse.config.json` and are\n * overridden via `ph connect build --<field>` or `ph connect config\n * --<field>`.\n *\n * What stays env-driven below is non-runtime: build metadata, Sentry\n * credentials, analytics processor toggles, etc.\n */\nconst appConfigSchema = z.object({\n /**\n * Application version number (build metadata stamp)\n * @default \"unknown\"\n */\n PH_CONNECT_VERSION: z.string().default(\"unknown\"),\n\n /**\n * CLI version number (build metadata stamp)\n */\n PH_CONNECT_CLI_VERSION: z.string().optional(),\n});\n\n// ============================================================================\n// Analytics Processor Configuration\n// ============================================================================\n\n/**\n * Analytics processor configuration schema. These are non-runtime feature\n * toggles for the analytics subsystem — they don't live in the runtime\n * schema and stay env-driven.\n */\nconst processorsConfigSchema = z.object({\n /**\n * Enable diff analytics tracking\n * @default false\n */\n PH_CONNECT_DIFF_ANALYTICS_ENABLED: booleanString.default(false),\n\n /**\n * Enable drive analytics tracking\n * @default true\n */\n PH_CONNECT_DRIVE_ANALYTICS_ENABLED: booleanString.default(true),\n\n /**\n * Enable external analytics processors\n * @default true\n */\n PH_CONNECT_EXTERNAL_ANALYTICS_PROCESSORS_ENABLED: booleanString.default(true),\n});\n\n// ============================================================================\n// OpenPanel Configuration\n// ============================================================================\n\n/**\n * OpenPanel analytics configuration schema\n */\nconst openPanelConfigSchema = z.object({\n /**\n * OpenPanel client ID. When unset, the OpenPanel subsystem is a no-op.\n */\n PH_CONNECT_OPENPANEL_CLIENT_ID: z.string().optional(),\n\n /**\n * OpenPanel API URL override. Defaults to the OpenPanel cloud when unset.\n */\n PH_CONNECT_OPENPANEL_API_URL: z.string().optional(),\n\n /**\n * Track UI events via the useOpenPanel() hook\n * @default true\n */\n PH_CONNECT_OPENPANEL_TRACK_UI_EVENTS: booleanString.default(true),\n\n /**\n * Track document operations via the OpenPanel processor\n * @default true\n */\n PH_CONNECT_OPENPANEL_TRACK_OPERATIONS: booleanString.default(true),\n});\n\n// ============================================================================\n// Combined Schemas\n// ============================================================================\n\n/**\n * Complete runtime environment schema (all PH_CONNECT_* vars). Only\n * build-metadata + analytics-processor toggles live here; all Connect\n * runtime config lives in `powerhouse.config.json`.\n */\nexport const runtimeEnvSchema = appConfigSchema\n .extend(processorsConfigSchema.shape)\n .extend(openPanelConfigSchema.shape);\n\n/**\n * Complete environment schema (build + runtime)\n */\nexport const connectEnvSchema = buildEnvSchema.extend(runtimeEnvSchema.shape);\n\n/**\n * Inferred TypeScript types from schemas\n */\nexport type ConnectBuildEnv = z.infer<typeof buildEnvSchema>;\nexport type ConnectRuntimeEnv = z.infer<typeof runtimeEnvSchema>;\nexport type ConnectEnv = z.infer<typeof connectEnvSchema>;\n\n// ============================================================================\n// Environment Loading Functions\n// ============================================================================\n\n/**\n * Options for loading environment variables\n */\nexport interface LoadEnvOptions {\n /**\n * Environment variables from process.env (highest priority)\n */\n processEnv?: Record<string, string | undefined>;\n /**\n * Environment variables from .env file (lowest priority)\n */\n fileEnv?: Record<string, string | undefined>;\n}\n\n/**\n * Internal helper to merge environment sources with priority.\n * Validates each value and falls back to next priority if invalid.\n */\nfunction mergeEnvSources(\n options: LoadEnvOptions,\n keys: Set<string>,\n schema: z.ZodObject<Record<string, z.ZodTypeAny>>,\n): Record<string, unknown> {\n const { processEnv = {}, fileEnv = {} } = options;\n const merged: Record<string, unknown> = {};\n\n // Apply priority: fileEnv < processEnv\n for (const key of keys) {\n const sources = [\n { name: \"process.env\", value: processEnv[key] },\n { name: \"fileEnv\", value: fileEnv[key] },\n ];\n\n // Try each source in priority order\n for (const source of sources) {\n const value = source.value;\n if (value === undefined || value === \"\") continue;\n\n // Try to validate just this field\n try {\n const fieldSchema = schema.shape[key];\n if (fieldSchema) {\n fieldSchema.parse(value);\n merged[key] = value;\n break; // Successfully validated, use this value\n }\n // No schema for this key, accept it\n console.warn(`Unknown environment variable: '${key}'`);\n merged[key] = value;\n break;\n } catch {\n // Validation failed, log warning and try next source\n const valueStr =\n value === null\n ? \"null\"\n : typeof value === \"object\"\n ? JSON.stringify(value)\n : (value as string);\n console.warn(\n `Invalid value for ${key} from ${source.name}: ${valueStr}. Trying next source.`,\n );\n }\n }\n }\n\n return merged;\n}\n\n/**\n * Loads and validates environment variables with priority:\n * 1. process.env (highest)\n * 2. fileEnv\n * 3. defaults from schema (lowest)\n *\n * @param options - Environment sources in priority order\n * @returns Validated and typed environment configuration\n */\nexport function loadConnectEnv(options: LoadEnvOptions = {}): ConnectEnv {\n const allKeys = new Set([\n ...Object.keys(buildEnvSchema.shape),\n ...Object.keys(runtimeEnvSchema.shape),\n ]);\n\n const merged = mergeEnvSources(options, allKeys, connectEnvSchema);\n return connectEnvSchema.parse(merged);\n}\n\n/**\n * Loads only runtime environment variables (build metadata + Sentry +\n * analytics-processor toggles — everything in the Connect runtime schema\n * is sourced from powerhouse.config.json, not env).\n *\n * @param options - Environment sources in priority order\n * @returns Validated runtime environment configuration\n */\nexport function loadRuntimeEnv(\n options: LoadEnvOptions = {},\n): ConnectRuntimeEnv {\n const allKeys = new Set(Object.keys(runtimeEnvSchema.shape));\n const merged = mergeEnvSources(options, allKeys, runtimeEnvSchema);\n return runtimeEnvSchema.parse(merged);\n}\n\n/**\n * Safely sets Connect environment variables with validation.\n * Invalid values will log a warning and be skipped.\n *\n * @param values - Type-safe object with key-value pairs to set\n *\n * @example\n * ```ts\n * setConnectEnv({\n * PH_CONNECT_VERSION: \"1.2.3\",\n * PH_CONNECT_SENTRY_DSN: \"https://…\",\n * });\n * ```\n */\nexport function setConnectEnv(values: Partial<ConnectEnv>): void {\n for (const [key, value] of Object.entries(values)) {\n // Check if key exists in schema\n const fieldSchema =\n connectEnvSchema.shape[key as keyof typeof connectEnvSchema.shape];\n\n if (!fieldSchema) {\n console.warn(\n `Unknown environment variable: ${key}. Variable not set. Valid keys: ${Object.keys(connectEnvSchema.shape).join(\", \")}`,\n );\n continue;\n }\n\n try {\n // Validate the value\n fieldSchema.parse(value);\n\n // Set the value (convert to string for process.env compatibility)\n process.env[key] = String(value);\n } catch (error) {\n console.warn(\n `Invalid value for ${key}: ${String(value)}. Validation failed.`,\n error,\n );\n }\n }\n}\n\n/**\n * Normalizes a base path to ensure it:\n * - Starts with a forward slash (/)\n * - Ends with a forward slash (/)\n * - Has no relative path prefix (.)\n *\n * @param basePath - The base path to normalize\n * @returns The normalized base path\n *\n * @example\n * normalizeBasePath('/app') // '/app/'\n * normalizeBasePath('./app/') // '/app/'\n * normalizeBasePath('app') // '/app/'\n * normalizeBasePath('/') // '/'\n * normalizeBasePath('') // '/'\n */\nexport function normalizeBasePath(basePath: string): string {\n if (!basePath) {\n return \"/\";\n }\n\n let normalized = basePath;\n\n // Remove relative path prefix\n if (normalized.startsWith(\".\")) {\n normalized = normalized.slice(1);\n }\n\n // Ensure it starts with a forward slash\n if (!normalized.startsWith(\"/\")) {\n normalized = `/${normalized}`;\n }\n\n // Ensure it ends with a forward slash\n if (!normalized.endsWith(\"/\")) {\n normalized = `${normalized}/`;\n }\n\n return normalized;\n}\n\n/**\n * Base storage namespace for a Connect instance served at the root of an\n * origin. Kept as a literal so root deployments resolve to a byte-identical\n * value with no migration.\n */\nexport const ROOT_STORAGE_NAMESPACE = \"reactor\";\n\n/**\n * Derives the origin-scoped storage namespace from a Connect base path.\n *\n * Connect instances served under different path prefixes of the same origin\n * (e.g. behind a reverse proxy) otherwise share all origin-scoped browser\n * storage (PGlite data dirs, IndexedDB). This produces a deterministic,\n * collision-free namespace per distinct prefix that is valid as an\n * IndexedDB database name.\n *\n * - root base path (\"/\" or unset) -> \"reactor\" (byte-identical to the legacy\n * key, so existing root deployments keep their data with zero migration)\n * - any non-root base path -> \"reactor--<slug>\", e.g.\n * \"/reactor-project/vetra-studio/\" -> \"reactor--reactor-project-vetra-studio\"\n *\n * @param basePath - The Connect base path (env.PH_CONNECT_BASE_PATH ||\n * import.meta.env.BASE_URL); normalized internally.\n * @returns The storage namespace.\n *\n * @example\n * getStorageNamespace('/') // 'reactor'\n * getStorageNamespace('/reactor-project/vetra-studio/') // 'reactor--reactor-project-vetra-studio'\n */\nexport function getStorageNamespace(basePath: string): string {\n const normalized = normalizeBasePath(basePath);\n if (normalized === \"/\") {\n return ROOT_STORAGE_NAMESPACE;\n }\n const slug = normalized\n .slice(1, -1)\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n // A non-root base path whose slug normalizes to nothing (e.g. \"/-/\") must\n // not collapse into the root namespace and share its storage.\n return `${ROOT_STORAGE_NAMESPACE}--${slug || \"default\"}`;\n}\n","// Merging of Connect PWA override fragments.\n//\n// PWA config comes from several layers — Connect's hardcoded defaults, each\n// build-time-known package's `pwa` fragment, and the project's `connect.pwa`\n// block. A naive deep-merge is wrong here: runtime-caching rules and precache\n// globs are ADDITIVE (a later layer must not drop an earlier layer's offline\n// coverage), and the precache size ceiling must be the MAX so no contributor\n// can silently shrink another's limit. This module encodes those per-field\n// strategies: `mergePwaConfig(contributions)` folds an ordered list of\n// serialisable `PHConnectPwa` fragments (lowest precedence first) into one\n// effective fragment, warning when multiple packages set the same manifest\n// scalar to different values.\n//\n// Laying the effective fragment over Connect's hardcoded VitePWA base happens\n// in builder-tools (`connect-utils/vite-plugins/pwa-overrides.ts`), where\n// vite-plugin-pwa's manifest types are available.\n\nimport type {\n PHConnectPwa,\n PHConnectPwaManifest,\n PHConnectPwaUrlPattern,\n} from \"../clis/types.js\";\nimport { deepMerge } from \"./config-loader.js\";\n\n// Re-exported so the PWA override types are reachable from the same\n// `@powerhousedao/shared/connect` entry as the merge helpers that consume them.\nexport type {\n PHConnectPwa,\n PHConnectPwaCacheStrategy,\n PHConnectPwaFileHandler,\n PHConnectPwaIcon,\n PHConnectPwaManifest,\n PHConnectPwaRuntimeCaching,\n PHConnectPwaUrlPattern,\n} from \"../clis/types.js\";\n\n/** A labelled PWA fragment, so merge diagnostics can name the contributor. */\nexport type PwaContribution = {\n /** Human-readable origin (package name, or the project config file). */\n source: string;\n config: PHConnectPwa;\n};\n\n// Manifest scalar fields — the ones where \"two layers set it\" is a genuine\n// conflict (as opposed to the additive arrays, which never conflict).\nconst MANIFEST_SCALAR_KEYS: readonly (keyof PHConnectPwaManifest)[] = [\n \"name\",\n \"short_name\",\n \"description\",\n \"theme_color\",\n \"background_color\",\n \"display\",\n \"start_url\",\n \"scope\",\n \"launch_handler\",\n];\n\n// Manifest fields merged additively (concatenated/unioned across every layer),\n// never as scalar conflicts. Kept out of the deepMerge path, which replaces\n// arrays wholesale and would drop earlier contributions. `categories` is\n// derived (from the manifest `category` field) but merges the same additive way.\nconst ADDITIVE_MANIFEST_KEYS = new Set<keyof PHConnectPwaManifest>([\n \"icons\",\n \"file_handlers\",\n \"categories\",\n]);\n\n// Structural icon shape shared by PHConnectPwaIcon and vite-plugin-pwa's\n// IconResource (whose `purpose` may also be an array of purposes).\ntype IconLike = {\n src: string;\n sizes?: string;\n purpose?: string | readonly string[];\n};\n\nfunction iconKey(icon: IconLike): string {\n const purpose =\n typeof icon.purpose === \"string\"\n ? icon.purpose\n : (icon.purpose?.join(\",\") ?? \"\");\n return `${icon.src}|${icon.sizes ?? \"\"}|${purpose}`;\n}\n\n/** Concatenate, keeping the first occurrence per `key`. */\nfunction dedupeBy<T>(items: T[], key: (item: T) => string): T[] {\n const seen = new Set<string>();\n const result: T[] = [];\n for (const item of items) {\n const k = key(item);\n if (seen.has(k)) continue;\n seen.add(k);\n result.push(item);\n }\n return result;\n}\n\n/** Concatenate icons, keeping the first occurrence of each (src,sizes,purpose). */\nexport function dedupeIcons<T extends IconLike>(icons: T[]): T[] {\n return dedupeBy(icons, iconKey);\n}\n\n/** `JSON.stringify` with object keys sorted recursively, so two structurally\n * equal values always serialise identically (accept-map key order etc.). */\nfunction stableStringify(value: unknown): string {\n if (Array.isArray(value)) {\n return `[${value.map(stableStringify).join(\",\")}]`;\n }\n if (value !== null && typeof value === \"object\") {\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`);\n return `{${entries.join(\",\")}}`;\n }\n return JSON.stringify(value);\n}\n\n/**\n * Concatenate file handlers, keeping the first occurrence of each entry.\n * Deduped on the WHOLE entry (canonical JSON) rather than any single field:\n * every handler shares Connect's fixed action, and two handlers accepting\n * different file types are both real contributions — only the exact same\n * fragment arriving via two layers is a duplicate. Structural, so it also\n * works on the vite-plugin-pwa handler shape in builder-tools.\n */\nexport function dedupeFileHandlers<T extends object>(handlers: T[]): T[] {\n return dedupeBy(handlers, stableStringify);\n}\n\n/** Fold a manifest's top-level `category` string into a PWA config as a\n * `categories: [category]` entry. PWA `categories` is DERIVED from the\n * `category` field of every contributing `powerhouse.manifest.json` (never\n * authored under `pwa`); `mergePwaConfig`/`mergeManifest` then union them\n * across contributors. No-op when there is no usable category. */\nexport function withInferredCategory(\n config: PHConnectPwa,\n category: unknown,\n): PHConnectPwa {\n if (typeof category !== \"string\" || !category) return config;\n return {\n ...config,\n manifest: { ...config.manifest, categories: [category] },\n };\n}\n\n/** Order-preserving string union (used for the precache glob lists). */\nexport function unionStrings(\n base: string[] | undefined,\n extra: string[],\n): string[] {\n const result = [...(base ?? [])];\n for (const item of extra) if (!result.includes(item)) result.push(item);\n return result;\n}\n\nfunction patternKey(pattern: PHConnectPwaUrlPattern): string {\n return typeof pattern === \"string\"\n ? `s:${pattern}`\n : `r:${pattern.source}:${pattern.flags ?? \"\"}`;\n}\n\nfunction unionPatterns(\n base: PHConnectPwaUrlPattern[] | undefined,\n extra: PHConnectPwaUrlPattern[],\n): PHConnectPwaUrlPattern[] {\n const result = [...(base ?? [])];\n const seen = new Set(result.map(patternKey));\n for (const pattern of extra) {\n const key = patternKey(pattern);\n if (seen.has(key)) continue;\n seen.add(key);\n result.push(pattern);\n }\n return result;\n}\n\n/** Merge one fragment into `target` in place, applying the per-field\n * strategies (manifest scalars deep-merge and win; icons/file_handlers/globs/\n * rules/denylist are additive; size ceiling takes the max). */\nfunction mergeInto(target: PHConnectPwa, config: PHConnectPwa): void {\n if (config.manifest) {\n // The additive arrays are pulled out of the deepMerge path: deepMerge\n // replaces arrays wholesale, which would drop earlier contributions.\n const { icons, file_handlers, categories, ...scalars } = config.manifest;\n if (Object.keys(scalars).length > 0) {\n target.manifest = deepMerge(\n target.manifest ?? {},\n scalars as PHConnectPwaManifest,\n );\n }\n if (icons?.length) {\n target.manifest = {\n ...(target.manifest ?? {}),\n icons: dedupeIcons([...(target.manifest?.icons ?? []), ...icons]),\n };\n }\n if (file_handlers?.length) {\n target.manifest = {\n ...(target.manifest ?? {}),\n file_handlers: dedupeFileHandlers([\n ...(target.manifest?.file_handlers ?? []),\n ...file_handlers,\n ]),\n };\n }\n if (categories?.length) {\n target.manifest = {\n ...(target.manifest ?? {}),\n categories: unionStrings(target.manifest?.categories, categories),\n };\n }\n }\n if (config.globPatterns?.length) {\n target.globPatterns = unionStrings(\n target.globPatterns,\n config.globPatterns,\n );\n }\n if (config.globIgnores?.length) {\n target.globIgnores = unionStrings(target.globIgnores, config.globIgnores);\n }\n if (config.runtimeCaching?.length) {\n target.runtimeCaching = [\n ...(target.runtimeCaching ?? []),\n ...config.runtimeCaching,\n ];\n }\n if (config.navigateFallbackDenylist?.length) {\n target.navigateFallbackDenylist = unionPatterns(\n target.navigateFallbackDenylist,\n config.navigateFallbackDenylist,\n );\n }\n if (typeof config.maximumFileSizeToCacheInBytes === \"number\") {\n target.maximumFileSizeToCacheInBytes = Math.max(\n target.maximumFileSizeToCacheInBytes ?? 0,\n config.maximumFileSizeToCacheInBytes,\n );\n }\n}\n\n/**\n * Fold the build-time-known package PWA fragments and the project's\n * `connect.pwa` block into one effective fragment. Precedence is\n * `packageContributions (in order) < projectConfig` — the project config wins\n * scalar fields, while arrays (`icons`, globs, `runtimeCaching`,\n * `navigateFallbackDenylist`) are additive across every layer and the size\n * ceiling takes the max.\n *\n * `onWarn` fires when two or more PACKAGES set the same manifest scalar to\n * different values and the project config doesn't settle it — the winner is\n * otherwise decided silently by package load order. The operator resolves it\n * by setting that field in `connect.pwa`, which both wins and silences the\n * warning.\n */\nexport function mergePwaConfig(\n packageContributions: PwaContribution[],\n projectConfig?: PHConnectPwa,\n onWarn: (message: string) => void = () => {},\n): PHConnectPwa {\n const merged: PHConnectPwa = {};\n // Which packages set each manifest scalar, and to what (for the conflict\n // warning). The project config is deliberately excluded — it is the\n // authority, not a conflicting sibling.\n const packageScalarSetters: Partial<\n Record<string, { source: string; value: unknown }[]>\n > = {};\n\n for (const { source, config } of packageContributions) {\n mergeInto(merged, config);\n for (const [key, value] of Object.entries(config.manifest ?? {})) {\n if (ADDITIVE_MANIFEST_KEYS.has(key as keyof PHConnectPwaManifest)) {\n continue;\n }\n (packageScalarSetters[key] ??= []).push({ source, value });\n }\n }\n if (projectConfig) mergeInto(merged, projectConfig);\n\n const projectManifest = projectConfig?.manifest ?? {};\n for (const key of MANIFEST_SCALAR_KEYS) {\n const setters = packageScalarSetters[key];\n const projectSettles = projectManifest[key] !== undefined;\n if (!setters || setters.length < 2 || projectSettles) continue;\n // Same value from every package is agreement, not a conflict. Compared\n // via stableStringify, not by identity — launch_handler is object-valued,\n // and two packages sending equal objects (in any key order) must not read\n // as a conflict.\n const distinctValues = new Set(\n setters.map((s) => stableStringify(s.value)),\n );\n if (distinctValues.size < 2) continue;\n const sources = setters.map((s) => s.source);\n onWarn(\n `PWA config: manifest.${key} set by multiple packages (${sources.join(\n \", \",\n )}); '${sources[sources.length - 1]}' wins by load order. Set connect.pwa.manifest.${key} in the project config to make the winner explicit.`,\n );\n }\n\n return merged;\n}\n\n/** A serialisable URL pattern as Workbox consumes it: strings pass through\n * verbatim, `{ source, flags }` is rebuilt into a RegExp. */\nexport function toRegExpOrString(\n pattern: PHConnectPwaUrlPattern,\n): string | RegExp {\n return typeof pattern === \"string\"\n ? pattern\n : new RegExp(pattern.source, pattern.flags);\n}\n","// Building the effective web-app manifest from a base manifest plus a\n// `PHConnectPwaManifest` fragment. Pure JSON in / JSON out — no PWA-toolchain\n// or DOM dependency — so the SAME code path runs at build time (laying the\n// effective build-merged fragment over Connect's hardcoded base, see\n// applyPwaOverrides) and at runtime inside the service worker (laying a\n// dynamically-installed package's fragment over the build-embedded base to\n// serve the live manifest).\n//\n// Connect owns the \"where\" of every OS integration: file handlers open at the\n// app root, `web+…` protocol links and shared files route through fixed\n// in-scope endpoints. Contributors declare only WHAT they accept; the routes\n// below are injected here so a package can never point the OS at an arbitrary\n// URL. Injection is idempotent, so re-merging a manifest that already carries\n// the routes is a no-op.\n\nimport type {\n PHConnectPwaFileHandler,\n PHConnectPwaIcon,\n PHConnectPwaManifest,\n} from \"../clis/types.js\";\nimport { dedupeFileHandlers, dedupeIcons, unionStrings } from \"./pwa-config.js\";\n\n/**\n * The one route launched files open at, shared by the built-in handler and\n * injected into every contributed one. Not configurable: consuming launched\n * files takes runtime code that lives in Connect itself, and a relative \".\"\n * resolves against the manifest URL so it tracks any deploy base (the\n * webmanifest is served dynamically and never rewritten by the dynamic-base\n * plugin) — same trick as the base start_url/scope.\n */\nexport const PWA_FILE_HANDLER_ACTION = \".\";\n\n// IndexedDB schema for the page->service-worker PWA-fragment mirror. A SW can't\n// read localStorage (where the installed-package list lives), so the SPA\n// mirrors the merged fragment here and the SW reads it to serve a live\n// manifest. Both sides MUST agree, so the schema lives here as the single\n// source of truth (the SPA writer and the SW reader both import these) —\n// a rename or version bump can no longer desync one side silently.\nexport const PWA_IDB_NAME = \"ph-pwa\";\nexport const PWA_IDB_STORE = \"fragments\";\nexport const PWA_IDB_KEY = \"merged\";\nexport const PWA_IDB_VERSION = 1;\n\n/** The subset of a web-app manifest this module reads/writes, plus an index\n * signature so untouched fields (name, theme_color, launch_handler, …) pass\n * through verbatim. */\nexport interface PwaWebManifest {\n icons?: PHConnectPwaIcon[];\n file_handlers?: (PHConnectPwaFileHandler & { action?: string })[];\n categories?: string[];\n [key: string]: unknown;\n}\n\n/**\n * Lay a `PHConnectPwaManifest` fragment over a base web-manifest object.\n *\n * - **scalars** (name, theme_color, launch_handler, …): governed by\n * `scalarPolicy`. `\"fragment-wins\"` lets the fragment overwrite the base;\n * `\"base-wins\"` keeps the base and only fills fields it left unset. Keys\n * listed in `protectedScalars` always behave as base-wins even under a\n * fragment-wins policy — used at runtime to fragment-win cosmetic scalars\n * while still protecting navigation-critical ones (`start_url`/`scope`) from\n * an untrusted dynamically-installed package.\n * - **arrays** (icons, file_handlers): always additive, base entries first,\n * de-duplicated — so a package can extend but never displace a built-in\n * (Chromium is first-registered-wins per file extension, so `.phd`/`.phdm`\n * stay Connect's).\n * - **categories**: order-preserving string union (derived from the manifest\n * `category` field, not authored under `pwa`).\n *\n * The Connect-owned file-handler action is injected idempotently.\n */\nexport function mergeManifest(\n base: PwaWebManifest,\n fragment: PHConnectPwaManifest | undefined,\n opts?: {\n scalarPolicy?: \"base-wins\" | \"fragment-wins\";\n protectedScalars?: readonly string[];\n },\n): PwaWebManifest {\n const scalarPolicy = opts?.scalarPolicy ?? \"base-wins\";\n const protectedScalars = opts?.protectedScalars ?? [];\n const result: PwaWebManifest = { ...base };\n const { icons, file_handlers, categories, ...scalars } = fragment ?? {};\n\n const takeScalar = (key: string): boolean => {\n // Protected keys stay base-wins regardless of the policy.\n const policy = protectedScalars.includes(key) ? \"base-wins\" : scalarPolicy;\n return policy === \"fragment-wins\" || result[key] === undefined;\n };\n\n for (const [key, value] of Object.entries(scalars)) {\n if (takeScalar(key)) result[key] = value;\n }\n\n if (icons?.length) {\n result.icons = dedupeIcons([...(result.icons ?? []), ...icons]);\n }\n if (file_handlers?.length) {\n // Force the Connect-owned action (spread first, action last) so contributed\n // handlers match the base's already-injected shape and de-dupe correctly.\n const injected = file_handlers.map((handler) => ({\n ...handler,\n action: PWA_FILE_HANDLER_ACTION,\n }));\n result.file_handlers = dedupeFileHandlers([\n ...(result.file_handlers ?? []),\n ...injected,\n ]);\n }\n if (categories?.length) {\n result.categories = unionStrings(result.categories, categories);\n }\n\n // Idempotently (re-)assert the Connect-owned file-handler action across the\n // merged result, covering both fragment contributions and any base entries.\n if (result.file_handlers?.length) {\n result.file_handlers = result.file_handlers.map((handler) => ({\n ...handler,\n action: PWA_FILE_HANDLER_ACTION,\n }));\n }\n\n return result;\n}\n","// Single source of truth for JSON Schema shapes shared between the source\n// PowerhouseConfig schema (packages/shared/clis/source-config-schema.ts) and\n// the runtime RuntimePowerhouseConfig schema\n// (packages/builder-tools/connect-utils/runtime-config-schema.ts).\n//\n// When a shared shape changes, edit it here — both schemas pick it up.\n\nexport const powerhousePackageSchema = {\n type: \"object\",\n additionalProperties: false,\n required: [\"packageName\"],\n properties: {\n packageName: {\n type: \"string\",\n description: \"Fully qualified npm package name (e.g. @scope/name).\",\n },\n version: {\n type: \"string\",\n description: \"Exact version (registry providers) or omit to take latest.\",\n },\n provider: {\n type: \"string\",\n enum: [\"npm\", \"github\", \"local\", \"registry\"],\n description: \"Where Connect should resolve the package from at runtime.\",\n },\n url: {\n type: \"string\",\n description:\n \"Override URL for non-registry providers (e.g. github tarball).\",\n },\n },\n} as const;\n\n// Reusable shape for `connect.drives.sections.{remote,local}` — three\n// affirmative-named toggles per section. The legacy public+cloud sections\n// have been collapsed into a single `remote`.\nconst driveSectionSchema = {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Visibility and add/delete affordances for a drive section in the sidebar.\",\n properties: {\n enabled: {\n type: \"boolean\",\n description: \"When false, the section is hidden in the sidebar.\",\n default: true,\n },\n allowAdd: {\n type: \"boolean\",\n description:\n \"When false, the section's 'add drive' affordance is hidden.\",\n default: true,\n },\n allowDelete: {\n type: \"boolean\",\n description:\n \"When false, drives in this section cannot be deleted from the UI.\",\n default: true,\n },\n },\n} as const;\n\n// Reusable shape for a runtime-caching / denylist URL match. A string is\n// handed to Workbox verbatim; `{ source, flags }` is rebuilt into a RegExp at\n// build time. Function patterns aren't serialisable and can't be expressed\n// from config — only Connect's built-in rules use them (see the runtime-caching\n// rules in builder-tools' connect-utils/service-worker/service-worker.ts).\nconst pwaUrlPatternSchema = {\n description:\n \"URL match. A string is matched verbatim by Workbox; { source, flags } is rebuilt into a RegExp at build time.\",\n oneOf: [\n { type: \"string\" },\n {\n type: \"object\",\n additionalProperties: false,\n required: [\"source\"],\n properties: {\n source: { type: \"string\", description: \"RegExp source.\" },\n flags: { type: \"string\", description: \"RegExp flags (e.g. 'i').\" },\n },\n },\n ],\n} as const;\n\n// Reusable web-app-manifest icon shape (manifest.icons and file-handler icons).\nconst pwaIconSchema = {\n type: \"object\",\n additionalProperties: false,\n required: [\"src\"],\n properties: {\n src: { type: \"string\" },\n sizes: { type: \"string\" },\n type: { type: \"string\" },\n purpose: { type: \"string\" },\n },\n} as const;\n\nexport const phConnectRuntimeConfigSchema = {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Connect-specific UI customisations. All fields optional; omit the section entirely for default behaviour.\",\n properties: {\n branding: {\n type: \"object\",\n additionalProperties: false,\n description: \"App identity and visual branding.\",\n properties: {\n appName: {\n type: \"string\",\n description:\n \"Browser tab title and any in-app brand text. Defaults to 'Powerhouse Connect'.\",\n },\n homeBackground: {\n type: [\"string\", \"null\"],\n description:\n \"Hero image on the empty home screen. URL or path to override; null or omitted uses the bundled default image.\",\n },\n },\n },\n app: {\n type: \"object\",\n additionalProperties: false,\n description: \"Top-level Connect application behaviour.\",\n properties: {\n logLevel: {\n type: \"string\",\n enum: [\"debug\", \"info\", \"warn\", \"error\"],\n description:\n \"Log level applied by Connect's logger at boot. Affects browser-side output only.\",\n default: \"info\",\n },\n basePath: {\n type: \"string\",\n description:\n \"Base path Connect is mounted under (e.g. '/connect' for subpath deploys). Normalised at runtime to start and end with '/'. Defaults to the build-time BASE_URL.\",\n default: \"/\",\n },\n offline: {\n type: \"boolean\",\n description:\n \"When true (default), the build emits a precaching service worker so Connect's app shell works offline, and the SPA registers it at boot. Set false to opt this deployment out: no service worker is built, the SPA skips registration, and any previously-installed worker is unregistered.\",\n default: true,\n },\n studioMode: {\n type: \"boolean\",\n description:\n \"Studio mode. Enables builder-only capabilities: Connect loads the vetra package and exposes DocumentModel (and vetra spec types) as creatable documents. Forced on by `ph vetra` / `ph connect studio`; false by default.\",\n default: false,\n },\n workflowsEnabled: {\n type: \"boolean\",\n description:\n \"Powerhouse workflows in Connect. When true the tab loads the @powerhousedao/workflow package (workflow + connection documents, their editors and Workflow Studio) and the reactor worker registers its document models. Falls back to the top-level `workflows.enabled`; set it to override that for Connect. Independent of studioMode. False when neither is set.\",\n },\n },\n },\n ai: {\n type: \"object\",\n additionalProperties: false,\n description: \"AI assistant (chat) behaviour.\",\n properties: {\n assistantEnabled: {\n type: \"boolean\",\n description:\n \"When true, Connect mounts the in-browser AI assistant (bottom-right chat FAB that talks to a user-configured OpenAI-compatible endpoint and acts on the reactor). Disabled by default.\",\n default: false,\n },\n },\n },\n packages: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Runtime behaviour for the Connect package manager (separate from top-level `packages[]`, which lists which packages to load).\",\n properties: {\n externalEnabled: {\n type: \"boolean\",\n description:\n \"When false, Connect refuses to load any package that wasn't bundled at build time. Affirmative replacement for the legacy PH_CONNECT_EXTERNAL_PACKAGES_DISABLED env var.\",\n default: true,\n },\n liveReload: {\n type: \"boolean\",\n description:\n \"When true, Connect subscribes to the static-mode `/__packages` SSE channel so live publishes flow into the running tab without a page reload. Only works under hosting that serves this channel (e.g. ph-clint static mode).\",\n default: false,\n },\n },\n },\n drives: {\n type: \"object\",\n additionalProperties: false,\n description: \"Default-drive and add-drive UI behaviour.\",\n properties: {\n allowAddDrive: {\n type: \"boolean\",\n description:\n \"When false, the SPA hides the 'add drive' affordance entirely (top-level). Per-section overrides live in `sections.{remote,local}.allowAdd`.\",\n default: true,\n },\n defaultDrives: {\n type: \"array\",\n description:\n \"Drives the SPA auto-connects to on first load. Each entry is either a remote drive (a URL, with optional name/icon overrides) or a local drive (created locally on first boot, with a stable id and optional name/icon/app).\",\n default: [],\n items: {\n oneOf: [\n {\n type: \"object\",\n additionalProperties: false,\n required: [\"url\"],\n properties: {\n url: { type: \"string\" },\n name: { type: [\"string\", \"null\"] },\n icon: { type: [\"string\", \"null\"] },\n },\n },\n {\n type: \"object\",\n additionalProperties: false,\n required: [\"local\", \"id\"],\n properties: {\n local: {\n const: true,\n description:\n \"Discriminator: this entry is a local drive created on first boot.\",\n },\n id: {\n type: \"string\",\n description:\n \"Stable drive id. The drive is created with this id on first boot and is not re-created on later boots.\",\n },\n name: { type: [\"string\", \"null\"] },\n icon: { type: [\"string\", \"null\"] },\n app: {\n type: \"string\",\n description:\n \"Drive app (preferred editor) to open on the drive.\",\n },\n },\n },\n ],\n },\n },\n preserveStrategy: {\n type: \"string\",\n enum: [\"preserve-all\", \"preserve-by-url-and-detach\"],\n description:\n \"Strategy applied when defaultDrives change between deploys. 'preserve-all' keeps user-added drives untouched; 'preserve-by-url-and-detach' detaches removed default drives. No schema default — opt-in only.\",\n },\n sections: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Per-section visibility and affordance toggles. `remote` covers what was historically split into 'public' + 'cloud'; `local` is browser-local drives.\",\n properties: {\n remote: driveSectionSchema,\n local: driveSectionSchema,\n },\n },\n },\n },\n renown: {\n type: \"object\",\n additionalProperties: false,\n description: \"Renown identity / authentication coordinates.\",\n properties: {\n url: {\n type: \"string\",\n description: \"Renown auth service URL.\",\n default: \"https://www.renown.id\",\n },\n networkId: {\n type: \"string\",\n description: \"CAIP-2 network namespace (e.g. 'eip155').\",\n default: \"eip155\",\n },\n chainId: {\n type: \"number\",\n description: \"CAIP-2 chain reference within the network namespace.\",\n default: 1,\n },\n namespace: {\n type: \"string\",\n description:\n \"Renown localStorage namespace; share it across Connects to share login.\",\n },\n switchboardUrl: {\n type: \"string\",\n description:\n \"Switchboard GraphQL URL. When set, Connect enables in-page (no-redirect) Renown sign-in; otherwise it falls back to the redirect flow via `url`.\",\n },\n adapters: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Per-adapter wallet config for in-page auth. Presence of an adapter key enables it; omit or leave empty for redirect-only behaviour.\",\n properties: {\n rainbow: {\n type: \"object\",\n additionalProperties: false,\n description: \"wagmi + RainbowKit external-wallet adapter config.\",\n properties: {\n walletConnectProjectId: {\n type: \"string\",\n description:\n \"WalletConnect project id; required for this adapter to function.\",\n },\n infuraProjectId: {\n type: \"string\",\n description:\n \"Optional Infura project id used to build RPC transports.\",\n },\n },\n },\n privy: {\n type: \"object\",\n additionalProperties: false,\n description: \"Privy embedded/social adapter config.\",\n properties: {\n appId: {\n type: \"string\",\n description:\n \"Privy application id; required for this adapter to function.\",\n },\n clientId: {\n type: \"string\",\n description: \"Optional Privy client id.\",\n },\n methods: {\n type: \"array\",\n description:\n \"Login methods this adapter offers; default per adapter when omitted.\",\n items: { type: \"string\" },\n },\n },\n },\n },\n },\n },\n },\n sentry: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Sentry error-tracking coordinates. Set `dsn` to enable Sentry; leave `dsn` null to disable. The Sentry release tag stays build-time (stamped via Vite's `define` from WORKSPACE_VERSION) so it always matches the sourcemaps uploaded by CI.\",\n properties: {\n dsn: {\n type: [\"string\", \"null\"],\n description:\n \"Sentry DSN URL. `null` disables Sentry entirely; the SPA never loads the Sentry SDK chunk.\",\n default: null,\n },\n env: {\n type: \"string\",\n description:\n \"Sentry environment label, surfaced as the `environment` tag on every event.\",\n default: \"dev\",\n },\n tracing: {\n type: \"boolean\",\n description: \"Enable Sentry performance tracing.\",\n default: false,\n },\n },\n },\n openPanel: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"OpenPanel product analytics. Set `clientId` to enable; an empty `clientId` disables it. Events are only sent after the user accepts analytics cookies. Takes precedence over the build-time PH_CONNECT_OPENPANEL_* env vars.\",\n properties: {\n clientId: {\n type: \"string\",\n description:\n \"OpenPanel client id. Empty string disables OpenPanel entirely.\",\n default: \"\",\n },\n apiUrl: {\n type: \"string\",\n description:\n \"OpenPanel API URL for self-hosted instances (e.g. 'https://openpanel.example/api'). Omit to use OpenPanel's hosted API.\",\n },\n trackUiEvents: {\n type: \"boolean\",\n description: \"Track UI events.\",\n default: true,\n },\n trackOperations: {\n type: \"boolean\",\n description: \"Track document operations.\",\n default: true,\n },\n },\n },\n instance: {\n type: \"object\",\n additionalProperties: false,\n required: [\"namespace\", \"reactorWorker\"],\n description:\n \"Per-instance identity. Lets one origin host multiple isolated Connect instances, each with its own storage + SharedWorker namespace.\",\n properties: {\n namespace: {\n type: [\"string\", \"null\"],\n description:\n \"Explicit storage/SharedWorker namespace for this instance. `null` derives it from the base path (and, later, the configured endpoint), so root deployments stay byte-identical.\",\n default: null,\n },\n reactorWorker: {\n type: \"boolean\",\n description:\n \"Host the reactor in a shared worker instead of on the main thread. Off by default; the main-thread reactor stays the proven path until cutover is verified.\",\n default: false,\n },\n },\n },\n reactor: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Settings for the reactor Connect runs in the browser, on the main thread or in the shared worker alike.\",\n properties: {\n featureFlags: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Enforcement flags. Each implies its predecessors, and the reactor refuses to boot on a set that names a later flag without an earlier one. These are consensus settings: a Connect syncing with a fleet must carry the same flags the fleet does, or the two reach different replay outcomes for the same history and diverge.\",\n properties: {\n documentDecisions: {\n type: \"boolean\",\n description:\n \"Decide writes from the document stream rather than the document meta cache, so a backdated deletion denies the operations that sort after it.\",\n default: false,\n },\n authEnforcement: {\n type: \"boolean\",\n description:\n \"Enforce the auth scope's policy at admission, replay, and read. Requires documentDecisions.\",\n default: false,\n },\n authGroups: {\n type: \"boolean\",\n description:\n \"Let `{ group }` principals match against the rosters of the group documents a policy names. Requires authEnforcement.\",\n default: false,\n },\n authConditions: {\n type: \"boolean\",\n description:\n \"Evaluate `where` and `match` conditions on grants. Requires authGroups. Do not enable on a fleet `preflight:auth` reports as crossing a reducer version.\",\n default: false,\n },\n },\n },\n createSignaturePolicy: {\n type: \"string\",\n enum: [\"legacy\", \"v2-required\"],\n description:\n \"What new documents are created as. `v2-required` documents accept only v2 action signatures and take content-addressed ids; set `legacy` while any peer Connect syncs with predates them. Existing documents keep their policy.\",\n default: \"v2-required\",\n },\n },\n },\n pwa: {\n type: \"object\",\n additionalProperties: false,\n description:\n \"Progressive-web-app / service-worker overrides, layered on Connect's built-in PWA defaults at build time. Scalar fields deep-merge (this layer wins); the array members (icons, file_handlers, globs, runtimeCaching and denylist patterns) are additive; maximumFileSizeToCacheInBytes takes the max across contributors. (categories is not set here — it is derived from the manifest's category field.) Only applied when connect.app.offline is true.\",\n properties: {\n manifest: {\n type: \"object\",\n additionalProperties: false,\n description: \"Web-app-manifest field overrides.\",\n properties: {\n name: { type: \"string\" },\n short_name: { type: \"string\" },\n description: { type: \"string\" },\n theme_color: { type: \"string\" },\n background_color: { type: \"string\" },\n display: {\n type: \"string\",\n enum: [\"fullscreen\", \"standalone\", \"minimal-ui\", \"browser\"],\n },\n start_url: { type: \"string\" },\n scope: { type: \"string\" },\n icons: {\n type: \"array\",\n description:\n \"Icons appended to the built-in set and de-duplicated by (src, sizes, purpose).\",\n items: pwaIconSchema,\n },\n file_handlers: {\n type: \"array\",\n description:\n \"File associations appended after Connect's built-in .phd/.phdm handler and de-duplicated on the whole entry. Entries only declare accepted types; there is no action field, because opening the files requires Connect's own runtime handling, so every handler opens at the app root.\",\n items: {\n type: \"object\",\n additionalProperties: false,\n required: [\"accept\"],\n properties: {\n accept: {\n type: \"object\",\n description:\n \"MIME type → file extensions. Each extension must start with '.'; browsers ignore entries without it.\",\n additionalProperties: {\n type: \"array\",\n items: { type: \"string\", pattern: \"^\\\\.\" },\n },\n },\n icons: {\n type: \"array\",\n description: \"OS-level file-type icons.\",\n items: pwaIconSchema,\n },\n launch_type: {\n type: \"string\",\n enum: [\"single-client\", \"multiple-clients\"],\n },\n },\n },\n },\n launch_handler: {\n type: \"object\",\n additionalProperties: false,\n required: [\"client_mode\"],\n description:\n \"How the OS launches the app for handled files/links. Connect defaults to focus-existing.\",\n properties: {\n client_mode: {\n type: \"string\",\n enum: [\n \"auto\",\n \"focus-existing\",\n \"navigate-existing\",\n \"navigate-new\",\n ],\n },\n },\n },\n },\n },\n globPatterns: {\n type: \"array\",\n items: { type: \"string\" },\n description:\n \"Extra Workbox precache globs, unioned with the built-ins.\",\n },\n globIgnores: {\n type: \"array\",\n items: { type: \"string\" },\n description:\n \"Extra precache ignore globs, unioned with the built-ins.\",\n },\n maximumFileSizeToCacheInBytes: {\n type: \"number\",\n description:\n \"Raise the precache file-size ceiling. The max across all contributors wins, so no contributor can shrink another's limit.\",\n },\n runtimeCaching: {\n type: \"array\",\n description:\n \"Runtime-caching rules appended after the built-in rules. Workbox is first-match-wins, so these cannot override a built-in rule matching the same URL.\",\n items: {\n type: \"object\",\n additionalProperties: false,\n required: [\"urlPattern\", \"handler\"],\n properties: {\n urlPattern: pwaUrlPatternSchema,\n handler: {\n type: \"string\",\n enum: [\n \"CacheFirst\",\n \"CacheOnly\",\n \"NetworkFirst\",\n \"NetworkOnly\",\n \"StaleWhileRevalidate\",\n ],\n },\n method: {\n type: \"string\",\n enum: [\"GET\", \"POST\", \"PUT\", \"DELETE\", \"HEAD\", \"PATCH\"],\n },\n options: {\n type: \"object\",\n additionalProperties: false,\n properties: {\n cacheName: { type: \"string\" },\n networkTimeoutSeconds: {\n type: \"number\",\n description:\n \"Seconds a NetworkFirst rule waits for the network before falling back to the cache.\",\n },\n expiration: {\n type: \"object\",\n additionalProperties: false,\n properties: {\n maxEntries: { type: \"number\" },\n maxAgeSeconds: { type: \"number\" },\n },\n },\n cacheableResponse: {\n type: \"object\",\n additionalProperties: false,\n properties: {\n statuses: { type: \"array\", items: { type: \"number\" } },\n headers: {\n type: \"object\",\n additionalProperties: { type: \"string\" },\n },\n },\n },\n },\n },\n },\n },\n },\n navigateFallbackDenylist: {\n type: \"array\",\n description:\n \"Extra SPA navigate-fallback denylist patterns, unioned with the built-ins.\",\n items: pwaUrlPatternSchema,\n },\n },\n },\n },\n} as const;\n","import { satisfies, validRange } from \"semver\";\n\nexport type SharedDep = { specifier: string; package: string };\n\n/**\n * The dependency set Connect and loaded packages share via the import map.\n * `@powerhousedao/connect` is deliberately absent: it is the Connect app\n * itself (no importable exports), so there is nothing to share.\n */\nexport const SHARED_DEPS: readonly SharedDep[] = [\n { specifier: \"document-model\", package: \"document-model\" },\n {\n specifier: \"@powerhousedao/document-engineering\",\n package: \"@powerhousedao/document-engineering\",\n },\n { specifier: \"@powerhousedao/shared\", package: \"@powerhousedao/shared\" },\n {\n specifier: \"@powerhousedao/shared/registry/urls\",\n package: \"@powerhousedao/shared\",\n },\n {\n specifier: \"@powerhousedao/design-system/connect\",\n package: \"@powerhousedao/design-system\",\n },\n {\n specifier: \"@powerhousedao/reactor-browser\",\n package: \"@powerhousedao/reactor-browser\",\n },\n // Connect already vendors zod (it is in DEFAULT_VENDOR_INCLUDE, so the\n // import map publishes an entry for it) and every generated project already\n // declares it as a peerDependency -- yet it was missing from this set, so\n // each package inlined a private copy anyway. It is the single biggest\n // dependency left in a minimal package.\n { specifier: \"zod\", package: \"zod\" },\n];\n\nexport const SHARED_DEP_SPECIFIERS: readonly string[] = SHARED_DEPS.map(\n (d) => d.specifier,\n);\n\n/**\n * The `@powerhousedao/shared` subpaths the production vendor bundles. The\n * bare root is deliberately absent: its type barrel references node-only\n * modules (`clis/`), which the current vite/rolldown cannot bundle for the\n * browser — vendoring the root fails the build (a pre-existing latent\n * issue). A package that imports the bare root is simply not shared; it\n * bundles its own copy.\n */\nexport const SHARED_SUBPATHS: readonly string[] = [\n \"connect\",\n \"document-model\",\n \"processors\",\n \"document-drive\",\n \"registry\",\n \"registry/urls\",\n \"registry/manifest-slim\",\n];\n\n/**\n * The specifiers a package build may safely externalize onto the host's\n * import map — i.e. the ones the vendor actually publishes an entry for.\n *\n * `@powerhousedao/shared` is narrowed to SHARED_SUBPATHS rather than taken as\n * a prefix: the bare root is never vendored (see SHARED_SUBPATHS), and\n * neither are its other subpaths (`analytics`, `constants`, `clis`, ...).\n * Externalizing those would leave a bare specifier in the package's output\n * that nothing in the import map resolves, so the package would fail to load\n * at runtime instead of simply bundling its own copy.\n */\nexport const EXTERNALIZABLE_SHARED_SPECIFIERS: readonly string[] = [\n ...new Set([\n ...SHARED_DEP_SPECIFIERS.filter((s) => s !== \"@powerhousedao/shared\"),\n ...SHARED_SUBPATHS.map((s) => `@powerhousedao/shared/${s}`),\n ]),\n];\n\n/** Split a specifier into its package name and subpath (\"\" for a root). */\nexport function parseDepSpec(spec: string): { pkg: string; sub: string } {\n if (spec.startsWith(\"@\")) {\n const parts = spec.split(\"/\");\n return { pkg: parts.slice(0, 2).join(\"/\"), sub: parts.slice(2).join(\"/\") };\n }\n const i = spec.indexOf(\"/\");\n return i === -1\n ? { pkg: spec, sub: \"\" }\n : { pkg: spec.slice(0, i), sub: spec.slice(i + 1) };\n}\n\nfunction isSharedSpecifier(spec: string, specs: readonly string[]): boolean {\n return specs.some((s) => spec === s || spec.startsWith(s + \"/\"));\n}\n\n/**\n * Return the import/export specifiers in `source` that are a shared\n * specifier (or a subpath of one), sorted. Heuristic: only statement\n * positions are scanned (`from \"x\"`, `import \"x\"`, `import(\"x\")`;\n * `export … from \"x\"` is covered by the `from` pattern), so import-like\n * text inside comments or strings can be reported too. That errs toward\n * over-reporting, which is the safe direction for the advisory build\n * warning.\n */\nexport function findSharedImports(\n source: string,\n specs: readonly string[] = SHARED_DEP_SPECIFIERS,\n): string[] {\n const found = new Set<string>();\n const patterns = [\n /\\bfrom\\s+[\"']([^\"'\\\\]+)[\"']/g,\n /\\bimport\\s+[\"']([^\"'\\\\]+)[\"']/g,\n /\\bimport\\s*\\(\\s*[\"']([^\"'\\\\]+)[\"']\\s*\\)/g,\n ];\n for (const re of patterns) {\n for (const m of source.matchAll(re)) {\n const spec = m[1];\n if (isSharedSpecifier(spec, specs)) found.add(spec);\n }\n }\n return [...found].sort();\n}\n\n/**\n * Rewrite a package source for blob import in a worker context (import maps\n * don't apply there): shared specifiers become their mapped URLs, and\n * relative (`./`, `../`) specifiers become absolute against `sourceUrl`\n * (a blob URL has no directory to resolve against). `#` subpath imports are\n * deliberately left alone: they resolve via the package's own\n * `package.json` \"imports\" field, which the rewrite cannot reproduce.\n * Returns the input unchanged when nothing matched.\n */\nexport function rewritePackageSource(\n source: string,\n sourceUrl: string,\n imports: Record<string, string>,\n): string {\n if (!Object.keys(imports).length) return source;\n const base = new URL(sourceUrl);\n const map = (spec: string): string | null => {\n const mapped = imports[spec];\n if (mapped) return mapped;\n if (spec.startsWith(\"./\") || spec.startsWith(\"../\")) {\n return new URL(spec, base).href;\n }\n return null;\n };\n let out = source;\n // The quote character is captured and reused: a source that quotes its\n // specifiers with ' would otherwise never match the replacement and be\n // left un-rewritten — silently, since the specifier still maps.\n for (const re of [\n /\\bfrom\\s+([\"'])([^\"'\\\\]+)\\1/g,\n /\\bimport\\s+([\"'])([^\"'\\\\]+)\\1/g,\n /\\bimport\\s*\\(\\s*([\"'])([^\"'\\\\]+)\\1\\s*\\)/g,\n ]) {\n out = out.replace(re, (match, quote: string, spec: string) => {\n // The match contains the quoted specifier exactly once and the\n // captured group has no quotes/backslashes ([^\"'\\\\]), so a literal\n // replace is safe.\n const mapped = map(spec);\n return mapped\n ? match.replace(`${quote}${spec}${quote}`, `${quote}${mapped}${quote}`)\n : match;\n });\n }\n return out;\n}\n\nexport type SharedDepMismatch = {\n package: string;\n required: string;\n provided: string;\n};\n\nexport type PackageDeps = {\n dependencies?: Record<string, unknown>;\n peerDependencies?: Record<string, unknown>;\n};\n\n/**\n * Compare a package's declared ranges against the host's version table.\n * `hostVersions` defines the checked set (only deps present in it are\n * checked). `*`, non-semver protocols (workspace:, file:, git:, npm:, URLs)\n * and unparseable ranges never mismatch.\n */\nexport function checkSharedDeps(\n pkgJson: PackageDeps,\n hostVersions: Record<string, string>,\n): SharedDepMismatch[] {\n const out: SharedDepMismatch[] = [];\n const entries = [\n ...Object.entries(pkgJson.dependencies ?? {}),\n ...Object.entries(pkgJson.peerDependencies ?? {}),\n ];\n for (const [dep, range] of entries) {\n const provided = hostVersions[dep];\n if (provided === undefined || typeof range !== \"string\") continue;\n if (range === \"*\" || /^[a-z]+:/i.test(range)) continue;\n if (!validRange(range)) continue;\n if (!satisfies(provided, range, { includePrerelease: true })) {\n out.push({ package: dep, required: range, provided });\n }\n }\n return out;\n}\n\nexport function formatSharedDepWarnings(\n mismatches: SharedDepMismatch[],\n): string[] {\n return mismatches.map(\n (m) =>\n `${m.package}: requires ${m.required}, Connect provides ${m.provided}`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,MAAa,2BAA2B;;;;;;;ACNxC,MAAM,gBAAgB,EACnB,MAAM,CAAC,EAAE,QAAQ,GAAG,EAAE,KAAK,CAAC,QAAQ,OAAO,CAAC,C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KACN,aACE;KACF,SAAS;IACX;IACA,kBAAkB;KAChB,MAAM;KACN,aACE;IACJ;GACF;EACF;EACA,IAAI;GACF,MAAM;GACN,sBAAsB;GACtB,aAAa;GACb,YAAY,EACV,kBAAkB;IAChB,MAAM;IACN,aACE;IACF,SAAS;GACX,EACF;EACF;EACA,UAAU;GACR,MAAM;GACN,sBAAsB;GACtB,aACE;GACF,YAAY;IACV,iBAAiB;KACf,MAAM;KACN,aACE;KACF,SAAS;IACX;IACA,YAAY;KACV,MAAM;KACN,aACE;KACF,SAAS;IACX;GACF;EACF;EACA,QAAQ;GACN,MAAM;GACN,sBAAsB;GACtB,aAAa;GACb,YAAY;IACV,eAAe;KACb,MAAM;KACN,aACE;KACF,SAAS;IACX;IACA,eAAe;KACb,MAAM;KACN,aACE;KACF,SAAS,CAAC;KACV,OAAO,EACL,OAAO,CACL;MACE,MAAM;MACN,sBAAsB;MACtB,UAAU,CAAC,KAAK;MAChB,YAAY;OACV,KAAK,EAAE,MAAM,SAAS;OACtB,MAAM,EAAE,MAAM,CAAC,UAAU,MAAM,EAAE;OACjC,MAAM,EAAE,MAAM,CAAC,UAAU,MAAM,EAAE;MACnC;KACF,GACA;MACE,MAAM;MACN,sBAAsB;MACtB,UAAU,CAAC,SAAS,IAAI;MACxB,YAAY;OACV,OAAO;QACL,OAAO;QACP,aACE;OACJ;OACA,IAAI;QACF,MAAM;QACN,aACE;OACJ;OACA,MAAM,EAAE,MAAM,CAAC,UAAU,MAAM,EAAE;OACjC,MAAM,EAAE,MAAM,CAAC,UAAU,MAAM,EAAE;OACjC,KAAK;QACH,MAAM;QACN,aACE;OACJ;MACF;KACF,CACF,EACF;IACF;IACA,kBAAkB;KAChB,MAAM;KACN,MAAM,CAAC,gBAAgB,4BAA4B;KACnD,aACE;IACJ;IACA,UAAU;KACR,MAAM;KACN,sBAAsB;KACtB,aACE;KACF,YAAY;MACV,QAAQ;MACR,OAAO;KACT;IACF;GACF;EACF;EACA,QAAQ;GACN,MAAM;GACN,sBAAsB;GACtB,aAAa;GACb,YAAY;IACV,KAAK;KACH,MAAM;KACN,aAAa;KACb,SAAS;IACX;IACA,WAAW;KACT,MAAM;KACN,aAAa;KACb,SAAS;IACX;IACA,SAAS;KACP,MAAM;KACN,aAAa;KACb,SAAS;IACX;IACA,WAAW;KACT,MAAM;KACN,aACE;IACJ;IACA,gBAAgB;KACd,MAAM;KACN,aACE;IACJ;IACA,UAAU;KACR,MAAM;KACN,sBAAsB;KACtB,aACE;KACF,YAAY;MACV,SAAS;OACP,MAAM;OACN,sBAAsB;OACtB,aAAa;OACb,YAAY;QACV,wBAAwB;SACtB,MAAM;SACN,aACE;QACJ;QACA,iBAAiB;SACf,MAAM;SACN,aACE;QACJ;OACF;MACF;MACA,OAAO;OACL,MAAM;OACN,sBAAsB;OACtB,aAAa;OACb,YAAY;QACV,OAAO;SACL,MAAM;SACN,aACE;QACJ;QACA,UAAU;SACR,MAAM;SACN,aAAa;QACf;QACA,SAAS;SACP,MAAM;SACN,aACE;SACF,OAAO,EAAE,MAAM,SAAS;QAC1B;OACF;MACF;KACF;IACF;GACF;EACF;EACA,QAAQ;GACN,MAAM;GACN,sBAAsB;GACtB,aACE;GACF,YAAY;IACV,KAAK;KACH,MAAM,CAAC,UAAU,MAAM;KACvB,aACE;KACF,SAAS;IACX;IACA,KAAK;KACH,MAAM;KACN,aACE;KACF,SAAS;IACX;IACA,SAAS;KACP,MAAM;KACN,aAAa;KACb,SAAS;IACX;GACF;EACF;EACA,WAAW;GACT,MAAM;GACN,sBAAsB;GACtB,aACE;GACF,YAAY;IACV,UAAU;KACR,MAAM;KACN,aACE;KACF,SAAS;IACX;IACA,QAAQ;KACN,MAAM;KACN,aACE;IACJ;IACA,eAAe;KACb,MAAM;KACN,aAAa;KACb,SAAS;IACX;IACA,iBAAiB;KACf,MAAM;KACN,aAAa;KACb,SAAS;IACX;GACF;EACF;EACA,UAAU;GACR,MAAM;GACN,sBAAsB;GACtB,UAAU,CAAC,aAAa,eA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AmB,KAAK,CAAC,GACzD,IAAI,KAAK;GAAE,SAAS;GAAK,UAAU;GAAO;EAAS,CAAC;CAExD;CACA,OAAO;AACT;AAEA,SAAgB,wBACd,YACU;CACV,OAAO,WAAW,KACf,MACC,GAAG,EAAE,QAAQ,aAAa,EAAE,SAAS,qBAAqB,EAAE,UAChE;AACF"}
@@ -1,7 +1,7 @@
1
- import { Bt as DocumentModelGlobalState, En as IsStateOfType, Kr as Reducer, On as LoadFromInput, Pn as Maybe, Tn as IsDocumentOfType, fi as SaveToFileHandle, gt as CreateDocument, ot as AssertIsDocumentOfType, st as AssertIsStateOfType, yt as CreateState, zu as PHBaseState } from "../types-xLPOHE23.js";
2
- import "../index-CDDyUSHE.js";
3
- import { $ as DeleteNodeAction, A as TriggerData, C as RemoveTriggerInput, D as SetSharingTypeInput, E as SetDriveNameInput, G as DocumentDriveAction, J as LegacyAddFileInput, K as DocumentDriveDocument, M as TriggerType, N as UpdateFileInput, O as TransmitterType, P as UpdateNodeInput, Q as CopyNodeAction, S as RemoveListenerInput, T as SetDriveIconInput, U as DocumentDrivePHState, W as DriveDocumentModelModule, X as AddFileAction, Y as LegacySynchronizationUnit, Z as AddFolderAction, _ as ListenerInput, a as CopyNodeInput, at as AddListenerAction, b as PullResponderTriggerData, c as DocumentDriveLocalState, ct as DocumentDriveDriveOperations, d as FolderNode, dt as SetAvailableOfflineAction, et as DocumentDriveNodeAction, f as Listener, ft as SetDriveIconAction, g as ListenerFilterInput, h as ListenerFilter, i as AddTriggerInput, it as UpdateNodeAction, j as TriggerInput, k as Trigger, l as DocumentDrivePHState$1, lt as RemoveListenerAction, m as ListenerCallInfoInput, mt as SetSharingTypeAction, n as AddFolderInput, nt as MoveNodeAction, o as DeleteNodeInput, ot as AddTriggerAction, p as ListenerCallInfo, pt as SetDriveNameAction, q as LegacyAddFileAction, r as AddListenerInput, rt as UpdateFileAction, s as DocumentDriveGlobalState, st as DocumentDriveDriveAction, t as AddFileInput, tt as DocumentDriveNodeOperations, u as FileNode, ut as RemoveTriggerAction, v as MoveNodeInput, w as SetAvailableOfflineInput, x as PullResponderTriggerDataInput, y as Node } from "../types-VDHUeQnm.js";
4
- import { a as GenerateNodesCopyIdGenerator, i as DriveInput, o as GenerateNodesCopySrc, s as SharingType } from "../index-D0JljlgO.js";
1
+ import { Bu as PHBaseState, Dn as IsStateOfType, En as IsDocumentOfType, Fn as Maybe, Vt as DocumentModelGlobalState, _t as CreateDocument, bt as CreateState, ct as AssertIsStateOfType, kn as LoadFromInput, pi as SaveToFileHandle, qr as Reducer, st as AssertIsDocumentOfType } from "../types-Dr6-2rMp.js";
2
+ import "../index-BHdnKfWp.js";
3
+ import { $ as DeleteNodeAction, A as TriggerData, C as RemoveTriggerInput, D as SetSharingTypeInput, E as SetDriveNameInput, G as DocumentDriveAction, J as LegacyAddFileInput, K as DocumentDriveDocument, M as TriggerType, N as UpdateFileInput, O as TransmitterType, P as UpdateNodeInput, Q as CopyNodeAction, S as RemoveListenerInput, T as SetDriveIconInput, U as DocumentDrivePHState, W as DriveDocumentModelModule, X as AddFileAction, Y as LegacySynchronizationUnit, Z as AddFolderAction, _ as ListenerInput, a as CopyNodeInput, at as AddListenerAction, b as PullResponderTriggerData, c as DocumentDriveLocalState, ct as DocumentDriveDriveOperations, d as FolderNode, dt as SetAvailableOfflineAction, et as DocumentDriveNodeAction, f as Listener, ft as SetDriveIconAction, g as ListenerFilterInput, h as ListenerFilter, i as AddTriggerInput, it as UpdateNodeAction, j as TriggerInput, k as Trigger, l as DocumentDrivePHState$1, lt as RemoveListenerAction, m as ListenerCallInfoInput, mt as SetSharingTypeAction, n as AddFolderInput, nt as MoveNodeAction, o as DeleteNodeInput, ot as AddTriggerAction, p as ListenerCallInfo, pt as SetDriveNameAction, q as LegacyAddFileAction, r as AddListenerInput, rt as UpdateFileAction, s as DocumentDriveGlobalState, st as DocumentDriveDriveAction, t as AddFileInput, tt as DocumentDriveNodeOperations, u as FileNode, ut as RemoveTriggerAction, v as MoveNodeInput, w as SetAvailableOfflineInput, x as PullResponderTriggerDataInput, y as Node } from "../types-DvE2gUGf.js";
4
+ import { a as GenerateNodesCopyIdGenerator, i as DriveInput, o as GenerateNodesCopySrc, s as SharingType } from "../index-skEwkUNm.js";
5
5
  import { z } from "zod";
6
6
  //#region document-drive/constants.d.ts
7
7
  export declare const driveDocumentFileExtension = "phdd";
@@ -1,5 +1,5 @@
1
- import { $ as AddOperationExampleAction, $a as AddOperationExampleInputSchema, $c as deleteOperationExample, $i as SetOperationReducerAction, $l as checkCleanedOperationsIntegrity, $n as MutationRedoArgs, $o as SetOperationErrorTemplateInputSchema, $r as ReorderModuleOperationsAction, $t as DocumentModelOperationExampleOperations, $u as defaultGlobalState, Aa as UpdateChangeLogItemAction, Ad as Signature, Ai as SetModelIdAction, Al as setOperationErrorTemplate, An as MakeMaybe, Ao as RedoSchema, Ar as NOOPAction, As as signActionV2, At as DeleteOperationErrorInput, Au as split, Ba as User, Bc as addModule, Bi as SetNameOperation, Bl as updateOperationExample, Bn as MutationAddChangeLogItemInputArgs, Bo as SetInitialStateInputSchema, Br as PowerhouseModule, Bt as DocumentModelGlobalState, Bu as PHDocumentState, Ca as State, Cd as setPreferredEditorOperation, Ci as SetAuthorWebsiteInput, Cl as setModuleDescription, Cn as Incremental, Co as PieceModulesSchema, Cr as MutationSetOperationSchemaArgs, Cs as DOCUMENT_SCOPE_ACTION_TYPES, Ct as DeleteChildDocumentSignal, Cu as removeExistingOperations, Da as UndoAction, Dd as AppActionSigner, Di as SetModelDescriptionInput, Dl as setOperationErrorCode, Dn as LoadFromFile, Do as PwaConfigSchema, Dr as MutationUpdateChangeLogItemInputArgs, Ds as canonicalJson, Dt as DeleteModuleInput, Du as skipHeaderOperations, Ea as Undo, Ed as ActionSigner, Ei as SetModelDescriptionAction, El as setOperationDescription, En as IsStateOfType, Eo as PublisherSchema, Er as MutationUndoArgs, Es as actionSigningTarget, Et as DeleteModuleAction, Eu as reshuffleByTimestampAndIndex, Fa as UpdateRelationshipActionInput, Fc as actionContext, Fi as SetModuleDescriptionInput, Fl as setOperationTemplate, Fn as MinimalBackupData, Fo as ReorderOperationExamplesInputSchema, Fr as PartialRecord, Ft as DeleteStateExampleInput, Fu as Condition, G as Actions, Ga as applyDeleteDocumentAction, Gc as baseActions, Gi as SetOperationErrorDescriptionAction, Gl as PHDocument, Gn as MutationAddStateExampleArgs, Go as SetModuleDescriptionInputSchema, Gr as RedoActionInput, Gt as DocumentModelLocalState, Gu as createBaseState, H as ActionSignatureContext, Ha as UpgradeManifest, Hc as addOperationError, Hi as SetOperationDescriptionInput, Hl as verifyOperationSignature, Hn as MutationAddOperationArgs, Ho as SetModelExtensionInputSchema, Hr as Query, Ht as DocumentModelHeaderOperations, Hu as Principal, Ia as UpdateStateExampleAction, Ic as actionFromAction, Ii as SetModuleNameAction, Il as setPreferredEditor, In as ModuleSpecification, Io as ReorderStateExamplesInputSchema, Ir as PartialState, It as DocumentAction, Iu as Grant, J as AddModuleAction, Ja as normalizeDocumentModelVersion, Jc as createAction, Ji as SetOperationErrorNameInput, Jl as addUndo, Jn as MutationDeleteOperationArgs, Jo as SetNameActionSchema, Jr as ReleaseNewVersionAction, Jt as DocumentModelModuleOperations, Ju as createLocalState, K as AddChangeLogItemAction, Ka as applyUpgradeDocumentAction, Kc as buildOperationSignature, Ki as SetOperationErrorDescriptionInput, Kl as PHDocumentHeader, Kn as MutationDeleteChangeLogItemInputArgs, Ko as SetModuleNameInputSchema, Kr as Reducer, Kt as DocumentModelModule, Ku as createDocumentState, La as UpdateStateExampleInput, Lc as actionSigner, Li as SetModuleNameInput, Ll as setStateSchema, Ln as MoveOperationAction, Lo as ScopeStateSchema, Lr as PhAiToolAnnotations, Lt as DocumentModelAction, Lu as Operand, Ma as UpdateOperationExampleAction, Md as deserializeSignature, Mi as SetModelNameAction, Ml as setOperationReducer, Mn as Manifest, Mo as ReorderModuleOperationsInputSchema, Mr as OperationIndex, Ms as v2TupleProblem, Mt as DeleteOperationExampleInput, Mu as withSignaturePolicy, Na as UpdateOperationExampleInput, Nc as Action, Nd as serializeSignature, Ni as SetModelNameInput, Nl as setOperationSchema, Nn as MappedOperation, No as ReorderModulesInputSchema, Nr as OperationSpecification, Nt as DeleteOperationInput, Nu as AuthGroups, Oa as UndoActionInput, Od as HashConfig, Oi as SetModelExtensionAction, Ol as setOperationErrorDescription, On as LoadFromInput, Oo as RedoActionInputSchema, Or as MutationUpdateOperationExampleArgs, Os as hashActionV2, Ot as DeleteOperationAction, Ou as sortMappedOperations, Pa as UpdateRelationshipAction, Pc as ActionContext, Pi as SetModuleDescriptionAction, Pl as setOperationScope, Pn as Maybe, Po as ReorderOperationErrorsInputSchema, Pr as OperationsByScope, Pt as DeleteStateExampleAction, Pu as Capability, Q as AddOperationErrorInput, Qa as AddOperationErrorInputSchema, Qc as deleteOperationError, Qi as SetOperationNameInput, Ql as baseReducerVersion, Qn as MutationMoveOperationArgs, Qo as SetOperationErrorNameInputSchema, Qr as ReorderChangeLogItemsInput, Qt as DocumentModelOperationExampleAction, Qu as defaultDocumentState, Ra as UpgradeDocumentAction, Rc as actions, Ri as SetNameAction, Rl as undo, Rn as MoveOperationInput, Ro as SetAuthorNameInputSchema, Rr as PhAiToolDescriptor, Rt as DocumentModelDocument, Ru as PHAuthState, Sa as SkipHeaderOperations, Sd as setNameOperation, Si as SetAuthorWebsiteAction, Sl as setModelName, Sn as ISigner, So as PieceModuleSchema, Sr as MutationSetOperationReducerArgs, Ss as CanonicalJsonError, St as DeleteChildDocumentInput, Su as readOnly, Ta as SubgraphModule, Td as undoOperationV2, Ti as SetInitialStateInput, Tl as setName, Tn as IsDocumentOfType, To as PowerhouseModulesSchema, Tr as MutationSetStateSchemaArgs, Ts as actionSignerIdentity, Tt as DeleteDocumentActionInput, Tu as reshuffleByTimestamp, U as ActionSigningHandler, Ua as UpgradeReducer, Uc as addOperationExample, Ui as SetOperationErrorCodeAction, Ul as IntegrityIssueSubType, Un as MutationAddOperationErrorArgs, Uo as SetModelIdInputSchema, Ur as Redo, Ut as DocumentModelInput, Uu as backfillAuthState, V as ActionErrorCallback, Va as ValidationError, Vc as addOperation, Vi as SetOperationDescriptionAction, Vl as updateStateExample, Vn as MutationAddModuleArgs, Vo as SetModelDescriptionInputSchema, Vr as Publisher, Vt as DocumentModelHeaderAction, Vu as PHGroupState, W as ActionVerificationHandler, Wa as UpgradeTransition, Wc as addStateExample, Wi as SetOperationErrorCodeInput, Wl as IntegrityIssueType, Wn as MutationAddOperationExampleArgs, Wo as SetModelNameInputSchema, Wr as RedoAction, Wt as DocumentModelLib, Wu as createAuthState, X as AddOperationAction, Xa as AddChangeLogItemInputSchema, Xc as deleteModule, Xi as SetOperationErrorTemplateInput, Xl as attachBranch, Xn as MutationDeleteOperationExampleArgs, Xo as SetOperationErrorCodeInputSchema, Xr as RemoveRelationshipActionInput, Xt as DocumentModelOperationErrorAction, Xu as defaultAuthState, Y as AddModuleInput, Ya as withProtocolVersions, Yc as deleteChangeLogItem, Yi as SetOperationErrorTemplateAction, Yl as appendWithoutApplying, Yn as MutationDeleteOperationErrorArgs, Yo as SetOperationDescriptionInputSchema, Yr as RemoveRelationshipAction, Yt as DocumentModelOperationAction, Yu as createState, Z as AddOperationErrorAction, Za as AddModuleInputSchema, Zc as deleteOperation, Zi as SetOperationNameAction, Zl as baseCreateDocument, Zn as MutationDeleteStateExampleArgs, Zo as SetOperationErrorDescriptionInputSchema, Zr as ReorderChangeLogItemsAction, Zt as DocumentModelOperationErrorOperations, Zu as defaultBaseState, _a as SignalResults, _d as OperationContext, _i as SchemaSetPreferredEditorAction, _l as setAuthorWebsite, _n as ID, _o as ModuleSchema, _r as MutationSetOperationErrorCodeArgs, _s as definedNonNullAnySchema, _t as CreateDocumentAction, _u as nextSkipNumber, aa as SetOperationTemplateAction, ad as SIGNATURE_PROTOCOL, ai as ReorderOperationExamplesAction, al as operationFromAction, an as DocumentModelVersioningAction, ao as ConfigEntryTypeSchema, ar as MutationReorderStateExamplesArgs, as as SetPreferredEditorActionInputSchema, at as AddStateExampleInput, au as garbageCollectDocumentOperations, ba as SigningParameters, bd as operationOutcome, bi as SetAuthorNameAction, bl as setModelExtension, bn as ISignal, bo as OperationScopeSchema, br as MutationSetOperationErrorTemplateArgs, bs as ActionSignerIdentity, bt as DeleteChangeLogItemAction, bu as precedes, ca as SetPreferredEditorActionInput, cd as deriveDocumentId, ci as ReorderStateExamplesInput, cl as redo, cn as DocumentSpecification, co as DeleteOperationErrorInputSchema, cr as MutationSetInitialStateArgs, cs as Set_NameSchema, ct as Author, cu as groupOperationsByScope, da as SetStateSchemaInput, dd as protocolVersionsFor, di as SaveToFile, dl as reorderModuleOperations, dn as EditorModule, do as DeleteStateExampleInputSchema, dr as MutationSetModelIdArgs, ds as UndoActionInputSchema, dt as ConfigEntryType, du as isNoopOperation, ea as SetOperationReducerInput, ed as defaultLocalState, ei as ReorderModuleOperationsInput, el as deleteStateExample, en as DocumentModelOperationOperations, eo as AddOperationInputSchema, er as MutationReorderChangeLogItemsInputArgs, es as SetOperationNameInputSchema, et as AddOperationExampleInput, eu as checkOperationsIntegrity, fa as Set_Name, fd as requestedSignaturePolicy, fi as SaveToFileHandle, fl as reorderModules, fn as EditorProps, fo as DocumentActionSchema, fr as MutationSetModelNameArgs, fs as UndoActionSchema, ft as CopyChildDocumentInput, fu as isUndo, ga as SignalResult, gd as Operation, gi as SchemaSetNameAction, gl as setAuthorName, gn as IAction, go as ManifestSchema, gr as MutationSetOperationDescriptionArgs, gs as UpdateStateExampleInputSchema, gt as CreateDocument, gu as merge, ha as SignalDispatch, hd as DocumentOperations, hi as SchemaRedoAction, hl as reorderStateExamples, hn as GetDocumentOptions, ho as DocumentSpecificationSchema, hr as MutationSetNameArgs, hs as UpdateOperationExampleInputSchema, ht as CreateChildDocumentSignal, hu as mapSkippedOperationsV2, ia as SetOperationScopeInput, id as ProtocolVersions, ii as ReorderOperationErrorsInput, il as operationExampleCreators, in as DocumentModelUtils, io as ConfigEntrySchema, ir as MutationReorderOperationExamplesArgs, is as SetOperationTemplateInputSchema, it as AddStateExampleAction, iu as garbageCollect, ja as UpdateChangeLogItemInput, jd as UserActionSigner, ji as SetModelIdInput, jl as setOperationName, jn as MakeOptional, jo as ReorderChangeLogItemsInputSchema, jr as OperationErrorSpecification, js as targetDocumentId, jt as DeleteOperationExampleAction, ju as updateHeaderRevision, ka as UndoRedoAction, kd as PHDocumentSignatureInfo, ki as SetModelExtensionInput, kl as setOperationErrorName, kn as MakeEmpty, ko as RedoActionSchema, kr as MutationUpdateStateExampleArgs, ks as isV2ActionHash, kt as DeleteOperationErrorAction, ku as sortOperations, la as SetPreferredEditorOperation, ld as isDerivedDocumentId, li as ReplayDocumentOptions, ll as releaseNewVersion, ln as ENSInfo, lo as DeleteOperationExampleInputSchema, lr as MutationSetModelDescriptionArgs, ls as Set_PreferredEditorSchema, lt as CodeExample, lu as hashDocumentStateForScope, ma as Signal, md as v2RequiredProtocolVersions, mi as SchemaNOOPAction, ml as reorderOperationExamples, mn as FileInput, mo as DocumentModelInputSchema, mr as MutationSetModuleNameArgs, ms as UpdateChangeLogItemInputSchema, mt as CreateChildDocumentInput, mu as mapSkippedOperations, na as SetOperationSchemaInput, nd as DEFAULT_SIGNATURE_POLICY, ni as ReorderModulesInput, nl as moveOperation, nn as DocumentModelStateAction, no as AuthorSchema, nr as MutationReorderModulesArgs, ns as SetOperationSchemaInputSchema, nt as AddRelationshipAction, nu as filterDocumentOperationsResultingState, oa as SetOperationTemplateInput, od as SIGNATURE_PROTOCOL_V2, oi as ReorderOperationExamplesInput, ol as operationFromOperation, on as DocumentModelVersioningOperations, oo as DeleteChangeLogItemInputSchema, or as MutationSetAuthorNameArgs, os as SetPreferredEditorActionSchema, ot as AssertIsDocumentOfType, ou as garbageCollectV2, pa as Set_PreferredEditor, pd as signaturePolicyOf, pi as Scalars, pl as reorderOperationErrors, pn as Exact, po as DocumentModelGlobalStateSchema, pr as MutationSetModuleDescriptionArgs, ps as UndoSchema, pt as CopyChildDocumentSignal, pu as isUndoRedo, q as AddChangeLogItemInput, qa as computeUpgradeTransitions, qc as buildSignedAction, qi as SetOperationErrorNameAction, ql as PHDocumentMeta, qn as MutationDeleteModuleArgs, qo as SetNameActionInputSchema, qr as ReducerOptions, qt as DocumentModelModuleAction, qu as createGlobalState, ra as SetOperationScopeAction, rd as DocumentIdParams, ri as ReorderOperationErrorsAction, rl as noop, rn as DocumentModelStateOperations, ro as CodeExampleSchema, rr as MutationReorderOperationErrorsArgs, rs as SetOperationScopeInputSchema, rt as AddRelationshipActionInput, ru as filterDuplicatedOperations, sa as SetPreferredEditorAction, sd as SignaturePolicy, si as ReorderStateExamplesAction, sl as operationWithContext, sn as DocumentOperationsIgnoreMap, so as DeleteModuleInputSchema, sr as MutationSetAuthorWebsiteArgs, ss as SetStateSchemaInputSchema, st as AssertIsStateOfType, su as getDocumentLastModified, ta as SetOperationSchemaAction, td as defaultPHState, ti as ReorderModulesAction, tl as documentModelActions, tn as DocumentModelPHState, to as AddStateExampleInputSchema, tr as MutationReorderModuleOperationsArgs, ts as SetOperationReducerInputSchema, tt as AddOperationInput, tu as diffOperations, ua as SetStateSchemaAction, ud as isSignaturePolicy, ui as RevisionsFilter, ul as reorderChangeLogItems, un as EditorDispatch, uo as DeleteOperationInputSchema, ur as MutationSetModelExtensionArgs, us as StateSchema, ut as ConfigEntry, uu as isDocumentAction, va as SignalType, vd as OperationOutcome, vi as SchemaUndoAction, vl as setInitialState, vn as IDocument, vo as MoveOperationInputSchema, vr as MutationSetOperationErrorDescriptionArgs, vs as isDefinedNonNullAny, vt as CreateDocumentActionInput, vu as operationsAreEqual, wa as StateReducer, wd as undoOperation, wi as SetInitialStateAction, wl as setModuleName, wn as InputMaybe, wo as PowerhouseModuleSchema, wr as MutationSetOperationTemplateArgs, ws as actionPreimageV2, wt as DeleteDocumentAction, wu as replayDocument, xa as SkipHeaderOperationIndex, xd as redoOperation, xi as SetAuthorNameInput, xl as setModelId, xn as ISignalResult, xo as OperationSpecificationSchema, xr as MutationSetOperationNameArgs, xs as ActionSigningTarget, xt as DeleteChangeLogItemInput, xu as prepareOperations, ya as SignatureVerificationHandler, yd as OperationWithContext, yi as ScopeState, yl as setModelDescription, yn as IOperation, yo as OperationErrorSchema, yr as MutationSetOperationErrorNameArgs, ys as ACTION_SIGNATURE_V2_PREFIX, yt as CreateState, yu as parseResultingState, za as UpgradeDocumentActionInput, zc as addChangeLogItem, zi as SetNameActionInput, zl as updateChangeLogItem, zn as Mutation, zo as SetAuthorWebsiteInputSchema, zr as PieceModule, zt as DocumentModelDocumentModelModule, zu as PHBaseState } from "../types-xLPOHE23.js";
2
- import { $ as fetchFileBrowser, $n as isDocumentCreator, $t as documentModelInitialGlobalState, A as documentModelVersioningReducer, An as InitializeAuthActionInput, At as assertIsDocumentModelState, B as createVerificationSigner, Bn as SetGrantActionInput, Bt as base64UrlToBytes, C as documentModelModuleReducer, Cn as AuthEvaluation, Ct as groupMembershipActionTypes, D as documentModelReducer, Dn as AuthVerb, Dt as DocumentModelPHStateSchema, E as documentModelOperationReducer, En as AuthSubject, Et as DocumentModelHeaderSchema, F as updateDocument, Fn as MoveGrantActionInputSchema, Ft as AUTH_VERSION_UNSUPPORTED_REASON, G as BulkArchiveEntry, Gn as applyRemoveGrantAction, Gt as hex2ab, H as sign, Hn as applyAuthAction, Ht as buildOperationSignatureParams, I as createCopyHeader, In as RemoveGrantAction, It as DOCUMENT_DELETED_REASON, J as baseSaveToFileHandle, Jn as assertAuthScopeActionAllowed, Jt as HASH_ALGORITHM_SHA512, K as baseLoadFromInput, Kn as applySetGrantAction, Kt as HASH_ALGORITHM_SHA1, L as createPresignedHeader, Ln as RemoveGrantActionInput, Lt as isDenied, M as createReducer, Mn as MAX_SUPPORTED_AUTH_VERSION, Mt as isDocumentModelState, N as processUndoRedo, Nn as MoveGrantAction, Nt as AUTH_DENIED_BY_GRANT_REASON, O as documentModelStateReducer, On as ConditionContext, Ot as DocumentModelSchema, P as replayOperations, Pn as MoveGrantActionInput, Pt as AUTH_NO_GRANT_REASON, Q as documentModelSaveToFileHandle, Qn as isAuthAction, Qt as documentModelGlobalState, R as createSignedHeader, Rn as RemoveGrantActionInputSchema, Rt as ab2hex, S as documentModelHeaderReducer, Sn as AuthDecision, St as groupDocumentType, T as documentModelOperationExampleReducer, Tn as AuthRequest, Tt as BaseDocumentStateSchema, U as validateHeader, Un as applyInitializeAuthAction, Ut as getUnixTimestamp, V as hasDerivedDocumentId, Vn as SetGrantActionInputSchema, Vt as buildOperationSignatureMessage, W as verify, Wn as applyMoveGrantAction, Wt as hashBrowser, X as createZip, Xn as evaluate, Xt as HASH_ENCODING_HEX, Y as createMinimalZip, Yn as decide, Yt as HASH_ENCODING_BASE64, Z as documentModelLoadFromInput, Zn as initializeAuth, Zt as documentModelFileExtension, _ as validateModuleOperation, _n as grantProblem, _t as InvalidActionInputError, a as assertOperationErrorIdUnique, an as InvalidGrantError, ar as TransportAction, at as zipEntries, b as validateOperations, bn as AUTH_ACTION_TYPES, bt as UnsupportedDocumentModelVersionError, c as findModuleOrThrow, cn as MAX_CONDITION_DEPTH, cr as toTransportAction, ct as replayDocumentVersioned, d as findOperationOrThrow, dn as assertValidGrant, dt as AuthInitializerNotCreatorError, en as documentModelInitialLocalState, er as mentionedGroupIds, et as getFileBrowser, f as getAllOperationNames, fn as assertValidGrantUpsert, ft as AuthPolicyNotPreservedError, g as validateModule, gn as evaluateGrants, gt as HashMismatchError, h as validateInitialState, hn as evaluateGrantStack, ht as GrantNotFoundError, i as assertModuleIdUnique, in as GroupPrincipalNotAllowedError, ir as setGrant, it as writeFileBrowser, j as baseReducer, jn as InitializeAuthActionInputSchema, jt as isDocumentModelDocument, k as documentModelStateSchemaReducer, kn as InitializeAuthAction, kt as assertIsDocumentModelDocument, l as findOperationErrorOrThrow, ln as MAX_CONDITION_NODES, lt as AuthActionNotAllowedError, m as isValidOperationNameFormat, mn as evaluateCondition, mt as FileSystemError, n as RESERVED_OPERATION_NAMES, nn as AuthAdministrationMissingError, nr as removeGrant, nt as parseBulkArchive, o as assertOperationExampleIdUnique, on as MAX_AUTH_GRANTS, or as TransportActionContext, ot as VersionedReducers, p as isReservedOperationName, pn as assertValidInitialGrants, pt as DowngradeNotSupportedError, q as baseLoadFromInputVersioned, qn as assertAuthPreservedOnDuplicate, qt as HASH_ALGORITHM_SHA256, r as ReservedOperationName, rn as GrantSchema, rr as resolveSnapshotAuth, rt as readFileBrowser, s as assertOperationIdUnique, sn as MAX_CAPABILITY_OPERATIONS, sr as TransportSigner, st as VersionedReplayConfig, t as OPERATION_NAME_PATTERN, tn as AuthAdministrationLockoutError, tr as moveGrant, tt as isDocumentZip, u as findOperationExampleOrThrow, un as assertAuthAdministrationRetained, ut as AuthAlreadyInitializedError, v as validateModules, vn as isPlainValue, vt as InvalidActionInputZodError, w as documentModelOperationErrorReducer, wn as AuthRefusal, wt as BaseDocumentHeaderSchema, x as validateStateSchemaName, xn as AuthAction, xt as documentModelDocumentType, y as validateOperationName, yn as referencedGroupIds, yt as InvalidAuthVersionError, z as createSignedHeaderForSigner, zn as SetGrantAction, zt as base58Decode } from "../index-CDDyUSHE.js";
1
+ import { $ as AddOperationErrorInput, $a as AddOperationErrorInputSchema, $c as deleteOperationError, $i as SetOperationNameInput, $l as baseReducerVersion, $n as MutationMoveOperationArgs, $o as SetOperationErrorNameInputSchema, $r as ReorderChangeLogItemsInput, $t as DocumentModelOperationExampleAction, $u as defaultDocumentState, Aa as UndoRedoAction, Ad as PHDocumentSignatureInfo, Ai as SetModelExtensionInput, Al as setOperationErrorName, An as MakeEmpty, Ao as RedoActionSchema, Ar as MutationUpdateStateExampleArgs, As as isV2ActionHash, At as DeleteOperationErrorAction, Au as sortOperations, Ba as UpgradeDocumentActionInput, Bc as addChangeLogItem, Bi as SetNameActionInput, Bl as updateChangeLogItem, Bn as Mutation, Bo as SetAuthorWebsiteInputSchema, Br as PieceModule, Bt as DocumentModelDocumentModelModule, Bu as PHBaseState, Ca as SkipHeaderOperations, Cd as setNameOperation, Ci as SetAuthorWebsiteAction, Cl as setModelName, Cn as ISigner, Co as PieceModuleSchema, Cr as MutationSetOperationReducerArgs, Cs as CanonicalJsonError, Ct as DeleteChildDocumentInput, Cu as readOnly, Da as Undo, Dd as ActionSigner, Di as SetModelDescriptionAction, Dl as setOperationDescription, Dn as IsStateOfType, Do as PublisherSchema, Dr as MutationUndoArgs, Ds as actionSigningTarget, Dt as DeleteModuleAction, Du as reshuffleByTimestampAndIndex, Ea as SubgraphModule, Ed as undoOperationV2, Ei as SetInitialStateInput, El as setName, En as IsDocumentOfType, Eo as PowerhouseModulesSchema, Er as MutationSetStateSchemaArgs, Es as actionSignerIdentity, Et as DeleteDocumentActionInput, Eu as reshuffleByTimestamp, Fa as UpdateRelationshipAction, Fc as ActionContext, Fi as SetModuleDescriptionAction, Fl as setOperationScope, Fn as Maybe, Fo as ReorderOperationErrorsInputSchema, Fr as OperationsByScope, Ft as DeleteStateExampleAction, Fu as Capability, G as ActionVerificationHandler, Ga as UpgradeTransition, Gc as addStateExample, Gi as SetOperationErrorCodeInput, Gl as IntegrityIssueType, Gn as MutationAddOperationExampleArgs, Go as SetModelNameInputSchema, Gr as RedoAction, Gt as DocumentModelLib, Gu as createAuthState, H as ActionErrorCallback, Ha as ValidationError, Hc as addOperation, Hi as SetOperationDescriptionAction, Hl as updateStateExample, Hn as MutationAddModuleArgs, Ho as SetModelDescriptionInputSchema, Hr as Publisher, Ht as DocumentModelHeaderAction, Hu as PHGroupState, Ia as UpdateRelationshipActionInput, Ic as actionContext, Ii as SetModuleDescriptionInput, Il as setOperationTemplate, In as MinimalBackupData, Io as ReorderOperationExamplesInputSchema, Ir as PartialRecord, It as DeleteStateExampleInput, Iu as Condition, J as AddChangeLogItemInput, Ja as computeUpgradeTransitions, Jc as buildSignedAction, Ji as SetOperationErrorNameAction, Jl as PHDocumentMeta, Jn as MutationDeleteModuleArgs, Jo as SetNameActionInputSchema, Jr as ReducerOptions, Jt as DocumentModelModuleAction, Ju as createGlobalState, K as Actions, Ka as applyDeleteDocumentAction, Kc as baseActions, Ki as SetOperationErrorDescriptionAction, Kl as PHDocument, Kn as MutationAddStateExampleArgs, Ko as SetModuleDescriptionInputSchema, Kr as RedoActionInput, Kt as DocumentModelLocalState, Ku as createBaseState, La as UpdateStateExampleAction, Lc as actionFromAction, Li as SetModuleNameAction, Ll as setPreferredEditor, Ln as ModuleSpecification, Lo as ReorderStateExamplesInputSchema, Lr as PartialState, Lt as DocumentAction, Lu as Grant, Ma as UpdateChangeLogItemInput, Md as UserActionSigner, Mi as SetModelIdInput, Ml as setOperationName, Mn as MakeOptional, Mo as ReorderChangeLogItemsInputSchema, Mr as OperationErrorSpecification, Ms as targetDocumentId, Mt as DeleteOperationExampleAction, Mu as updateHeaderRevision, Na as UpdateOperationExampleAction, Nd as deserializeSignature, Ni as SetModelNameAction, Nl as setOperationReducer, Nn as Manifest, No as ReorderModuleOperationsInputSchema, Nr as OperationIndex, Ns as v2TupleProblem, Nt as DeleteOperationExampleInput, Nu as withSignaturePolicy, Oa as UndoAction, Od as AppActionSigner, Oi as SetModelDescriptionInput, Ol as setOperationErrorCode, On as LoadFromFile, Oo as PwaConfigSchema, Or as MutationUpdateChangeLogItemInputArgs, Os as canonicalJson, Ot as DeleteModuleInput, Ou as skipHeaderOperations, Pa as UpdateOperationExampleInput, Pc as Action, Pd as serializeSignature, Pi as SetModelNameInput, Pl as setOperationSchema, Pn as MappedOperation, Po as ReorderModulesInputSchema, Pr as OperationSpecification, Pt as DeleteOperationInput, Pu as AuthGroups, Q as AddOperationErrorAction, Qa as AddModuleInputSchema, Qc as deleteOperation, Qi as SetOperationNameAction, Ql as baseCreateDocument, Qn as MutationDeleteStateExampleArgs, Qo as SetOperationErrorDescriptionInputSchema, Qr as ReorderChangeLogItemsAction, Qt as DocumentModelOperationErrorOperations, Qu as defaultBaseState, Ra as UpdateStateExampleInput, Rc as actionSigner, Ri as SetModuleNameInput, Rl as setStateSchema, Rn as MoveOperationAction, Ro as ScopeStateSchema, Rr as PhAiToolAnnotations, Rt as DocumentModelAction, Ru as Operand, Sa as SkipHeaderOperationIndex, Sd as redoOperation, Si as SetAuthorNameInput, Sl as setModelId, Sn as ISignalResult, So as OperationSpecificationSchema, Sr as MutationSetOperationNameArgs, Ss as ActionSigningTarget, St as DeleteChangeLogItemInput, Su as prepareOperations, Ta as StateReducer, Td as undoOperation, Ti as SetInitialStateAction, Tl as setModuleName, Tn as InputMaybe, To as PowerhouseModuleSchema, Tr as MutationSetOperationTemplateArgs, Ts as actionPreimageV2, Tt as DeleteDocumentAction, Tu as replayDocument, U as ActionSignatureContext, Ua as UpgradeManifest, Uc as addOperationError, Ui as SetOperationDescriptionInput, Ul as verifyOperationSignature, Un as MutationAddOperationArgs, Uo as SetModelExtensionInputSchema, Ur as Query, Ut as DocumentModelHeaderOperations, Uu as Principal, Va as User, Vc as addModule, Vi as SetNameOperation, Vl as updateOperationExample, Vn as MutationAddChangeLogItemInputArgs, Vo as SetInitialStateInputSchema, Vr as PowerhouseModule, Vt as DocumentModelGlobalState, Vu as PHDocumentState, W as ActionSigningHandler, Wa as UpgradeReducer, Wc as addOperationExample, Wi as SetOperationErrorCodeAction, Wl as IntegrityIssueSubType, Wn as MutationAddOperationErrorArgs, Wo as SetModelIdInputSchema, Wr as Redo, Wt as DocumentModelInput, Wu as backfillAuthState, X as AddModuleInput, Xa as withProtocolVersions, Xc as deleteChangeLogItem, Xi as SetOperationErrorTemplateAction, Xl as appendWithoutApplying, Xn as MutationDeleteOperationErrorArgs, Xo as SetOperationDescriptionInputSchema, Xr as RemoveRelationshipAction, Xt as DocumentModelOperationAction, Xu as createState, Y as AddModuleAction, Ya as normalizeDocumentModelVersion, Yc as createAction, Yi as SetOperationErrorNameInput, Yl as addUndo, Yn as MutationDeleteOperationArgs, Yo as SetNameActionSchema, Yr as ReleaseNewVersionAction, Yt as DocumentModelModuleOperations, Yu as createLocalState, Z as AddOperationAction, Za as AddChangeLogItemInputSchema, Zc as deleteModule, Zi as SetOperationErrorTemplateInput, Zl as attachBranch, Zn as MutationDeleteOperationExampleArgs, Zo as SetOperationErrorCodeInputSchema, Zr as RemoveRelationshipActionInput, Zt as DocumentModelOperationErrorAction, Zu as defaultAuthState, _a as SignalResult, _d as Operation, _i as SchemaSetNameAction, _l as setAuthorName, _n as IAction, _o as ManifestSchema, _r as MutationSetOperationDescriptionArgs, _s as UpdateStateExampleInputSchema, _t as CreateDocument, _u as merge, aa as SetOperationScopeInput, ad as ProtocolVersions, ai as ReorderOperationErrorsInput, al as operationExampleCreators, an as DocumentModelUtils, ao as ConfigEntrySchema, ar as MutationReorderOperationExamplesArgs, as as SetOperationTemplateInputSchema, at as AddStateExampleAction, au as garbageCollect, ba as SignatureVerificationHandler, bd as OperationWithContext, bi as ScopeState, bl as setModelDescription, bn as IOperation, bo as OperationErrorSchema, br as MutationSetOperationErrorNameArgs, bs as ACTION_SIGNATURE_V2_PREFIX, bt as CreateState, bu as parseResultingState, ca as SetPreferredEditorAction, cd as SignaturePolicy, ci as ReorderStateExamplesAction, cl as operationWithContext, cn as DocumentOperationsIgnoreMap, co as DeleteModuleInputSchema, cr as MutationSetAuthorWebsiteArgs, cs as SetStateSchemaInputSchema, ct as AssertIsStateOfType, cu as getDocumentLastModified, da as SetStateSchemaAction, dd as isSignaturePolicy, di as RevisionsFilter, dl as reorderChangeLogItems, dn as EditorDispatch, do as DeleteOperationInputSchema, dr as MutationSetModelExtensionArgs, ds as StateSchema, dt as ConfigEntry, du as isDocumentAction, ea as SetOperationReducerAction, ed as defaultGlobalState, ei as ReorderModuleOperationsAction, el as deleteOperationExample, en as DocumentModelOperationExampleOperations, eo as AddOperationExampleInputSchema, er as MutationRedoArgs, es as SetOperationErrorTemplateInputSchema, et as AddOperationExampleAction, eu as checkCleanedOperationsIntegrity, fa as SetStateSchemaInput, fd as protocolVersionsFor, fi as SaveToFile, fl as reorderModuleOperations, fn as EditorModule, fo as DeleteStateExampleInputSchema, fr as MutationSetModelIdArgs, fs as UndoActionInputSchema, ft as ConfigEntryType, fu as isNoopOperation, ga as SignalDispatch, gd as DocumentOperations, gi as SchemaRedoAction, gl as reorderStateExamples, gn as GetDocumentOptions, go as DocumentSpecificationSchema, gr as MutationSetNameArgs, gs as UpdateOperationExampleInputSchema, gt as CreateChildDocumentSignal, gu as mapSkippedOperationsV2, ha as Signal, hd as v2RequiredProtocolVersions, hi as SchemaNOOPAction, hl as reorderOperationExamples, hn as FileInput, ho as DocumentModelInputSchema, hr as MutationSetModuleNameArgs, hs as UpdateChangeLogItemInputSchema, ht as CreateChildDocumentInput, hu as mapSkippedOperations, ia as SetOperationScopeAction, id as DocumentIdParams, ii as ReorderOperationErrorsAction, il as noop, in as DocumentModelStateOperations, io as CodeExampleSchema, ir as MutationReorderOperationErrorsArgs, is as SetOperationScopeInputSchema, it as AddRelationshipActionInput, iu as filterDuplicatedOperations, ja as UpdateChangeLogItemAction, jd as Signature, ji as SetModelIdAction, jl as setOperationErrorTemplate, jn as MakeMaybe, jo as RedoSchema, jr as NOOPAction, js as signActionV2, jt as DeleteOperationErrorInput, ju as split, ka as UndoActionInput, kd as HashConfig, ki as SetModelExtensionAction, kl as setOperationErrorDescription, kn as LoadFromInput, ko as RedoActionInputSchema, kr as MutationUpdateOperationExampleArgs, ks as hashActionV2, kt as DeleteOperationAction, ku as sortMappedOperations, la as SetPreferredEditorActionInput, ld as deriveDocumentId, li as ReorderStateExamplesInput, ll as redo, ln as DocumentSpecification, lo as DeleteOperationErrorInputSchema, lr as MutationSetInitialStateArgs, ls as Set_NameSchema, lt as Author, lu as groupOperationsByScope, ma as Set_PreferredEditor, md as signaturePolicyOf, mi as Scalars, ml as reorderOperationErrors, mn as Exact, mo as DocumentModelGlobalStateSchema, mr as MutationSetModuleDescriptionArgs, ms as UndoSchema, mt as CopyChildDocumentSignal, mu as isUndoRedo, na as SetOperationSchemaAction, nd as defaultPHState, ni as ReorderModulesAction, nl as documentModelActions, nn as DocumentModelPHState, no as AddStateExampleInputSchema, nr as MutationReorderModuleOperationsArgs, ns as SetOperationReducerInputSchema, nt as AddOperationInput, nu as diffOperations, oa as SetOperationTemplateAction, od as SIGNATURE_PROTOCOL, oi as ReorderOperationExamplesAction, ol as operationFromAction, on as DocumentModelVersioningAction, oo as ConfigEntryTypeSchema, or as MutationReorderStateExamplesArgs, os as SetPreferredEditorActionInputSchema, ot as AddStateExampleInput, ou as garbageCollectDocumentOperations, pa as Set_Name, pd as requestedSignaturePolicy, pi as SaveToFileHandle, pl as reorderModules, pn as EditorProps, po as DocumentActionSchema, pr as MutationSetModelNameArgs, ps as UndoActionSchema, pt as CopyChildDocumentInput, pu as isUndo, q as AddChangeLogItemAction, qa as applyUpgradeDocumentAction, qc as buildOperationSignature, qi as SetOperationErrorDescriptionInput, ql as PHDocumentHeader, qn as MutationDeleteChangeLogItemInputArgs, qo as SetModuleNameInputSchema, qr as Reducer, qt as DocumentModelModule, qu as createDocumentState, ra as SetOperationSchemaInput, rd as DEFAULT_SIGNATURE_POLICY, ri as ReorderModulesInput, rl as moveOperation, rn as DocumentModelStateAction, ro as AuthorSchema, rr as MutationReorderModulesArgs, rs as SetOperationSchemaInputSchema, rt as AddRelationshipAction, ru as filterDocumentOperationsResultingState, sa as SetOperationTemplateInput, sd as SIGNATURE_PROTOCOL_V2, si as ReorderOperationExamplesInput, sl as operationFromOperation, sn as DocumentModelVersioningOperations, so as DeleteChangeLogItemInputSchema, sr as MutationSetAuthorNameArgs, ss as SetPreferredEditorActionSchema, st as AssertIsDocumentOfType, su as garbageCollectV2, ta as SetOperationReducerInput, td as defaultLocalState, ti as ReorderModuleOperationsInput, tl as deleteStateExample, tn as DocumentModelOperationOperations, to as AddOperationInputSchema, tr as MutationReorderChangeLogItemsInputArgs, ts as SetOperationNameInputSchema, tt as AddOperationExampleInput, tu as checkOperationsIntegrity, ua as SetPreferredEditorOperation, ud as isDerivedDocumentId, ui as ReplayDocumentOptions, ul as releaseNewVersion, un as ENSInfo, uo as DeleteOperationExampleInputSchema, ur as MutationSetModelDescriptionArgs, us as Set_PreferredEditorSchema, ut as CodeExample, uu as hashDocumentStateForScope, va as SignalResults, vd as OperationContext, vi as SchemaSetPreferredEditorAction, vl as setAuthorWebsite, vn as ID, vo as ModuleSchema, vr as MutationSetOperationErrorCodeArgs, vs as definedNonNullAnySchema, vt as CreateDocumentAction, vu as nextSkipNumber, wa as State, wd as setPreferredEditorOperation, wi as SetAuthorWebsiteInput, wl as setModuleDescription, wn as Incremental, wo as PieceModulesSchema, wr as MutationSetOperationSchemaArgs, ws as DOCUMENT_SCOPE_ACTION_TYPES, wt as DeleteChildDocumentSignal, wu as removeExistingOperations, xa as SigningParameters, xd as operationOutcome, xi as SetAuthorNameAction, xl as setModelExtension, xn as ISignal, xo as OperationScopeSchema, xr as MutationSetOperationErrorTemplateArgs, xs as ActionSignerIdentity, xt as DeleteChangeLogItemAction, xu as precedes, ya as SignalType, yd as OperationOutcome, yi as SchemaUndoAction, yl as setInitialState, yn as IDocument, yo as MoveOperationInputSchema, yr as MutationSetOperationErrorDescriptionArgs, ys as isDefinedNonNullAny, yt as CreateDocumentActionInput, yu as operationsAreEqual, za as UpgradeDocumentAction, zc as actions, zi as SetNameAction, zl as undo, zn as MoveOperationInput, zo as SetAuthorNameInputSchema, zr as PhAiToolDescriptor, zt as DocumentModelDocument, zu as PHAuthState } from "../types-Dr6-2rMp.js";
2
+ import { $ as fetchFileBrowser, $n as isDocumentCreator, $t as documentModelInitialGlobalState, A as documentModelVersioningReducer, An as InitializeAuthActionInput, At as assertIsDocumentModelState, B as createVerificationSigner, Bn as SetGrantActionInput, Bt as base64UrlToBytes, C as documentModelModuleReducer, Cn as AuthEvaluation, Ct as groupMembershipActionTypes, D as documentModelReducer, Dn as AuthVerb, Dt as DocumentModelPHStateSchema, E as documentModelOperationReducer, En as AuthSubject, Et as DocumentModelHeaderSchema, F as updateDocument, Fn as MoveGrantActionInputSchema, Ft as AUTH_VERSION_UNSUPPORTED_REASON, G as BulkArchiveEntry, Gn as applyRemoveGrantAction, Gt as hex2ab, H as sign, Hn as applyAuthAction, Ht as buildOperationSignatureParams, I as createCopyHeader, In as RemoveGrantAction, It as DOCUMENT_DELETED_REASON, J as baseSaveToFileHandle, Jn as assertAuthScopeActionAllowed, Jt as HASH_ALGORITHM_SHA512, K as baseLoadFromInput, Kn as applySetGrantAction, Kt as HASH_ALGORITHM_SHA1, L as createPresignedHeader, Ln as RemoveGrantActionInput, Lt as isDenied, M as createReducer, Mn as MAX_SUPPORTED_AUTH_VERSION, Mt as isDocumentModelState, N as processUndoRedo, Nn as MoveGrantAction, Nt as AUTH_DENIED_BY_GRANT_REASON, O as documentModelStateReducer, On as ConditionContext, Ot as DocumentModelSchema, P as replayOperations, Pn as MoveGrantActionInput, Pt as AUTH_NO_GRANT_REASON, Q as documentModelSaveToFileHandle, Qn as isAuthAction, Qt as documentModelGlobalState, R as createSignedHeader, Rn as RemoveGrantActionInputSchema, Rt as ab2hex, S as documentModelHeaderReducer, Sn as AuthDecision, St as groupDocumentType, T as documentModelOperationExampleReducer, Tn as AuthRequest, Tt as BaseDocumentStateSchema, U as validateHeader, Un as applyInitializeAuthAction, Ut as getUnixTimestamp, V as hasDerivedDocumentId, Vn as SetGrantActionInputSchema, Vt as buildOperationSignatureMessage, W as verify, Wn as applyMoveGrantAction, Wt as hashBrowser, X as createZip, Xn as evaluate, Xt as HASH_ENCODING_HEX, Y as createMinimalZip, Yn as decide, Yt as HASH_ENCODING_BASE64, Z as documentModelLoadFromInput, Zn as initializeAuth, Zt as documentModelFileExtension, _ as validateModuleOperation, _n as grantProblem, _t as InvalidActionInputError, a as assertOperationErrorIdUnique, an as InvalidGrantError, ar as TransportAction, at as zipEntries, b as validateOperations, bn as AUTH_ACTION_TYPES, bt as UnsupportedDocumentModelVersionError, c as findModuleOrThrow, cn as MAX_CONDITION_DEPTH, cr as toTransportAction, ct as replayDocumentVersioned, d as findOperationOrThrow, dn as assertValidGrant, dt as AuthInitializerNotCreatorError, en as documentModelInitialLocalState, er as mentionedGroupIds, et as getFileBrowser, f as getAllOperationNames, fn as assertValidGrantUpsert, ft as AuthPolicyNotPreservedError, g as validateModule, gn as evaluateGrants, gt as HashMismatchError, h as validateInitialState, hn as evaluateGrantStack, ht as GrantNotFoundError, i as assertModuleIdUnique, in as GroupPrincipalNotAllowedError, ir as setGrant, it as writeFileBrowser, j as baseReducer, jn as InitializeAuthActionInputSchema, jt as isDocumentModelDocument, k as documentModelStateSchemaReducer, kn as InitializeAuthAction, kt as assertIsDocumentModelDocument, l as findOperationErrorOrThrow, ln as MAX_CONDITION_NODES, lt as AuthActionNotAllowedError, m as isValidOperationNameFormat, mn as evaluateCondition, mt as FileSystemError, n as RESERVED_OPERATION_NAMES, nn as AuthAdministrationMissingError, nr as removeGrant, nt as parseBulkArchive, o as assertOperationExampleIdUnique, on as MAX_AUTH_GRANTS, or as TransportActionContext, ot as VersionedReducers, p as isReservedOperationName, pn as assertValidInitialGrants, pt as DowngradeNotSupportedError, q as baseLoadFromInputVersioned, qn as assertAuthPreservedOnDuplicate, qt as HASH_ALGORITHM_SHA256, r as ReservedOperationName, rn as GrantSchema, rr as resolveSnapshotAuth, rt as readFileBrowser, s as assertOperationIdUnique, sn as MAX_CAPABILITY_OPERATIONS, sr as TransportSigner, st as VersionedReplayConfig, t as OPERATION_NAME_PATTERN, tn as AuthAdministrationLockoutError, tr as moveGrant, tt as isDocumentZip, u as findOperationExampleOrThrow, un as assertAuthAdministrationRetained, ut as AuthAlreadyInitializedError, v as validateModules, vn as isPlainValue, vt as InvalidActionInputZodError, w as documentModelOperationErrorReducer, wn as AuthRefusal, wt as BaseDocumentHeaderSchema, x as validateStateSchemaName, xn as AuthAction, xt as documentModelDocumentType, y as validateOperationName, yn as referencedGroupIds, yt as InvalidAuthVersionError, z as createSignedHeaderForSigner, zn as SetGrantAction, zt as base58Decode } from "../index-BHdnKfWp.js";
3
3
  import { n as generateId, r as generateMock, t as deriveOperationId } from "../utils-BrKxCmKx.js";
4
4
  export { ACTION_SIGNATURE_V2_PREFIX, AUTH_ACTION_TYPES, AUTH_DENIED_BY_GRANT_REASON, AUTH_NO_GRANT_REASON, AUTH_VERSION_UNSUPPORTED_REASON, Action, ActionContext, type ActionErrorCallback, type ActionSignatureContext, ActionSigner, ActionSignerIdentity, type ActionSigningHandler, ActionSigningTarget, type ActionVerificationHandler, type Actions, type AddChangeLogItemAction, type AddChangeLogItemInput, AddChangeLogItemInputSchema, type AddModuleAction, type AddModuleInput, AddModuleInputSchema, type AddOperationAction, type AddOperationErrorAction, type AddOperationErrorInput, AddOperationErrorInputSchema, type AddOperationExampleAction, type AddOperationExampleInput, AddOperationExampleInputSchema, type AddOperationInput, AddOperationInputSchema, type AddRelationshipAction, type AddRelationshipActionInput, type AddStateExampleAction, type AddStateExampleInput, AddStateExampleInputSchema, AppActionSigner, type AssertIsDocumentOfType, type AssertIsStateOfType, AuthAction, AuthActionNotAllowedError, AuthAdministrationLockoutError, AuthAdministrationMissingError, AuthAlreadyInitializedError, AuthDecision, AuthEvaluation, AuthGroups, AuthInitializerNotCreatorError, AuthPolicyNotPreservedError, AuthRefusal, AuthRequest, AuthSubject, AuthVerb, type Author, AuthorSchema, BaseDocumentHeaderSchema, BaseDocumentStateSchema, BulkArchiveEntry, CanonicalJsonError, Capability, type CodeExample, CodeExampleSchema, Condition, ConditionContext, type ConfigEntry, ConfigEntrySchema, type ConfigEntryType, ConfigEntryTypeSchema, type CopyChildDocumentInput, type CopyChildDocumentSignal, type CreateChildDocumentInput, type CreateChildDocumentSignal, type CreateDocument, type CreateDocumentAction, type CreateDocumentActionInput, type CreateState, DEFAULT_SIGNATURE_POLICY, DOCUMENT_DELETED_REASON, DOCUMENT_SCOPE_ACTION_TYPES, type DeleteChangeLogItemAction, type DeleteChangeLogItemInput, DeleteChangeLogItemInputSchema, type DeleteChildDocumentInput, type DeleteChildDocumentSignal, type DeleteDocumentAction, type DeleteDocumentActionInput, type DeleteModuleAction, type DeleteModuleInput, DeleteModuleInputSchema, type DeleteOperationAction, type DeleteOperationErrorAction, type DeleteOperationErrorInput, DeleteOperationErrorInputSchema, type DeleteOperationExampleAction, type DeleteOperationExampleInput, DeleteOperationExampleInputSchema, type DeleteOperationInput, DeleteOperationInputSchema, type DeleteStateExampleAction, type DeleteStateExampleInput, DeleteStateExampleInputSchema, type DocumentAction, DocumentActionSchema, DocumentIdParams, type DocumentModelAction, type DocumentModelDocument, type DocumentModelDocumentModelModule, type DocumentModelGlobalState, DocumentModelGlobalStateSchema, type DocumentModelHeaderAction, type DocumentModelHeaderOperations, DocumentModelHeaderSchema, type DocumentModelInput, DocumentModelInputSchema, type DocumentModelLib, type DocumentModelLocalState, type DocumentModelModule, type DocumentModelModuleAction, type DocumentModelModuleOperations, type DocumentModelOperationAction, type DocumentModelOperationErrorAction, type DocumentModelOperationErrorOperations, type DocumentModelOperationExampleAction, type DocumentModelOperationExampleOperations, type DocumentModelOperationOperations, type DocumentModelPHState, DocumentModelPHStateSchema, DocumentModelSchema, type DocumentModelStateAction, type DocumentModelStateOperations, type DocumentModelUtils, type DocumentModelVersioningAction, type DocumentModelVersioningOperations, DocumentOperations, type DocumentOperationsIgnoreMap, type DocumentSpecification, DocumentSpecificationSchema, DowngradeNotSupportedError, type ENSInfo, type EditorDispatch, type EditorModule, type EditorProps, type Exact, type FileInput, FileSystemError, type GetDocumentOptions, Grant, GrantNotFoundError, GrantSchema, GroupPrincipalNotAllowedError, HASH_ALGORITHM_SHA1, HASH_ALGORITHM_SHA256, HASH_ALGORITHM_SHA512, HASH_ENCODING_BASE64, HASH_ENCODING_HEX, HashConfig, HashMismatchError, type IAction, type ID, type IDocument, type IOperation, type ISignal, type ISignalResult, type ISigner, type Incremental, InitializeAuthAction, InitializeAuthActionInput, InitializeAuthActionInputSchema, type InputMaybe, IntegrityIssueSubType, IntegrityIssueType, InvalidActionInputError, InvalidActionInputZodError, InvalidAuthVersionError, InvalidGrantError, type IsDocumentOfType, type IsStateOfType, type LoadFromFile, type LoadFromInput, MAX_AUTH_GRANTS, MAX_CAPABILITY_OPERATIONS, MAX_CONDITION_DEPTH, MAX_CONDITION_NODES, MAX_SUPPORTED_AUTH_VERSION, type MakeEmpty, type MakeMaybe, type MakeOptional, type Manifest, ManifestSchema, type MappedOperation, type Maybe, type MinimalBackupData, ModuleSchema, type ModuleSpecification, MoveGrantAction, MoveGrantActionInput, MoveGrantActionInputSchema, type MoveOperationAction, type MoveOperationInput, MoveOperationInputSchema, type Mutation, type MutationAddChangeLogItemInputArgs, type MutationAddModuleArgs, type MutationAddOperationArgs, type MutationAddOperationErrorArgs, type MutationAddOperationExampleArgs, type MutationAddStateExampleArgs, type MutationDeleteChangeLogItemInputArgs, type MutationDeleteModuleArgs, type MutationDeleteOperationArgs, type MutationDeleteOperationErrorArgs, type MutationDeleteOperationExampleArgs, type MutationDeleteStateExampleArgs, type MutationMoveOperationArgs, type MutationRedoArgs, type MutationReorderChangeLogItemsInputArgs, type MutationReorderModuleOperationsArgs, type MutationReorderModulesArgs, type MutationReorderOperationErrorsArgs, type MutationReorderOperationExamplesArgs, type MutationReorderStateExamplesArgs, type MutationSetAuthorNameArgs, type MutationSetAuthorWebsiteArgs, type MutationSetInitialStateArgs, type MutationSetModelDescriptionArgs, type MutationSetModelExtensionArgs, type MutationSetModelIdArgs, type MutationSetModelNameArgs, type MutationSetModuleDescriptionArgs, type MutationSetModuleNameArgs, type MutationSetNameArgs, type MutationSetOperationDescriptionArgs, type MutationSetOperationErrorCodeArgs, type MutationSetOperationErrorDescriptionArgs, type MutationSetOperationErrorNameArgs, type MutationSetOperationErrorTemplateArgs, type MutationSetOperationNameArgs, type MutationSetOperationReducerArgs, type MutationSetOperationSchemaArgs, type MutationSetOperationTemplateArgs, type MutationSetStateSchemaArgs, type MutationUndoArgs, type MutationUpdateChangeLogItemInputArgs, type MutationUpdateOperationExampleArgs, type MutationUpdateStateExampleArgs, type NOOPAction, OPERATION_NAME_PATTERN, Operand, Operation, OperationContext, OperationErrorSchema, type OperationErrorSpecification, type OperationIndex, OperationOutcome, OperationScopeSchema, type OperationSpecification, OperationSpecificationSchema, OperationWithContext, type OperationsByScope, PHAuthState, PHBaseState, PHDocument, PHDocumentHeader, PHDocumentMeta, PHDocumentSignatureInfo, PHDocumentState, PHGroupState, type PartialRecord, type PartialState, type PhAiToolAnnotations, type PhAiToolDescriptor, type PieceModule, PieceModuleSchema, PieceModulesSchema, type PowerhouseModule, PowerhouseModuleSchema, PowerhouseModulesSchema, Principal, ProtocolVersions, type Publisher, PublisherSchema, PwaConfigSchema, type Query, RESERVED_OPERATION_NAMES, type Redo, type RedoAction, type RedoActionInput, RedoActionInputSchema, RedoActionSchema, RedoSchema, type Reducer, type ReducerOptions, type ReleaseNewVersionAction, RemoveGrantAction, RemoveGrantActionInput, RemoveGrantActionInputSchema, type RemoveRelationshipAction, type RemoveRelationshipActionInput, type ReorderChangeLogItemsAction, type ReorderChangeLogItemsInput, ReorderChangeLogItemsInputSchema, type ReorderModuleOperationsAction, type ReorderModuleOperationsInput, ReorderModuleOperationsInputSchema, type ReorderModulesAction, type ReorderModulesInput, ReorderModulesInputSchema, type ReorderOperationErrorsAction, type ReorderOperationErrorsInput, ReorderOperationErrorsInputSchema, type ReorderOperationExamplesAction, type ReorderOperationExamplesInput, ReorderOperationExamplesInputSchema, type ReorderStateExamplesAction, type ReorderStateExamplesInput, ReorderStateExamplesInputSchema, type ReplayDocumentOptions, ReservedOperationName, type RevisionsFilter, SIGNATURE_PROTOCOL, SIGNATURE_PROTOCOL_V2, type SaveToFile, type SaveToFileHandle, type Scalars, type SchemaNOOPAction, type SchemaRedoAction, type SchemaSetNameAction, type SchemaSetPreferredEditorAction, type SchemaUndoAction, type ScopeState, ScopeStateSchema, type SetAuthorNameAction, type SetAuthorNameInput, SetAuthorNameInputSchema, type SetAuthorWebsiteAction, type SetAuthorWebsiteInput, SetAuthorWebsiteInputSchema, SetGrantAction, SetGrantActionInput, SetGrantActionInputSchema, type SetInitialStateAction, type SetInitialStateInput, SetInitialStateInputSchema, type SetModelDescriptionAction, type SetModelDescriptionInput, SetModelDescriptionInputSchema, type SetModelExtensionAction, type SetModelExtensionInput, SetModelExtensionInputSchema, type SetModelIdAction, type SetModelIdInput, SetModelIdInputSchema, type SetModelNameAction, type SetModelNameInput, SetModelNameInputSchema, type SetModuleDescriptionAction, type SetModuleDescriptionInput, SetModuleDescriptionInputSchema, type SetModuleNameAction, type SetModuleNameInput, SetModuleNameInputSchema, type SetNameAction, type SetNameActionInput, SetNameActionInputSchema, SetNameActionSchema, type SetNameOperation, type SetOperationDescriptionAction, type SetOperationDescriptionInput, SetOperationDescriptionInputSchema, type SetOperationErrorCodeAction, type SetOperationErrorCodeInput, SetOperationErrorCodeInputSchema, type SetOperationErrorDescriptionAction, type SetOperationErrorDescriptionInput, SetOperationErrorDescriptionInputSchema, type SetOperationErrorNameAction, type SetOperationErrorNameInput, SetOperationErrorNameInputSchema, type SetOperationErrorTemplateAction, type SetOperationErrorTemplateInput, SetOperationErrorTemplateInputSchema, type SetOperationNameAction, type SetOperationNameInput, SetOperationNameInputSchema, type SetOperationReducerAction, type SetOperationReducerInput, SetOperationReducerInputSchema, type SetOperationSchemaAction, type SetOperationSchemaInput, SetOperationSchemaInputSchema, type SetOperationScopeAction, type SetOperationScopeInput, SetOperationScopeInputSchema, type SetOperationTemplateAction, type SetOperationTemplateInput, SetOperationTemplateInputSchema, type SetPreferredEditorAction, type SetPreferredEditorActionInput, SetPreferredEditorActionInputSchema, SetPreferredEditorActionSchema, type SetPreferredEditorOperation, type SetStateSchemaAction, type SetStateSchemaInput, SetStateSchemaInputSchema, type Set_Name, Set_NameSchema, type Set_PreferredEditor, Set_PreferredEditorSchema, type Signal, type SignalDispatch, type SignalResult, type SignalResults, type SignalType, Signature, SignaturePolicy, type SignatureVerificationHandler, type SigningParameters, type SkipHeaderOperationIndex, type SkipHeaderOperations, type State, type StateReducer, StateSchema, type SubgraphModule, TransportAction, TransportActionContext, TransportSigner, type Undo, type UndoAction, type UndoActionInput, UndoActionInputSchema, UndoActionSchema, type UndoRedoAction, UndoSchema, UnsupportedDocumentModelVersionError, type UpdateChangeLogItemAction, type UpdateChangeLogItemInput, UpdateChangeLogItemInputSchema, type UpdateOperationExampleAction, type UpdateOperationExampleInput, UpdateOperationExampleInputSchema, type UpdateRelationshipAction, type UpdateRelationshipActionInput, type UpdateStateExampleAction, type UpdateStateExampleInput, UpdateStateExampleInputSchema, type UpgradeDocumentAction, type UpgradeDocumentActionInput, UpgradeManifest, UpgradeReducer, UpgradeTransition, type User, UserActionSigner, type ValidationError, VersionedReducers, VersionedReplayConfig, ab2hex, actionContext, actionFromAction, actionPreimageV2, actionSigner, actionSignerIdentity, actionSigningTarget, actions, addChangeLogItem, addModule, addOperation, addOperationError, addOperationExample, addStateExample, addUndo, appendWithoutApplying, applyAuthAction, applyDeleteDocumentAction, applyInitializeAuthAction, applyMoveGrantAction, applyRemoveGrantAction, applySetGrantAction, applyUpgradeDocumentAction, assertAuthAdministrationRetained, assertAuthPreservedOnDuplicate, assertAuthScopeActionAllowed, assertIsDocumentModelDocument, assertIsDocumentModelState, assertModuleIdUnique, assertOperationErrorIdUnique, assertOperationExampleIdUnique, assertOperationIdUnique, assertValidGrant, assertValidGrantUpsert, assertValidInitialGrants, attachBranch, backfillAuthState, base58Decode, base64UrlToBytes, baseActions, baseCreateDocument, baseLoadFromInput, baseLoadFromInputVersioned, baseReducer, baseReducerVersion, baseSaveToFileHandle, buildOperationSignature, buildOperationSignatureMessage, buildOperationSignatureParams, buildSignedAction, canonicalJson, checkCleanedOperationsIntegrity, checkOperationsIntegrity, computeUpgradeTransitions, createAction, createAuthState, createBaseState, createCopyHeader, createDocumentState, createGlobalState, createLocalState, createMinimalZip, createPresignedHeader, createReducer, createSignedHeader, createSignedHeaderForSigner, createState, createVerificationSigner, createZip, decide, defaultAuthState, defaultBaseState, defaultDocumentState, defaultGlobalState, defaultLocalState, defaultPHState, definedNonNullAnySchema, deleteChangeLogItem, deleteModule, deleteOperation, deleteOperationError, deleteOperationExample, deleteStateExample, deriveDocumentId, deriveOperationId, deserializeSignature, diffOperations, documentModelActions, documentModelDocumentType, documentModelFileExtension, documentModelGlobalState, documentModelHeaderReducer, documentModelInitialGlobalState, documentModelInitialLocalState, documentModelLoadFromInput, documentModelModuleReducer, documentModelOperationErrorReducer, documentModelOperationExampleReducer, documentModelOperationReducer, documentModelReducer, documentModelSaveToFileHandle, documentModelStateReducer, documentModelStateSchemaReducer, documentModelVersioningReducer, evaluate, evaluateCondition, evaluateGrantStack, evaluateGrants, fetchFileBrowser, filterDocumentOperationsResultingState, filterDuplicatedOperations, findModuleOrThrow, findOperationErrorOrThrow, findOperationExampleOrThrow, findOperationOrThrow, garbageCollect, garbageCollectDocumentOperations, garbageCollectV2, generateId, generateMock, getAllOperationNames, getDocumentLastModified, getFileBrowser, getUnixTimestamp, grantProblem, groupDocumentType, groupMembershipActionTypes, groupOperationsByScope, hasDerivedDocumentId, hashActionV2, hashBrowser, hashDocumentStateForScope, hex2ab, initializeAuth, isAuthAction, isDefinedNonNullAny, isDenied, isDerivedDocumentId, isDocumentAction, isDocumentCreator, isDocumentModelDocument, isDocumentModelState, isDocumentZip, isNoopOperation, isPlainValue, isReservedOperationName, isSignaturePolicy, isUndo, isUndoRedo, isV2ActionHash, isValidOperationNameFormat, mapSkippedOperations, mapSkippedOperationsV2, mentionedGroupIds, merge, moveGrant, moveOperation, nextSkipNumber, noop, normalizeDocumentModelVersion, operationExampleCreators, operationFromAction, operationFromOperation, operationOutcome, operationWithContext, operationsAreEqual, parseBulkArchive, parseResultingState, precedes, prepareOperations, processUndoRedo, protocolVersionsFor, readFileBrowser, readOnly, redo, redoOperation, referencedGroupIds, releaseNewVersion, removeExistingOperations, removeGrant, reorderChangeLogItems, reorderModuleOperations, reorderModules, reorderOperationErrors, reorderOperationExamples, reorderStateExamples, replayDocument, replayDocumentVersioned, replayOperations, requestedSignaturePolicy, reshuffleByTimestamp, reshuffleByTimestampAndIndex, resolveSnapshotAuth, serializeSignature, setAuthorName, setAuthorWebsite, setGrant, setInitialState, setModelDescription, setModelExtension, setModelId, setModelName, setModuleDescription, setModuleName, setName, setNameOperation, setOperationDescription, setOperationErrorCode, setOperationErrorDescription, setOperationErrorName, setOperationErrorTemplate, setOperationName, setOperationReducer, setOperationSchema, setOperationScope, setOperationTemplate, setPreferredEditor, setPreferredEditorOperation, setStateSchema, sign, signActionV2, signaturePolicyOf, skipHeaderOperations, sortMappedOperations, sortOperations, split, targetDocumentId, toTransportAction, undo, undoOperation, undoOperationV2, updateChangeLogItem, updateDocument, updateHeaderRevision, updateOperationExample, updateStateExample, v2RequiredProtocolVersions, v2TupleProblem, validateHeader, validateInitialState, validateModule, validateModuleOperation, validateModules, validateOperationName, validateOperations, validateStateSchemaName, verify, verifyOperationSignature, withProtocolVersions, withSignaturePolicy, writeFileBrowser, zipEntries };
5
5
  export {};
@@ -1,4 +1,4 @@
1
- import { $t as DocumentModelOperationExampleOperations, Bt as DocumentModelGlobalState, Fn as MinimalBackupData, Fu as Condition, Gl as PHDocument, Gt as DocumentModelLocalState, H as ActionSignatureContext, Ha as UpgradeManifest, Ht as DocumentModelHeaderOperations, In as ModuleSpecification, Iu as Grant, Jt as DocumentModelModuleOperations, Kl as PHDocumentHeader, Kr as Reducer, Nc as Action, Nr as OperationSpecification, Nu as AuthGroups, On as LoadFromInput, Rt as DocumentModelDocument, Ru as PHAuthState, Sa as SkipHeaderOperations, Sn as ISigner, Va as ValidationError, Zt as DocumentModelOperationErrorOperations, _d as OperationContext, ba as SigningParameters, cn as DocumentSpecification, ct as Author, en as DocumentModelOperationOperations, fi as SaveToFileHandle, gd as Operation, ha as SignalDispatch, hd as DocumentOperations, id as ProtocolVersions, jr as OperationErrorSpecification, li as ReplayDocumentOptions, lt as CodeExample, mn as FileInput, on as DocumentModelVersioningOperations, qr as ReducerOptions, rn as DocumentModelStateOperations, sd as SignaturePolicy, tn as DocumentModelPHState, wa as StateReducer, zu as PHBaseState } from "./types-xLPOHE23.js";
1
+ import { Bu as PHBaseState, Ca as SkipHeaderOperations, Cn as ISigner, Ha as ValidationError, In as MinimalBackupData, Iu as Condition, Jr as ReducerOptions, Kl as PHDocument, Kt as DocumentModelLocalState, Ln as ModuleSpecification, Lu as Grant, Mr as OperationErrorSpecification, Pc as Action, Pr as OperationSpecification, Pu as AuthGroups, Qt as DocumentModelOperationErrorOperations, Ta as StateReducer, U as ActionSignatureContext, Ua as UpgradeManifest, Ut as DocumentModelHeaderOperations, Vt as DocumentModelGlobalState, Yt as DocumentModelModuleOperations, _d as Operation, ad as ProtocolVersions, cd as SignaturePolicy, en as DocumentModelOperationExampleOperations, ga as SignalDispatch, gd as DocumentOperations, hn as FileInput, in as DocumentModelStateOperations, kn as LoadFromInput, ln as DocumentSpecification, lt as Author, nn as DocumentModelPHState, pi as SaveToFileHandle, ql as PHDocumentHeader, qr as Reducer, sn as DocumentModelVersioningOperations, tn as DocumentModelOperationOperations, ui as ReplayDocumentOptions, ut as CodeExample, vd as OperationContext, xa as SigningParameters, zt as DocumentModelDocument, zu as PHAuthState } from "./types-Dr6-2rMp.js";
2
2
  import "./utils-BrKxCmKx.js";
3
3
  import { ZodIssue, z } from "zod";
4
4
  //#region document-model/action-transport.d.ts
@@ -845,4 +845,4 @@ declare function validateOperations(operations: DocumentOperations): ValidationE
845
845
  //#endregion
846
846
  export { fetchFileBrowser as $, isDocumentCreator as $n, documentModelInitialGlobalState as $t, documentModelVersioningReducer as A, InitializeAuthActionInput as An, assertIsDocumentModelState as At, createVerificationSigner as B, SetGrantActionInput as Bn, base64UrlToBytes as Bt, documentModelModuleReducer as C, AuthEvaluation as Cn, groupMembershipActionTypes as Ct, documentModelReducer as D, AuthVerb as Dn, DocumentModelPHStateSchema as Dt, documentModelOperationReducer as E, AuthSubject as En, DocumentModelHeaderSchema as Et, updateDocument as F, MoveGrantActionInputSchema as Fn, AUTH_VERSION_UNSUPPORTED_REASON as Ft, BulkArchiveEntry as G, applyRemoveGrantAction as Gn, hex2ab as Gt, sign as H, applyAuthAction as Hn, buildOperationSignatureParams as Ht, createCopyHeader as I, RemoveGrantAction as In, DOCUMENT_DELETED_REASON as It, baseSaveToFileHandle as J, assertAuthScopeActionAllowed as Jn, HASH_ALGORITHM_SHA512 as Jt, baseLoadFromInput as K, applySetGrantAction as Kn, HASH_ALGORITHM_SHA1 as Kt, createPresignedHeader as L, RemoveGrantActionInput as Ln, isDenied as Lt, createReducer as M, MAX_SUPPORTED_AUTH_VERSION as Mn, isDocumentModelState as Mt, processUndoRedo as N, MoveGrantAction as Nn, AUTH_DENIED_BY_GRANT_REASON as Nt, documentModelStateReducer as O, ConditionContext as On, DocumentModelSchema as Ot, replayOperations as P, MoveGrantActionInput as Pn, AUTH_NO_GRANT_REASON as Pt, documentModelSaveToFileHandle as Q, isAuthAction as Qn, documentModelGlobalState as Qt, createSignedHeader as R, RemoveGrantActionInputSchema as Rn, ab2hex as Rt, documentModelHeaderReducer as S, AuthDecision as Sn, groupDocumentType as St, documentModelOperationExampleReducer as T, AuthRequest as Tn, BaseDocumentStateSchema as Tt, validateHeader as U, applyInitializeAuthAction as Un, getUnixTimestamp as Ut, hasDerivedDocumentId as V, SetGrantActionInputSchema as Vn, buildOperationSignatureMessage as Vt, verify as W, applyMoveGrantAction as Wn, hashBrowser as Wt, createZip as X, evaluate as Xn, HASH_ENCODING_HEX as Xt, createMinimalZip as Y, decide as Yn, HASH_ENCODING_BASE64 as Yt, documentModelLoadFromInput as Z, initializeAuth as Zn, documentModelFileExtension as Zt, validateModuleOperation as _, grantProblem as _n, InvalidActionInputError as _t, assertOperationErrorIdUnique as a, InvalidGrantError as an, TransportAction as ar, zipEntries as at, validateOperations as b, AUTH_ACTION_TYPES as bn, UnsupportedDocumentModelVersionError as bt, findModuleOrThrow as c, MAX_CONDITION_DEPTH as cn, toTransportAction as cr, replayDocumentVersioned as ct, findOperationOrThrow as d, assertValidGrant as dn, AuthInitializerNotCreatorError as dt, documentModelInitialLocalState as en, mentionedGroupIds as er, getFileBrowser as et, getAllOperationNames as f, assertValidGrantUpsert as fn, AuthPolicyNotPreservedError as ft, validateModule as g, evaluateGrants as gn, HashMismatchError as gt, validateInitialState as h, evaluateGrantStack as hn, GrantNotFoundError as ht, assertModuleIdUnique as i, GroupPrincipalNotAllowedError as in, setGrant as ir, writeFileBrowser as it, baseReducer as j, InitializeAuthActionInputSchema as jn, isDocumentModelDocument as jt, documentModelStateSchemaReducer as k, InitializeAuthAction as kn, assertIsDocumentModelDocument as kt, findOperationErrorOrThrow as l, MAX_CONDITION_NODES as ln, AuthActionNotAllowedError as lt, isValidOperationNameFormat as m, evaluateCondition as mn, FileSystemError as mt, RESERVED_OPERATION_NAMES as n, AuthAdministrationMissingError as nn, removeGrant as nr, parseBulkArchive as nt, assertOperationExampleIdUnique as o, MAX_AUTH_GRANTS as on, TransportActionContext as or, VersionedReducers as ot, isReservedOperationName as p, assertValidInitialGrants as pn, DowngradeNotSupportedError as pt, baseLoadFromInputVersioned as q, assertAuthPreservedOnDuplicate as qn, HASH_ALGORITHM_SHA256 as qt, ReservedOperationName as r, GrantSchema as rn, resolveSnapshotAuth as rr, readFileBrowser as rt, assertOperationIdUnique as s, MAX_CAPABILITY_OPERATIONS as sn, TransportSigner as sr, VersionedReplayConfig as st, OPERATION_NAME_PATTERN as t, AuthAdministrationLockoutError as tn, moveGrant as tr, isDocumentZip as tt, findOperationExampleOrThrow as u, assertAuthAdministrationRetained as un, AuthAlreadyInitializedError as ut, validateModules as v, isPlainValue as vn, InvalidActionInputZodError as vt, documentModelOperationErrorReducer as w, AuthRefusal as wn, BaseDocumentHeaderSchema as wt, validateStateSchemaName as x, AuthAction as xn, documentModelDocumentType as xt, validateOperationName as y, referencedGroupIds as yn, InvalidAuthVersionError as yt, createSignedHeaderForSigner as z, SetGrantAction as zn, base58Decode as zt };
847
847
  export {};
848
- //# sourceMappingURL=index-CDDyUSHE.d.ts.map
848
+ //# sourceMappingURL=index-BHdnKfWp.d.ts.map