@bitcobblers/wod-wiki-lang 0.37.2139 → 0.37.2140

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.
@@ -37,6 +37,30 @@ type EffortRegistrySource = 'bundled' | 'user' | 'synthetic-unresolved';
37
37
  /** Origins that hold real registry records (synthetic-unresolved entries are
38
38
  * resolver phantoms, never listed) — the WQL `origin:` filter vocabulary. */
39
39
  declare const EFFORT_REGISTRY_ORIGINS: readonly ["bundled", "user"];
40
+ /**
41
+ * Precedence tiers for resolving collisions across seed catalogs and local edits.
42
+ * Order: core (0) < community (1) < imported (2) < user (3).
43
+ */
44
+ type CatalogPrecedenceTier = 'core' | 'community' | 'imported' | 'user';
45
+ declare const CATALOG_PRECEDENCE_RANK: Readonly<Record<CatalogPrecedenceTier, number>>;
46
+ /** Resolve the precedence tier for a seed source id or checkpoint key (`seed:<id>`). */
47
+ declare function resolveSourceTier(sourceIdOrMetaKey?: string | null, explicitTier?: CatalogPrecedenceTier): CatalogPrecedenceTier;
48
+ declare function resolveSourceRank(sourceIdOrMetaKey?: string | null, explicitTier?: CatalogPrecedenceTier): number;
49
+ /** Resolve the precedence tier of an effort/equipment definition record. */
50
+ declare function resolveEntityTier(entity: {
51
+ registrySource?: string;
52
+ sourceId?: string | null;
53
+ }): CatalogPrecedenceTier;
54
+ declare function resolveEntityRank(entity: {
55
+ registrySource?: string;
56
+ sourceId?: string | null;
57
+ }): number;
58
+ /** Deduplicate definition entities by slug, retaining the highest-precedence record per slug. */
59
+ declare function dedupeEntitiesByPrecedence<T extends {
60
+ slug: string;
61
+ registrySource?: string;
62
+ sourceId?: string | null;
63
+ }>(entities: readonly T[]): T[];
40
64
  /** Intensity tiers, low → high — the WQL `intensity:` filter vocabulary. */
41
65
  declare const INTENSITY_TIERS: readonly ["low", "moderate", "high"];
42
66
  type IntensityTier = (typeof INTENSITY_TIERS)[number];
@@ -2497,4 +2521,4 @@ declare function getRuntimeNowMs(): number;
2497
2521
  /** Creates an INowProvider that reads the browser sender-clock when available. */
2498
2522
  declare function createBrowserRuntimeNow(): INowProvider;
2499
2523
 
2500
- export { type HandlerScope as $, type AnalyticsContext as A, type BehaviorEventType as B, type IBlockContext as C, type MetricVisibility as D, type EffortResolverOptions as E, type BlockLifecycleOptions as F, type CompletionDecision as G, type IRuntimeMemory as H, type IEquipment as I, TypedMemoryReference as J, type MemorySearchCriteria as K, type IMemoryReference as L, type MemoryTag as M, type RuntimeStackLogger as N, type OutputListener as O, type StackObserver as P, type StackSnapshot as Q, type ReferenceIndex as R, type SubscribeOptions as S, TimeSpan as T, type Unsubscribe as U, type StackListener as V, WhiteboardScript as W, MemoryTypeEnum as X, type IAnchorValue as Y, type ButtonConfig as Z, type IEventHandler as _, type ReferenceResolutionDefaults as a, type IScriptRuntime as a0, type TestableBlockConfig as a1, type IRuntimeOptions as a2, ScriptRuntime as a3, type EventHandlerOptions as a4, type EventCallback as a5, type TimerState as a6, type IRealtimeProcessor as a7, type ISummaryProcessor as a8, type ProjectionResult as a9, type MemoryType as aA, type MemoryTypeMap as aB, type MemoryValueOf as aC, type ReferenceCatalog as aD, type ResolvedReferences as aE, type RoundState as aF, type RuntimeState as aG, type ScriptRuntimeDependencies as aH, type StackEvent as aI, type TimerDirection as aJ, VISIBILITY_ICONS as aK, VISIBILITY_LABELS as aL, createBrowserRuntimeNow as aM, createReferenceIndex as aN, disciplineFactorFor as aO, extractStatementRefs as aP, filterTagsByVisibility as aQ, frozenNow as aR, getMetricVisibility as aS, getRuntimeNowMs as aT, isEffortDiscipline as aU, isFragmentTag as aV, slugifyRefLabel as aW, wallClockNow as aX, type ButtonVariant as aa, type ButtonsState as ab, type ChildrenStatusState as ac, type CompletionState as ad, DEFAULT_RESOLVER_OPTIONS as ae, DEFAULT_RUNTIME_OPTIONS as af, DISCIPLINE_FACTORS as ag, type DisplayState as ah, EFFORT_DISCIPLINES as ai, EFFORT_REGISTRY_ORIGINS as aj, type EffortBaseAttributes as ak, type EffortDerivation as al, type EffortDiscipline as am, type EffortMaterializer as an, type EffortResolvedFrom as ao, type EquipmentStorageAdapter as ap, type FenceDialect as aq, type FragmentDisplayState as ar, type FragmentState as as, type IAnalyticsProcessorDescriptor as at, type IEquipmentRegistry as au, INTENSITY_TIERS as av, type IScript as aw, type IntensityTier as ax, type InterceptMode as ay, MemoryLocation as az, type IEffort as b, type IEffortResolver as c, type IEffortRegistry as d, type EffortResolutionOptions as e, type ResolvedEffort as f, type EffortRegistrySource as g, type EffortStorageAdapter as h, type IRuntimeActionable as i, type IEventBus as j, type IRuntimeStack as k, type IRuntimeClock as l, type IJitCompiler as m, type INowProvider as n, type RuntimeStackOptions as o, type RuntimeError as p, type IEvent as q, type IRuntimeAction as r, type IAnalyticsEngine as s, type IRuntimeBlock as t, type IBehaviorContext as u, type BehaviorEventListener as v, type Unsubscribe$1 as w, type OutputOptions as x, type IMemoryLocation as y, type IRuntimeBehavior as z };
2524
+ export { type HandlerScope as $, type AnalyticsContext as A, type BehaviorEventType as B, type IBlockContext as C, type MetricVisibility as D, type EffortResolverOptions as E, type BlockLifecycleOptions as F, type CompletionDecision as G, type IRuntimeMemory as H, type IEquipment as I, TypedMemoryReference as J, type MemorySearchCriteria as K, type IMemoryReference as L, type MemoryTag as M, type RuntimeStackLogger as N, type OutputListener as O, type StackObserver as P, type StackSnapshot as Q, type ReferenceIndex as R, type SubscribeOptions as S, TimeSpan as T, type Unsubscribe as U, type StackListener as V, WhiteboardScript as W, MemoryTypeEnum as X, type IAnchorValue as Y, type ButtonConfig as Z, type IEventHandler as _, type ReferenceResolutionDefaults as a, resolveSourceRank as a$, type IScriptRuntime as a0, type TestableBlockConfig as a1, type IRuntimeOptions as a2, ScriptRuntime as a3, type EventHandlerOptions as a4, type EventCallback as a5, type TimerState as a6, type IRealtimeProcessor as a7, type ISummaryProcessor as a8, type ProjectionResult as a9, type InterceptMode as aA, MemoryLocation as aB, type MemoryType as aC, type MemoryTypeMap as aD, type MemoryValueOf as aE, type ReferenceCatalog as aF, type ResolvedReferences as aG, type RoundState as aH, type RuntimeState as aI, type ScriptRuntimeDependencies as aJ, type StackEvent as aK, type TimerDirection as aL, VISIBILITY_ICONS as aM, VISIBILITY_LABELS as aN, createBrowserRuntimeNow as aO, createReferenceIndex as aP, dedupeEntitiesByPrecedence as aQ, disciplineFactorFor as aR, extractStatementRefs as aS, filterTagsByVisibility as aT, frozenNow as aU, getMetricVisibility as aV, getRuntimeNowMs as aW, isEffortDiscipline as aX, isFragmentTag as aY, resolveEntityRank as aZ, resolveEntityTier as a_, type ButtonVariant as aa, type ButtonsState as ab, CATALOG_PRECEDENCE_RANK as ac, type CatalogPrecedenceTier as ad, type ChildrenStatusState as ae, type CompletionState as af, DEFAULT_RESOLVER_OPTIONS as ag, DEFAULT_RUNTIME_OPTIONS as ah, DISCIPLINE_FACTORS as ai, type DisplayState as aj, EFFORT_DISCIPLINES as ak, EFFORT_REGISTRY_ORIGINS as al, type EffortBaseAttributes as am, type EffortDerivation as an, type EffortDiscipline as ao, type EffortMaterializer as ap, type EffortResolvedFrom as aq, type EquipmentStorageAdapter as ar, type FenceDialect as as, type FragmentDisplayState as at, type FragmentState as au, type IAnalyticsProcessorDescriptor as av, type IEquipmentRegistry as aw, INTENSITY_TIERS as ax, type IScript as ay, type IntensityTier as az, type IEffort as b, resolveSourceTier as b0, slugifyRefLabel as b1, wallClockNow as b2, type IEffortResolver as c, type IEffortRegistry as d, type EffortResolutionOptions as e, type ResolvedEffort as f, type EffortRegistrySource as g, type EffortStorageAdapter as h, type IRuntimeActionable as i, type IEventBus as j, type IRuntimeStack as k, type IRuntimeClock as l, type IJitCompiler as m, type INowProvider as n, type RuntimeStackOptions as o, type RuntimeError as p, type IEvent as q, type IRuntimeAction as r, type IAnalyticsEngine as s, type IRuntimeBlock as t, type IBehaviorContext as u, type BehaviorEventListener as v, type Unsubscribe$1 as w, type OutputOptions as x, type IMemoryLocation as y, type IRuntimeBehavior as z };
@@ -37,6 +37,30 @@ type EffortRegistrySource = 'bundled' | 'user' | 'synthetic-unresolved';
37
37
  /** Origins that hold real registry records (synthetic-unresolved entries are
38
38
  * resolver phantoms, never listed) — the WQL `origin:` filter vocabulary. */
39
39
  declare const EFFORT_REGISTRY_ORIGINS: readonly ["bundled", "user"];
40
+ /**
41
+ * Precedence tiers for resolving collisions across seed catalogs and local edits.
42
+ * Order: core (0) < community (1) < imported (2) < user (3).
43
+ */
44
+ type CatalogPrecedenceTier = 'core' | 'community' | 'imported' | 'user';
45
+ declare const CATALOG_PRECEDENCE_RANK: Readonly<Record<CatalogPrecedenceTier, number>>;
46
+ /** Resolve the precedence tier for a seed source id or checkpoint key (`seed:<id>`). */
47
+ declare function resolveSourceTier(sourceIdOrMetaKey?: string | null, explicitTier?: CatalogPrecedenceTier): CatalogPrecedenceTier;
48
+ declare function resolveSourceRank(sourceIdOrMetaKey?: string | null, explicitTier?: CatalogPrecedenceTier): number;
49
+ /** Resolve the precedence tier of an effort/equipment definition record. */
50
+ declare function resolveEntityTier(entity: {
51
+ registrySource?: string;
52
+ sourceId?: string | null;
53
+ }): CatalogPrecedenceTier;
54
+ declare function resolveEntityRank(entity: {
55
+ registrySource?: string;
56
+ sourceId?: string | null;
57
+ }): number;
58
+ /** Deduplicate definition entities by slug, retaining the highest-precedence record per slug. */
59
+ declare function dedupeEntitiesByPrecedence<T extends {
60
+ slug: string;
61
+ registrySource?: string;
62
+ sourceId?: string | null;
63
+ }>(entities: readonly T[]): T[];
40
64
  /** Intensity tiers, low → high — the WQL `intensity:` filter vocabulary. */
41
65
  declare const INTENSITY_TIERS: readonly ["low", "moderate", "high"];
42
66
  type IntensityTier = (typeof INTENSITY_TIERS)[number];
@@ -2497,4 +2521,4 @@ declare function getRuntimeNowMs(): number;
2497
2521
  /** Creates an INowProvider that reads the browser sender-clock when available. */
2498
2522
  declare function createBrowserRuntimeNow(): INowProvider;
2499
2523
 
2500
- export { type HandlerScope as $, type AnalyticsContext as A, type BehaviorEventType as B, type IBlockContext as C, type MetricVisibility as D, type EffortResolverOptions as E, type BlockLifecycleOptions as F, type CompletionDecision as G, type IRuntimeMemory as H, type IEquipment as I, TypedMemoryReference as J, type MemorySearchCriteria as K, type IMemoryReference as L, type MemoryTag as M, type RuntimeStackLogger as N, type OutputListener as O, type StackObserver as P, type StackSnapshot as Q, type ReferenceIndex as R, type SubscribeOptions as S, TimeSpan as T, type Unsubscribe as U, type StackListener as V, WhiteboardScript as W, MemoryTypeEnum as X, type IAnchorValue as Y, type ButtonConfig as Z, type IEventHandler as _, type ReferenceResolutionDefaults as a, type IScriptRuntime as a0, type TestableBlockConfig as a1, type IRuntimeOptions as a2, ScriptRuntime as a3, type EventHandlerOptions as a4, type EventCallback as a5, type TimerState as a6, type IRealtimeProcessor as a7, type ISummaryProcessor as a8, type ProjectionResult as a9, type MemoryType as aA, type MemoryTypeMap as aB, type MemoryValueOf as aC, type ReferenceCatalog as aD, type ResolvedReferences as aE, type RoundState as aF, type RuntimeState as aG, type ScriptRuntimeDependencies as aH, type StackEvent as aI, type TimerDirection as aJ, VISIBILITY_ICONS as aK, VISIBILITY_LABELS as aL, createBrowserRuntimeNow as aM, createReferenceIndex as aN, disciplineFactorFor as aO, extractStatementRefs as aP, filterTagsByVisibility as aQ, frozenNow as aR, getMetricVisibility as aS, getRuntimeNowMs as aT, isEffortDiscipline as aU, isFragmentTag as aV, slugifyRefLabel as aW, wallClockNow as aX, type ButtonVariant as aa, type ButtonsState as ab, type ChildrenStatusState as ac, type CompletionState as ad, DEFAULT_RESOLVER_OPTIONS as ae, DEFAULT_RUNTIME_OPTIONS as af, DISCIPLINE_FACTORS as ag, type DisplayState as ah, EFFORT_DISCIPLINES as ai, EFFORT_REGISTRY_ORIGINS as aj, type EffortBaseAttributes as ak, type EffortDerivation as al, type EffortDiscipline as am, type EffortMaterializer as an, type EffortResolvedFrom as ao, type EquipmentStorageAdapter as ap, type FenceDialect as aq, type FragmentDisplayState as ar, type FragmentState as as, type IAnalyticsProcessorDescriptor as at, type IEquipmentRegistry as au, INTENSITY_TIERS as av, type IScript as aw, type IntensityTier as ax, type InterceptMode as ay, MemoryLocation as az, type IEffort as b, type IEffortResolver as c, type IEffortRegistry as d, type EffortResolutionOptions as e, type ResolvedEffort as f, type EffortRegistrySource as g, type EffortStorageAdapter as h, type IRuntimeActionable as i, type IEventBus as j, type IRuntimeStack as k, type IRuntimeClock as l, type IJitCompiler as m, type INowProvider as n, type RuntimeStackOptions as o, type RuntimeError as p, type IEvent as q, type IRuntimeAction as r, type IAnalyticsEngine as s, type IRuntimeBlock as t, type IBehaviorContext as u, type BehaviorEventListener as v, type Unsubscribe$1 as w, type OutputOptions as x, type IMemoryLocation as y, type IRuntimeBehavior as z };
2524
+ export { type HandlerScope as $, type AnalyticsContext as A, type BehaviorEventType as B, type IBlockContext as C, type MetricVisibility as D, type EffortResolverOptions as E, type BlockLifecycleOptions as F, type CompletionDecision as G, type IRuntimeMemory as H, type IEquipment as I, TypedMemoryReference as J, type MemorySearchCriteria as K, type IMemoryReference as L, type MemoryTag as M, type RuntimeStackLogger as N, type OutputListener as O, type StackObserver as P, type StackSnapshot as Q, type ReferenceIndex as R, type SubscribeOptions as S, TimeSpan as T, type Unsubscribe as U, type StackListener as V, WhiteboardScript as W, MemoryTypeEnum as X, type IAnchorValue as Y, type ButtonConfig as Z, type IEventHandler as _, type ReferenceResolutionDefaults as a, resolveSourceRank as a$, type IScriptRuntime as a0, type TestableBlockConfig as a1, type IRuntimeOptions as a2, ScriptRuntime as a3, type EventHandlerOptions as a4, type EventCallback as a5, type TimerState as a6, type IRealtimeProcessor as a7, type ISummaryProcessor as a8, type ProjectionResult as a9, type InterceptMode as aA, MemoryLocation as aB, type MemoryType as aC, type MemoryTypeMap as aD, type MemoryValueOf as aE, type ReferenceCatalog as aF, type ResolvedReferences as aG, type RoundState as aH, type RuntimeState as aI, type ScriptRuntimeDependencies as aJ, type StackEvent as aK, type TimerDirection as aL, VISIBILITY_ICONS as aM, VISIBILITY_LABELS as aN, createBrowserRuntimeNow as aO, createReferenceIndex as aP, dedupeEntitiesByPrecedence as aQ, disciplineFactorFor as aR, extractStatementRefs as aS, filterTagsByVisibility as aT, frozenNow as aU, getMetricVisibility as aV, getRuntimeNowMs as aW, isEffortDiscipline as aX, isFragmentTag as aY, resolveEntityRank as aZ, resolveEntityTier as a_, type ButtonVariant as aa, type ButtonsState as ab, CATALOG_PRECEDENCE_RANK as ac, type CatalogPrecedenceTier as ad, type ChildrenStatusState as ae, type CompletionState as af, DEFAULT_RESOLVER_OPTIONS as ag, DEFAULT_RUNTIME_OPTIONS as ah, DISCIPLINE_FACTORS as ai, type DisplayState as aj, EFFORT_DISCIPLINES as ak, EFFORT_REGISTRY_ORIGINS as al, type EffortBaseAttributes as am, type EffortDerivation as an, type EffortDiscipline as ao, type EffortMaterializer as ap, type EffortResolvedFrom as aq, type EquipmentStorageAdapter as ar, type FenceDialect as as, type FragmentDisplayState as at, type FragmentState as au, type IAnalyticsProcessorDescriptor as av, type IEquipmentRegistry as aw, INTENSITY_TIERS as ax, type IScript as ay, type IntensityTier as az, type IEffort as b, resolveSourceTier as b0, slugifyRefLabel as b1, wallClockNow as b2, type IEffortResolver as c, type IEffortRegistry as d, type EffortResolutionOptions as e, type ResolvedEffort as f, type EffortRegistrySource as g, type EffortStorageAdapter as h, type IRuntimeActionable as i, type IEventBus as j, type IRuntimeStack as k, type IRuntimeClock as l, type IJitCompiler as m, type INowProvider as n, type RuntimeStackOptions as o, type RuntimeError as p, type IEvent as q, type IRuntimeAction as r, type IAnalyticsEngine as s, type IRuntimeBlock as t, type IBehaviorContext as u, type BehaviorEventListener as v, type Unsubscribe$1 as w, type OutputOptions as x, type IMemoryLocation as y, type IRuntimeBehavior as z };
package/dist/index.cjs CHANGED
@@ -2998,6 +2998,42 @@ function whiteboardScript() {
2998
2998
 
2999
2999
  // src/effort-registry/types.ts
3000
3000
  var EFFORT_REGISTRY_ORIGINS = ["bundled", "user"];
3001
+ var CATALOG_PRECEDENCE_RANK = {
3002
+ core: 0,
3003
+ community: 1,
3004
+ imported: 2,
3005
+ user: 3
3006
+ };
3007
+ function resolveSourceTier(sourceIdOrMetaKey, explicitTier) {
3008
+ if (explicitTier) return explicitTier;
3009
+ if (!sourceIdOrMetaKey) return "core";
3010
+ if (sourceIdOrMetaKey === "user") return "user";
3011
+ const id = sourceIdOrMetaKey.startsWith("seed:") ? sourceIdOrMetaKey.slice(5) : sourceIdOrMetaKey;
3012
+ if (id === "core" || id === "efforts" || id === "equipment") return "core";
3013
+ if (id === "community" || id.startsWith("community-") || id === "common") return "community";
3014
+ return "imported";
3015
+ }
3016
+ function resolveSourceRank(sourceIdOrMetaKey, explicitTier) {
3017
+ return CATALOG_PRECEDENCE_RANK[resolveSourceTier(sourceIdOrMetaKey, explicitTier)];
3018
+ }
3019
+ function resolveEntityTier(entity) {
3020
+ if (entity.registrySource === "user") return "user";
3021
+ return resolveSourceTier(entity.sourceId);
3022
+ }
3023
+ function resolveEntityRank(entity) {
3024
+ return CATALOG_PRECEDENCE_RANK[resolveEntityTier(entity)];
3025
+ }
3026
+ function dedupeEntitiesByPrecedence(entities) {
3027
+ const bySlug = /* @__PURE__ */ new Map();
3028
+ for (const entity of entities) {
3029
+ const key = entity.slug.toLowerCase();
3030
+ const prior = bySlug.get(key);
3031
+ if (!prior || resolveEntityRank(entity) >= resolveEntityRank(prior)) {
3032
+ bySlug.set(key, entity);
3033
+ }
3034
+ }
3035
+ return Array.from(bySlug.values());
3036
+ }
3001
3037
  var INTENSITY_TIERS = ["low", "moderate", "high"];
3002
3038
  var DEFAULT_RESOLVER_OPTIONS = {
3003
3039
  defaultMet: 5,
@@ -3851,13 +3887,10 @@ var CompositeEffortRegistry = class {
3851
3887
  */
3852
3888
  async loadBundled(customBundled) {
3853
3889
  this.bundledEfforts.clear();
3854
- if (customBundled) {
3855
- for (const effort of customBundled) {
3856
- this.bundledEfforts.set(effort.slug, effort);
3857
- }
3858
- } else {
3859
- const seed = this.initialBundled ?? bundledEfforts;
3860
- for (const effort of seed) {
3890
+ const source = customBundled ?? this.initialBundled ?? bundledEfforts;
3891
+ for (const effort of source) {
3892
+ const prior = this.bundledEfforts.get(effort.slug);
3893
+ if (!prior || resolveEntityRank(effort) >= resolveEntityRank(prior)) {
3861
3894
  this.bundledEfforts.set(effort.slug, effort);
3862
3895
  }
3863
3896
  }
@@ -3891,8 +3924,8 @@ var CompositeEffortRegistry = class {
3891
3924
  if (normalizeForFuzzy(alias) === normalized) return effort;
3892
3925
  }
3893
3926
  }
3894
- for (const effort of this.bundledEfforts.values()) {
3895
- if (this.userEfforts.has(effort.slug)) continue;
3927
+ const bundled = Array.from(this.bundledEfforts.values()).filter((effort) => !this.userEfforts.has(effort.slug)).sort((a, b) => resolveEntityRank(b) - resolveEntityRank(a));
3928
+ for (const effort of bundled) {
3896
3929
  if (normalizeForFuzzy(effort.label) === normalized) return effort;
3897
3930
  for (const alias of effort.aliases) {
3898
3931
  if (normalizeForFuzzy(alias) === normalized) return effort;
@@ -3992,6 +4025,7 @@ async function addAliasToEffort(registry, targetSlug, newAlias) {
3992
4025
  return updatedUserEffort;
3993
4026
  }
3994
4027
  function buildExactIndex(entities) {
4028
+ const deduped = dedupeEntitiesByPrecedence(entities);
3995
4029
  const byKey = /* @__PURE__ */ new Map();
3996
4030
  const add = (key, entity) => {
3997
4031
  if (!key) return;
@@ -4002,7 +4036,7 @@ function buildExactIndex(entities) {
4002
4036
  byKey.set(key, [entity]);
4003
4037
  }
4004
4038
  };
4005
- for (const entity of entities) {
4039
+ for (const entity of deduped) {
4006
4040
  add(entity.slug.toLowerCase(), entity);
4007
4041
  add(normalizeForFuzzy(entity.label), entity);
4008
4042
  for (const alias of entity.aliases) add(normalizeForFuzzy(alias), entity);
@@ -4013,7 +4047,14 @@ function buildExactIndex(entities) {
4013
4047
  const direct = byKey.get(key) ?? byKey.get(normalizeForFuzzy(key));
4014
4048
  if (!direct || direct.length === 0) return { entity: null, ambiguous: [] };
4015
4049
  if (direct.length === 1) return { entity: direct[0], ambiguous: [] };
4016
- return { entity: null, ambiguous: direct };
4050
+ let maxRank = -1;
4051
+ for (const candidate of direct) {
4052
+ const rank = resolveEntityRank(candidate);
4053
+ if (rank > maxRank) maxRank = rank;
4054
+ }
4055
+ const topTier = direct.filter((candidate) => resolveEntityRank(candidate) === maxRank);
4056
+ if (topTier.length === 1) return { entity: topTier[0], ambiguous: [] };
4057
+ return { entity: null, ambiguous: topTier };
4017
4058
  }
4018
4059
  };
4019
4060
  }
@@ -4032,9 +4073,10 @@ function dedupeRefs(refs) {
4032
4073
  return result;
4033
4074
  }
4034
4075
  function createReferenceIndex(catalog, materialize) {
4076
+ const dedupedEquipment = dedupeEntitiesByPrecedence(catalog.equipment ?? []);
4035
4077
  const efforts = buildExactIndex(catalog.efforts ?? []);
4036
- const equipment = buildExactIndex(catalog.equipment ?? []);
4037
- const prefixCandidates = (catalog.equipment ?? []).flatMap((entity) => [entity.label, ...entity.aliases].filter((name2) => !!name2 && !!name2.trim()).map((name2) => ({ lower: name2.trim().toLowerCase(), entity }))).sort((a, b) => b.lower.length - a.lower.length);
4078
+ const equipment = buildExactIndex(dedupedEquipment);
4079
+ const prefixCandidates = dedupedEquipment.flatMap((entity) => [entity.label, ...entity.aliases].filter((name2) => !!name2 && !!name2.trim()).map((name2) => ({ lower: name2.trim().toLowerCase(), entity }))).sort((a, b) => b.lower.length - a.lower.length);
4038
4080
  const materializer = materialize ?? ((effort) => ({
4039
4081
  effort,
4040
4082
  definition: effort,
@@ -14749,6 +14791,7 @@ exports.BehaviorContext = BehaviorContext;
14749
14791
  exports.BlockBuilder = BlockBuilder;
14750
14792
  exports.BlockContext = BlockContext;
14751
14793
  exports.ButtonBehavior = ButtonBehavior;
14794
+ exports.CATALOG_PRECEDENCE_RANK = CATALOG_PRECEDENCE_RANK;
14752
14795
  exports.CONSUMED_HINTS = CONSUMED_HINTS;
14753
14796
  exports.CONSUMED_HINT_KEYS = CONSUMED_HINT_KEYS;
14754
14797
  exports.CONTEXT_ATOMS = CONTEXT_ATOMS;
@@ -14911,6 +14954,7 @@ exports.createReferenceIndex = createReferenceIndex;
14911
14954
  exports.createRpeLabelsTable = createRpeLabelsTable;
14912
14955
  exports.dailySessionLoads = dailySessionLoads;
14913
14956
  exports.dayBucket = dayBucket;
14957
+ exports.dedupeEntitiesByPrecedence = dedupeEntitiesByPrecedence;
14914
14958
  exports.dialectRegistry = dialectRegistry;
14915
14959
  exports.dialectStack = dialectStack;
14916
14960
  exports.diffStatement = diffStatement;
@@ -14983,6 +15027,10 @@ exports.readTimer = readTimer;
14983
15027
  exports.realtimeProcessorRegistry = realtimeProcessorRegistry;
14984
15028
  exports.renderMetric = renderMetric;
14985
15029
  exports.resolveDominantOrigin = resolveDominantOrigin;
15030
+ exports.resolveEntityRank = resolveEntityRank;
15031
+ exports.resolveEntityTier = resolveEntityTier;
15032
+ exports.resolveSourceRank = resolveSourceRank;
15033
+ exports.resolveSourceTier = resolveSourceTier;
14986
15034
  exports.slugifyRefLabel = slugifyRefLabel;
14987
15035
  exports.startSpan = startSpan;
14988
15036
  exports.str = str;