// bootstrap-selective.mjs — Phase D1 helper, collapsed to a wildcard in
// Phase E5 (ATOMIC SERVING CUTOVER).
//
// Determines whether a SPA shell render path should SKIP the host-cp
// BOOTSTRAP_SCRIPT injection (cookie-bootstrap + fetch/EventSource
// rewrite shim) and instead let the served SPA's own auth resolver +
// world-fetch shim handle auth.
//
// Phase E5: plan-chat-spa is now host-cp's SOLE served SPA. Its bundle
// re-homes the cookie-bootstrap + world-fetch-rewrite + 401-recover shim
// (packages/plan-chat-spa/src/lib/worldFetch.ts, installed at the top of
// src/main.tsx — Phase C). Therefore host-cp NEVER needs to inject
// BOOTSTRAP_SCRIPT anymore: every path is a "planning" (== SPA-owned)
// path. isPlanningPath() is collapsed to a wildcard accordingly.
//
// Reversal: set isPlanningPath to consult BOOTSTRAP_NOOP_PLANNING_PATHS
// again (restore the prefix-match body below) to re-narrow the no-op to
// the explicit planning prefixes; or, for full pre-D behaviour, also set
// BOOTSTRAP_NOOP_PLANNING_PATHS to []. The const is retained as the
// documented revert seam.
//
// Per K1 SCP-3 + phase-d-tasks.md D1 + phase-e-tasks.md E2.

/**
 * Path prefixes that WERE owned by plan-chat-spa under the Phase D
 * selective no-op. Retained as the documented single-line revert seam:
 * to re-narrow the bootstrap no-op back to only the planning surfaces,
 * restore the prefix-match body in isPlanningPath() (see git history of
 * this file at the Phase E5 commit) so it consults this array again.
 *
 * Format: include both the bare segment ("/plan") and the trailing-slash
 * variant ("/plan/"). The trailing-slash form is the prefix-match
 * generator for "/plan/<rest>".
 *
 * @type {readonly string[]}
 */
export const BOOTSTRAP_NOOP_PLANNING_PATHS = Object.freeze([
  '/plan',
  '/plan/',
]);

/**
 * Phase E5 wildcard: TRUE for every string path.
 *
 * host-cp now serves plan-chat-spa exclusively, whose bundle re-homes the
 * cookie-bootstrap + world-fetch-rewrite shim (worldFetch.ts). No served
 * path needs host-cp's BOOTSTRAP_SCRIPT injection anymore, so every path
 * is treated as an SPA-owned ("planning") path and skips bootstrap.
 *
 * Returns false only for non-string input (defensive — a non-string
 * pathname is never a real served path).
 *
 * @param {unknown} pathname
 * @returns {boolean}
 */
export function isPlanningPath(pathname) {
  return typeof pathname === 'string';
}
