{"version":3,"sources":["../src/dev-true.ts","../src/index.ts"],"names":["dev_true_default","directiveContext","DirectiveController","host","system","DerivedController","key","result","id","FactController","factKey","InspectController","options","computeInspectState","update","throttled","cleanup","createThrottle","RequirementStatusController","statusPlugin","type","DirectiveSelectorController","selector","equalityFn","defaultEquality","initial","runTrackedSelector","unsub","onUpdate","depsChanged","WatchController","callback","ExplainController","requirementId","ConstraintStatusController","constraintId","inspection","c","OptimisticUpdateController","requirementType","updateFn","status","SystemController","createSystem","err","ModuleController","moduleDef","config","allPlugins","sp","createRequirementStatusPlugin","derivationKeys","getDerived","event","createDerived","createFact","createInspect","createRequirementStatus","createWatch","derivationId","createDirectiveSelector","createExplain","createConstraintStatus","createOptimisticUpdate","createModuleController","createModule","useDispatch","assertSystem","useEvents","HistoryController","_host","_system","buildHistoryState","getHistory","useHistory","getFact","createTypedHooks","NamespacedSelectorController","keys","createNamespacedSelector","QuerySystemController","factory","HydrationController","snapshot","mergedFacts","mergeHydrationFacts","AuditLedgerController","ledger","filter","opts","requestedPollMs","entryCount","next","moved"],"mappings":"+GAAA,IAAOA,CAAAA,CAAQ,OAAO,OAAA,CAAY,GAAA,EAChC,QAAQ,GAAA,EAAK,QAAA,GAAa,YAAA,CCoErB,IAAMC,CAAAA,CAAmB,MAAA,CAAO,WAAW,CAAA,CASnCC,CAAAA,CAAf,KAAiE,CACrD,IAAA,CACA,MAAA,CACA,WAAA,CAEV,WAAA,CAAYC,CAAAA,CAA8BC,EAAiC,CACzE,IAAA,CAAK,IAAA,CAAOD,CAAAA,CACZ,IAAA,CAAK,MAAA,CAASC,CAAAA,CACdD,CAAAA,CAAK,cAAc,IAAI,EACzB,CAEA,aAAA,EAAsB,CACpB,IAAA,CAAK,SAAA,GACP,CAEA,gBAAA,EAAyB,CACvB,IAAA,CAAK,WAAA,IAAc,CACnB,IAAA,CAAK,WAAA,CAAc,OACrB,CAIU,aAAA,EAAsB,CAC9B,IAAA,CAAK,IAAA,CAAK,aAAA,GACZ,CACF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env?.NODE_ENV !== \"production\";\n","/**\n * Lit Adapter - Consolidated Web Components integration for Directive\n *\n * Controllers: DerivedController, FactController,\n * InspectController (with throttle), RequirementStatusController,\n * DirectiveSelectorController,\n * WatchController (with fact mode), SystemController,\n * ExplainController, ConstraintStatusController, OptimisticUpdateController, ModuleController\n *\n * Factories: createDerived, createFact, createInspect,\n * createRequirementStatus, createWatch,\n * createDirectiveSelector, useDispatch, useEvents, useHistory,\n * getDerived, getFact, createTypedHooks, shallowEqual\n */\n\nimport type {\n  CreateSystemOptionsSingle,\n  ErrorBoundaryConfig,\n  HistoryState,\n  InferDerivations,\n  InferEvents,\n  InferFacts,\n  InferSelectorState,\n  ModuleDef,\n  ModuleSchema,\n  ModulesMap,\n  NamespacedSystem,\n  Plugin,\n  SingleModuleSystem,\n  SystemSnapshot,\n  TraceOption,\n} from \"@directive-run/core\";\nimport {\n  createRequirementStatusPlugin,\n  createSystem,\n} from \"@directive-run/core\";\nimport type { RequirementTypeStatus } from \"@directive-run/core\";\nimport {\n  type ConstraintInfo,\n  type InspectState,\n  type TrackedSelectorResult,\n  assertSystem,\n  buildHistoryState,\n  computeInspectState,\n  createThrottle,\n  defaultEquality,\n  depsChanged,\n  mergeHydrationFacts,\n  runTrackedSelector,\n  shallowEqual,\n} from \"@directive-run/core/adapter-utils\";\nimport type { ReactiveController, ReactiveControllerHost } from \"lit\";\nimport isDevelopment from \"#is-development\";\n\n// Re-export for convenience\nexport type { RequirementTypeStatus, InspectState, ConstraintInfo };\nexport { shallowEqual };\n\n/** Type for the requirement status plugin return value */\nexport type StatusPlugin = ReturnType<typeof createRequirementStatusPlugin>;\n\n// ============================================================================\n// Context\n// ============================================================================\n\n/**\n * Context key for Directive system.\n * Use with @lit/context for dependency injection across shadow DOM boundaries.\n */\nexport const directiveContext = Symbol(\"directive\");\n\n// ============================================================================\n// Base Controller\n// ============================================================================\n\n/**\n * Base controller that manages system subscription lifecycle.\n */\nabstract class DirectiveController implements ReactiveController {\n  protected host: ReactiveControllerHost;\n  protected system: SingleModuleSystem<any>;\n  protected unsubscribe?: () => void;\n\n  constructor(host: ReactiveControllerHost, system: SingleModuleSystem<any>) {\n    this.host = host;\n    this.system = system;\n    host.addController(this);\n  }\n\n  hostConnected(): void {\n    this.subscribe();\n  }\n\n  hostDisconnected(): void {\n    this.unsubscribe?.();\n    this.unsubscribe = undefined;\n  }\n\n  protected abstract subscribe(): void;\n\n  protected requestUpdate(): void {\n    this.host.requestUpdate();\n  }\n}\n\n// ============================================================================\n// Core Controllers\n// ============================================================================\n\n/**\n * Reactive controller for derivations.\n * Accepts a single key (string) or an array of keys (string[]).\n * - Single key: `.value` returns `T`\n * - Array of keys: `.value` returns `Record<string, unknown>`\n */\nexport class DerivedController<T> extends DirectiveController {\n  private keys: string[];\n  private isMulti: boolean;\n  value: T;\n\n  constructor(\n    host: ReactiveControllerHost,\n    system: SingleModuleSystem<any>,\n    key: string | string[],\n  ) {\n    super(host, system);\n    this.isMulti = Array.isArray(key);\n    this.keys = this.isMulti ? (key as string[]) : [key as string];\n    this.value = this.getValues();\n\n    if (isDevelopment) {\n      if (!this.isMulti && this.value === undefined) {\n        console.warn(\n          `[Directive] DerivedController(\"${this.keys[0]}\") returned undefined. ` +\n            `Check that \"${this.keys[0]}\" is defined in your module's derive property.`,\n        );\n      }\n    }\n  }\n\n  private getValues(): T {\n    if (this.isMulti) {\n      const result: Record<string, unknown> = {};\n      for (const id of this.keys) {\n        result[id] = this.system.read(id);\n      }\n      return result as T;\n    }\n    return this.system.read(this.keys[0]!) as T;\n  }\n\n  protected subscribe(): void {\n    this.value = this.getValues();\n    this.unsubscribe = this.system.subscribe(this.keys, () => {\n      this.value = this.getValues();\n      this.requestUpdate();\n    });\n  }\n}\n\n/**\n * Reactive controller for a single fact value.\n */\nexport class FactController<T> extends DirectiveController {\n  private factKey: string;\n  value: T | undefined;\n\n  constructor(\n    host: ReactiveControllerHost,\n    system: SingleModuleSystem<any>,\n    factKey: string,\n  ) {\n    super(host, system);\n    this.factKey = factKey;\n    this.value = system.facts.$store.get(factKey) as T | undefined;\n\n    if (isDevelopment) {\n      if (!system.facts.$store.has(factKey)) {\n        console.warn(\n          `[Directive] FactController(\"${factKey}\") — fact not found in store. ` +\n            `Check that \"${factKey}\" is defined in your module's schema.`,\n        );\n      }\n    }\n  }\n\n  protected subscribe(): void {\n    this.value = this.system.facts.$store.get(this.factKey) as T | undefined;\n    this.unsubscribe = this.system.facts.$store.subscribe(\n      [this.factKey],\n      () => {\n        this.value = this.system.facts.$store.get(this.factKey) as\n          | T\n          | undefined;\n        this.requestUpdate();\n      },\n    );\n  }\n}\n\n/**\n * Consolidated inspection controller.\n * Returns InspectState with optional throttling.\n */\nexport class InspectController extends DirectiveController {\n  value: InspectState;\n  private throttleMs: number;\n  private throttleCleanup?: () => void;\n  private unsubSettled?: () => void;\n\n  constructor(\n    host: ReactiveControllerHost,\n    system: SingleModuleSystem<any>,\n    options?: { throttleMs?: number },\n  ) {\n    super(host, system);\n    this.throttleMs = options?.throttleMs ?? 0;\n    this.value = computeInspectState(system);\n  }\n\n  protected subscribe(): void {\n    this.value = computeInspectState(this.system);\n\n    const update = () => {\n      this.value = computeInspectState(this.system);\n      this.requestUpdate();\n    };\n\n    if (this.throttleMs > 0) {\n      const { throttled, cleanup } = createThrottle(update, this.throttleMs);\n      this.throttleCleanup = cleanup;\n      this.unsubscribe = this.system.facts.$store.subscribeAll(throttled);\n      this.unsubSettled = this.system.onSettledChange(throttled);\n    } else {\n      this.unsubscribe = this.system.facts.$store.subscribeAll(update);\n      this.unsubSettled = this.system.onSettledChange(update);\n    }\n  }\n\n  hostDisconnected(): void {\n    this.throttleCleanup?.();\n    this.unsubSettled?.();\n    super.hostDisconnected();\n  }\n}\n\n/**\n * Reactive controller for requirement status.\n */\nexport class RequirementStatusController implements ReactiveController {\n  private host: ReactiveControllerHost;\n  private statusPlugin: StatusPlugin;\n  private type: string;\n  private unsubscribe?: () => void;\n  value: RequirementTypeStatus;\n\n  constructor(\n    host: ReactiveControllerHost,\n    statusPlugin: StatusPlugin,\n    type: string,\n  ) {\n    this.host = host;\n    this.statusPlugin = statusPlugin;\n    this.type = type;\n    this.value = statusPlugin.getStatus(type);\n    host.addController(this);\n  }\n\n  hostConnected(): void {\n    this.value = this.statusPlugin.getStatus(this.type);\n    this.unsubscribe = this.statusPlugin.subscribe(() => {\n      this.value = this.statusPlugin.getStatus(this.type);\n      this.host.requestUpdate();\n    });\n  }\n\n  hostDisconnected(): void {\n    this.unsubscribe?.();\n    this.unsubscribe = undefined;\n  }\n}\n\n// ============================================================================\n// Selector Controllers\n// ============================================================================\n\n/**\n * Reactive controller for selecting across all facts.\n * Uses `withTracking()` for auto-tracking when constructed with `autoTrack: true`.\n */\nexport class DirectiveSelectorController<\n  S extends ModuleSchema = ModuleSchema,\n  R = unknown,\n> extends DirectiveController {\n  private selector: (state: InferSelectorState<S>) => R;\n  private equalityFn: (a: R, b: R) => boolean;\n  private autoTrack: boolean;\n  private deriveKeySet: Set<string>;\n  private trackedFactKeys: string[] = [];\n  private trackedDeriveKeys: string[] = [];\n  private unsubs: Array<() => void> = [];\n  value: R;\n\n  constructor(\n    host: ReactiveControllerHost,\n    system: SingleModuleSystem<S>,\n    selector: (state: InferSelectorState<S>) => R,\n    equalityFn: (a: R, b: R) => boolean = defaultEquality,\n    options?: { autoTrack?: boolean },\n  ) {\n    super(host, system);\n    this.selector = selector;\n    this.equalityFn = equalityFn;\n    this.autoTrack = options?.autoTrack ?? true;\n    this.deriveKeySet = new Set(Object.keys(system.derive ?? {}));\n\n    const initial = this.runWithTracking();\n    this.value = initial.value;\n    this.trackedFactKeys = initial.factKeys;\n    this.trackedDeriveKeys = initial.deriveKeys;\n  }\n\n  private runWithTracking(): TrackedSelectorResult<R> {\n    return runTrackedSelector(\n      this.system,\n      this.deriveKeySet,\n      this.selector as (state: Record<string, unknown>) => R,\n    );\n  }\n\n  private resubscribe(): void {\n    for (const unsub of this.unsubs) unsub();\n    this.unsubs = [];\n\n    const onUpdate = () => {\n      const result = this.runWithTracking();\n      if (!this.equalityFn(this.value, result.value)) {\n        this.value = result.value;\n        this.requestUpdate();\n      }\n      if (this.autoTrack) {\n        // Re-track: check if deps changed\n        if (\n          depsChanged(\n            this.trackedFactKeys,\n            result.factKeys,\n            this.trackedDeriveKeys,\n            result.deriveKeys,\n          )\n        ) {\n          this.trackedFactKeys = result.factKeys;\n          this.trackedDeriveKeys = result.deriveKeys;\n          this.resubscribe();\n        }\n      }\n    };\n\n    if (this.autoTrack) {\n      if (this.trackedFactKeys.length > 0) {\n        this.unsubs.push(\n          this.system.facts.$store.subscribe(this.trackedFactKeys, onUpdate),\n        );\n      } else if (this.trackedDeriveKeys.length === 0) {\n        this.unsubs.push(this.system.facts.$store.subscribeAll(onUpdate));\n      }\n      if (this.trackedDeriveKeys.length > 0) {\n        this.unsubs.push(\n          this.system.subscribe(this.trackedDeriveKeys, onUpdate),\n        );\n      }\n    } else {\n      this.unsubs.push(this.system.facts.$store.subscribeAll(onUpdate));\n    }\n  }\n\n  protected subscribe(): void {\n    const result = this.runWithTracking();\n    this.value = result.value;\n    this.trackedFactKeys = result.factKeys;\n    this.trackedDeriveKeys = result.deriveKeys;\n    this.resubscribe();\n  }\n\n  hostDisconnected(): void {\n    for (const unsub of this.unsubs) unsub();\n    this.unsubs = [];\n    super.hostDisconnected();\n  }\n}\n\n/**\n * Reactive controller that watches a fact or derivation and calls a callback on change.\n * The key is auto-detected — works with both fact keys and derivation keys.\n */\nexport class WatchController<T> extends DirectiveController {\n  private key: string;\n  private callback: (newValue: T, previousValue: T | undefined) => void;\n\n  /** Watch a derivation or fact by key (auto-detected). When a key exists in both facts and derivations, the derivation overload takes priority. */\n  constructor(\n    host: ReactiveControllerHost,\n    system: SingleModuleSystem<any>,\n    key: string,\n    callback: (newValue: T, previousValue: T | undefined) => void,\n  ) {\n    super(host, system);\n    this.key = key;\n    this.callback = callback;\n  }\n\n  protected subscribe(): void {\n    this.unsubscribe = this.system.watch<T>(this.key, this.callback);\n  }\n}\n\n// ============================================================================\n// New Controllers\n// ============================================================================\n\n/**\n * Reactive controller for requirement explanations.\n */\nexport class ExplainController extends DirectiveController {\n  private requirementId: string;\n  value: string | null;\n  private unsubSettled?: () => void;\n\n  constructor(\n    host: ReactiveControllerHost,\n    system: SingleModuleSystem<any>,\n    requirementId: string,\n  ) {\n    super(host, system);\n    this.requirementId = requirementId;\n    this.value = system.explain(requirementId);\n  }\n\n  protected subscribe(): void {\n    this.value = this.system.explain(this.requirementId);\n\n    const update = () => {\n      this.value = this.system.explain(this.requirementId);\n      this.requestUpdate();\n    };\n\n    this.unsubscribe = this.system.facts.$store.subscribeAll(update);\n    this.unsubSettled = this.system.onSettledChange(update);\n  }\n\n  hostDisconnected(): void {\n    this.unsubSettled?.();\n    super.hostDisconnected();\n  }\n}\n\n/**\n * Reactive controller for constraint status.\n */\nexport class ConstraintStatusController extends DirectiveController {\n  private constraintId?: string;\n  value: ConstraintInfo[] | ConstraintInfo | null;\n  private unsubSettled?: () => void;\n\n  constructor(\n    host: ReactiveControllerHost,\n    system: SingleModuleSystem<any>,\n    constraintId?: string,\n  ) {\n    super(host, system);\n    this.constraintId = constraintId;\n    this.value = this.getVal();\n  }\n\n  private getVal(): ConstraintInfo[] | ConstraintInfo | null {\n    const inspection = this.system.inspect();\n    if (!this.constraintId) return inspection.constraints;\n    return (\n      inspection.constraints.find(\n        (c: ConstraintInfo) => c.id === this.constraintId,\n      ) ?? null\n    );\n  }\n\n  protected subscribe(): void {\n    this.value = this.getVal();\n\n    const update = () => {\n      this.value = this.getVal();\n      this.requestUpdate();\n    };\n\n    this.unsubscribe = this.system.facts.$store.subscribeAll(update);\n    this.unsubSettled = this.system.onSettledChange(update);\n  }\n\n  hostDisconnected(): void {\n    this.unsubSettled?.();\n    super.hostDisconnected();\n  }\n}\n\n/**\n * Reactive controller for optimistic updates.\n */\nexport class OptimisticUpdateController implements ReactiveController {\n  private host: ReactiveControllerHost;\n  private system: SingleModuleSystem<any>;\n  private statusPlugin?: StatusPlugin;\n  private requirementType?: string;\n  private snapshot: SystemSnapshot | null = null;\n  private statusUnsub: (() => void) | null = null;\n\n  isPending = false;\n  error: Error | null = null;\n\n  constructor(\n    host: ReactiveControllerHost,\n    system: SingleModuleSystem<any>,\n    statusPlugin?: StatusPlugin,\n    requirementType?: string,\n  ) {\n    this.host = host;\n    this.system = system;\n    this.statusPlugin = statusPlugin;\n    this.requirementType = requirementType;\n    host.addController(this);\n  }\n\n  hostConnected(): void {}\n\n  hostDisconnected(): void {\n    this.statusUnsub?.();\n    this.statusUnsub = null;\n  }\n\n  rollback(): void {\n    if (this.snapshot) {\n      this.system.restore(this.snapshot);\n      this.snapshot = null;\n    }\n    this.isPending = false;\n    this.error = null;\n    this.statusUnsub?.();\n    this.statusUnsub = null;\n    this.host.requestUpdate();\n  }\n\n  mutate(updateFn: () => void): void {\n    this.snapshot = this.system.getSnapshot();\n    this.isPending = true;\n    this.error = null;\n    this.system.batch(updateFn);\n    this.host.requestUpdate();\n\n    if (this.statusPlugin && this.requirementType) {\n      this.statusUnsub?.();\n      this.statusUnsub = this.statusPlugin.subscribe(() => {\n        const status = this.statusPlugin!.getStatus(this.requirementType!);\n        if (!status.isLoading && !status.hasError) {\n          this.snapshot = null;\n          this.isPending = false;\n          this.statusUnsub?.();\n          this.statusUnsub = null;\n          this.host.requestUpdate();\n        } else if (status.hasError) {\n          this.error = status.lastError;\n          this.rollback();\n        }\n      });\n    }\n  }\n}\n\n/**\n * Reactive controller that creates and manages a Directive system.\n * The system is automatically started when the host connects and destroyed when it disconnects.\n */\nexport class SystemController<M extends ModuleSchema>\n  implements ReactiveController\n{\n  private options: ModuleDef<M> | CreateSystemOptionsSingle<M>;\n  private _system: SingleModuleSystem<M> | null = null;\n\n  constructor(\n    host: ReactiveControllerHost,\n    options: ModuleDef<M> | CreateSystemOptionsSingle<M>,\n  ) {\n    this.options = options;\n    host.addController(this);\n  }\n\n  get system(): SingleModuleSystem<M> {\n    if (!this._system) {\n      throw new Error(\n        \"[Directive] SystemController.system is not available. \" +\n          \"This can happen if:\\n\" +\n          \"  1. Accessed before hostConnected (e.g., in a class field initializer)\\n\" +\n          \"  2. Accessed after hostDisconnected (system was destroyed)\\n\" +\n          \"Solution: Access system only in lifecycle methods (connectedCallback, render) \" +\n          \"or after the element is connected to the DOM.\",\n      );\n    }\n    return this._system;\n  }\n\n  hostConnected(): void {\n    const isModule = \"id\" in this.options && \"schema\" in this.options;\n    const system = isModule\n      ? createSystem({ module: this.options as ModuleDef<M> })\n      : createSystem(this.options as CreateSystemOptionsSingle<M>);\n    this._system = system as unknown as SingleModuleSystem<M>;\n    this._system.start();\n  }\n\n  hostDisconnected(): void {\n    // RFC 0009 follow-up (R18 Tier 2-B): destroyAsync so source\n    // unsubscribes complete; fire-and-forget with swallow-catch\n    // (Lit's hostDisconnected is sync).\n    this._system?.destroyAsync().catch((err: unknown) => {\n      if (isDevelopment)\n        console.warn(\"[Directive] destroyAsync rejected during unmount:\", err);\n    });\n    this._system = null;\n  }\n}\n\n/**\n * Module controller — zero-config all-in-one.\n * Creates system, starts it, subscribes to all facts/derivations.\n */\nexport class ModuleController<M extends ModuleSchema>\n  implements ReactiveController\n{\n  private host: ReactiveControllerHost;\n  private moduleDef: ModuleDef<M>;\n  private config?: {\n    plugins?: Plugin<any>[];\n    trace?: TraceOption;\n    errorBoundary?: ErrorBoundaryConfig;\n    tickMs?: number;\n    zeroConfig?: boolean;\n    initialFacts?: Record<string, any>;\n    status?: boolean;\n  };\n\n  private _system: SingleModuleSystem<M> | null = null;\n  private unsubFacts?: () => void;\n  private unsubDerived?: () => void;\n\n  facts: InferFacts<M> = {} as InferFacts<M>;\n  derived: InferDerivations<M> = {} as InferDerivations<M>;\n  statusPlugin?: StatusPlugin;\n\n  get system(): SingleModuleSystem<M> {\n    if (!this._system) {\n      throw new Error(\n        \"[Directive] ModuleController.system is not available before hostConnected.\",\n      );\n    }\n    return this._system;\n  }\n\n  get events(): SingleModuleSystem<M>[\"events\"] {\n    return this.system.events;\n  }\n\n  constructor(\n    host: ReactiveControllerHost,\n    moduleDef: ModuleDef<M>,\n    config?: {\n      plugins?: Plugin<any>[];\n      trace?: TraceOption;\n      errorBoundary?: ErrorBoundaryConfig;\n      tickMs?: number;\n      zeroConfig?: boolean;\n      initialFacts?: Record<string, any>;\n      status?: boolean;\n    },\n  ) {\n    this.host = host;\n    this.moduleDef = moduleDef;\n    this.config = config;\n    host.addController(this);\n  }\n\n  hostConnected(): void {\n    const allPlugins = [...(this.config?.plugins ?? [])];\n\n    if (this.config?.status) {\n      const sp = createRequirementStatusPlugin();\n      this.statusPlugin = sp;\n      allPlugins.push(sp.plugin as Plugin<any>);\n    }\n\n    const system = createSystem({\n      module: this.moduleDef,\n      plugins: allPlugins.length > 0 ? allPlugins : undefined,\n      trace: this.config?.trace,\n      errorBoundary: this.config?.errorBoundary,\n      tickMs: this.config?.tickMs,\n      zeroConfig: this.config?.zeroConfig,\n      initialFacts: this.config?.initialFacts,\n    } as any) as unknown as SingleModuleSystem<M>;\n\n    this._system = system;\n    system.start();\n\n    // Subscribe to all facts\n    this.facts = system.facts.$store.toObject() as InferFacts<M>;\n    this.unsubFacts = system.facts.$store.subscribeAll(() => {\n      this.facts = system.facts.$store.toObject() as InferFacts<M>;\n      this.host.requestUpdate();\n    });\n\n    // Subscribe to all derivations\n    const derivationKeys = Object.keys(system.derive ?? {});\n    const getDerived = (): InferDerivations<M> => {\n      const result: Record<string, unknown> = {};\n      for (const key of derivationKeys) {\n        result[key] = system.read(key);\n      }\n      return result as InferDerivations<M>;\n    };\n    this.derived = getDerived();\n\n    if (derivationKeys.length > 0) {\n      this.unsubDerived = system.subscribe(derivationKeys, () => {\n        this.derived = getDerived();\n        this.host.requestUpdate();\n      });\n    }\n  }\n\n  hostDisconnected(): void {\n    this.unsubFacts?.();\n    this.unsubDerived?.();\n    // follow-up — R18 Tier 2-B switched `SystemController` and\n    // `DirectiveQueryController` to `destroyAsync` but missed the\n    // zero-config `ModuleController` (this class). Same rationale:\n    // source unsubscribes are async (Supabase, MCP); sync destroy\n    // would drop those Promises on the floor and leave brokers\n    // holding ghost subscriptions until heartbeat. Fire-and-forget\n    // with a swallow-catch — Lit's hostDisconnected is sync.\n    this._system?.destroyAsync().catch((err: unknown) => {\n      if (isDevelopment)\n        console.warn(\"[Directive] destroyAsync rejected during unmount:\", err);\n    });\n    this._system = null;\n  }\n\n  dispatch(event: InferEvents<M>): void {\n    this.system.dispatch(event);\n  }\n}\n\n// ============================================================================\n// Factory Functions (active)\n// ============================================================================\n\nexport function createDerived<T>(\n  host: ReactiveControllerHost,\n  system: SingleModuleSystem<any>,\n  key: string | string[],\n): DerivedController<T> {\n  return new DerivedController<T>(host, system, key);\n}\n\nexport function createFact<T>(\n  host: ReactiveControllerHost,\n  system: SingleModuleSystem<any>,\n  factKey: string,\n): FactController<T> {\n  return new FactController<T>(host, system, factKey);\n}\n\n/**\n * Create an inspect controller.\n * Returns InspectState; pass `{ throttleMs }` for throttled updates.\n */\nexport function createInspect(\n  host: ReactiveControllerHost,\n  system: SingleModuleSystem<any>,\n  options?: { throttleMs?: number },\n): InspectController {\n  return new InspectController(host, system, options);\n}\n\nexport function createRequirementStatus(\n  host: ReactiveControllerHost,\n  statusPlugin: StatusPlugin,\n  type: string,\n): RequirementStatusController {\n  return new RequirementStatusController(host, statusPlugin, type);\n}\n\nexport function createWatch<T>(\n  host: ReactiveControllerHost,\n  system: SingleModuleSystem<any>,\n  derivationId: string,\n  callback: (newValue: T, previousValue: T | undefined) => void,\n): WatchController<T> {\n  return new WatchController<T>(host, system, derivationId, callback);\n}\n\nexport function createDirectiveSelector<S extends ModuleSchema, R>(\n  host: ReactiveControllerHost,\n  system: SingleModuleSystem<S>,\n  selector: (state: InferSelectorState<S>) => R,\n  equalityFn: (a: R, b: R) => boolean = defaultEquality,\n  options?: { autoTrack?: boolean },\n): DirectiveSelectorController<S, R> {\n  return new DirectiveSelectorController<S, R>(\n    host,\n    system,\n    selector,\n    equalityFn,\n    options,\n  );\n}\n\nexport function createExplain(\n  host: ReactiveControllerHost,\n  system: SingleModuleSystem<any>,\n  requirementId: string,\n): ExplainController {\n  return new ExplainController(host, system, requirementId);\n}\n\nexport function createConstraintStatus(\n  host: ReactiveControllerHost,\n  system: SingleModuleSystem<any>,\n  constraintId?: string,\n): ConstraintStatusController {\n  return new ConstraintStatusController(host, system, constraintId);\n}\n\nexport function createOptimisticUpdate(\n  host: ReactiveControllerHost,\n  system: SingleModuleSystem<any>,\n  statusPlugin?: StatusPlugin,\n  requirementType?: string,\n): OptimisticUpdateController {\n  return new OptimisticUpdateController(\n    host,\n    system,\n    statusPlugin,\n    requirementType,\n  );\n}\n\n/**\n * Build a `ModuleController` from a Directive module definition.\n *\n * The function is exported as both `createModuleController` (preferred)\n * and `createModule` (legacy alias). The original `createModule` name\n * collides with `@directive-run/core`'s `createModule` — importing\n * both into the same scope shadows whichever lands last in editor\n * auto-import order. New code should use `createModuleController`;\n * the `createModule` alias remains so existing imports still resolve.\n */\nexport function createModuleController<M extends ModuleSchema>(\n  host: ReactiveControllerHost,\n  moduleDef: ModuleDef<M>,\n  config?: {\n    plugins?: Plugin<any>[];\n    trace?: TraceOption;\n    errorBoundary?: ErrorBoundaryConfig;\n    tickMs?: number;\n    zeroConfig?: boolean;\n    initialFacts?: Record<string, any>;\n    status?: boolean;\n  },\n): ModuleController<M> {\n  return new ModuleController<M>(host, moduleDef, config);\n}\n\n/**\n * Legacy alias for `createModuleController`. Collides by name with\n * `@directive-run/core`'s `createModule`. New code should prefer\n * `createModuleController`.\n *\n * @deprecated Renamed to `createModuleController` — same shape, no\n * import collision with `@directive-run/core`. The function-wrapper\n * shape (vs `export const x = y`) ensures the `@deprecated` JSDoc\n * tag renders the strikethrough in every TS-aware editor.\n */\nexport function createModule<M extends ModuleSchema>(\n  host: ReactiveControllerHost,\n  moduleDef: ModuleDef<M>,\n  config?: Parameters<typeof createModuleController<M>>[2],\n): ModuleController<M> {\n  return createModuleController<M>(host, moduleDef, config);\n}\n\n// ============================================================================\n// Functional Helpers\n// ============================================================================\n\nexport function useDispatch<M extends ModuleSchema = ModuleSchema>(\n  system: SingleModuleSystem<M>,\n): (event: InferEvents<M>) => void {\n  assertSystem(\"useDispatch\", system);\n  return (event: InferEvents<M>) => {\n    system.dispatch(event);\n  };\n}\n\n/**\n * Returns the system's events dispatcher.\n */\nexport function useEvents<M extends ModuleSchema = ModuleSchema>(\n  system: SingleModuleSystem<M>,\n): SingleModuleSystem<M>[\"events\"] {\n  assertSystem(\"useEvents\", system);\n  return system.events;\n}\n\n/**\n * Reactive controller for history state.\n * Triggers host updates when snapshots change or navigation occurs.\n *\n * @example\n * ```typescript\n * class MyElement extends LitElement {\n *   private _history = new HistoryController(this, system);\n *   render() {\n *     const h = this._history.value;\n *     return html`<button ?disabled=${!h?.canGoBack} @click=${() => h?.goBack()}>Undo</button>`;\n *   }\n * }\n * ```\n */\nexport class HistoryController implements ReactiveController {\n  value: HistoryState | null = null;\n  private _unsub?: () => void;\n\n  constructor(\n    private _host: ReactiveControllerHost,\n    private _system: SingleModuleSystem<any>,\n  ) {\n    this._host.addController(this);\n  }\n\n  hostConnected(): void {\n    this.value = buildHistoryState(this._system);\n    this._unsub = this._system.onHistoryChange(() => {\n      this.value = buildHistoryState(this._system);\n      this._host.requestUpdate();\n    });\n  }\n\n  hostDisconnected(): void {\n    this._unsub?.();\n    this._unsub = undefined;\n  }\n}\n\n/**\n * Snapshot-only history helper. Returns the current `HistoryState`\n * once and does not re-fire when history mutates.\n *\n * **Named `getHistory` to match the snapshot semantics.** The Lit\n * adapter intentionally provides a non-reactive variant alongside\n * the reactive `HistoryController` so callers reading history once\n * (e.g. logging the last snapshot before a destroy) don't have to\n * spin up a controller. The previous name `useHistory` collided\n * with the reactive `useHistory` semantics in\n * `@directive-run/{react,vue,svelte,solid}` where the hook IS\n * reactive — same name, opposite contract.\n *\n * For reactive history, use `HistoryController`.\n */\nexport function getHistory(\n  system: SingleModuleSystem<any>,\n): HistoryState | null {\n  assertSystem(\"getHistory\", system);\n  return buildHistoryState(system);\n}\n\n/**\n * @deprecated Renamed to `getHistory`. The Lit functional helper is\n * snapshot-only; React/Vue/Svelte/Solid `useHistory` is reactive.\n * Use `HistoryController` for the reactive Lit equivalent. The\n * function-wrapper shape (vs `export const x = y`) ensures the\n * `@deprecated` JSDoc tag renders in every TS-aware editor.\n */\nexport function useHistory(\n  system: SingleModuleSystem<any>,\n): HistoryState | null {\n  return getHistory(system);\n}\n\nexport function getDerived<T>(\n  system: SingleModuleSystem<any>,\n  derivationId: string,\n): () => T {\n  return () => system.read(derivationId) as T;\n}\n\nexport function getFact<T>(\n  system: SingleModuleSystem<any>,\n  factKey: string,\n): () => T | undefined {\n  return () => system.facts.$store.get(factKey) as T | undefined;\n}\n\n// ============================================================================\n// Typed Hooks Factory\n// ============================================================================\n\nexport function createTypedHooks<M extends ModuleSchema>(): {\n  createDerived: <K extends keyof InferDerivations<M>>(\n    host: ReactiveControllerHost,\n    system: SingleModuleSystem<M>,\n    derivationId: K,\n  ) => DerivedController<InferDerivations<M>[K]>;\n  createFact: <K extends keyof InferFacts<M>>(\n    host: ReactiveControllerHost,\n    system: SingleModuleSystem<M>,\n    factKey: K,\n  ) => FactController<InferFacts<M>[K]>;\n  useDispatch: (\n    system: SingleModuleSystem<M>,\n  ) => (event: InferEvents<M>) => void;\n  useEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>[\"events\"];\n  createWatch: <K extends string>(\n    host: ReactiveControllerHost,\n    system: SingleModuleSystem<M>,\n    key: K,\n    callback: (newValue: unknown, previousValue: unknown) => void,\n  ) => WatchController<unknown>;\n} {\n  return {\n    createDerived: <K extends keyof InferDerivations<M>>(\n      host: ReactiveControllerHost,\n      system: SingleModuleSystem<M>,\n      derivationId: K,\n    ) =>\n      createDerived<InferDerivations<M>[K]>(\n        host,\n        system,\n        derivationId as string,\n      ),\n    createFact: <K extends keyof InferFacts<M>>(\n      host: ReactiveControllerHost,\n      system: SingleModuleSystem<M>,\n      factKey: K,\n    ) => createFact<InferFacts<M>[K]>(host, system, factKey as string),\n    useDispatch: (system: SingleModuleSystem<M>) => {\n      return (event: InferEvents<M>) => {\n        system.dispatch(event);\n      };\n    },\n    useEvents: (system: SingleModuleSystem<M>) => system.events,\n    createWatch: <K extends string>(\n      host: ReactiveControllerHost,\n      system: SingleModuleSystem<M>,\n      key: K,\n      callback: (newValue: unknown, previousValue: unknown) => void,\n    ) => createWatch<unknown>(host, system, key, callback),\n  };\n}\n\n// ============================================================================\n// NamespacedSelectorController — select from a NamespacedSystem\n// ============================================================================\n\n/**\n * Reactive controller that selects from a NamespacedSystem.\n * Subscribes to specified keys and triggers host updates.\n *\n * @example\n * ```typescript\n * class MyElement extends LitElement {\n *   private token = new NamespacedSelectorController(\n *     this, system, [\"auth.token\"], (s) => s.facts.auth.token,\n *   );\n *   render() {\n *     return html`<span>${this.token.value}</span>`;\n *   }\n * }\n * ```\n */\nexport class NamespacedSelectorController<Modules extends ModulesMap, R>\n  implements ReactiveController\n{\n  private host: ReactiveControllerHost;\n  private system: NamespacedSystem<Modules>;\n  private keys: string[];\n  private selector: (system: NamespacedSystem<Modules>) => R;\n  private unsubscribe?: () => void;\n  value: R;\n\n  constructor(\n    host: ReactiveControllerHost,\n    system: NamespacedSystem<Modules>,\n    keys: string[],\n    selector: (system: NamespacedSystem<Modules>) => R,\n  ) {\n    this.host = host;\n    this.system = system;\n    this.keys = keys;\n    this.selector = selector;\n    this.value = selector(system);\n    host.addController(this);\n  }\n\n  hostConnected(): void {\n    this.value = this.selector(this.system);\n    this.unsubscribe = this.system.subscribe(this.keys, () => {\n      this.value = this.selector(this.system);\n      this.host.requestUpdate();\n    });\n  }\n\n  hostDisconnected(): void {\n    this.unsubscribe?.();\n    this.unsubscribe = undefined;\n  }\n}\n\nexport function createNamespacedSelector<Modules extends ModulesMap, R>(\n  host: ReactiveControllerHost,\n  system: NamespacedSystem<Modules>,\n  keys: string[],\n  selector: (system: NamespacedSystem<Modules>) => R,\n): NamespacedSelectorController<Modules, R> {\n  return new NamespacedSelectorController(host, system, keys, selector);\n}\n\n// ============================================================================\n// QuerySystemController — Stable query system with Lit lifecycle\n// ============================================================================\n\n/**\n * Lit reactive controller that creates and manages a query system.\n * Starts on connect, destroys on disconnect.\n *\n * @example\n * ```typescript\n * import { LitElement, html } from \"lit\";\n * import { QuerySystemController } from \"@directive-run/lit\";\n * import { createQuerySystem } from \"@directive-run/query\";\n *\n * class MyApp extends LitElement {\n *   private app = new QuerySystemController(this, () =>\n *     createQuerySystem({\n *       facts: { userId: \"\" },\n *       queries: { user: { key: ..., fetcher: ... } },\n *       autoStart: false,\n *     })\n *   );\n *\n *   render() {\n *     const user = this.app.system.read(\"user\");\n *     return html`<div>${user.data?.name}</div>`;\n *   }\n * }\n * ```\n */\nexport class QuerySystemController<\n  T extends {\n    start: () => void;\n    destroy: () => void;\n    isRunning?: boolean;\n    [key: string]: any;\n  },\n> implements ReactiveController\n{\n  private _system: T | null = null;\n  private factory: () => T;\n\n  constructor(host: ReactiveControllerHost, factory: () => T) {\n    this.factory = factory;\n    host.addController(this);\n  }\n\n  get system(): T {\n    if (!this._system) {\n      throw new Error(\n        \"[Directive] QuerySystemController.system is not available. \" +\n          \"Access it only in lifecycle methods or after the element is connected.\",\n      );\n    }\n    return this._system;\n  }\n\n  hostConnected(): void {\n    this._system = this.factory();\n    if (!this._system.isRunning) {\n      this._system.start();\n    }\n  }\n\n  hostDisconnected(): void {\n    // RFC 0009 follow-up (R18 Tier 2-B): destroyAsync so source\n    // unsubscribes complete; fire-and-forget with swallow-catch\n    // (Lit's hostDisconnected is sync).\n    this._system?.destroyAsync().catch((err: unknown) => {\n      if (isDevelopment)\n        console.warn(\"[Directive] destroyAsync rejected during unmount:\", err);\n    });\n    this._system = null;\n  }\n}\n\n// ============================================================================\n// SSR Hydration\n// ============================================================================\n\n/**\n * Lit reactive controller for SSR hydration.\n * Accepts a DistributableSnapshot and creates a hydrated system.\n *\n * @example\n * ```typescript\n * class MyElement extends LitElement {\n *   private hydration = new HydrationController(this, serverSnapshot);\n *   private system = this.hydration.createSystem(myModule);\n * }\n * ```\n */\nexport class HydrationController implements ReactiveController {\n  private snapshot: Record<string, unknown> | undefined;\n  private systems: SingleModuleSystem<any>[] = [];\n\n  constructor(\n    host: ReactiveControllerHost,\n    snapshot?: Record<string, unknown>,\n  ) {\n    this.snapshot = snapshot;\n    host.addController(this);\n  }\n\n  hostConnected(): void {}\n\n  hostDisconnected(): void {\n    // RFC 0009 follow-up (R18 Tier 2-B): destroyAsync per system so\n    // source unsubscribes complete; fire-and-forget with swallow-catch\n    // (Lit's hostDisconnected is sync).\n    for (const system of this.systems) {\n      system.destroyAsync().catch((err: unknown) => {\n        if (isDevelopment)\n          console.warn(\n            \"[Directive] destroyAsync rejected during unmount:\",\n            err,\n          );\n      });\n    }\n    this.systems = [];\n  }\n\n  createSystem<S extends ModuleSchema>(\n    moduleDef: ModuleDef<S>,\n    config?: {\n      plugins?: Plugin<any>[];\n      trace?: TraceOption;\n      errorBoundary?: ErrorBoundaryConfig;\n      tickMs?: number;\n      zeroConfig?: boolean;\n      initialFacts?: Record<string, any>;\n    },\n  ): SingleModuleSystem<S> {\n    const mergedFacts = mergeHydrationFacts(\n      this.snapshot,\n      config?.initialFacts,\n    );\n    const system = createSystem({\n      module: moduleDef,\n      plugins: config?.plugins,\n      trace: config?.trace,\n      errorBoundary: config?.errorBoundary,\n      tickMs: config?.tickMs,\n      zeroConfig: config?.zeroConfig,\n      initialFacts: mergedFacts,\n    } as any) as unknown as SingleModuleSystem<S>;\n\n    this.systems.push(system);\n\n    if (typeof window !== \"undefined\") {\n      system.start();\n    }\n\n    return system;\n  }\n}\n\n// ============================================================================\n// AuditLedgerController — live ledger entries with filter (R4.I parity)\n// ============================================================================\n\nimport type { AuditEntry, AuditLedger, QueryFilter } from \"@directive-run/core\";\n\n/**\n * Reactive controller exposing the latest audit-ledger entries matching\n * `filter` as `.value`. Polls (default 250 ms — override with `pollMs`)\n * and re-renders the host on each tick that brings new matches.\n *\n * **Polling floor:** `pollMs` is clamped to a minimum of 50 ms to prevent\n * accidental DoS from typos like `pollMs: 5`. Values below the floor are\n * silently clamped in production; dev mode logs a warning.\n *\n * @example\n * ```ts\n * import { AuditLedgerController } from \"@directive-run/lit\";\n *\n * class AuditLog extends LitElement {\n *   private ledgerCtrl = new AuditLedgerController(\n *     this,\n *     ledger,\n *     { kind: \"constraint.evaluate\", limit: 20 },\n *   );\n *\n *   render() {\n *     return html`<ul>\n *       ${this.ledgerCtrl.value.map(e => html`<li>${e.kind} @ ${e.ts}</li>`)}\n *     </ul>`;\n *   }\n * }\n * ```\n */\nexport class AuditLedgerController implements ReactiveController {\n  private host: ReactiveControllerHost;\n  private ledger: AuditLedger;\n  private filter: QueryFilter;\n  private pollMs: number;\n  private intervalId: ReturnType<typeof setInterval> | null = null;\n\n  /**\n   * Latest matching audit entries. Updates on each poll tick when the\n   * seq-window (first/last entry seq) changes. Lit `requestUpdate()` is\n   * only called when the window moves — in-place tombstone replacement\n   * within the visible window does NOT trigger re-render (use the ledger's\n   * onWrite hook for revision-level updates when added).\n   */\n  value: readonly AuditEntry[];\n\n  constructor(\n    host: ReactiveControllerHost,\n    ledger: AuditLedger,\n    filter: QueryFilter = {},\n    opts: { pollMs?: number } = {},\n  ) {\n    this.host = host;\n    this.ledger = ledger;\n    this.filter = filter;\n    const requestedPollMs = opts.pollMs ?? 250;\n    this.pollMs = Math.max(50, requestedPollMs);\n\n    if (isDevelopment) {\n      if (opts.pollMs !== undefined && opts.pollMs < 50) {\n        console.warn(\n          `[Directive] AuditLedgerController pollMs=${opts.pollMs} is below the 50 ms floor; clamped to 50 ms.`,\n        );\n      }\n      if (this.pollMs < 100) {\n        const entryCount = ledger.toJSON().entries.length;\n        if (entryCount > 1000) {\n          console.warn(\n            `[Directive] AuditLedgerController polling every ${this.pollMs} ms against a ${entryCount}-entry ledger — that's a lot of CPU per tick. Consider raising pollMs or tightening the filter.`,\n          );\n        }\n      }\n    }\n\n    this.value = ledger.query(filter);\n    host.addController(this);\n  }\n\n  hostConnected(): void {\n    this.intervalId = setInterval(() => {\n      const next = this.ledger.query(this.filter);\n      // Always replace the array reference so consumers reading\n      // `.value` see the latest snapshot, but only request a render\n      // when the seq-window actually moved. At steady-state capacity\n      // (e.g. 10k entries rolling over) the length is constant — using\n      // length-diff alone misses every change. Compare the first and\n      // last seq instead. (R4.C7)\n      const moved =\n        next[0]?.seq !== this.value[0]?.seq ||\n        next[next.length - 1]?.seq !== this.value[this.value.length - 1]?.seq;\n      this.value = next;\n      if (moved) {\n        this.host.requestUpdate();\n      }\n    }, this.pollMs);\n  }\n\n  hostDisconnected(): void {\n    if (this.intervalId !== null) {\n      clearInterval(this.intervalId);\n      this.intervalId = null;\n    }\n  }\n}\n"]}