beadscope 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +4 -4
- package/.next/required-server-files.js +8 -8
- package/.next/required-server-files.json +8 -8
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +2 -2
- package/.next/server/app/_not-found.rsc +4 -4
- package/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +4 -4
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/config/route.js.nft.json +1 -1
- package/.next/server/app/api/fs/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/activity/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/attachments/[...path]/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/attachments/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/beads/[id]/archive/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/beads/[id]/assist/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/beads/[id]/comments/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/beads/[id]/deps/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/beads/[id]/gate/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/beads/[id]/human/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/beads/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/beads/[id]/status/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/beads/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/beads/stream/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/doctor/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/gamification/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/insights/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/order/route.js.nft.json +1 -1
- package/.next/server/app/api/p/[projectId]/publish/route.js.nft.json +1 -1
- package/.next/server/app/api/projects/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/projects/route.js.nft.json +1 -1
- package/.next/server/app/api/telemetry/route.js.nft.json +1 -1
- package/.next/server/app/api/update/check/route.js +3 -3
- package/.next/server/app/api/update/check/route.js.nft.json +1 -1
- package/.next/server/app/api/update/run/route.js +3 -3
- package/.next/server/app/api/update/run/route.js.nft.json +1 -1
- package/.next/server/app/api/viewer-mode/route.js.nft.json +1 -1
- package/.next/server/app/index.html +2 -2
- package/.next/server/app/index.rsc +7 -7
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +7 -7
- package/.next/server/app/index.segments/_full.segment.rsc +7 -7
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/p/[projectId]/page.js.nft.json +1 -1
- package/.next/server/app/p/[projectId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0190u3x31o2kc._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0190u3x31o2kc._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__1-f7qk3-8a266._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1zrubp2jc8bi0._.js +1 -1
- package/.next/server/chunks/_004qegokrf7fy._.js +1 -1
- package/.next/server/chunks/_004qegokrf7fy._.js.map +1 -1
- package/.next/server/chunks/_0vx1iev9xu_vx._.js +1 -1
- package/.next/server/chunks/_0vx1iev9xu_vx._.js.map +1 -1
- package/.next/server/chunks/_10s9tyeasgb0i._.js +1 -1
- package/.next/server/chunks/_10s9tyeasgb0i._.js.map +1 -1
- package/.next/server/chunks/_146xyuw6iu78n._.js +1 -1
- package/.next/server/chunks/_146xyuw6iu78n._.js.map +1 -1
- package/.next/server/chunks/_1n-6yntr59hz-._.js +1 -1
- package/.next/server/chunks/_1n-6yntr59hz-._.js.map +1 -1
- package/.next/server/chunks/_1tji4d-rsralm._.js +1 -1
- package/.next/server/chunks/lib_beads-view_ts_1fvxcrevh9zu_._.js +1 -1
- package/.next/server/chunks/lib_beads-view_ts_1fvxcrevh9zu_._.js.map +1 -1
- package/.next/server/chunks/lib_config_ts_0zrjxh_mm8sv8._.js +1 -1
- package/.next/server/chunks/lib_config_ts_0zrjxh_mm8sv8._.js.map +1 -1
- package/.next/server/chunks/lib_self-update_ts_1s_0im4leryko._.js +1 -1
- package/.next/server/chunks/lib_self-update_ts_1s_0im4leryko._.js.map +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__10sjsc4ko7y98._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__10sjsc4ko7y98._.js.map +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1xizcyi5hek65._.js +7 -7
- package/.next/server/chunks/ssr/[root-of-the-server]__1xizcyi5hek65._.js.map +1 -1
- package/.next/server/chunks/ssr/_0_ky_k50rh6-9._.js +1 -1
- package/.next/server/chunks/ssr/_0_ky_k50rh6-9._.js.map +1 -1
- package/.next/server/chunks/ssr/_16j7dxy5pqj44._.js +291 -0
- package/.next/server/chunks/ssr/_16j7dxy5pqj44._.js.map +1 -0
- package/.next/server/chunks/ssr/_1bulx6_unf6c7._.js +3 -0
- package/.next/server/chunks/ssr/_1bulx6_unf6c7._.js.map +1 -0
- package/.next/server/chunks/ssr/_1mzldxegsozij._.js +1 -1
- package/.next/server/chunks/ssr/_1mzldxegsozij._.js.map +1 -1
- package/.next/server/chunks/ssr/_1obdc2e416ry-._.js +3 -0
- package/.next/server/chunks/ssr/_1obdc2e416ry-._.js.map +1 -0
- package/.next/server/chunks/ssr/components_launcher_tsx_1i40oht1v6miz._.js +1 -1
- package/.next/server/chunks/ssr/components_launcher_tsx_1i40oht1v6miz._.js.map +1 -1
- package/.next/server/chunks/ssr/components_providers_tsx_0thx-xfvr_dtx._.js.map +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/middleware.js.nft.json +1 -1
- package/.next/server/pages/404.html +2 -2
- package/.next/server/pages/500.html +1 -1
- package/.next/server/preview-props.json +3 -3
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/0gexf4-utluu4.js +1 -0
- package/.next/static/chunks/23nopl40nheqr.js +1 -0
- package/.next/static/chunks/2c10hhzk7mgkf.js +58 -0
- package/.next/static/chunks/2n4lv4u0xo5oz.css +3 -0
- package/.next/static/chunks/3m8u_309a1_fw.js +1 -0
- package/.next/static/chunks/3tepw2noo82tm.js +1 -0
- package/README.md +91 -25
- package/bin/beadscope.mjs +75 -32
- package/package.json +2 -1
- package/.next/server/chunks/ssr/_02mwe4ucwaopu._.js +0 -291
- package/.next/server/chunks/ssr/_02mwe4ucwaopu._.js.map +0 -1
- package/.next/server/chunks/ssr/_1020o02v8ucmf._.js +0 -3
- package/.next/server/chunks/ssr/_1020o02v8ucmf._.js.map +0 -1
- package/.next/server/chunks/ssr/_1i_x4qkev3tax._.js +0 -3
- package/.next/server/chunks/ssr/_1i_x4qkev3tax._.js.map +0 -1
- package/.next/static/chunks/07balm4l-kilq.js +0 -1
- package/.next/static/chunks/0lf_v5uyq3i9q.js +0 -1
- package/.next/static/chunks/21v6r4y8vgqng.css +0 -3
- package/.next/static/chunks/2xh00k9l33qnb.js +0 -1
- package/.next/static/chunks/3yk880zca6oid.js +0 -58
- package/.next/static/chunks/3yqhmu1hny1_2.js +0 -1
- /package/.next/static/{CNwJGIAhEiVMAkf3ebvok → BoR0CvHf7BXhmN1hRjwWk}/_buildManifest.js +0 -0
- /package/.next/static/{CNwJGIAhEiVMAkf3ebvok → BoR0CvHf7BXhmN1hRjwWk}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{CNwJGIAhEiVMAkf3ebvok → BoR0CvHf7BXhmN1hRjwWk}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../app/p/%5BprojectId%5D/page.tsx","../../../../lib/config.ts","../../../../components/app-shell.tsx/__nextjs-internal-proxy.mjs%20%7B%20server%20%3D%3E%20%22%5Bproject%5D/components/app-shell.tsx%22%20%7D"],"sourcesContent":["import { Suspense } from \"react\";\nimport type { Metadata } from \"next\";\nimport { AppShell } from \"@/components/app-shell\";\nimport { projectTitle } from \"@/lib/app-title\";\nimport { getProject } from \"@/lib/config\";\n\ntype Props = {\n params: Promise<{ projectId: string }>;\n};\n\nexport async function generateMetadata({ params }: Props): Promise<Metadata> {\n const { projectId } = await params;\n const project = getProject(projectId);\n\n return project ? { title: projectTitle(project.name) } : {};\n}\n\nexport default async function ProjectPage({ params }: Props) {\n const { projectId } = await params;\n // A project route owns transient UI state (drawer trails, palettes, and the\n // notification watcher baseline). A distinct key prevents state from one\n // client-side project visit leaking into the next one.\n return <Suspense fallback={<div className=\"p-6 text-sm\">Loading project…</div>}><AppShell key={projectId} projectId={projectId} /></Suspense>;\n}\n","import \"server-only\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport os from \"node:os\";\nimport { execFileSync } from \"node:child_process\";\n\n/**\n * Local app config (NOT stored in beads). Lives as a small JSON file under the\n * OS config dir. Holds the human actor used to stamp writes, the human allowlist\n * for origin detection, the poll interval, and the registry of beads projects\n * the app knows about.\n *\n * Project identity is per-request (driven by the /p/<projectId> URL), so the\n * \"active\" project is NOT stored here — only the durable list of discovered ones.\n */\nexport interface ProjectEntry {\n id: string;\n name: string;\n path: string;\n /** ISO timestamps. */\n addedAt: string;\n lastOpened: string;\n}\n\nexport interface AppConfig {\n humanActor: string;\n humanAllowlist: string[];\n pollIntervalMs: number;\n projects: ProjectEntry[];\n /**\n * Manual board ordering, kept app-local (NOT in beads): projectId → columnId →\n * ordered bead ids. Lets users drag beads within a column to set work order.\n */\n orders: Record<string, Record<string, string[]>>;\n /** Opt-in: show the gamification XP/level layer (off by default). */\n gamification: boolean;\n /**\n * True once the human actor was saved from Settings. Until then the actor\n * follows the computed default, even if an older version wrote it to disk.\n */\n humanActorChosen?: boolean;\n}\n\n/**\n * The built-in demo dataset, surfaced as an always-available pseudo-project.\n * It has no filesystem path; the store resolver maps it to the in-memory store.\n */\nexport const DEMO_PROJECT = {\n id: \"demo\",\n name: \"Demo\",\n path: null,\n} as const;\nexport type DemoProject = typeof DEMO_PROJECT;\n\nexport class ConfigError extends Error {\n code: string;\n constructor(message: string, code: string) {\n super(message);\n this.name = \"ConfigError\";\n this.code = code;\n }\n}\n\n/**\n * BEADSCOPE_READ_ONLY=1 (or \"true\") supplies the default for new browser sessions.\n * The session cookie overrides that default when the user changes the mode.\n * In the effective read-only mode, project writes are refused server-side and\n * editing controls are disabled. App settings remain available.\n */\nexport const VIEWER_MODE_COOKIE = \"beadscope-viewer-mode\";\n\nexport function isReadOnly(request?: Request): boolean {\n // This is a browser preference, not an authorization boundary. A session\n // cookie lets one browser override the launch default without affecting others.\n const cookie = request?.headers.get(\"cookie\")?.split(\";\").map((v) => v.trim())\n .find((v) => v.startsWith(`${VIEWER_MODE_COOKIE}=`))?.slice(VIEWER_MODE_COOKIE.length + 1);\n if (cookie === \"read-only\") return true;\n if (cookie === \"editing\") return false;\n const v = process.env.BEADSCOPE_READ_ONLY;\n return v === \"1\" || v === \"true\";\n}\n\n/**\n * Focus-view lane chips: BEADSCOPE_LANE_PREFIX names a label prefix (e.g. \"ctx:\")\n * whose values partition work into lanes/teams/areas. When set, the Focus view\n * offers one filter chip per lane label found on the visible beads. Unset →\n * no chips (the feature is invisible).\n */\nexport function lanePrefix(): string | null {\n return process.env.BEADSCOPE_LANE_PREFIX || null;\n}\n\nexport function configDir(): string {\n const base = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), \".config\");\n return path.join(base, \"beadscope\");\n}\nfunction configFile(): string {\n return path.join(configDir(), \"config.json\");\n}\n\nfunction osUserName(): string {\n try {\n return os.userInfo().username || \"you\";\n } catch {\n return \"you\";\n }\n}\n\n/** git's user.name as seen from the launch directory, or null without git or a name. */\nfunction gitUserName(): string | null {\n try {\n const name = execFileSync(\"git\", [\"config\", \"--get\", \"user.name\"], {\n cwd: process.cwd(),\n encoding: \"utf8\",\n timeout: 2000,\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim();\n return name || null;\n } catch {\n return null;\n }\n}\n\nfunction defaults(): AppConfig {\n // Same order as bd's own actor (`bd --help`, --actor): BEADS_ACTOR, then git\n // user.name, then the OS user. If Beadscope stamped writes with the OS name\n // while `bd update --claim` used the git name, bd would refuse to let the UI\n // close beads the user claimed from the CLI.\n const humanActor = process.env.BEADS_ACTOR || gitUserName() || osUserName();\n return {\n humanActor,\n humanAllowlist: [humanActor],\n // Fallback refresh interval. The SSE change stream (see lib/beads-watch)\n // drives fast updates; this interval only backstops a dropped stream.\n pollIntervalMs: 30000,\n projects: [],\n orders: {},\n gamification: false,\n };\n}\n\n// ---- helpers -------------------------------------------------------------\n\nfunction hasBeads(p: string): boolean {\n try {\n return fs.existsSync(path.join(p, \".beads\"));\n } catch {\n return false;\n }\n}\nfunction realpathOrSelf(p: string): string {\n try {\n return fs.realpathSync(p);\n } catch {\n return path.resolve(p);\n }\n}\nfunction sameDir(a: string, b: string): boolean {\n return realpathOrSelf(a) === realpathOrSelf(b);\n}\nfunction slug(s: string): string {\n return (\n s\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\") || \"project\"\n );\n}\nfunction makeId(absPath: string, taken: Set<string>): string {\n const base = slug(path.basename(absPath));\n let id = base;\n while (taken.has(id) || id === DEMO_PROJECT.id) {\n id = `${base}-${Math.random().toString(36).slice(2, 6)}`;\n }\n return id;\n}\nfunction makeEntry(inputPath: string, taken: Set<string>): ProjectEntry {\n const abs = path.resolve(inputPath);\n const now = new Date().toISOString();\n return {\n id: makeId(abs, taken),\n name: path.basename(abs) || abs,\n path: abs,\n addedAt: now,\n lastOpened: now,\n };\n}\n\n/** Drop malformed registry entries so a bad config file never crashes startup. */\nfunction sanitizeProjects(input: unknown): ProjectEntry[] {\n if (!Array.isArray(input)) return [];\n const out: ProjectEntry[] = [];\n const seen = new Set<string>();\n for (const it of input) {\n if (!it || typeof it !== \"object\") continue;\n const e = it as Record<string, unknown>;\n if (typeof e.id !== \"string\" || typeof e.path !== \"string\") continue;\n if (e.id === DEMO_PROJECT.id || seen.has(e.id)) continue;\n seen.add(e.id);\n out.push({\n id: e.id,\n path: e.path,\n name: typeof e.name === \"string\" && e.name ? e.name : path.basename(e.path) || e.path,\n addedAt: typeof e.addedAt === \"string\" ? e.addedAt : new Date().toISOString(),\n lastOpened: typeof e.lastOpened === \"string\" ? e.lastOpened : new Date().toISOString(),\n });\n }\n return out;\n}\n\n// ---- load / persist ------------------------------------------------------\n\nlet cached: AppConfig | null = null;\n\n/**\n * Persist the config, preserving any unknown keys already on disk (e.g. the\n * legacy `repoPath`/`demo` fields) so older app versions can still read them.\n */\nfunction persist(cfg: AppConfig): void {\n cached = cfg;\n try {\n fs.mkdirSync(configDir(), { recursive: true });\n let base: Record<string, unknown> = {};\n try {\n base = JSON.parse(fs.readFileSync(configFile(), \"utf8\")) as Record<string, unknown>;\n } catch {\n base = {};\n }\n const next = { ...base, ...cfg };\n fs.writeFileSync(configFile(), JSON.stringify(next, null, 2), \"utf8\");\n } catch {\n /* best-effort; config still applies for the session */\n }\n}\n\nexport function getConfig(): AppConfig {\n if (cached) return cached;\n const d = defaults();\n\n let onDisk:\n | (Partial<AppConfig> & { repoPath?: string; demo?: boolean })\n | null = null;\n try {\n onDisk = JSON.parse(fs.readFileSync(configFile(), \"utf8\"));\n } catch {\n onDisk = null;\n }\n\n // Before 0.3.1 the computed default (the OS user) was written to disk along\n // with the first project, so an unchosen OS username on disk is a stale\n // default rather than a preference. Replace it, and keep the new actor in the\n // allowlist so the user's own writes still render as human.\n const staleActor =\n !onDisk?.humanActorChosen && onDisk?.humanActor === osUserName() && d.humanActor !== onDisk.humanActor;\n const storedAllowlist = onDisk?.humanAllowlist && onDisk.humanAllowlist.length ? onDisk.humanAllowlist : null;\n const merged: AppConfig = {\n humanActor: staleActor ? d.humanActor : onDisk?.humanActor || d.humanActor,\n humanAllowlist: !storedAllowlist\n ? d.humanAllowlist\n : staleActor && !storedAllowlist.includes(d.humanActor)\n ? [...storedAllowlist, d.humanActor]\n : storedAllowlist,\n pollIntervalMs:\n typeof onDisk?.pollIntervalMs === \"number\" ? onDisk.pollIntervalMs : d.pollIntervalMs,\n projects: sanitizeProjects(onDisk?.projects),\n orders:\n onDisk?.orders && typeof onDisk.orders === \"object\" && !Array.isArray(onDisk.orders)\n ? (onDisk.orders as Record<string, Record<string, string[]>>)\n : {},\n gamification: typeof onDisk?.gamification === \"boolean\" ? onDisk.gamification : d.gamification,\n humanActorChosen: onDisk?.humanActorChosen === true,\n };\n\n // One-time migration: back-fill the registry from the legacy single repoPath\n // (or BEADS_REPO / cwd) when no projects array exists yet.\n let migrated = false;\n if (!onDisk || onDisk.projects === undefined) {\n const legacyPath = onDisk?.repoPath || process.env.BEADS_REPO || process.cwd();\n if (\n legacyPath &&\n hasBeads(legacyPath) &&\n !merged.projects.some((p) => sameDir(p.path, legacyPath))\n ) {\n merged.projects.push(makeEntry(legacyPath, new Set(merged.projects.map((p) => p.id))));\n migrated = true;\n }\n }\n\n cached = merged;\n // Persist the migrated entry so its id is stable across restarts.\n if (migrated) persist(merged);\n return cached;\n}\n\n/**\n * The actor to close a bead as. bd refuses to close a claimed bead as anyone\n * but its assignee. Before 0.3.1 Beadscope wrote as the OS user, so beads people\n * assigned to themselves then still carry that name. It is the same person on\n * this machine, so close those as it rather than failing — #61 in reverse.\n * Every other assignee (a teammate, an agent) keeps bd's protection.\n */\nexport function closeActor(assignee: string | null | undefined): string {\n const { humanActor } = getConfig();\n return assignee && assignee !== humanActor && assignee === osUserName() ? assignee : humanActor;\n}\n\n/** Update global settings (actor / allowlist / poll). Project registry has its own mutators. */\nexport function saveConfig(\n patch: Partial<Pick<AppConfig, \"humanActor\" | \"humanAllowlist\" | \"pollIntervalMs\" | \"gamification\">>,\n): AppConfig {\n const next = { ...getConfig(), ...patch };\n if (patch.humanActor !== undefined) next.humanActorChosen = true;\n persist(next);\n return next;\n}\n\n// ---- project registry ----------------------------------------------------\n\nexport function listProjects(): ProjectEntry[] {\n return getConfig().projects;\n}\n\nexport function getProject(id: string): ProjectEntry | DemoProject | undefined {\n if (id === DEMO_PROJECT.id) return DEMO_PROJECT;\n return getConfig().projects.find((p) => p.id === id);\n}\n\n/** Add (or re-touch) a project by folder path. Validates a `.beads` dir exists. */\nexport function addProject(inputPath: string): ProjectEntry {\n const cfg = getConfig();\n const abs = path.resolve(inputPath);\n if (!hasBeads(abs)) {\n throw new ConfigError(`No .beads directory found in ${abs}`, \"no_beads\");\n }\n const existing = cfg.projects.find((p) => sameDir(p.path, abs));\n if (existing) {\n existing.lastOpened = new Date().toISOString();\n persist(cfg);\n return existing;\n }\n const entry = makeEntry(abs, new Set(cfg.projects.map((p) => p.id)));\n cfg.projects.push(entry);\n persist(cfg);\n return entry;\n}\n\nexport function removeProject(id: string): void {\n const cfg = getConfig();\n cfg.projects = cfg.projects.filter((p) => p.id !== id);\n // Drop any saved board ordering for the removed project so it can't orphan.\n if (cfg.orders[id]) {\n const rest = { ...cfg.orders };\n delete rest[id];\n cfg.orders = rest;\n }\n persist(cfg);\n}\n\nexport function touchProject(id: string): void {\n const cfg = getConfig();\n const p = cfg.projects.find((x) => x.id === id);\n if (p) {\n p.lastOpened = new Date().toISOString();\n persist(cfg);\n }\n}\n\nexport function renameProject(id: string, name: string): ProjectEntry | undefined {\n const cfg = getConfig();\n const p = cfg.projects.find((x) => x.id === id);\n if (!p) return undefined;\n p.name = name;\n persist(cfg);\n return p;\n}\n\n// ---- manual board ordering ------------------------------------------------\n\n/** All saved column orders for a project: columnId → ordered bead ids. */\nexport function getColumnOrders(projectId: string): Record<string, string[]> {\n return getConfig().orders[projectId] ?? {};\n}\n\n/** Replace the saved order for one column of one project. */\nexport function setColumnOrder(\n projectId: string,\n columnId: string,\n ids: string[],\n): Record<string, string[]> {\n const cfg = getConfig();\n const proj = { ...(cfg.orders[projectId] ?? {}) };\n proj[columnId] = ids;\n cfg.orders = { ...cfg.orders, [projectId]: proj };\n persist(cfg);\n return proj;\n}\n","// This file is generated by next-core EcmascriptClientReferenceModule.\nimport { registerClientReference } from \"react-server-dom-turbopack/server\";\nexport const AppShell = registerClientReference(\n function() { throw new Error(\"Attempted to call AppShell() from the server but AppShell is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.\"); },\n \"[project]/components/app-shell.tsx\",\n \"AppShell\",\n);\n"],"names":["DEMO_PROJECT","id","name","path","ConfigError","Error","code","message","VIEWER_MODE_COOKIE","isReadOnly","request","cookie","headers","get","split","map","v","trim","find","startsWith","slice","length","process","env","BEADSCOPE_READ_ONLY","lanePrefix","BEADSCOPE_LANE_PREFIX","configDir","base","XDG_CONFIG_HOME","join","homedir","configFile","osUserName","userInfo","username","gitUserName","cwd","encoding","timeout","stdio","defaults","humanActor","BEADS_ACTOR","humanAllowlist","pollIntervalMs","projects","orders","gamification","hasBeads","p","existsSync","realpathOrSelf","realpathSync","resolve","sameDir","a","b","slug","s","toLowerCase","replace","makeId","absPath","taken","basename","has","Math","random","toString","makeEntry","inputPath","abs","now","Date","toISOString","addedAt","lastOpened","sanitizeProjects","input","Array","isArray","out","seen","Set","it","e","add","push","cached","persist","cfg","mkdirSync","recursive","JSON","parse","readFileSync","next","writeFileSync","stringify","getConfig","d","onDisk","staleActor","humanActorChosen","storedAllowlist","merged","includes","migrated","undefined","legacyPath","repoPath","BEADS_REPO","some","closeActor","assignee","saveConfig","patch","listProjects","getProject","addProject","existing","entry","removeProject","filter","rest","touchProject","x","renameProject","getColumnOrders","projectId","setColumnOrder","columnId","ids","proj","AppShell"],"mappings":"2CAAA,EAAA,EAAA,CAAA,CAAA,KAEA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,KCFA,EAAA,EAAA,CAAA,CAAA,MACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OA2CO,IAAMA,EAAe,CAC1BC,GAAI,OACJC,KAAM,OACNC,KAAM,IACR,EAyCO,SAASwB,IACd,IAAMC,EAAON,QAAQC,GAAG,CAACM,eAAe,EAAI,EAAA,OAAI,CAACC,IAAI,CAAC,EAAA,OAAE,CAACC,OAAO,GAAI,WACpE,OAAO,EAAA,OAAI,CAACD,IAAI,CAACF,EAAM,YACzB,CACA,SAASI,IACP,OAAO,EAAA,OAAI,CAACF,IAAI,CAACH,IAAa,cAChC,CAEA,SAASM,IACP,GAAI,CACF,OAAO,EAAA,OAAE,CAACC,QAAQ,GAAGC,QAAQ,EAAI,KACnC,CAAE,KAAM,CACN,MAAO,KACT,CACF,CA4CA,SAASiB,EAAeF,CAAS,EAC/B,GAAI,CACF,OAAO,EAAA,OAAE,CAACG,YAAY,CAACH,EACzB,CAAE,KAAM,CACN,OAAO,EAAA,OAAI,CAACI,OAAO,CAACJ,EACtB,CACF,CAwDA,IAAIuC,EAA2B,KD1MxB,eAAe,EAAiB,CAAE,QAAM,CAAS,EACtD,GAAM,WAAE,CAAS,CAAE,CAAG,MAAM,EACtB,ECuTN,AAAIxF,IAAOD,EAAaC,EAAE,ADvTV,CCuTmBD,CAA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/config.ts","../../../../lib/agents.ts","../../../../components/app-shell.tsx/__nextjs-internal-proxy.mjs%20%7B%20server%20%3D%3E%20%22%5Bproject%5D/components/app-shell.tsx%22%20%7D"],"sourcesContent":["import type { Metadata } from \"next\";\nimport { AppShell } from \"@/components/app-shell\";\nimport { projectTitle } from \"@/lib/app-title\";\nimport { getProject } from \"@/lib/config\";\n\ntype Props = {\n params: Promise<{ projectId: string }>;\n};\n\nexport async function generateMetadata({ params }: Props): Promise<Metadata> {\n const { projectId } = await params;\n const project = getProject(projectId);\n\n return project ? { title: projectTitle(project.name) } : {};\n}\n\nexport default async function ProjectPage({ params }: Props) {\n const { projectId } = await params;\n // A project route owns transient UI state (drawer trails, palettes, and the\n // notification watcher baseline). A distinct key prevents state from one\n // client-side project visit leaking into the next one.\n return <AppShell key={projectId} projectId={projectId} />;\n}\n","import \"server-only\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport os from \"node:os\";\nimport { execFileSync } from \"node:child_process\";\nimport { defaultAgents, normalizeAgents, validateAgents, type AgentIdentity } from \"./agents.ts\";\n\n/**\n * Local app config (NOT stored in beads). Lives as a small JSON file under the\n * OS config dir. Holds the human actor used to stamp writes, the human allowlist\n * for origin detection, the poll interval, and the registry of beads projects\n * the app knows about.\n *\n * Project identity is per-request (driven by the /p/<projectId> URL), so the\n * \"active\" project is NOT stored here — only the durable list of discovered ones.\n */\nexport interface ProjectEntry {\n id: string;\n name: string;\n path: string;\n /** ISO timestamps. */\n addedAt: string;\n lastOpened: string;\n}\n\nexport interface AppConfig {\n humanActor: string;\n humanAllowlist: string[];\n /** Agent identities (the assignee picker choices); see lib/agents.ts. */\n agents: AgentIdentity[];\n pollIntervalMs: number;\n projects: ProjectEntry[];\n /**\n * Manual board ordering, kept app-local (NOT in beads): projectId → columnId →\n * ordered bead ids. Lets users drag beads within a column to set work order.\n */\n orders: Record<string, Record<string, string[]>>;\n /** Opt-in: show the gamification XP/level layer (off by default). */\n gamification: boolean;\n /**\n * True once the human actor was saved from Settings. Until then the actor\n * follows the computed default, even if an older version wrote it to disk.\n */\n humanActorChosen?: boolean;\n}\n\n/**\n * The built-in demo dataset, surfaced as an always-available pseudo-project.\n * It has no filesystem path; the store resolver maps it to the in-memory store.\n */\nexport const DEMO_PROJECT = {\n id: \"demo\",\n name: \"Demo\",\n path: null,\n} as const;\nexport type DemoProject = typeof DEMO_PROJECT;\n\nexport class ConfigError extends Error {\n code: string;\n constructor(message: string, code: string) {\n super(message);\n this.name = \"ConfigError\";\n this.code = code;\n }\n}\n\n/**\n * BEADSCOPE_READ_ONLY=1 (or \"true\") supplies the default for new browser sessions.\n * The session cookie overrides that default when the user changes the mode.\n * In the effective read-only mode, project writes are refused server-side and\n * editing controls are disabled. App settings remain available.\n */\nexport const VIEWER_MODE_COOKIE = \"beadscope-viewer-mode\";\n\nexport function isReadOnly(request?: Request): boolean {\n // This is a browser preference, not an authorization boundary. A session\n // cookie lets one browser override the launch default without affecting others.\n const cookie = request?.headers.get(\"cookie\")?.split(\";\").map((v) => v.trim())\n .find((v) => v.startsWith(`${VIEWER_MODE_COOKIE}=`))?.slice(VIEWER_MODE_COOKIE.length + 1);\n if (cookie === \"read-only\") return true;\n if (cookie === \"editing\") return false;\n const v = process.env.BEADSCOPE_READ_ONLY;\n return v === \"1\" || v === \"true\";\n}\n\n/**\n * Focus-view lane chips: BEADSCOPE_LANE_PREFIX names a label prefix (e.g. \"ctx:\")\n * whose values partition work into lanes/teams/areas. When set, the Focus view\n * offers one filter chip per lane label found on the visible beads. Unset →\n * no chips (the feature is invisible).\n */\nexport function lanePrefix(): string | null {\n return process.env.BEADSCOPE_LANE_PREFIX || null;\n}\n\nexport function configDir(): string {\n const base = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), \".config\");\n return path.join(base, \"beadscope\");\n}\nfunction configFile(): string {\n return path.join(configDir(), \"config.json\");\n}\n\nfunction osUserName(): string {\n try {\n return os.userInfo().username || \"you\";\n } catch {\n return \"you\";\n }\n}\n\n/** git's user.name as seen from the launch directory, or null without git or a name. */\nfunction gitUserName(): string | null {\n try {\n const name = execFileSync(\"git\", [\"config\", \"--get\", \"user.name\"], {\n cwd: process.cwd(),\n encoding: \"utf8\",\n timeout: 2000,\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim();\n return name || null;\n } catch {\n return null;\n }\n}\n\nfunction defaults(): AppConfig {\n // Same order as bd's own actor (`bd --help`, --actor): BEADS_ACTOR, then git\n // user.name, then the OS user. If Beadscope stamped writes with the OS name\n // while `bd update --claim` used the git name, bd would refuse to let the UI\n // close beads the user claimed from the CLI.\n const humanActor = process.env.BEADS_ACTOR || gitUserName() || osUserName();\n return {\n humanActor,\n humanAllowlist: [humanActor],\n agents: defaultAgents(),\n // Fallback refresh interval. The SSE change stream (see lib/beads-watch)\n // drives fast updates; this interval only backstops a dropped stream.\n pollIntervalMs: 30000,\n projects: [],\n orders: {},\n gamification: false,\n };\n}\n\n// ---- helpers -------------------------------------------------------------\n\n/**\n * Whether `p` holds a beads workspace. bd also keeps per-user state (a machine-id\n * and an event queue) in `~/.beads`; that folder is not a workspace, so it must not\n * make the home directory look like a project. A workspace has a config.yaml or\n * metadata.json next to its database.\n */\nexport function hasBeads(p: string): boolean {\n try {\n const dir = path.join(p, \".beads\");\n if (!fs.existsSync(dir)) return false;\n const isUserStateDir =\n fs.existsSync(path.join(dir, \"machine-id\")) &&\n !fs.existsSync(path.join(dir, \"config.yaml\")) &&\n !fs.existsSync(path.join(dir, \"metadata.json\"));\n return !isUserStateDir;\n } catch {\n return false;\n }\n}\nfunction realpathOrSelf(p: string): string {\n try {\n return fs.realpathSync(p);\n } catch {\n return path.resolve(p);\n }\n}\nfunction sameDir(a: string, b: string): boolean {\n return realpathOrSelf(a) === realpathOrSelf(b);\n}\nfunction slug(s: string): string {\n return (\n s\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\") || \"project\"\n );\n}\nfunction makeId(absPath: string, taken: Set<string>): string {\n const base = slug(path.basename(absPath));\n let id = base;\n while (taken.has(id) || id === DEMO_PROJECT.id) {\n id = `${base}-${Math.random().toString(36).slice(2, 6)}`;\n }\n return id;\n}\nfunction makeEntry(inputPath: string, taken: Set<string>): ProjectEntry {\n const abs = path.resolve(inputPath);\n const now = new Date().toISOString();\n return {\n id: makeId(abs, taken),\n name: path.basename(abs) || abs,\n path: abs,\n addedAt: now,\n lastOpened: now,\n };\n}\n\n/** Drop malformed registry entries so a bad config file never crashes startup. */\nfunction sanitizeProjects(input: unknown): ProjectEntry[] {\n if (!Array.isArray(input)) return [];\n const out: ProjectEntry[] = [];\n const seen = new Set<string>();\n for (const it of input) {\n if (!it || typeof it !== \"object\") continue;\n const e = it as Record<string, unknown>;\n if (typeof e.id !== \"string\" || typeof e.path !== \"string\") continue;\n if (e.id === DEMO_PROJECT.id || seen.has(e.id)) continue;\n seen.add(e.id);\n out.push({\n id: e.id,\n path: e.path,\n name: typeof e.name === \"string\" && e.name ? e.name : path.basename(e.path) || e.path,\n addedAt: typeof e.addedAt === \"string\" ? e.addedAt : new Date().toISOString(),\n lastOpened: typeof e.lastOpened === \"string\" ? e.lastOpened : new Date().toISOString(),\n });\n }\n return out;\n}\n\n// ---- load / persist ------------------------------------------------------\n\n// Keyed off globalThis, not module scope: the page renderer (generateMetadata) and the API route\n// handlers are separate bundles with their own copy of this module, so a module-level cache would\n// leave the page showing the old project name after a rename.\nconst CACHE_KEY = Symbol.for(\"beadscope.config.cache\");\ntype CacheHolder = Record<symbol, AppConfig | null | undefined>;\nfunction readCache(): AppConfig | null {\n return (globalThis as unknown as CacheHolder)[CACHE_KEY] ?? null;\n}\nfunction writeCache(cfg: AppConfig | null): void {\n (globalThis as unknown as CacheHolder)[CACHE_KEY] = cfg;\n}\n\n/**\n * Persist the config, preserving any unknown keys already on disk (e.g. the\n * legacy `repoPath`/`demo` fields) so older app versions can still read them.\n */\nfunction persist(cfg: AppConfig): void {\n writeCache(cfg);\n try {\n fs.mkdirSync(configDir(), { recursive: true });\n let base: Record<string, unknown> = {};\n try {\n base = JSON.parse(fs.readFileSync(configFile(), \"utf8\")) as Record<string, unknown>;\n } catch {\n base = {};\n }\n const next = { ...base, ...cfg };\n fs.writeFileSync(configFile(), JSON.stringify(next, null, 2), \"utf8\");\n } catch {\n /* best-effort; config still applies for the session */\n }\n}\n\nexport function getConfig(): AppConfig {\n const hit = readCache();\n if (hit) return hit;\n const d = defaults();\n\n let onDisk:\n | (Partial<AppConfig> & { repoPath?: string; demo?: boolean })\n | null = null;\n try {\n onDisk = JSON.parse(fs.readFileSync(configFile(), \"utf8\"));\n } catch {\n onDisk = null;\n }\n\n // Before 0.3.1 the computed default (the OS user) was written to disk along\n // with the first project, so an unchosen OS username on disk is a stale\n // default rather than a preference. Replace it, and keep the new actor in the\n // allowlist so the user's own writes still render as human.\n const staleActor =\n !onDisk?.humanActorChosen && onDisk?.humanActor === osUserName() && d.humanActor !== onDisk.humanActor;\n const storedAllowlist = onDisk?.humanAllowlist && onDisk.humanAllowlist.length ? onDisk.humanAllowlist : null;\n const merged: AppConfig = {\n humanActor: staleActor ? d.humanActor : onDisk?.humanActor || d.humanActor,\n humanAllowlist: !storedAllowlist\n ? d.humanAllowlist\n : staleActor && !storedAllowlist.includes(d.humanActor)\n ? [...storedAllowlist, d.humanActor]\n : storedAllowlist,\n agents: normalizeAgents(onDisk?.agents),\n pollIntervalMs:\n typeof onDisk?.pollIntervalMs === \"number\" ? onDisk.pollIntervalMs : d.pollIntervalMs,\n projects: sanitizeProjects(onDisk?.projects),\n orders:\n onDisk?.orders && typeof onDisk.orders === \"object\" && !Array.isArray(onDisk.orders)\n ? (onDisk.orders as Record<string, Record<string, string[]>>)\n : {},\n gamification: typeof onDisk?.gamification === \"boolean\" ? onDisk.gamification : d.gamification,\n humanActorChosen: onDisk?.humanActorChosen === true,\n };\n\n // One-time migration: back-fill the registry from the legacy single repoPath\n // (or BEADS_REPO / cwd) when no projects array exists yet.\n let migrated = false;\n if (!onDisk || onDisk.projects === undefined) {\n const legacyPath = onDisk?.repoPath || process.env.BEADS_REPO || process.cwd();\n if (\n legacyPath &&\n hasBeads(legacyPath) &&\n !merged.projects.some((p) => sameDir(p.path, legacyPath))\n ) {\n merged.projects.push(makeEntry(legacyPath, new Set(merged.projects.map((p) => p.id))));\n migrated = true;\n }\n }\n\n writeCache(merged);\n // Persist the migrated entry so its id is stable across restarts.\n if (migrated) persist(merged);\n return merged;\n}\n\n/**\n * The actor to close a bead as. bd refuses to close a claimed bead as anyone\n * but its assignee. Before 0.3.1 Beadscope wrote as the OS user, so beads people\n * assigned to themselves then still carry that name. It is the same person on\n * this machine, so close those as it rather than failing — #61 in reverse.\n * Every other assignee (a teammate, an agent) keeps bd's protection.\n */\nexport function closeActor(assignee: string | null | undefined): string {\n const { humanActor } = getConfig();\n return assignee && assignee !== humanActor && assignee === osUserName() ? assignee : humanActor;\n}\n\n/** Update global settings (actor / allowlist / poll). Project registry has its own mutators. */\nexport function saveConfig(\n patch: Partial<Pick<AppConfig, \"humanActor\" | \"humanAllowlist\" | \"agents\" | \"pollIntervalMs\" | \"gamification\">>,\n): AppConfig {\n const current = getConfig();\n const next = { ...current, ...patch };\n if (patch.humanActor !== undefined) next.humanActorChosen = true;\n // Check the names as sent (before normalizing quietly repairs an empty one), against\n // the humans being saved, so an agent cannot take a human name.\n if (patch.agents !== undefined || patch.humanActor !== undefined || patch.humanAllowlist !== undefined) {\n const problem = validateAgents(patch.agents ?? next.agents, [next.humanActor, ...next.humanAllowlist]);\n if (problem) throw new ConfigError(problem, \"invalid_agents\");\n }\n if (patch.agents !== undefined) next.agents = normalizeAgents(patch.agents);\n persist(next);\n return next;\n}\n\n// ---- project registry ----------------------------------------------------\n\nexport function listProjects(): ProjectEntry[] {\n return getConfig().projects;\n}\n\nexport function getProject(id: string): ProjectEntry | DemoProject | undefined {\n if (id === DEMO_PROJECT.id) return DEMO_PROJECT;\n return getConfig().projects.find((p) => p.id === id);\n}\n\n/** Add (or re-touch) a project by folder path. Validates a `.beads` dir exists. */\nexport function addProject(inputPath: string): ProjectEntry {\n const cfg = getConfig();\n const abs = path.resolve(inputPath);\n if (!hasBeads(abs)) {\n throw new ConfigError(`No .beads directory found in ${abs}`, \"no_beads\");\n }\n const existing = cfg.projects.find((p) => sameDir(p.path, abs));\n if (existing) {\n existing.lastOpened = new Date().toISOString();\n persist(cfg);\n return existing;\n }\n const entry = makeEntry(abs, new Set(cfg.projects.map((p) => p.id)));\n cfg.projects.push(entry);\n persist(cfg);\n return entry;\n}\n\nexport function removeProject(id: string): void {\n const cfg = getConfig();\n cfg.projects = cfg.projects.filter((p) => p.id !== id);\n // Drop any saved board ordering for the removed project so it can't orphan.\n if (cfg.orders[id]) {\n const rest = { ...cfg.orders };\n delete rest[id];\n cfg.orders = rest;\n }\n persist(cfg);\n}\n\nexport function touchProject(id: string): void {\n const cfg = getConfig();\n const p = cfg.projects.find((x) => x.id === id);\n if (p) {\n p.lastOpened = new Date().toISOString();\n persist(cfg);\n }\n}\n\nexport function renameProject(id: string, name: string): ProjectEntry | undefined {\n const cfg = getConfig();\n const p = cfg.projects.find((x) => x.id === id);\n if (!p) return undefined;\n p.name = name;\n persist(cfg);\n return p;\n}\n\n// ---- manual board ordering ------------------------------------------------\n\n/** All saved column orders for a project: columnId → ordered bead ids. */\nexport function getColumnOrders(projectId: string): Record<string, string[]> {\n return getConfig().orders[projectId] ?? {};\n}\n\n/** Replace the saved order for one column of one project. */\nexport function setColumnOrder(\n projectId: string,\n columnId: string,\n ids: string[],\n): Record<string, string[]> {\n const cfg = getConfig();\n const proj = { ...(cfg.orders[projectId] ?? {}) };\n proj[columnId] = ids;\n cfg.orders = { ...cfg.orders, [projectId]: proj };\n persist(cfg);\n return proj;\n}\n","/**\n * Agent identities: the names an AI agent works under (the `bd` actor string),\n * managed in Settings. Shared by the server (config) and the UI, so this file\n * must not import anything server-only.\n *\n * An identity only labels and offers a name. `bd` stores the plain string in\n * `assignee` / `created_by`; Beadscope already treats any name that is not on the\n * human allowlist as an agent (lib/attribution.ts), so identities do not change\n * that rule. They give the assignee picker its choices and give those names an icon.\n */\n\n/** What is stored in config.json. */\nexport interface AgentIdentity {\n /**\n * Stable key. Renaming an identity changes `name`, never `id`. Pre-defined\n * identities use their preset key (\"claude-code\"); user-added ones \"custom-…\".\n */\n id: string;\n /** The actor name: what `bd` records as the assignee. Editable. */\n name: string;\n /** Only enabled identities are offered in the assignee picker. */\n enabled: boolean;\n /** User-added identities only: a stock emoji from AGENT_EMOJIS. Wins over `color`. */\n emoji?: string;\n /** User-added identities only: a colour from AGENT_COLORS. */\n color?: string;\n}\n\nexport interface AgentPreset {\n id: string;\n /** The default actor name. */\n name: string;\n /** Product name shown beside the name in Settings. */\n label: string;\n /** Brand colour behind the icon. */\n color: string;\n /** Enabled the first time Beadscope sees it. */\n enabled: boolean;\n}\n\n/** Pre-defined identities, in display order. They can be disabled and renamed, not deleted. */\nexport const AGENT_PRESETS: AgentPreset[] = [\n { id: \"claude-code\", name: \"claude-code\", label: \"Claude Code\", color: \"#d97757\", enabled: true },\n { id: \"codex\", name: \"codex\", label: \"Codex\", color: \"#10a37f\", enabled: false },\n { id: \"cursor\", name: \"cursor-agent\", label: \"Cursor\", color: \"#4b5563\", enabled: false },\n { id: \"gemini\", name: \"gemini\", label: \"Gemini CLI\", color: \"#4285f4\", enabled: false },\n { id: \"copilot\", name: \"copilot\", label: \"GitHub Copilot\", color: \"#8957e5\", enabled: false },\n];\n\n/** Stock emoji for identities the user adds. */\nexport const AGENT_EMOJIS = [\n \"🤖\", \"🧠\", \"⚡\", \"🛠️\", \"🚀\", \"🦾\", \"🔮\", \"🛰️\",\n \"🦉\", \"🐙\", \"🦊\", \"🐱\", \"🧪\", \"🎯\", \"🌟\", \"🧩\",\n];\n\n/** Colours for identities the user adds (shown behind the initials). */\nexport const AGENT_COLORS = [\n \"#ef4444\", \"#f97316\", \"#eab308\", \"#22c55e\",\n \"#14b8a6\", \"#3b82f6\", \"#8b5cf6\", \"#ec4899\",\n];\n\nexport const DEFAULT_AGENT_COLOR = AGENT_COLORS[5];\nexport const MAX_AGENT_NAME = 64;\n\nexport function presetOf(id: string): AgentPreset | undefined {\n return AGENT_PRESETS.find((p) => p.id === id);\n}\n\nexport function defaultAgents(): AgentIdentity[] {\n return AGENT_PRESETS.map((p) => ({ id: p.id, name: p.name, enabled: p.enabled }));\n}\n\n/**\n * Turn whatever is on disk (or in a request) into a clean list: every preset\n * present and in order, then the user's own, with unknown fields dropped.\n * Never throws, so a bad config file cannot break startup.\n */\nexport function normalizeAgents(input: unknown): AgentIdentity[] {\n const stored = new Map<string, Record<string, unknown>>();\n const custom: AgentIdentity[] = [];\n if (Array.isArray(input)) {\n for (const item of input) {\n if (!item || typeof item !== \"object\") continue;\n const e = item as Record<string, unknown>;\n if (typeof e.id !== \"string\" || !e.id || stored.has(e.id)) continue;\n stored.set(e.id, e);\n }\n }\n const nameOf = (e: Record<string, unknown> | undefined, fallback: string) => {\n const n = typeof e?.name === \"string\" ? e.name.trim().slice(0, MAX_AGENT_NAME) : \"\";\n return n || fallback;\n };\n const out: AgentIdentity[] = AGENT_PRESETS.map((p) => {\n const e = stored.get(p.id);\n return {\n id: p.id,\n name: nameOf(e, p.name),\n enabled: typeof e?.enabled === \"boolean\" ? e.enabled : p.enabled,\n };\n });\n for (const [id, e] of stored) {\n if (presetOf(id) || !id.startsWith(\"custom-\")) continue;\n const name = nameOf(e, \"\");\n if (!name) continue;\n const agent: AgentIdentity = { id, name, enabled: e.enabled !== false };\n if (typeof e.emoji === \"string\" && AGENT_EMOJIS.includes(e.emoji)) agent.emoji = e.emoji;\n if (typeof e.color === \"string\" && AGENT_COLORS.includes(e.color)) agent.color = e.color;\n custom.push(agent);\n }\n return [...out, ...custom];\n}\n\n/**\n * Check a list a user is saving. Returns a message for the first problem, or\n * null. Names must be unique (ignoring case) and must not collide with a human\n * name, which would make the agent's work render as human's.\n */\nexport function validateAgents(agents: AgentIdentity[], humanNames: string[]): string | null {\n const seen = new Set<string>();\n const humans = new Set(humanNames.map((n) => n.trim().toLowerCase()).filter(Boolean));\n for (const a of agents) {\n const name = a.name.trim();\n if (!name) return \"Every agent needs a name.\";\n if (name.length > MAX_AGENT_NAME) return `Agent names are at most ${MAX_AGENT_NAME} characters.`;\n if (/[\\u0000-\\u001f\\u007f]/.test(name)) return \"Agent names cannot contain control characters.\";\n const key = name.toLowerCase();\n if (humans.has(key)) return `\"${name}\" is a human name (the human actor or allowlist); agents need their own.`;\n if (seen.has(key)) return `\"${name}\" is used twice. Agent names must be unique.`;\n seen.add(key);\n }\n return null;\n}\n\n/** Enabled identities' names, in list order: what the assignee picker offers. */\nexport function enabledAgentNames(agents: AgentIdentity[] | undefined): string[] {\n return (agents ?? []).filter((a) => a.enabled).map((a) => a.name);\n}\n\n/** The identity an assignee name belongs to, enabled or not (so old beads keep their icon). */\nexport function agentByName(agents: AgentIdentity[] | undefined, name: string | null | undefined): AgentIdentity | undefined {\n const key = name?.trim().toLowerCase();\n if (!key) return undefined;\n return (agents ?? []).find((a) => a.name.trim().toLowerCase() === key);\n}\n\nexport function newCustomAgentId(): string {\n return `custom-${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;\n}\n","// This file is generated by next-core EcmascriptClientReferenceModule.\nimport { registerClientReference } from \"react-server-dom-turbopack/server\";\nexport const AppShell = registerClientReference(\n function() { throw new Error(\"Attempted to call AppShell() from the server but AppShell is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.\"); },\n \"[project]/components/app-shell.tsx\",\n \"AppShell\",\n);\n"],"names":["AGENT_PRESETS","id","name","label","color","enabled","AGENT_EMOJIS","AGENT_COLORS","DEFAULT_AGENT_COLOR","MAX_AGENT_NAME","presetOf","find","p","defaultAgents","map","normalizeAgents","input","stored","Map","custom","Array","isArray","item","e","has","set","nameOf","fallback","n","trim","slice","out","get","startsWith","agent","emoji","includes","push","validateAgents1","agents","humanNames","seen","Set","humans","toLowerCase","filter","Boolean","a","length","test","key","add","enabledAgentNames","agentByName","undefined","newCustomAgentId","Date","now","toString","Math","random","AppShell","Error"],"mappings":"2CACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,KCDA,EAAA,EAAA,CAAA,CAAA,MACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OCqCO,IAAMA,EAA+B,CAC1C,CAAEC,GAAI,cAAeC,KAAM,cAAeC,MAAO,cAAeC,MAAO,UAAWC,SAAS,CAAK,EAChG,CAAEJ,GAAI,QAASC,KAAM,QAASC,MAAO,QAASC,MAAO,UAAWC,SAAS,CAAM,EAC/E,CAAEJ,GAAI,SAAUC,KAAM,eAAgBC,MAAO,SAAUC,MAAO,UAAWC,SAAS,CAAM,EACxF,CAAEJ,GAAI,SAAUC,KAAM,SAAUC,MAAO,aAAcC,MAAO,UAAWC,SAAS,CAAM,EACtF,CAAEJ,GAAI,UAAWC,KAAM,UAAWC,MAAO,iBAAkBC,MAAO,UAAWC,SAAS,CAAM,EAC7F,CAGYC,EAAe,CAC1B,KAAM,KAAM,IAAK,MAAO,KAAM,KAAM,KAAM,MAC1C,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,KAC3C,CAGYC,EAAe,CAC1B,UAAW,UAAW,UAAW,UACjC,UAAW,UAAW,UAAW,UAClC,CAEkCA,CAAY,CAAC,EAAE,CDX3C,IAAM,EAAe,CAC1B,GAAI,OACJ,KAAM,OACNJ,KAAM,IACR,EAyCO,SAASoB,IACd,IAAM,EAAO,QAAQ,GAAG,CAACE,eAAe,EAAI,EAAA,OAAI,CAAC,IAAI,CAAC,EAAA,OAAE,CAACC,OAAO,GAAI,WACpE,OAAO,EAAA,OAAI,CAAC,IAAI,CAAC,EAAM,YACzB,CACA,SAAS,IACP,OAAO,EAAA,OAAI,CAAC,IAAI,CAAC,IAAa,cAChC,CAEA,SAAS,IACP,GAAI,CACF,OAAO,E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OAAE,CAAC,aAAa,CAAC,IAAc,KAAK,SAAS,CAAC,EAAM,KAAM,GAAI,OAChE,CAAE,KAAM,CAER,CACF,EA2DwB,GACf,EACT,IAwCqB,QAAQ,CAAC,IAAI,CAAC,AAAC,GAAM,EAAE,EAAE,GD7VjB,EC6VsB,CD3VjD,OAAO,EAAU,CAAE,MAAO,CAAA,EAAA,EAAA,CAAA,AAAY,EAAC,EAAQ,IAAI,CAAE,EAAI,CAAC,CAC5D,CAEe,eAAe,EAAY,QAAE,CAAM,CAAS,EACzD,GAAM,WAAE,CAAS,CAAE,CAAG,MAAM,EAI5B,MAAO,CAAA,EAAA,EAAA,GAAA,EAAC,EAAA,QAAQ,CAAA,CAAiB,UAAW,GAAtB,EACxB,8DGpBO,IAAMW,EAAW,CAAA,EADxB,AACwB,EADxB,CAAA,CAAA,OACwB,uBAAA,AAAuB,EAC3C,WAAa,MAAM,AAAIC,MAAM,8NAAgO,EAC7P,qCACA","ignoreList":[3]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
(()=>{"use strict";module.exports=[59493,a=>{var b=a.i(87924),c=a.i(35985);a.s(["f",0,function({icon:a,size:d="md",children:e,className:f="",...g}){let h="sm"===d;return(0,b.jsxs)("button",{type:"button",...g,className:`flex flex-shrink-0 items-center justify-center whitespace-nowrap text-white tap-target disabled:opacity-50 ${h?"h-8 gap-[6px] rounded-lg px-3 text-label font-medium":"h-9 gap-[6px] rounded-[9px] px-[14px] text-body font-semibold"} ${f}`,style:{background:"var(--brand-solid)",...h?{}:{boxShadow:"0 2px 8px -2px var(--brand)"},...g.style},children:[a&&(0,b.jsx)(c.W,{name:a,size:h?14:15}),(0,b.jsx)("span",{className:"inline-flex items-center gap-[inherit]",children:e})]})}])},32123,a=>{var b=a.i(87924),c=a.i(72131),d=a.i(33217),e=a.i(70025),f=a.i(37927),g=a.i(50944),h=a.i(23292),i=a.i(69095),j=a.i(44561),k=a.i(55486),l=a.i(27598),m=a.i(52562),n=a.i(75160),o=a.i(90702),p=a.i(65733),q=a.i(71630),r=a.i(59493),s=a.i(69937);function t({onClose:a}){let u=(0,g.useRouter)(),v=(0,f.d)(),[w,x]=c.useState(void 0),{data:y,isLoading:z,error:A}=(0,d.f)({queryKey:["fs",w??"~home"],queryFn:()=>q.k.fs.browse(w)}),B=(0,e.f)({mutationFn:a=>q.k.projects.add(a),onSuccess:b=>{v.invalidateQueries({queryKey:["projects"]}),h.c.success(`Added ${b.name}`),a(),u.push(`/p/${b.id}`)},onError:a=>h.c.error(a.message)}),C=A?A.message:void 0;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"flex items-center gap-[10px] border-b border-border p-[17px_20px]",children:[(0,b.jsx)("div",{className:"flex h-[30px] w-[30px] items-center justify-center rounded-[9px] bg-[var(--brand-weak)] text-[var(--brand)]",children:(0,b.jsx)(j.f,{size:16})}),(0,b.jsxs)("div",{className:"flex-1",children:[(0,b.jsx)(p.F,{className:"text-section font-semibold",children:"Add a project"}),(0,b.jsxs)(p.C,{className:"text-meta text-[var(--text-3)]",children:["Pick a folder that contains a ",(0,b.jsx)("span",{className:"font-mono",children:".beads"})," directory"]})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 border-b border-border bg-[var(--surface-2)] p-[10px_16px]",children:[(0,b.jsx)(s._,{label:"Home",title:"Home",onClick:()=>x(void 0),children:(0,b.jsx)(k.f,{size:14})}),(0,b.jsx)(s._,{label:"Up one level",title:"Up one level",onClick:()=>y?.parent&&x(y.parent),disabled:!y?.parent,children:(0,b.jsx)(l.f,{size:14})}),(0,b.jsx)(s.C,{size:"sm",mono:!0,defaultValue:y?.path??"",onKeyDown:a=>{if("Enter"===a.key){let b;a.preventDefault(),(b=a.target.value.trim())&&x(b)}},spellCheck:!1,autoComplete:"off",placeholder:"Type or paste a path, then press Enter","aria-label":"Folder path",className:`w-0 flex-1 bg-[var(--surface)] ${C?"border-[#d97706]":""}`},y?.path??"home")]}),(0,b.jsx)("div",{className:"bd-scroll max-h-[340px] min-h-[200px] overflow-y-auto p-2",children:z?(0,b.jsx)("div",{className:"flex h-[180px] items-center justify-center text-[var(--text-3)]",children:(0,b.jsx)(n.f,{size:18,className:"animate-spin"})}):C?(0,b.jsxs)("div",{className:"flex h-[180px] flex-col items-center justify-center gap-2 px-6 text-center",children:[(0,b.jsx)(o.f,{size:20,className:"text-[#d97706]"}),(0,b.jsx)("p",{className:"text-label text-[var(--text-2)]",children:C}),(0,b.jsx)(s.K,{variant:"outline",size:"sm",onClick:()=>x(void 0),children:"Go home"})]}):y&&0===y.entries.length?(0,b.jsx)("div",{className:"flex h-[180px] items-center justify-center text-label text-[var(--text-3)]",children:"No subfolders here"}):y?.entries.map(a=>(0,b.jsxs)("button",{onDoubleClick:()=>x(a.path),onClick:()=>x(a.path),className:"flex w-full items-center gap-[10px] rounded-[9px] px-[10px] py-2 text-left tap-target hover:bg-[var(--surface-2)]",children:[(0,b.jsx)(i.f,{size:16,className:a.hasBeads?"text-[var(--brand)]":"text-[var(--text-3)]"}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-body text-[var(--text)]",children:a.name}),a.hasBeads&&(0,b.jsx)("span",{className:"rounded-full bg-[var(--brand-weak)] px-2 py-0.5 font-mono text-meta font-medium text-[var(--brand)]",children:"beads"})]},a.path))}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-[10px] border-t border-border p-[14px_18px]",children:[(0,b.jsx)("div",{className:"min-w-[8rem] flex-1 text-meta text-[var(--text-3)] max-md:basis-full",children:y?.hasBeads?(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-[var(--text-2)]",children:[(0,b.jsx)(m.f,{size:13,className:"flex-shrink-0 text-[#22c55e]"}),(0,b.jsxs)("span",{children:["This folder has a ",(0,b.jsx)("span",{className:"font-mono",children:".beads"})," repo"]})]}):"Navigate into a folder that contains a .beads directory"}),(0,b.jsx)(s.K,{size:"lg",className:"max-md:flex-1",onClick:a,children:"Cancel"}),(0,b.jsxs)(r.f,{className:"max-md:flex-[2]",onClick:()=>y?.path&&B.mutate(y.path),disabled:!y?.hasBeads||B.isPending,children:[B.isPending?(0,b.jsx)(n.f,{size:14,className:"animate-spin"}):(0,b.jsx)(m.f,{size:15}),"Add this folder"]})]})]})}a.s(["f",0,function({open:a,onOpenChange:c}){return(0,b.jsx)(p.N,{open:a,onOpenChange:c,children:(0,b.jsx)(p.d,{showCloseButton:!1,className:"w-[580px] max-w-[100%] gap-0 overflow-hidden rounded-2xl border border-border bg-[var(--surface)] p-0 shadow-[var(--shadow-lg)]",children:a&&(0,b.jsx)(t,{onClose:()=>c(!1)})})})}])},52025,a=>{var b=a.i(87924),c=a.i(35985),d=a.i(69937),e=a.i(4365),f=a.i(22675);a.s(["f",0,function({size:a="md"}){let{mode:g,choice:h,toggle:i}=(0,e.i)(),j=(0,f.a)(h,g);return(0,b.jsx)(d._,{size:a,label:j.title,title:j.title,onClick:i,children:(0,b.jsx)(c.W,{name:j.icon,size:15})})}])},65733,40197,72925,21341,32489,68758,5358,49867,8842,40695,23251,a=>{let b,c;var d=a.i(87924),e=a.i(12765),f=a.i(29302),g=a.i(83603),h=a.i(49670),i=a.i(91034),j=a.i(18836),k=a.i(73343),l=a.i(54662),m=a.i(72131),n=a.i(23689),o=a.i(21436),p=a.i(26184),q=a.i(75633),r=a.i(82204),s=a.i(84204),t=a.i(557),u=a.i(31973),v=a.i(29752);let w=m.forwardRef(function(a,b){let{render:c,className:d,style:e,disabled:f=!1,nativeButton:g=!0,id:h,payload:i,handle:j,...k}=a,w=(0,n.x)(!0),x=j?.store??w?.store;if(!x)throw Error((0,l.f)(79));let y=(0,t.f)(h),z=x.useState("floatingRootContext"),A=x.useState("isOpenedByTrigger",y),B=x.useState("triggerPopupId",y),C=m.useRef(null),{registerTrigger:D,isMountedByThisTrigger:E}=(0,s.F)(y,C,x,{payload:i}),{getButtonProps:F,buttonRef:G}=(0,o.f)({disabled:f,native:g}),H=(0,u.f)(z,{enabled:null!=z}),I=(0,v.p)(()=>x.select("open"),a=>{x.set("openMethod",a)}),J=x.useState("triggerProps",E);return(0,p.f)("button",a,{state:{disabled:f,open:A},ref:[G,b,D,C],props:[H.reference,J,I,{[r.j]:"",id:y,"aria-haspopup":"dialog","aria-expanded":A,"aria-controls":B},k,F],stateAttributesMapping:q.J})});a.s(["Backdrop",()=>e.f,"Close",()=>f.f,"Description",()=>g.f,"Popup",()=>h.f,"Portal",()=>i.f,"Root",()=>j.f,"Title",()=>k.f,"Trigger",0,w],17953);var x=a.i(17953);a.s(["f",0,x],40197);var x=x,y=x;a.s(["f",0,y],72925);var y=x,z=x;a.s(["f",0,z],21341);var z=x,A=x;a.s(["f",0,A],32489);var A=x,B=x;a.s(["f",0,B],68758);var B=x,C=x;a.s(["f",0,C],5358);var C=x,D=x;a.s(["f",0,D],49867);var D=x,E=x;a.s(["f",0,E],8842);var E=x,F=a.i(97895);let G=m.forwardRef(function(a,b){let{render:c,className:d,disabled:e=!1,focusableWhenDisabled:f=!1,nativeButton:g=!0,style:h,...i}=a,{getButtonProps:j,buttonRef:k}=(0,o.f)({disabled:e,focusableWhenDisabled:f,native:g});return(0,p.f)("button",a,{state:{disabled:e},ref:[b,k],props:[i,j]})});var H=a.i(98621);let I=a=>"boolean"==typeof a?`${a}`:0===a?"0":a,J=H.q,K=(b="group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-body font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",c={variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-label in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-label in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}},a=>{var d;if((null==c?void 0:c.variants)==null)return J(b,null==a?void 0:a.class,null==a?void 0:a.className);let{variants:e,defaultVariants:f}=c,g=Object.keys(e).map(b=>{let c=null==a?void 0:a[b],d=null==f?void 0:f[b];if(null===c)return null;let g=I(c)||I(d);return e[b][g]}),h=a&&Object.entries(a).reduce((a,b)=>{let[c,d]=b;return void 0===d||(a[c]=d),a},{});return J(b,g,null==c||null==(d=c.compoundVariants)?void 0:d.reduce((a,b)=>{let{class:c,className:d,...e}=b;return Object.entries(e).every(a=>{let[b,c]=a;return Array.isArray(c)?c.includes({...f,...h}[b]):({...f,...h})[b]===c})?[...a,c,d]:a},[]),null==a?void 0:a.class,null==a?void 0:a.className)});function L({className:a,variant:b="default",size:c="default",...e}){return(0,d.jsx)(G,{"data-slot":"button",className:(0,F.f)(K({variant:b,size:c,className:a})),...e})}a.s(["f",0,L],40695);let M=(0,a.i(64831).f)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function N({...a}){return(0,d.jsx)(z.Portal,{"data-slot":"dialog-portal",...a})}function O({className:a,...b}){return(0,d.jsx)(B.Backdrop,{"data-slot":"dialog-overlay",className:(0,F.f)("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",a),...b})}a.s(["f",0,M],23251),a.s(["N",0,function({...a}){return(0,d.jsx)(x.Root,{"data-slot":"dialog",...a})},"d",0,function({className:a,children:b,showCloseButton:c=!0,...e}){return(0,d.jsxs)(N,{children:[(0,d.jsx)(O,{}),(0,d.jsxs)(C.Popup,{"data-slot":"dialog-content",className:(0,F.f)("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-body text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",a),...e,children:[b,c&&(0,d.jsxs)(A.Close,{"data-slot":"dialog-close",render:(0,d.jsx)(L,{variant:"ghost",className:"absolute top-2 right-2 max-md:size-11",size:"icon-sm"}),children:[(0,d.jsx)(M,{}),(0,d.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})},"C",0,function({className:a,...b}){return(0,d.jsx)(E.Description,{"data-slot":"dialog-description",className:(0,F.f)("text-body text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",a),...b})},"F",0,function({className:a,...b}){return(0,d.jsx)(D.Title,{"data-slot":"dialog-title",className:(0,F.f)("font-heading text-section leading-none font-medium",a),...b})}],65733)},6113,69095,44561,55486,27598,a=>{var b=a.i(33217),c=a.i(71630);a.s(["f",0,function(){return(0,b.f)({queryKey:["projects"],queryFn:c.k.projects.list})}],6113);var d=a.i(64831);let e=(0,d.f)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);a.s(["f",0,e],69095);let f=(0,d.f)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);a.s(["f",0,f],44561);let g=(0,d.f)("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]]);a.s(["f",0,g],55486);let h=(0,d.f)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);a.s(["f",0,h],27598)},71630,a=>{class b extends Error{code;detail;status;constructor(a,b,c,d){super(a),this.name="ApiError",this.status=b,this.code=c,this.detail=d}}async function c(a,c){let d=await fetch(a,{...c,headers:{"Content-Type":"application/json",...c?.headers??{}}}),e=await d.json().catch(()=>({}));if(!d.ok)throw new b(e.error||`Request failed (${d.status})`,d.status,e.code,e.detail);return e}let d=encodeURIComponent,e=a=>`/api/p/${d(a)}`;a.s(["a",0,b,"k",0,{viewerMode:()=>c("/api/viewer-mode",{cache:"no-store"}),setViewerMode:a=>c("/api/viewer-mode",{method:"PUT",body:JSON.stringify({readOnly:a})}),list:a=>c(`${e(a)}/beads`),get:(a,b)=>c(`${e(a)}/beads/${d(b)}`),create:(a,b)=>c(`${e(a)}/beads`,{method:"POST",body:JSON.stringify(b)}),update:(a,b,f)=>c(`${e(a)}/beads/${d(b)}`,{method:"PATCH",body:JSON.stringify(f)}),setStatus:(a,b,f,g)=>c(`${e(a)}/beads/${d(b)}/status`,{method:"POST",body:JSON.stringify({status:f,reason:g})}),remove:(a,b)=>c(`${e(a)}/beads/${d(b)}`,{method:"DELETE"}),addComment:(a,b,f)=>c(`${e(a)}/beads/${d(b)}/comments`,{method:"POST",body:JSON.stringify({text:f})}),addDep:(a,b,f,g)=>c(`${e(a)}/beads/${d(b)}/deps`,{method:"POST",body:JSON.stringify({depends_on_id:f,type:g})}),removeDep:(a,b,f)=>c(`${e(a)}/beads/${d(b)}/deps`,{method:"DELETE",body:JSON.stringify({depends_on_id:f})}),createGate:(a,b,f)=>c(`${e(a)}/beads/${d(b)}/gate`,{method:"POST",body:JSON.stringify({reason:f})}),archive:(a,b)=>c(`${e(a)}/beads/${d(b)}/archive`,{method:"POST"}),doctor:a=>c(`${e(a)}/doctor`),activity:a=>c(`${e(a)}/activity`),insights:(a,b)=>c(`${e(a)}/insights?days=${b}`),gamification:a=>c(`${e(a)}/gamification`),assist:(a,b)=>c(`${e(a)}/beads/${d(b)}/assist`,{method:"POST"}),human:{respond:(a,b,f)=>c(`${e(a)}/beads/${d(b)}/human`,{method:"POST",body:JSON.stringify({action:"respond",text:f})}),dismiss:(a,b)=>c(`${e(a)}/beads/${d(b)}/human`,{method:"POST",body:JSON.stringify({action:"dismiss"})})},order:{get:a=>c(`${e(a)}/order`),set:(a,b,d)=>c(`${e(a)}/order`,{method:"PUT",body:JSON.stringify({columnId:b,ids:d})})},attachments:{upload:async(a,b,c)=>{let d=new FormData;d.append("file",c),d.append("beadId",b);let f=await fetch(`${e(a)}/attachments`,{method:"POST",body:d}),g=await f.json().catch(()=>({}));if(!f.ok)throw Error(g.error||`Upload failed (${f.status})`);return g},finalize:(a,b,d)=>c(`${e(a)}/attachments`,{method:"PUT",body:JSON.stringify({draftId:b,beadId:d})}),urlFor:(a,b)=>{let c=b.replace(/^attachment:\/\//,"").split("/").filter(a=>a&&"."!==a&&".."!==a).map(encodeURIComponent).join("/");return`${e(a)}/attachments/${c}`}},showcase:{build:(a,b)=>c(`${e(a)}/publish`,{method:"POST",body:JSON.stringify({action:"build",...b})}),open:(a,b)=>c(`${e(a)}/publish`,{method:"POST",body:JSON.stringify({action:"open",path:b})}),deploy:(a,b)=>c(`${e(a)}/publish`,{method:"POST",body:JSON.stringify({action:"deploy",path:b})})},selfUpdate:{check:(a="stable")=>c(`/api/update/check?channel=${a}`),run:a=>c("/api/update/run",{method:"POST",body:JSON.stringify(a)})},saveConfig:a=>c("/api/config",{method:"PUT",body:JSON.stringify(a)}),projects:{list:()=>c("/api/projects"),add:a=>c("/api/projects",{method:"POST",body:JSON.stringify({path:a})}),remove:a=>c(`/api/projects/${d(a)}`,{method:"DELETE"}),rename:(a,b)=>c(`/api/projects/${d(a)}`,{method:"PATCH",body:JSON.stringify({name:b})})},fs:{browse:a=>c(`/api/fs${a?`?path=${d(a)}`:""}`)}}])},29302,83603,a=>{var b=a.i(72131),c=a.i(23689),d=a.i(26184),e=a.i(21436),f=a.i(94552),g=a.i(62600),g=g;let h=b.forwardRef(function(a,b){let{render:h,className:i,style:j,disabled:k=!1,nativeButton:l=!0,...m}=a,{store:n}=(0,c.x)(),o=n.useState("open"),{getButtonProps:p,buttonRef:q}=(0,e.f)({disabled:k,native:l});return(0,d.f)("button",a,{state:{disabled:k},ref:[b,q],props:[{onClick:function(a){o&&n.setOpen(!1,(0,f.f)(g.closePress,a.nativeEvent))}},m,p]})});a.s(["f",0,h],29302);var i=a.i(557);let j=b.forwardRef(function(a,b){let{render:e,className:f,style:g,id:h,...j}=a,{store:k}=(0,c.x)(),l=(0,i.f)(h);return k.useSyncedValueWithCleanup("descriptionElementId",l),(0,d.f)("p",a,{ref:b,props:[{id:l},j]})});a.s(["f",0,j],83603)},49670,a=>{var b=a.i(72131),c=a.i(50687),d=a.i(23689),e=a.i(26184),f=a.i(75633),g=a.i(81735),h=a.i(46164),i=a.i(15221),j=a.i(86070),k=a.i(5687),l=a.i(69649),m=a.i(84204),n=a.i(87924);let o={...f.E,...g.T,nestedDialogOpen:a=>a?{[i.f.nestedDialogOpen]:""}:null},p=b.forwardRef(function(a,b){let{render:f,className:g,style:i,finalFocus:p,initialFocus:q,...r}=a,{store:s}=(0,d.x)(),t=s.useState("descriptionElementId"),u=s.useState("disablePointerDismissal"),v=s.useState("floatingRootContext"),w=s.useState("popupProps"),x=s.useState("modal"),y=s.useState("mounted"),z=s.useState("nested"),A=s.useState("nestedOpenDialogCount"),B=s.useState("open"),C=s.useState("openMethod"),D=s.useState("titleElementId"),E=s.useState("transitionStatus"),F=s.useState("role"),G=v.useState("floatingId"),H=r.id??G;(0,j.Z)(),(0,k.f)({open:B,ref:s.context.popupRef,onComplete(){B&&s.context.onOpenChangeComplete?.(!0)}});let I=void 0===q?(0,m.H)(s.context.popupRef):q,J=s.useStateSetter("popupElement"),K=(0,e.f)("div",a,{state:{open:B,nested:z,transitionStatus:E,nestedDialogOpen:A>0},props:[w,{id:H,"aria-labelledby":D??void 0,"aria-describedby":t??void 0,role:F,...m.X,hidden:!y,onKeyDown(a){l.f.has(a.key)&&a.stopPropagation()},style:{[h.f.nestedDialogs]:A}},r],ref:[b,s.context.popupRef,J],stateAttributesMapping:o});return(0,n.jsx)(c.f,{context:v,openInteractionType:C,disabled:!y,closeOnFocusOut:!u,initialFocus:I,returnFocus:p,modal:!1!==x,restoreFocus:"popup",children:K})});a.s(["f",0,p])},46164,15221,86070,a=>{let b=((c={}).nestedDialogs="--nested-dialogs",c);a.s(["f",0,b],46164);var c,d,e=a.i(75633);let f=((d={})[d.open=e.q.open]="open",d[d.closed=e.q.closed]="closed",d[d.startingStyle=e.q.startingStyle]="startingStyle",d[d.endingStyle=e.q.endingStyle]="endingStyle",d.nested="data-nested",d.nestedDialogOpen="data-nested-dialog-open",d);a.s(["f",0,f],15221);var g=a.i(54662),h=a.i(72131);let i=h.createContext(void 0);a.s(["_",0,i,"Z",0,function(){let a=h.useContext(i);if(void 0===a)throw Error((0,g.f)(26));return a}],86070)},91034,a=>{var b=a.i(72131),c=a.i(54125),d=a.i(54098),e=a.i(23689),f=a.i(86070),g=a.i(30076),h=a.i(87924);let i=b.forwardRef(function(a,b){let{keepMounted:i=!1,...j}=a,{store:k}=(0,e.x)(),l=k.useState("mounted"),m=k.useState("modal"),n=k.useState("open");return l||i?(0,h.jsx)(f._.Provider,{value:i,children:(0,h.jsxs)(d.r,{ref:b,...j,children:[l&&!0===m&&(0,h.jsx)(g.f,{ref:k.context.internalBackdropRef,inert:(0,c.f)(!n)}),a.children]})}):null});a.s(["f",0,i])},18836,73343,a=>{var b=a.i(72131),c=a.i(23689),d=a.i(28693),e=a.i(13259),f=a.i(24715),g=a.i(38939),h=a.i(40014),i=a.i(94552),j=a.i(47462),k=a.i(84204);function l({store:a,parentContext:c,isDrawer:d}){let i=a.useState("open"),j=a.useState("disablePointerDismissal"),m=a.useState("modal"),n=a.useState("popupElement"),o=a.useState("floatingRootContext"),[p,q]=b.useState(0),[r,s]=b.useState(0),t=0===p,u=(0,g.f)(o,{outsidePressEvent:()=>a.context.internalBackdropRef.current||a.context.backdropRef.current?"intentional":{mouse:"trap-focus"===m?"sloppy":"intentional",touch:"sloppy"},outsidePress(b){if(!a.context.outsidePressEnabledRef.current||"button"in b&&0!==b.button||"touches"in b&&1!==b.touches.length)return!1;let c=(0,h.Z)(b);return!!t&&!j&&(!m||!a.context.internalBackdropRef.current&&!a.context.backdropRef.current||a.context.internalBackdropRef.current===c||a.context.backdropRef.current===c||(0,h.I)(c,n)&&!c?.hasAttribute("data-base-ui-portal"))},escapeKey:t});(0,e.f)(i&&!0===m,n),a.useContextCallback("onNestedDialogOpen",(a,b)=>{q(a),s(b)}),a.useContextCallback("onNestedDialogClose",()=>{q(0),s(0)}),b.useEffect(()=>(c?.onNestedDialogOpen&&i&&c.onNestedDialogOpen(p+1,r+ +!!d),c?.onNestedDialogClose&&!i&&c.onNestedDialogClose(),()=>{c?.onNestedDialogClose&&i&&c.onNestedDialogClose()}),[d,i,p,r,c]);let v=u.reference??f.w,w=u.trigger??f.w,x=u.floating??f.w;return(0,k.y)(a,{activeTriggerProps:v,inactiveTriggerProps:w,popupProps:x,nestedOpenDialogCount:p,nestedOpenDrawerCount:r}),null}var m=a.i(64074),n=a.i(17498),o=a.i(17017),p=a.i(51943);let q={...o.j,modal:(0,m.f)(a=>a.modal),nested:(0,m.f)(a=>a.nested),nestedOpenDialogCount:(0,m.f)(a=>a.nestedOpenDialogCount),nestedOpenDrawerCount:(0,m.f)(a=>a.nestedOpenDrawerCount),disablePointerDismissal:(0,m.f)(a=>a.disablePointerDismissal),openMethod:(0,m.f)(a=>a.openMethod),descriptionElementId:(0,m.f)(a=>a.descriptionElementId),titleElementId:(0,m.f)(a=>a.titleElementId),viewportElement:(0,m.f)(a=>a.viewportElement),role:(0,m.f)(a=>a.role)};class r extends n.f{constructor(a,c,d=!1){let e=new p.f,f=function(a={}){return{...(0,o.i)(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...a}}(a);f.floatingRootContext=(0,o.c)(e,c,d),super(f,{popupRef:b.createRef(),backdropRef:b.createRef(),internalBackdropRef:b.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0},q)}setOpen=(a,b)=>{if(b.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},a||null!=b.trigger||null==this.state.activeTriggerId||(b.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(a,b),b.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(a,b);let c={open:a};(0,k.s)(c,a,b.trigger),this.update(c)};static useStore(a,b){return(0,k.k)(a,(a,c)=>new r(b,a,c),!0).store}}var s=a.i(87924);a.s(["f",0,function(a){return function(a,e="dialog"){let{children:f,open:g,defaultOpen:h=!1,onOpenChange:m,onOpenChangeComplete:n,disablePointerDismissal:o=!1,modal:p=!0,actionsRef:q,handle:t,triggerId:u,defaultTriggerId:v=null}=a,w="alert-dialog"===e,x=(0,c.x)(!0),y={modal:!!w||p,disablePointerDismissal:w||o,nested:!!x,role:w?"alertdialog":"dialog"},z=r.useStore(t?.store,{open:h,openProp:g,activeTriggerId:v,triggerIdProp:u,...y});(0,d.f)(()=>{let a=void 0===g&&!1===z.state.open&&!0===h?{open:!0,activeTriggerId:v}:null;w?z.update(a?{...y,...a}:y):a&&z.update(a)}),z.useControlledProp("openProp",g),z.useControlledProp("triggerIdProp",u),z.useSyncedValues(y),z.useContextCallback("onOpenChange",m),z.useContextCallback("onOpenChangeComplete",n);let A=z.useState("open"),B=z.useState("mounted"),C=z.useState("payload");!function(a){let{store:c,actionsRef:d}=a,e=c.useState("open");(0,k.d)(c,e),(0,k.z)(c);let{forceUnmount:f}=(0,k.L)(e,c),g=b.useCallback(()=>{c.setOpen(!1,(0,i.f)(j.f.imperativeAction))},[c]);b.useImperativeHandle(d,()=>({unmount:f,close:g}),[f,g])}({store:z,actionsRef:q});let D=b.useMemo(()=>({store:z}),[z]);return(0,s.jsx)(c.S.Provider,{value:!1,children:(0,s.jsxs)(c.R.Provider,{value:D,children:[(A||B)&&(0,s.jsx)(l,{store:z,parentContext:x?.store.context,isDrawer:"drawer"===e}),"function"==typeof f?f({payload:C}):f]})})}(a,b.useContext(c.S)?"drawer":"dialog")}],18836);var t=a.i(26184),u=a.i(557);let v=b.forwardRef(function(a,b){let{render:d,className:e,style:f,id:g,...h}=a,{store:i}=(0,c.x)(),j=(0,u.f)(g);return i.useSyncedValueWithCleanup("titleElementId",j),(0,t.f)("h2",a,{ref:b,props:[{id:j},h]})});a.s(["f",0,v],73343)},50687,3889,a=>{var b=a.i(72131),c=a.i(26476),d=a.i(68536),e=a.i(43074),f=a.i(1811),g=a.i(89862),h=a.i(54401),i=a.i(57738),j=a.i(36069),k=a.i(48676),l=a.i(54184),m=a.i(87828),n=a.i(44530),o=a.i(61394),p=a.i(40014),q=a.i(61813),r=a.i(14209),s=a.i(56498),t=a.i(87084),u=a.i(96e3),v=a.i(94552),w=a.i(42955),x=a.i(33123),y=a.i(78064),z=a.i(80362),A=a.i(24715);let B=0;function C(a,b={}){let{preventScroll:c=!1,sync:d=!1,shouldFocus:e}=b;function f(){(!e||e())&&a?.focus({preventScroll:c})}if(cancelAnimationFrame(B),d)return f(),A.x;let g=requestAnimationFrame(f);return B=g,()=>{B===g&&(cancelAnimationFrame(g),B=0)}}a.s(["f",0,C],3889);let D={inert:new WeakMap,"aria-hidden":new WeakMap},E="data-base-ui-inert",F={inert:new WeakSet,"aria-hidden":new WeakSet},G=new WeakMap,H=0,I=(a,b)=>b.map(b=>{if(a.contains(b))return b;let d=function a(b){return b?(0,c.R)(b)?b.host:a(b.parentNode):null}(b);return a.contains(d)?d:null}).filter(a=>null!=a),J=a=>{let b=new Set;return a.forEach(a=>{let c=a;for(;c&&!b.has(c);)b.add(c),c=c.parentNode}),b},K=(a,b,d)=>{let e=[],f=a=>{!a||d.has(a)||Array.from(a.children).forEach(a=>{"script"!==(0,c.A)(a)&&(b.has(a)?f(a):e.push(a))})};return f(a),e};function L(a,b={}){let{ariaHidden:c=!1,inert:d=!1,mark:e=!0}=b,f=(0,m.f)(a[0]).body;return function(a,b,c,d,{mark:e=!0}){let f=null;d?f="inert":c&&(f="aria-hidden");let g=null,h=null,i=I(b,a),j=e?K(b,J(i),new Set(i)):[],k=[],l=[];if(f){let a=D[f],c=F[f];h=c,g=a;let d=I(b,Array.from(b.querySelectorAll("[aria-live]"))),e=i.concat(d);K(b,J(e),new Set(e)).forEach(b=>{let d=b.getAttribute(f),e=null!==d&&"false"!==d,g=(a.get(b)||0)+1;a.set(b,g),k.push(b),1===g&&e&&c.add(b),e||b.setAttribute(f,"inert"===f?"":"true")})}return e&&j.forEach(a=>{let b=(G.get(a)||0)+1;G.set(a,b),l.push(a),1===b&&a.setAttribute(E,"")}),H+=1,()=>{g&&k.forEach(a=>{let b=(g.get(a)||0)-1;g.set(a,b),b||(!h?.has(a)&&f&&a.removeAttribute(f),h?.delete(a))}),e&&l.forEach(a=>{let b=(G.get(a)||0)-1;G.set(a,b),b||a.removeAttribute(E)}),(H-=1)||(D.inert=new WeakMap,D["aria-hidden"]=new WeakMap,F.inert=new WeakSet,F["aria-hidden"]=new WeakSet,G=new WeakMap)}}(a,f,c,d,{mark:e})}var M=a.i(54098),N=a.i(25123),O=a.i(82204),P=a.i(80326),Q=a.i(87924);let R=[];function S(){R=R.filter(a=>a.deref()?.isConnected)}function T(a){S(),a&&"body"!==(0,c.A)(a)&&(R.push(new WeakRef(a)),R.length>20&&(R=R.slice(-20)))}function U(){return S(),R[R.length-1]?.deref()}function V(a){if(a.hasAttribute("tabindex")&&!a.hasAttribute("data-tabindex")||!a.getAttribute("role")?.includes("dialog"))return;let b=(0,s.J)(a).filter(a=>{let b=a.getAttribute("data-tabindex")||"";return(0,s.m)(a)||a.hasAttribute("data-tabindex")&&!b.startsWith("-")}),c=a.getAttribute("tabindex");0===b.length?"0"!==c&&(a.setAttribute("tabindex","0"),a.setAttribute("data-tabindex","0")):("-1"!==c||a.hasAttribute("data-tabindex")&&"-1"!==a.getAttribute("data-tabindex"))&&(a.setAttribute("tabindex","-1"),a.setAttribute("data-tabindex","-1"))}a.s(["f",0,function(a){let{context:A,children:B,disabled:D=!1,initialFocus:E=!0,returnFocus:F=!0,restoreFocus:G=!1,modal:H=!0,closeOnFocusOut:I=!0,openInteractionType:J="",nextFocusableElement:K,previousFocusableElement:R,beforeContentFocusGuardRef:W,externalTree:X,getInsideElements:Y}=a,Z="rootStore"in A?A.rootStore:A,$=Z.useState("open"),_=Z.useState("domReferenceElement"),aa=Z.useState("floatingElement"),{events:ab,dataRef:ac}=Z.context,ad=(0,h.f)(()=>ac.current.floatingContext?.nodeId),ae=(0,q.J)(_)&&!1===E,af=(0,g.f)(E),ag=(0,g.f)(F),ah=(0,g.f)(J),ai=(0,g.f)($),aj=(0,N.$)(X),ak=(0,M.M)(),al=b.useRef(!1),am=b.useRef(!1),an=b.useRef(!1),ao=b.useRef(null),ap=b.useRef(""),aq=b.useRef(""),ar=b.useRef(null),as=b.useRef(null),at=(0,f.A)(ar,W,ak?.beforeInsideRef),au=(0,f.A)(as,ak?.afterInsideRef),av=(0,j.e)(),aw=(0,j.e)(),ax=(0,l.z)(),ay=null!=ak,az=(0,q.G)(aa),aA=(0,h.f)((a=az)=>a?(0,s.T)(a):[]),aB=(0,h.f)(()=>Y?.().filter(a=>null!=a)??[]);b.useEffect(()=>{if(D||!H)return;let a=(0,m.f)(az);return(0,d.f)(a,"keydown",function(a){"Tab"===a.key&&(0,p.I)(az,(0,p.T)((0,m.f)(az)))&&0===aA().length&&!ae&&(0,r.Y)(a)})},[D,az,H,ae,aA]),b.useEffect(()=>{if(D||!$)return;let a=(0,m.f)(az);function b(){an.current=!1}return(0,e.f)((0,d.f)(a,"pointerdown",function(a){let b=(0,p.Z)(a),c=aB();an.current=!((0,p.I)(aa,b)||(0,p.I)(_,b)||(0,p.I)(ak?.portalNode,b)||c.some(a=>a===b||(0,p.I)(a,b))),aq.current=a.pointerType||"keyboard",b?.closest(`[${O.j}]`)&&(am.current=!0,aw.start(0,()=>{am.current=!1}))},!0),(0,d.f)(a,"pointerup",b,!0),(0,d.f)(a,"pointercancel",b,!0),(0,d.f)(a,"keydown",function(){aq.current="keyboard"},!0),b)},[D,aa,_,az,$,ak,aw,aB]),b.useEffect(()=>{if(D||!I)return;let a=(0,m.f)(az);function b(b){let d=b.relatedTarget,e=b.currentTarget,f=(0,p.Z)(b);H&&null==d&&null!=f&&(0,p.I)(aa,f)&&T(f),queueMicrotask(()=>{let g=ad(),h=Z.context.triggerElements,i=aB(),j=d?.hasAttribute((0,z.f)("focus-guard"))&&[ar.current,as.current,ak?.beforeInsideRef.current,ak?.afterInsideRef.current,ak?.beforeOutsideRef.current,ak?.afterOutsideRef.current,(0,P.f)(R),(0,P.f)(K)].includes(d),k=!((0,p.I)(_,d)||(0,p.I)(aa,d)||(0,p.I)(d,aa)||(0,p.I)(ak?.portalNode,d)||i.some(a=>a===d||(0,p.I)(a,d))||null!=d&&h.hasElement(d)||h.hasMatchingElement(a=>(0,p.I)(a,d))||j||aj&&((0,t.Q)(aj.nodesRef.current,g).find(a=>(0,p.I)(a.context?.elements.floating,d)||(0,p.I)(a.context?.elements.domReference,d))||(0,t.V)(aj.nodesRef.current,g).find(a=>[a.context?.elements.floating,(0,q.G)(a.context?.elements.floating)].includes(d)||a.context?.elements.domReference===d)));if(e===_&&az&&V(az),G&&e!==_&&!(0,u.v)(f)&&(0,p.T)(a)===a.body){if((0,c.E)(az)&&(az.focus(),"popup"===G))return void ax.request(()=>{az.focus()});let a=aA(),b=ao.current,d=(b&&a.includes(b)?b:null)||a[a.length-1]||az;(0,c.E)(d)&&d.focus()}if(ac.current.insideReactTree){ac.current.insideReactTree=!1;return}(ae||!H)&&d&&k&&!am.current&&(ae||d!==U())&&(al.current=!0,Z.setOpen(!1,(0,v.f)(w.f.focusOut,b)))})}let f=(0,c.E)(_)?_:null;if(aa||f)return(0,e.f)(f&&(0,d.f)(f,"focusout",b),f&&(0,d.f)(f,"pointerdown",function(){am.current=!0,aw.start(0,()=>{am.current=!1})}),aa&&(0,d.f)(aa,"focusin",function(a){let b=(0,p.Z)(a);(0,s.m)(b)&&(ao.current=b)}),aa&&(0,d.f)(aa,"focusout",b),aa&&ak&&(0,d.f)(aa,"focusout",function(){an.current||(ac.current.insideReactTree=!0,av.start(0,()=>{ac.current.insideReactTree=!1}))},!0))},[D,_,aa,az,H,aj,ak,Z,I,G,aA,ae,ad,ac,av,aw,ax,K,R,aB]),b.useEffect(()=>{if(D||!aa||!$)return;let a=Array.from(ak?.portalNode?.querySelectorAll(`[${(0,z.f)("portal")}]`)||[]),b=aj?(0,t.V)(aj.nodesRef.current,ad()):[],c=b.find(a=>(0,q.J)(a.context?.elements.domReference||null))?.context?.elements.domReference,d=L([aa,...a,ar.current,as.current,ak?.beforeOutsideRef.current,ak?.afterOutsideRef.current,...aB(),c,(0,P.f)(R),(0,P.f)(K),ae?_:null].filter(a=>null!=a),{ariaHidden:H||ae,mark:!1}),e=L([aa,...a].filter(a=>null!=a));return()=>{e(),d()}},[$,D,_,aa,H,ak,ae,aj,ad,K,R,aB]),(0,i.f)(()=>{if(!$||D||!(0,c.E)(az))return;let a=(0,m.f)(az),b=(0,p.T)(a);queueMicrotask(()=>{let c,d=af.current,e="function"==typeof d?d(ah.current||""):d;if(void 0===e||!1===e||(0,p.I)(az,b))return;let f=null,g=()=>(null==f&&(f=aA(az)),f[0]||az);c=(c=!0===e||null===e?g():(0,P.f)(e))||g();let h=(0,p.I)(az,(0,p.T)(a));C(c,{preventScroll:c===az,shouldFocus(){if(!ai.current)return!1;if(h)return!0;let b=(0,p.T)(a);return!(b!==c&&(0,p.I)(az,b))}})})},[D,$,az,aA,af,ah,ai]),(0,i.f)(()=>{if(D||!az)return;let a=(0,m.f)(az),b=(0,p.T)(a),d=null==ah.current;function e(a){var b,c;let d;if(a.open||(b=a.nativeEvent,c=aq.current,d=(0,n.f)((0,p.Z)(b)),ap.current=b instanceof d.KeyboardEvent?"keyboard":b instanceof d.FocusEvent?c||"keyboard":"pointerType"in b?b.pointerType||"keyboard":"touches"in b?"touch":b instanceof d.MouseEvent?c||(0===b.detail?"keyboard":"mouse"):""),a.reason===x.f.triggerHover&&"mouseleave"===a.nativeEvent.type&&(al.current=!0),a.reason===y.f.outsidePress)if(a.nested)al.current=!1;else if((0,r.E)(a.nativeEvent)||(0,r.$)(a.nativeEvent))al.current=!1;else{let a=!1;(0,m.f)(az).createElement("div").focus({get preventScroll(){return a=!0,!1}}),a?al.current=!1:al.current=!0}}return T(b),ab.on("openchange",e),()=>{ab.off("openchange",e);let f=(0,p.T)(a),g=aB(),h=(0,p.I)(aa,f)||g.some(a=>a===f||(0,p.I)(a,f))||aj&&(0,t.Q)(aj.nodesRef.current,ad(),!1).some(a=>(0,p.I)(a.context?.elements.floating,f)),i=ag.current,j=function(){let a=ag.current,e="function"==typeof a?a(ap.current):a;if(void 0===e||!1===e)return null;null===e&&(e=!0);let f=_?.isConnected?_:null,g=b?.isConnected&&"body"!==(0,c.A)(b)?b:null,h=d?g||f:f||g;return(h||(h=U()||null),"boolean"==typeof e)?h:(0,P.f)(e)||h||null}();queueMicrotask(()=>{let b=j?(0,s.m)(j)?j:(0,s.T)(j)[0]||j:null;i&&!al.current&&(0,c.E)(b)&&("boolean"!=typeof i||b===f||f===a.body||h)&&b.focus({preventScroll:!0}),al.current=!1})}},[D,aa,az,ag,ah,ab,aj,_,ad,aB]),(0,i.f)(()=>{if(!k.f.engine.webkit||$||!aa)return;let a=(0,p.T)((0,m.f)(aa));(0,c.E)(a)&&(0,q.Q)(a)&&(0,p.I)(aa,a)&&a.blur()},[$,aa]),(0,i.f)(()=>{if(!D&&ak)return ak.setFocusManagerState({modal:H,closeOnFocusOut:I,open:$,onOpenChange:Z.setOpen,domReference:_}),()=>{ak.setFocusManagerState(null)}},[D,ak,H,$,Z,I,_]),(0,i.f)(()=>{if(!D&&az)return V(az),()=>{queueMicrotask(S)}},[D,az]);let aC=!D&&(!H||!ae)&&(ay||H);return(0,Q.jsxs)(b.Fragment,{children:[aC&&(0,Q.jsx)(o.f,{"data-type":"inside",ref:at,onFocus:a=>{if(H){let a=aA();C(a[a.length-1])}else if(ak?.portalNode)if(al.current=!1,(0,s.A)(a,ak.portalNode)){let a=(0,s.O)(_);a?.focus()}else(0,P.f)(R??ak.beforeOutsideRef)?.focus()}}),B,aC&&(0,Q.jsx)(o.f,{"data-type":"inside",ref:au,onFocus:a=>{if(H)C(aA()[0]);else if(ak?.portalNode)if(I&&(al.current=!0),(0,s.A)(a,ak.portalNode)){let a=(0,s.B)(_);a?.focus()}else(0,P.f)(K??ak.afterOutsideRef)?.focus()}})]})}],50687)},31973,a=>{var b=a.i(72131),c=a.i(54184),d=a.i(36069),e=a.i(24715),f=a.i(40014),g=a.i(61813),h=a.i(14209),i=a.i(94552),j=a.i(39802);a.s(["f",0,function(a,k={}){let{enabled:l=!0,event:m="click",toggle:n=!0,ignoreMouse:o=!1,stickIfOpen:p=!0,touchOpenDelay:q=0,reason:r=j.f.triggerPress}=k,s="rootStore"in a?a.rootStore:a,t=s.context.dataRef,u=b.useRef(void 0),v=(0,c.z)(),w=(0,d.e)(),x=b.useMemo(()=>{function a(a,b,c,d){let e=(0,i.f)(r,b,c);a&&"touch"===d&&q>0?w.start(q,()=>{s.setOpen(!0,e)}):s.setOpen(a,e)}function b(a,b,c){let d=t.current.openEvent,e=s.select("domReferenceElement")!==b;return!!a&&!!e||!a||!n||!!d&&!!p&&!c(d.type)}return{onPointerDown(a){u.current=a.pointerType},onMouseDown(c){let d=u.current,e=c.nativeEvent,i=s.select("open");if(0!==c.button||"click"===m||(0,h.J)(d,!0)&&o)return;let j=b(i,c.currentTarget,a=>"click"===a||"mousedown"===a),k=(0,f.Z)(e);if((0,g.Q)(k))return void a(j,e,k,d);let l=c.currentTarget;v.request(()=>{a(j,e,l,d)})},onClick(c){if("mousedown-only"===m)return;let d=u.current;if("mousedown"===m&&d){u.current=void 0;return}(0,h.J)(d,!0)&&o||a(b(s.select("open"),c.currentTarget,a=>"click"===a||"mousedown"===a||"keydown"===a||"keyup"===a),c.nativeEvent,c.currentTarget,d)},onKeyDown(){u.current=void 0}}},[t,m,o,r,s,p,n,v,w,q]);return b.useMemo(()=>l?{reference:x}:e.w,[l,x])}])},69649,a=>{let b=new Set([...new Set([...new Set(["ArrowLeft","ArrowRight"]),...new Set(["ArrowUp","ArrowDown"])]),"Home","End"]);a.s(["f",0,b])},21436,59539,a=>{var b=a.i(72131),c=a.i(26476),d=a.i(54401),e=a.i(57738),f=a.i(76459),g=a.i(54662);let h=b.createContext(void 0);function i(a=!1){let c=b.useContext(h);if(void 0===c&&!a)throw Error((0,g.f)(16));return c}function j(a){return(0,c.E)(a)&&"BUTTON"===a.tagName}a.s(["f",0,i],59539),a.s(["f",0,function(a={}){let{disabled:c=!1,focusableWhenDisabled:g,tabIndex:h=0,native:k=!0,composite:l}=a,m=b.useRef(null),n=i(!0),o=l??void 0!==n,{props:p}=function(a){let{focusableWhenDisabled:c,disabled:d,composite:e=!1,tabIndex:f=0,isNativeButton:g}=a,h=e&&!1!==c,i=e&&!1===c;return{props:b.useMemo(()=>{let a={onKeyDown(a){d&&c&&"Tab"!==a.key&&a.preventDefault()}};return e||(a.tabIndex=f,!g&&d&&(a.tabIndex=c?f:-1)),(g&&(c||h)||!g&&d)&&(a["aria-disabled"]=d),g&&(!c||i)&&(a.disabled=d),a},[e,d,c,h,i,g,f])}}({focusableWhenDisabled:g,disabled:c,composite:o,tabIndex:h,isNativeButton:k}),q=b.useCallback(()=>{let a=m.current;j(a)&&o&&c&&void 0===p.disabled&&a.disabled&&(a.disabled=!1)},[c,p.disabled,o]);return(0,e.f)(q,[q]),{getButtonProps:b.useCallback((a={})=>{let{onClick:b,onMouseDown:d,onKeyUp:e,onKeyDown:g,onPointerDown:h,...i}=a;return(0,f.w)({onClick(a){c?a.preventDefault():b?.(a)},onMouseDown(a){c||d?.(a)},onKeyDown(a){var d;if(c||((0,f.U)(a),g?.(a),a.baseUIHandlerPrevented))return;let e=a.target===a.currentTarget,h=a.currentTarget,i=j(h),l=!k&&(d=h,!!(d?.tagName==="A"&&d?.href)),m=e&&(k?i:!l),n="Enter"===a.key,p=" "===a.key,q=h.getAttribute("role"),r=q?.startsWith("menuitem")||"option"===q||"gridcell"===q;if(e&&o&&p){if(a.defaultPrevented&&r)return;a.preventDefault(),l||k&&i?(h.click(),a.preventBaseUIHandler()):m&&(b?.(a),a.preventBaseUIHandler());return}m&&(!k&&(p||n)&&a.preventDefault(),!k&&n&&b?.(a))},onKeyUp(a){c||(((0,f.U)(a),e?.(a),a.target===a.currentTarget&&k&&o&&j(a.currentTarget)&&" "===a.key)?a.preventDefault():!a.baseUIHandlerPrevented&&(a.target!==a.currentTarget||k||o||" "!==a.key||b?.(a)))},onPointerDown(a){c?a.preventDefault():h?.(a)}},k?{type:"button"}:{role:"button"},p,i)},[c,p,o,k]),buttonRef:(0,d.f)(a=>{m.current=a,q()})}}],21436)},29752,a=>{var b=a.i(72131),c=a.i(54401),d=a.i(61475),e=a.i(57738);function f(a,e){var f;let g,h,{onClick:i,onPointerDown:j}=(f=(0,c.f)((b,c)=>{("function"==typeof a?a():a)||e(c||(d.f.os.ios?"touch":""))}),g=b.useRef(""),h=b.useCallback(a=>{a.defaultPrevented||(g.current=a.pointerType,f(a,a.pointerType))},[f]),{onClick:b.useCallback(a=>{0===a.detail?f(a,"keyboard"):("pointerType"in a?f(a,a.pointerType):f(a,g.current),g.current="")},[f]),onPointerDown:h});return b.useMemo(()=>({onClick:i,onPointerDown:j}),[i,j])}a.s(["$",0,function(a){var d;let g,h,[i,j]=b.useState(null),k=f(a,j);return d=b=>{b&&!a&&j(null)},g=b.useRef(a),h=(0,c.f)(d),(0,e.f)(()=>{g.current!==a&&h(g.current)},[a,h]),(0,e.f)(()=>{g.current=a},[a]),b.useMemo(()=>({openMethod:i,triggerProps:k}),[i,k])},"p",0,f],29752)},54125,30076,a=>{var b=a.i(59930);a.s(["f",0,function(a){return(0,b.f)(19)?a:a?"true":void 0}],54125);var c=a.i(72131),d=a.i(87924);let e=c.forwardRef(function(a,b){let c,{cutout:e,...f}=a;if(e){let a=e.getBoundingClientRect();c=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${a.left}px ${a.top}px,${a.left}px ${a.bottom}px,${a.right}px ${a.bottom}px,${a.right}px ${a.top}px,${a.left}px ${a.top}px)`}return(0,d.jsx)("div",{ref:b,role:"presentation","data-base-ui-inert":"",...f,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:c}})});a.s(["f",0,e],30076)},13259,a=>{var b=a.i(26476),c=a.i(68536),d=a.i(48676),e=a.i(61475),f=a.i(87828),g=a.i(44530),h=a.i(57738),i=a.i(36069),j=a.i(54184),k=a.i(24715);let l={},m={},n="",o=new class{lockCount=0;restore=null;timeoutLock=i.U.create();timeoutUnlock=i.U.create();acquire(a){return this.lockCount+=1,1===this.lockCount&&null===this.restore&&this.timeoutLock.start(0,()=>this.lock(a)),this.release}release=()=>{this.lockCount-=1,0===this.lockCount&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{0===this.lockCount&&this.restore&&(this.restore?.(),this.restore=null)};lock(a){let h,i,o,p,q;if(0===this.lockCount||null!==this.restore)return;let r=(0,f.f)(a).documentElement,s=(0,g.f)(r).getComputedStyle(r).overflowY;if("hidden"===s||"clip"===s){this.restore=k.x;return}let t=e.f.os.ios||!function(a){if("u"<typeof document)return!1;let b=(0,f.f)(a);return(0,g.f)(b).innerWidth-b.documentElement.clientWidth>0}(a);this.restore=t?(i=(h=(0,f.f)(a)).documentElement,o=h.body,q={overflowY:(p=(0,b.B)(i)?i:o).style.overflowY,overflowX:p.style.overflowX},Object.assign(p.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(p.style,q)}):function(a){let e=(0,f.f)(a),h=e.documentElement,i=e.body,k=(0,g.f)(h),o=0,p=0,q=!1,r=j.$.create();if(d.f.engine.webkit&&(k.visualViewport?.scale??1)!==1)return()=>{};function s(){let c=k.getComputedStyle(h),d=k.getComputedStyle(i),e=(c.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=h.scrollTop,p=h.scrollLeft,l={scrollbarGutter:h.style.scrollbarGutter,overflowY:h.style.overflowY,overflowX:h.style.overflowX},n=h.style.scrollBehavior,m={position:i.style.position,height:i.style.height,width:i.style.width,boxSizing:i.style.boxSizing,overflowY:i.style.overflowY,overflowX:i.style.overflowX,scrollBehavior:i.style.scrollBehavior};let g=h.scrollHeight>h.clientHeight,j=h.scrollWidth>h.clientWidth,r="scroll"===c.overflowY||"scroll"===d.overflowY,s="scroll"===c.overflowX||"scroll"===d.overflowX,t=Math.max(0,k.innerWidth-i.clientWidth),u=Math.max(0,k.innerHeight-i.clientHeight),v=parseFloat(d.marginTop)+parseFloat(d.marginBottom),w=parseFloat(d.marginLeft)+parseFloat(d.marginRight),x=(0,b.B)(h)?h:i;if(q=function(a){if(!("u">typeof CSS&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||"u"<typeof document)return!1;let c=(0,f.f)(a),d=c.documentElement,e=c.body,g=(0,b.B)(d)?d:e,h=g.style.overflowY,i=d.style.scrollbarGutter;d.style.scrollbarGutter="stable",g.style.overflowY="scroll";let j=g.offsetWidth;g.style.overflowY="hidden";let k=g.offsetWidth;return g.style.overflowY=h,d.style.scrollbarGutter=i,j===k}(a)){h.style.scrollbarGutter=e,x.style.overflowY="hidden",x.style.overflowX="hidden";return}Object.assign(h.style,{scrollbarGutter:e,overflowY:"hidden",overflowX:"hidden"}),(g||r)&&(h.style.overflowY="scroll"),(j||s)&&(h.style.overflowX="scroll"),Object.assign(i.style,{position:"relative",height:v||u?`calc(100dvh - ${v+u}px)`:"100dvh",width:w||t?`calc(100vw - ${w+t}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),i.scrollTop=o,i.scrollLeft=p,h.setAttribute("data-base-ui-scroll-locked",""),h.style.scrollBehavior="unset"}function t(){Object.assign(h.style,l),Object.assign(i.style,m),q||(h.scrollTop=o,h.scrollLeft=p,h.removeAttribute("data-base-ui-scroll-locked"),h.style.scrollBehavior=n)}s();let u=(0,c.f)(k,"resize",function(){t(),r.request(s)});return()=>{r.cancel(),t(),"function"==typeof k.removeEventListener&&u()}}(a)}};a.s(["f",0,function(a=!0,b=null){(0,h.f)(()=>{if(a)return o.acquire(b)},[a,b])}])},52562,2589,a=>{let b=(0,a.i(64831).f)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);a.s(["f",0,b],2589),a.s(["f",0,b],52562)},75160,a=>{var b=a.i(2918);a.s(["f",()=>b.f])},3512,a=>{let b=(0,a.i(64831).f)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);a.s(["f",0,b],3512)},90702,23689,12765,a=>{var b=a.i(23577);a.s(["f",()=>b.f],90702);var c=a.i(72131),d=a.i(54662);let e=c.createContext(!1),f=c.createContext(void 0);function g(a){let b=c.useContext(f);if(!1===a&&void 0===b)throw Error((0,d.f)(27));return b}a.s(["R",0,f,"S",0,e,"x",0,g],23689);var h=a.i(26184),i=a.i(75633),j=a.i(81735);let k={...i.E,...j.T},l=c.forwardRef(function(a,b){let{render:c,className:d,style:e,forceRender:f=!1,...i}=a,{store:j}=g(),l=j.useState("open"),m=j.useState("nested"),n=j.useState("mounted"),o=j.useState("transitionStatus");return(0,h.f)("div",a,{state:{open:l,transitionStatus:o},ref:[j.context.backdropRef,b],stateAttributesMapping:k,props:[{role:"presentation",hidden:!n,style:{userSelect:"none",WebkitUserSelect:"none"}},i],enabled:f||!m})});a.s(["f",0,l],12765)}]})();
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=_1obdc2e416ry-._.js.map
|