@vue-skuilder/standalone-ui 0.2.16 → 0.2.18

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.
@@ -24639,6 +24639,7 @@ var init_v4 = __esmMin((() => {
24639
24639
  ENV: () => ENV,
24640
24640
  FileSystemError: () => FileSystemError,
24641
24641
  GuestUsername: () => GuestUsername,
24642
+ HYDRATION_MARKER_ID: () => HYDRATION_MARKER_ID,
24642
24643
  Loggable: () => Loggable,
24643
24644
  NOT_SET: () => NOT_SET,
24644
24645
  NavigatorRole: () => NavigatorRole,
@@ -24654,8 +24655,10 @@ var init_v4 = __esmMin((() => {
24654
24655
  areQuestionRecords: () => areQuestionRecords,
24655
24656
  buildStrategyStateId: () => buildStrategyStateId,
24656
24657
  captureMixerRun: () => captureMixerRun,
24658
+ captureStrategyPressure: () => captureStrategyPressure,
24657
24659
  clearSrsBacklogDebug: () => clearSrsBacklogDebug,
24658
24660
  clearStaleSessionDebugState: () => clearStaleSessionDebugState,
24661
+ clearStrategyPressureDebug: () => clearStrategyPressureDebug,
24659
24662
  computeDeviation: () => computeDeviation,
24660
24663
  computeEffectiveWeight: () => computeEffectiveWeight,
24661
24664
  computeOutcomeSignal: () => computeOutcomeSignal,
@@ -24678,6 +24681,7 @@ var init_v4 = __esmMin((() => {
24678
24681
  getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
24679
24682
  getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
24680
24683
  getSrsBacklogDebug: () => getSrsBacklogDebug,
24684
+ getStrategyPressureDebug: () => getStrategyPressureDebug,
24681
24685
  getStudySource: () => getStudySource,
24682
24686
  hasRegisteredNavigator: () => hasRegisteredNavigator,
24683
24687
  importParsedCards: () => importParsedCards,
@@ -25254,6 +25258,15 @@ function getSrsBacklogDebug() {
25254
25258
  function clearSrsBacklogDebug() {
25255
25259
  snapshots.clear();
25256
25260
  }
25261
+ function captureStrategyPressure(t) {
25262
+ snapshots2.set(`${t.source}:${t.courseId}`, t);
25263
+ }
25264
+ function getStrategyPressureDebug() {
25265
+ return [...snapshots2.values()].sort((t, c) => c.timestamp - t.timestamp);
25266
+ }
25267
+ function clearStrategyPressureDebug() {
25268
+ snapshots2.clear();
25269
+ }
25257
25270
  function mergeHints(t) {
25258
25271
  let c = t.filter((t) => t !== void 0);
25259
25272
  if (c.length === 0) return;
@@ -25302,6 +25315,12 @@ function shuffleInPlace(t) {
25302
25315
  [t[c], t[u]] = [t[u], t[c]];
25303
25316
  }
25304
25317
  }
25318
+ function formatAge(t) {
25319
+ let c = Math.max(0, Math.round(t / 6e4));
25320
+ if (c < 60) return `${c}m`;
25321
+ let u = Math.round(c / 60);
25322
+ return u < 24 ? `${u}h` : `${Math.round(u / 24)}d`;
25323
+ }
25305
25324
  function pickTopByScore(t, c) {
25306
25325
  return [...t].sort((t, c) => c.score - t.score || t.cardId.localeCompare(c.cardId)).slice(0, c);
25307
25326
  }
@@ -25773,6 +25792,14 @@ function getStartAndEndKeys2(t) {
25773
25792
  endkey: t + "￰"
25774
25793
  };
25775
25794
  }
25795
+ function withTimeout(t, c, u) {
25796
+ let d;
25797
+ return Promise.race([t, new Promise((t, m) => {
25798
+ d = setTimeout(() => m(/* @__PURE__ */ Error(`${u} timed out after ${c}ms`)), c);
25799
+ })]).finally(() => {
25800
+ d !== void 0 && clearTimeout(d);
25801
+ });
25802
+ }
25776
25803
  function accomodateGuest() {
25777
25804
  if (logger.log("[funnel] accomodateGuest() called"), typeof localStorage > "u") return logger.log("[funnel] localStorage not available (Node.js environment), returning default guest"), {
25778
25805
  username: GuestUsername + "nodejs-test",
@@ -26608,7 +26635,7 @@ function render() {
26608
26635
  overlayEl.innerHTML = headerHtml(), attachHandlers();
26609
26636
  return;
26610
26637
  }
26611
- overlayEl.innerHTML = headerHtml() + replanHtml(c) + metaHtml(c) + hintsHtml(c.sessionHints) + backlogHtml(c.reviewBacklog) + queueHtml("supplyQ", "supplyQ", c.supplyQ) + queueHtml("failedQ", "failedQ", c.failedQ) + drawnHtml("drawn", c.drawnCards), attachHandlers();
26638
+ overlayEl.innerHTML = headerHtml() + replanHtml(c) + metaHtml(c) + hintsHtml(c.sessionHints) + backlogHtml(c.reviewBacklog) + strategyPressureHtml(c.strategyPressure) + queueHtml("supplyQ", "supplyQ", c.supplyQ) + queueHtml("failedQ", "failedQ", c.failedQ) + drawnHtml("drawn", c.drawnCards), attachHandlers();
26612
26639
  }
26613
26640
  function attachHandlers() {
26614
26641
  if (!overlayEl) return;
@@ -26660,6 +26687,30 @@ function backlogHtml(t) {
26660
26687
  return `<div style="margin-left:6px"><span style="opacity:.7">${esc(t.courseId.slice(0, 8))}</span> due ${t.dueNow}/${t.scheduledTotal} <span style="opacity:.6">(healthy ${t.healthyBacklog})</span>${g}<div style="margin-left:6px">pressure <span style="color:${u}">\xD7${t.backlogMultiplier.toFixed(2)}</span> <span style="opacity:.6">${d} \xB7 top review ${m}</span></div></div>`;
26661
26688
  }).join("")}</div>` : "";
26662
26689
  }
26690
+ function pressureColor(t, c) {
26691
+ return t <= 1.001 ? "#86efac" : c !== void 0 && c > 1 ? (t - 1) / (c - 1) >= .75 ? "#fca5a5" : "#fcd34d" : t >= 3 ? "#fca5a5" : "#fcd34d";
26692
+ }
26693
+ function toggleKey(t) {
26694
+ return t.replace(/[^\w:.|-]/g, "_");
26695
+ }
26696
+ function gaugeHtml(t, c) {
26697
+ let u = c.max === void 0 ? "" : `<span style="opacity:.5">/${c.max}</span>`, d = c.detail ? ` <span style="opacity:.6">${esc(c.detail)}</span>` : "", m = `<div style="margin-left:6px">${esc(c.label)} <span style="color:${pressureColor(c.multiplier, c.max)}">\xD7${c.multiplier.toFixed(2)}</span>${u}${d}`, g = c.items ?? [];
26698
+ if (g.length > 0) {
26699
+ let u = toggleKey(`sp|${t}|${c.id}`), d = !!expanded[u], b = d ? g : g.slice(0, INLINE_THRESHOLD);
26700
+ if (m += "<div style=\"margin-left:6px\">" + b.map((t) => `<div style="white-space:nowrap;opacity:.75">${esc(t.label)}${t.value ? ` <span style="opacity:.6">${esc(t.value)}</span>` : ""}</div>`).join(""), g.length > INLINE_THRESHOLD) {
26701
+ let t = d ? "▾ show less" : `\u2026 +${g.length - b.length} more`;
26702
+ m += `<div data-q="${u}" style="cursor:pointer;opacity:.6">${t}</div>`;
26703
+ }
26704
+ m += "</div>";
26705
+ }
26706
+ return m + "</div>";
26707
+ }
26708
+ function strategyPressureHtml(t) {
26709
+ return t.length ? `<div style="margin-bottom:6px"><div style="color:#fdba74">strategy backpressure</div>${t.map((t) => {
26710
+ let c = `${t.source}:${t.courseId.slice(0, 8)}`, u = t.topScore !== null && t.topScore !== void 0 ? t.topScore.toFixed(2) : "—", d = t.hintsLabel ? `<div style="margin-left:6px;opacity:.6">hints: ${esc(t.hintsLabel)}</div>` : "";
26711
+ return `<div style="margin-left:6px"><span style="opacity:.7">${esc(t.source)} \xB7 ${esc(t.courseId.slice(0, 8))}</span> <span style="opacity:.6">top score ${u}</span>` + t.gauges.map((t) => gaugeHtml(c, t)).join("") + d + "</div>";
26712
+ }).join("")}</div>` : "";
26713
+ }
26663
26714
  function fmtScore(t) {
26664
26715
  return t === void 0 ? "" : Number.isFinite(t) ? t.toFixed(2) : "REQ";
26665
26716
  }
@@ -26705,6 +26756,19 @@ function snapshotToText(t) {
26705
26756
  c.push(` ${u.courseId.slice(0, 8)}: due ${u.dueNow}/${u.scheduledTotal} (healthy ${u.healthyBacklog})${m}; pressure \xD7${u.backlogMultiplier.toFixed(2)} ${t}; top review ${d}`);
26706
26757
  }
26707
26758
  }
26759
+ if (t.strategyPressure.length) {
26760
+ c.push(""), c.push("strategy backpressure:");
26761
+ for (let u of t.strategyPressure) {
26762
+ let t = u.topScore !== null && u.topScore !== void 0 ? u.topScore.toFixed(2) : "—";
26763
+ c.push(` ${u.source} (${u.courseId.slice(0, 8)}): top score ${t}`);
26764
+ for (let t of u.gauges) {
26765
+ let u = t.max === void 0 ? "" : `/${t.max}`;
26766
+ c.push(` ${t.label} \xD7${t.multiplier.toFixed(2)}${u}${t.detail ? ` \u2014 ${t.detail}` : ""}`);
26767
+ for (let u of t.items ?? []) c.push(` ${u.label}${u.value ? ` (${u.value})` : ""}`);
26768
+ }
26769
+ u.hintsLabel && c.push(` hints: ${u.hintsLabel}`);
26770
+ }
26771
+ }
26708
26772
  let queueText = (t, u) => {
26709
26773
  c.push(""), c.push(`${t}: ${u.length} (drawn ${u.dequeueCount})`), u.cards.forEach((t, u) => {
26710
26774
  let d = fmtScore(t.score), m = `${t.origin === "review" ? "r" : "n"}${d ? " " + d : ""}`;
@@ -26724,7 +26788,7 @@ function esc(t) {
26724
26788
  return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
26725
26789
  }
26726
26790
  function clearStaleSessionDebugState() {
26727
- clearRunHistory(), clearSrsBacklogDebug();
26791
+ clearRunHistory(), clearSrsBacklogDebug(), clearStrategyPressureDebug();
26728
26792
  }
26729
26793
  function startSessionTracking(t, c) {
26730
26794
  let u = `session-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
@@ -26832,7 +26896,7 @@ function mountSessionDebugger() {
26832
26896
  let t = window;
26833
26897
  t.skuilder = t.skuilder || {}, t.skuilder.session = sessionDebugAPI;
26834
26898
  }
26835
- var import___vite_browser_external, import___vite_browser_external$1, import___vite_browser_external$2, import_browser_ponyfill, import_browser_ponyfill$1, import_browser, _SessionController2, __defProp, __getOwnPropNames, __glob, __esm, __export, init_adminDB, init_classroomDB, init_SyncStrategy, isDevelopment, logger, init_logger, GuestUsername, log, DocType, DocTypePrefixes, init_types_legacy, init_util, pouchdb_setup_default, init_pouchdb_setup, init_dataDirectory, REVIEW_TIME_FORMAT, log2, init_userDBHelpers, Loggable, init_Loggable, UpdateQueue, init_updateQueue, UsrCrsData, init_user_course_relDB, CLIENT_CACHE, init_clientCache, AlreadyTaggedErr, init_courseAPI, courseLookupDBTitle, CourseLookup, init_courseLookupDB, diversityRerank_exports, DIVERSITY_STRENGTH, DIVERSITY_FLOOR, STRATEGY, STRATEGY_ID, STRATEGY_NAME, init_diversityRerank, PipelineDebugger_exports, _activePipeline, MAX_RUNS, runHistory, DISCARDED_KEEP_TOP, _uiContainer, _selectedRunIndex, _cardSearchQuery, pipelineDebugAPI, init_PipelineDebugger, SrsDebugger_exports, snapshots, init_SrsDebugger, CompositeGenerator_exports, AggregationMode, DEFAULT_AGGREGATION_MODE, FREQUENCY_BOOST_FACTOR, CompositeGenerator, init_CompositeGenerator, elo_exports, ELO_RELEVANCE_SIGMA, ELONavigator, init_elo, generators_exports, init_generators, prescribed_exports, DEFAULT_FRESHNESS_WINDOW, DEFAULT_MAX_DIRECT_PER_RUN, DEFAULT_MAX_SUPPORT_PER_RUN, DEFAULT_HIERARCHY_DEPTH, DEFAULT_MIN_COUNT, DEFAULT_PRACTICE_MIN_COUNT, DEFAULT_MAX_PRACTICE_PER_RUN, BASE_TARGET_SCORE, BASE_SUPPORT_SCORE, DISCOVERED_SUPPORT_SCORE, BASE_PRACTICE_SCORE, PRACTICE_BASE_MULT, MAX_PRACTICE_MULTIPLIER, PRACTICE_STALENESS_BUMP_PER_DAY, MAX_TARGET_MULTIPLIER, MAX_SUPPORT_MULTIPLIER, PRESCRIBED_DEBUG_VERSION, PrescribedCardsGenerator, init_prescribed, srs_exports, DEFAULT_HEALTHY_BACKLOG, BACKLOG_GROWTH_RATE, SRSNavigator, init_srs, types_exports, init_types, globImport_generators, init_, DEFAULT_LEARNABLE_WEIGHT, init_contentNavigationStrategy, WeightedFilter_exports, WeightedFilter, init_WeightedFilter, eloDistance_exports, DEFAULT_HALF_LIFE, DEFAULT_MIN_MULTIPLIER, DEFAULT_MAX_MULTIPLIER, init_eloDistance, hierarchyDefinition_exports, DEFAULT_MIN_COUNT2, HierarchyDefinitionNavigator, init_hierarchyDefinition, userTagPreference_exports, UserTagPreferenceFilter, init_userTagPreference, filters_exports, init_filters, inferredPreferenceStub_exports, INFERRED_PREFERENCE_NAVIGATOR_STUB, init_inferredPreferenceStub, interferenceMitigator_exports, DEFAULT_MIN_COUNT3, DEFAULT_MIN_ELAPSED_DAYS, DEFAULT_INTERFERENCE_DECAY, InterferenceMitigatorNavigator, init_interferenceMitigator, relativePriority_exports, DEFAULT_PRIORITY, DEFAULT_PRIORITY_INFLUENCE, DEFAULT_COMBINE_MODE, RelativePriorityNavigator, init_relativePriority, types_exports2, init_types2, userGoalStub_exports, USER_GOAL_NAVIGATOR_STUB, init_userGoalStub, globImport_filters, init_2, init_gradient, MIN_OBSERVATIONS_FOR_UPDATE, LEARNING_RATE, MAX_WEIGHT_DELTA, MIN_R_SQUARED_FOR_GRADIENT, FLAT_GRADIENT_THRESHOLD, MAX_HISTORY_LENGTH, init_learning, init_signal, init_recording, MIN_SPREAD, MAX_SPREAD, MIN_WEIGHT, MAX_WEIGHT, init_orchestration, Pipeline_exports, VERBOSE_RESULTS, Pipeline, init_Pipeline, defaults_exports, init_defaults, PipelineAssembler_exports, PipelineAssembler, init_PipelineAssembler, globImport, init_3, navigators_exports, navigatorRegistry, Navigators, NavigatorRole, NavigatorRoles, ContentNavigator, init_navigators, CoursesDB, CourseDB, init_courseDB, classroomLookupDBTitle, CLASSROOM_CONFIG, ClassroomDBBase, StudentClassroomDB, TeacherClassroomDB, ClassroomLookupDB, init_classroomDB2, AdminDB, init_adminDB2, CourseSyncService_exports, DEFAULT_REPLICATION, CourseSyncService, init_CourseSyncService, init_auth, CouchDBSyncStrategy_exports, log3, CouchDBSyncStrategy, init_CouchDBSyncStrategy, isBrowser, GUEST_LOCAL_DB, localUserDB, pouchDBincludeCredentialsConfig, REVIEW_TIME_FORMAT2, init_couch, log4, BaseUser, userCoursesDoc, userClassroomsDoc, init_BaseUserDB, init_common, PouchDataLayerProvider_exports, CouchDataLayerProvider, init_PouchDataLayerProvider, pathUtils, nodeFS, StaticDataUnpacker, init_StaticDataUnpacker, StaticCourseDB, init_courseDB2, StaticCoursesDB, init_coursesDB, NoOpSyncStrategy, init_NoOpSyncStrategy, StaticDataLayerProvider_exports, StaticDataLayerProvider, init_StaticDataLayerProvider, NOT_SET, ENV, dataLayerInstance, init_factory, TagFilteredContentSource, init_TagFilteredContentSource, init_contentSource, init_courseDB3, init_dataLayerProvider, init_userDB, init_interfaces, init_user, init_strategyState, init_userOutcome, init_cardProcessor, init_types3, init_bulkImport, userDBDebugAPI, init_UserDBDebugger, init_core, duration, SrsService, EloService, ResponseProcessor, CardHydrationService, ItemQueue, CouchDBToStaticPacker, DEFAULT_MIGRATION_OPTIONS, FileSystemError, nodeFS2, nodeFS3, nodePath, StaticToCouchDBMigrator, QuotaRoundRobinMixer, MAX_RUNS2, runHistory2, mixerDebugAPI, activeController, OVERLAY_ID, POLL_MS, INLINE_THRESHOLD, SPINNER_FRAMES, spinnerFrame, overlayEl, pollHandle, lastSnapshot, copyFlashUntil, minified, expanded, activeSession, sessionHistory, MAX_HISTORY, sessionDebugAPI, SessionController, init_dist = __esmMin((() => {
26899
+ var import___vite_browser_external, import___vite_browser_external$1, import___vite_browser_external$2, import_browser_ponyfill, import_browser_ponyfill$1, import_browser, _SessionController2, __defProp, __getOwnPropNames, __glob, __esm, __export, init_adminDB, init_classroomDB, init_SyncStrategy, isDevelopment, logger, init_logger, GuestUsername, log, DocType, DocTypePrefixes, init_types_legacy, init_util, pouchdb_setup_default, init_pouchdb_setup, init_dataDirectory, REVIEW_TIME_FORMAT, log2, init_userDBHelpers, Loggable, init_Loggable, UpdateQueue, init_updateQueue, UsrCrsData, init_user_course_relDB, CLIENT_CACHE, init_clientCache, AlreadyTaggedErr, init_courseAPI, courseLookupDBTitle, CourseLookup, init_courseLookupDB, diversityRerank_exports, DIVERSITY_STRENGTH, DIVERSITY_FLOOR, STRATEGY, STRATEGY_ID, STRATEGY_NAME, init_diversityRerank, PipelineDebugger_exports, _activePipeline, MAX_RUNS, runHistory, DISCARDED_KEEP_TOP, _uiContainer, _selectedRunIndex, _cardSearchQuery, pipelineDebugAPI, init_PipelineDebugger, SrsDebugger_exports, snapshots, init_SrsDebugger, StrategyPressureDebugger_exports, snapshots2, init_StrategyPressureDebugger, CompositeGenerator_exports, AggregationMode, DEFAULT_AGGREGATION_MODE, FREQUENCY_BOOST_FACTOR, CompositeGenerator, init_CompositeGenerator, elo_exports, ELO_RELEVANCE_SIGMA, ELONavigator, init_elo, generators_exports, init_generators, prescribed_exports, DEFAULT_FRESHNESS_WINDOW, DEFAULT_MAX_DIRECT_PER_RUN, DEFAULT_MAX_SUPPORT_PER_RUN, DEFAULT_HIERARCHY_DEPTH, DEFAULT_MIN_COUNT, DEFAULT_PRACTICE_MIN_COUNT, DEFAULT_MAX_PRACTICE_PER_RUN, BASE_TARGET_SCORE, BASE_SUPPORT_SCORE, DISCOVERED_SUPPORT_SCORE, BASE_PRACTICE_SCORE, PRACTICE_BASE_MULT, MAX_PRACTICE_MULTIPLIER, PRACTICE_STALENESS_BUMP_PER_DAY, MAX_TARGET_MULTIPLIER, MAX_SUPPORT_MULTIPLIER, PRESCRIBED_DEBUG_VERSION, PrescribedCardsGenerator, init_prescribed, srs_exports, DEFAULT_HEALTHY_BACKLOG, BACKLOG_GROWTH_RATE, SRSNavigator, init_srs, types_exports, init_types, globImport_generators, init_, DEFAULT_LEARNABLE_WEIGHT, init_contentNavigationStrategy, WeightedFilter_exports, WeightedFilter, init_WeightedFilter, eloDistance_exports, DEFAULT_HALF_LIFE, DEFAULT_MIN_MULTIPLIER, DEFAULT_MAX_MULTIPLIER, init_eloDistance, hierarchyDefinition_exports, DEFAULT_MIN_COUNT2, HierarchyDefinitionNavigator, init_hierarchyDefinition, userTagPreference_exports, UserTagPreferenceFilter, init_userTagPreference, filters_exports, init_filters, inferredPreferenceStub_exports, INFERRED_PREFERENCE_NAVIGATOR_STUB, init_inferredPreferenceStub, interferenceMitigator_exports, DEFAULT_MIN_COUNT3, DEFAULT_MIN_ELAPSED_DAYS, DEFAULT_INTERFERENCE_DECAY, InterferenceMitigatorNavigator, init_interferenceMitigator, relativePriority_exports, DEFAULT_PRIORITY, DEFAULT_PRIORITY_INFLUENCE, DEFAULT_COMBINE_MODE, RelativePriorityNavigator, init_relativePriority, types_exports2, init_types2, userGoalStub_exports, USER_GOAL_NAVIGATOR_STUB, init_userGoalStub, globImport_filters, init_2, init_gradient, MIN_OBSERVATIONS_FOR_UPDATE, LEARNING_RATE, MAX_WEIGHT_DELTA, MIN_R_SQUARED_FOR_GRADIENT, FLAT_GRADIENT_THRESHOLD, MAX_HISTORY_LENGTH, init_learning, init_signal, init_recording, MIN_SPREAD, MAX_SPREAD, MIN_WEIGHT, MAX_WEIGHT, init_orchestration, Pipeline_exports, VERBOSE_RESULTS, Pipeline, init_Pipeline, defaults_exports, init_defaults, PipelineAssembler_exports, PipelineAssembler, init_PipelineAssembler, globImport, init_3, navigators_exports, navigatorRegistry, Navigators, NavigatorRole, NavigatorRoles, ContentNavigator, init_navigators, CoursesDB, CourseDB, init_courseDB, classroomLookupDBTitle, CLASSROOM_CONFIG, ClassroomDBBase, StudentClassroomDB, TeacherClassroomDB, ClassroomLookupDB, init_classroomDB2, AdminDB, init_adminDB2, CourseSyncService_exports, DEFAULT_REPLICATION, CourseSyncService, init_CourseSyncService, init_auth, CouchDBSyncStrategy_exports, log3, CouchDBSyncStrategy, init_CouchDBSyncStrategy, isBrowser, GUEST_LOCAL_DB, localUserDB, pouchDBincludeCredentialsConfig, REVIEW_TIME_FORMAT2, init_couch, log4, HYDRATION_TIMEOUT_MS, BaseUser, userCoursesDoc, userClassroomsDoc, init_BaseUserDB, init_common, PouchDataLayerProvider_exports, CouchDataLayerProvider, init_PouchDataLayerProvider, pathUtils, nodeFS, StaticDataUnpacker, init_StaticDataUnpacker, StaticCourseDB, init_courseDB2, StaticCoursesDB, init_coursesDB, NoOpSyncStrategy, init_NoOpSyncStrategy, StaticDataLayerProvider_exports, StaticDataLayerProvider, init_StaticDataLayerProvider, NOT_SET, ENV, dataLayerInstance, init_factory, TagFilteredContentSource, init_TagFilteredContentSource, init_contentSource, init_courseDB3, init_dataLayerProvider, init_userDB, init_interfaces, init_user, init_strategyState, init_userOutcome, HYDRATION_MARKER_ID, init_hydration, init_cardProcessor, init_types3, init_bulkImport, userDBDebugAPI, init_UserDBDebugger, init_core, duration, SrsService, EloService, ResponseProcessor, CardHydrationService, ItemQueue, CouchDBToStaticPacker, DEFAULT_MIGRATION_OPTIONS, FileSystemError, nodeFS2, nodeFS3, nodePath, StaticToCouchDBMigrator, QuotaRoundRobinMixer, MAX_RUNS2, runHistory2, mixerDebugAPI, activeController, OVERLAY_ID, POLL_MS, INLINE_THRESHOLD, SPINNER_FRAMES, spinnerFrame, overlayEl, pollHandle, lastSnapshot, copyFlashUntil, minified, expanded, activeSession, sessionHistory, MAX_HISTORY, sessionDebugAPI, SessionController, init_dist = __esmMin((() => {
26836
26900
  init_defineProperty(), init_index_browser_es$5(), init_index_browser_es(), init_index_es(), import___vite_browser_external = /* @__PURE__ */ __toESM$2(require___vite_browser_external(), 1), import___vite_browser_external$1 = /* @__PURE__ */ __toESM$2(require___vite_browser_external(), 1), import___vite_browser_external$2 = /* @__PURE__ */ __toESM$2(require___vite_browser_external(), 1), init_moment(), init_dist$1(), init_esm_browser(), import_browser_ponyfill = /* @__PURE__ */ __toESM$2(require_browser_ponyfill(), 1), import_browser_ponyfill$1 = /* @__PURE__ */ __toESM$2(require_browser_ponyfill(), 1), import_browser = /* @__PURE__ */ __toESM$2(require_browser(), 1), __defProp = Object.defineProperty, __getOwnPropNames = Object.getOwnPropertyNames, __glob = (t) => (c) => {
26837
26901
  var u = t[c];
26838
26902
  if (u) return u();
@@ -27266,6 +27330,12 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
27266
27330
  getSrsBacklogDebug: () => getSrsBacklogDebug
27267
27331
  }), init_SrsDebugger = __esm({ "src/core/navigators/SrsDebugger.ts"() {
27268
27332
  snapshots = /* @__PURE__ */ new Map();
27333
+ } }), StrategyPressureDebugger_exports = {}, __export(StrategyPressureDebugger_exports, {
27334
+ captureStrategyPressure: () => captureStrategyPressure,
27335
+ clearStrategyPressureDebug: () => clearStrategyPressureDebug,
27336
+ getStrategyPressureDebug: () => getStrategyPressureDebug
27337
+ }), init_StrategyPressureDebugger = __esm({ "src/core/navigators/StrategyPressureDebugger.ts"() {
27338
+ snapshots2 = /* @__PURE__ */ new Map();
27269
27339
  } }), CompositeGenerator_exports = {}, __export(CompositeGenerator_exports, {
27270
27340
  AggregationMode: () => AggregationMode,
27271
27341
  default: () => CompositeGenerator
@@ -27400,7 +27470,7 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
27400
27470
  }
27401
27471
  };
27402
27472
  } }), generators_exports = {}, init_generators = __esm({ "src/core/navigators/generators/index.ts"() {} }), prescribed_exports = {}, __export(prescribed_exports, { default: () => PrescribedCardsGenerator }), init_prescribed = __esm({ "src/core/navigators/generators/prescribed.ts"() {
27403
- init_navigators(), init_logger(), DEFAULT_FRESHNESS_WINDOW = 3, DEFAULT_MAX_DIRECT_PER_RUN = 3, DEFAULT_MAX_SUPPORT_PER_RUN = 3, DEFAULT_HIERARCHY_DEPTH = 2, DEFAULT_MIN_COUNT = 3, DEFAULT_PRACTICE_MIN_COUNT = 3, DEFAULT_MAX_PRACTICE_PER_RUN = 4, BASE_TARGET_SCORE = 1, BASE_SUPPORT_SCORE = .8, DISCOVERED_SUPPORT_SCORE = 12, BASE_PRACTICE_SCORE = 1, PRACTICE_BASE_MULT = 2, MAX_PRACTICE_MULTIPLIER = 4, PRACTICE_STALENESS_BUMP_PER_DAY = .5, MAX_TARGET_MULTIPLIER = 8, MAX_SUPPORT_MULTIPLIER = 4, PRESCRIBED_DEBUG_VERSION = "testversion-prescribed-v3", PrescribedCardsGenerator = class extends ContentNavigator {
27473
+ init_navigators(), init_StrategyPressureDebugger(), init_logger(), DEFAULT_FRESHNESS_WINDOW = 3, DEFAULT_MAX_DIRECT_PER_RUN = 3, DEFAULT_MAX_SUPPORT_PER_RUN = 3, DEFAULT_HIERARCHY_DEPTH = 2, DEFAULT_MIN_COUNT = 3, DEFAULT_PRACTICE_MIN_COUNT = 3, DEFAULT_MAX_PRACTICE_PER_RUN = 4, BASE_TARGET_SCORE = 1, BASE_SUPPORT_SCORE = .8, DISCOVERED_SUPPORT_SCORE = 12, BASE_PRACTICE_SCORE = 1, PRACTICE_BASE_MULT = 2, MAX_PRACTICE_MULTIPLIER = 4, PRACTICE_STALENESS_BUMP_PER_DAY = .5, MAX_TARGET_MULTIPLIER = 8, MAX_SUPPORT_MULTIPLIER = 4, PRESCRIBED_DEBUG_VERSION = "testversion-prescribed-v3", PrescribedCardsGenerator = class extends ContentNavigator {
27404
27474
  constructor(t, c, u) {
27405
27475
  super(t, c, u), _defineProperty$2(this, "name", void 0), _defineProperty$2(this, "config", void 0), this.name = u.name || "Prescribed Cards", this.config = this.parseConfig(u.serializedData), logger.debug(`[Prescribed] Initialized with ${this.config.groups.length} groups and ${this.config.groups.reduce((t, c) => t + c.targetCardIds.length, 0)} targets`);
27406
27476
  }
@@ -27424,7 +27494,7 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
27424
27494
  let Cr = {
27425
27495
  updatedAt: isoNow(),
27426
27496
  groups: {}
27427
- }, wr = [], Tr = /* @__PURE__ */ new Set(), Er = [], Dr = S.practiceDebt ?? {}, Or = {};
27497
+ }, wr = [], Tr = /* @__PURE__ */ new Set(), Er = [], Dr = S.practiceDebt ?? {}, Or = {}, kr = /* @__PURE__ */ new Map();
27428
27498
  for (let t of this.config.groups) {
27429
27499
  let c = this.buildGroupRuntimeState({
27430
27500
  group: t,
@@ -27451,43 +27521,43 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
27451
27521
  priorPracticeDebt: Dr,
27452
27522
  nextPracticeDebt: Or
27453
27523
  });
27454
- wr.push(...d, ...g, ...w, ...D);
27524
+ kr.set(t.id, D.debts), wr.push(...d, ...g, ...w, ...D.cards);
27455
27525
  }
27456
27526
  Cr.practiceDebt = Or;
27457
- let kr = this.buildSupportHintSummary(Er), Ar = Object.keys(kr.boostTags).length > 0 ? {
27458
- boostTags: kr.boostTags,
27459
- _label: `prescribed-support (${kr.supportTags.length} tags; blocked=${kr.blockedTargetIds.length}; testversion=${PRESCRIBED_DEBUG_VERSION})`
27527
+ let Ar = this.buildSupportHintSummary(Er), jr = Object.keys(Ar.boostTags).length > 0 ? {
27528
+ boostTags: Ar.boostTags,
27529
+ _label: `prescribed-support (${Ar.supportTags.length} tags; blocked=${Ar.blockedTargetIds.length}; testversion=${PRESCRIBED_DEBUG_VERSION})`
27460
27530
  } : void 0;
27461
- if (Ar) {
27462
- let t = Object.entries(Ar.boostTags ?? {});
27531
+ if (jr) {
27532
+ let t = Object.entries(jr.boostTags ?? {});
27463
27533
  logger.info(`[Prescribed] Emitting ${t.length} boost hint(s): ` + t.map(([t, c]) => `${t}\xD7${c.toFixed(1)}`).join(", "));
27464
27534
  } else logger.info("[Prescribed] No hints to emit (no blocked targets or no support tags)");
27465
- if (wr.length === 0) return logger.info("[Prescribed] 0 cards emitted (all targets blocked, authored/discovered support candidates exhausted)" + (Ar ? " — boost hints emitted but may not survive filters" : "")), await this.putStrategyState(Cr).catch((t) => {
27535
+ if (this.capturePressureSnapshot(u, Er, kr, wr, jr), wr.length === 0) return logger.info("[Prescribed] 0 cards emitted (all targets blocked, authored/discovered support candidates exhausted)" + (jr ? " — boost hints emitted but may not survive filters" : "")), await this.putStrategyState(Cr).catch((t) => {
27466
27536
  logger.debug(`[Prescribed] Failed to persist empty-state update: ${t}`);
27467
- }), Ar ? {
27537
+ }), jr ? {
27468
27538
  cards: [],
27469
- hints: Ar
27539
+ hints: jr
27470
27540
  } : { cards: [] };
27471
- let jr = pickTopByScore(wr, t), Mr = /* @__PURE__ */ new Map();
27472
- for (let t of jr) {
27541
+ let Mr = pickTopByScore(wr, t), Nr = /* @__PURE__ */ new Map();
27542
+ for (let t of Mr) {
27473
27543
  let c = t.provenance[0];
27474
27544
  if (c?.reason.includes("mode=practice")) continue;
27475
27545
  let u = c?.reason.match(/group=([^;]+)/)?.[1], d = c?.reason.includes("mode=support") ? "supportIds" : "targetIds";
27476
- u && (Mr.has(u) || Mr.set(u, {
27546
+ u && (Nr.has(u) || Nr.set(u, {
27477
27547
  targetIds: [],
27478
27548
  supportIds: []
27479
- }), Mr.get(u)[d].push(t.cardId));
27549
+ }), Nr.get(u)[d].push(t.cardId));
27480
27550
  }
27481
27551
  for (let t of this.config.groups) {
27482
- let c = Cr.groups[t.id], u = Mr.get(t.id);
27552
+ let c = Cr.groups[t.id], u = Nr.get(t.id);
27483
27553
  u && (u.targetIds.length > 0 || u.supportIds.length > 0) && (c.lastSurfacedAt = isoNow(), c.sessionsSinceSurfaced = 0, u.supportIds.length > 0 && (c.lastSupportAt = isoNow()));
27484
27554
  }
27485
27555
  return await this.putStrategyState(Cr).catch((t) => {
27486
27556
  logger.debug(`[Prescribed] Failed to persist prescribed progress: ${t}`);
27487
- }), logger.info(`[Prescribed] Emitting ${jr.length} cards (${jr.filter((t) => t.provenance[0]?.reason.includes("mode=target")).length} target, ${jr.filter((t) => t.provenance[0]?.reason.includes("mode=support")).length} support, ${jr.filter((t) => t.provenance[0]?.reason.includes("mode=discovered-support")).length} discovered support)`), Ar ? {
27488
- cards: jr,
27489
- hints: Ar
27490
- } : { cards: jr };
27557
+ }), logger.info(`[Prescribed] Emitting ${Mr.length} cards (${Mr.filter((t) => t.provenance[0]?.reason.includes("mode=target")).length} target, ${Mr.filter((t) => t.provenance[0]?.reason.includes("mode=support")).length} support, ${Mr.filter((t) => t.provenance[0]?.reason.includes("mode=discovered-support")).length} discovered support)`), jr ? {
27558
+ cards: Mr,
27559
+ hints: jr
27560
+ } : { cards: Mr };
27491
27561
  }
27492
27562
  buildSupportHintSummary(t) {
27493
27563
  let c = {}, u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
@@ -27501,6 +27571,53 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
27501
27571
  supportTags: [...d].sort()
27502
27572
  };
27503
27573
  }
27574
+ capturePressureSnapshot(t, c, u, d, m) {
27575
+ let g = Date.now(), b = [];
27576
+ for (let t of c) {
27577
+ let c = t.group, d = c.freshnessWindowSessions ?? DEFAULT_FRESHNESS_WINDOW;
27578
+ if (b.push({
27579
+ id: `group:${c.id}:target`,
27580
+ label: `${c.id} targets`,
27581
+ multiplier: t.pressureMultiplier,
27582
+ max: MAX_TARGET_MULTIPLIER,
27583
+ detail: `${t.pendingTargets.length} pending (${t.surfaceableTargets.length} surfaceable, ${t.blockedTargets.length} blocked) \xB7 sinceSurfaced ${t.sessionsSinceSurfaced}/${d}`,
27584
+ items: t.blockedTargets.map((t) => ({
27585
+ label: t,
27586
+ value: "blocked"
27587
+ }))
27588
+ }), t.blockedTargets.length > 0) {
27589
+ let u = t.supportCandidates.length > 0 ? "direct-support" : t.discoveredSupportCandidates.length > 0 ? "inserted-support" : "boost-only";
27590
+ b.push({
27591
+ id: `group:${c.id}:support`,
27592
+ label: `${c.id} support`,
27593
+ multiplier: t.supportMultiplier,
27594
+ max: MAX_SUPPORT_MULTIPLIER,
27595
+ detail: `mode=${u} \xB7 ${t.supportTags.length} support tag(s)`,
27596
+ items: t.supportTags.map((t) => ({ label: t }))
27597
+ });
27598
+ }
27599
+ let m = u.get(c.id) ?? [];
27600
+ m.length > 0 && b.push({
27601
+ id: `group:${c.id}:practice-debt`,
27602
+ label: `${c.id} practice debt`,
27603
+ multiplier: Math.max(...m.map((t) => t.multiplier)),
27604
+ max: MAX_PRACTICE_MULTIPLIER,
27605
+ detail: `${m.length} under-practiced skill(s)`,
27606
+ items: m.map((t) => ({
27607
+ label: t.tag,
27608
+ value: `\xD7${t.multiplier.toFixed(2)} \xB7 open ${formatAge(g - new Date(t.firstOwedAt).getTime())}`
27609
+ }))
27610
+ });
27611
+ }
27612
+ captureStrategyPressure({
27613
+ source: "prescribed",
27614
+ courseId: t,
27615
+ gauges: b,
27616
+ topScore: d.length > 0 ? Math.max(...d.map((t) => t.score)) : null,
27617
+ hintsLabel: m?._label,
27618
+ timestamp: g
27619
+ });
27620
+ }
27504
27621
  parseConfig(t) {
27505
27622
  try {
27506
27623
  let c = JSON.parse(t);
@@ -27579,6 +27696,7 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
27579
27696
  supportTags: [...br],
27580
27697
  pressureMultiplier: Er,
27581
27698
  supportMultiplier: Dr,
27699
+ sessionsSinceSurfaced: Cr,
27582
27700
  debugVersion: PRESCRIBED_DEBUG_VERSION
27583
27701
  };
27584
27702
  }
@@ -27649,9 +27767,15 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
27649
27767
  }
27650
27768
  buildPracticeCards(t) {
27651
27769
  let { group: c, courseId: u, emittedIds: d, cardsByTag: m, hierarchyConfigs: g, userTagElo: b, userGlobalElo: S, activeIds: C, seenIds: w, priorPracticeDebt: T, nextPracticeDebt: E } = t, D = c.practiceTagPatterns ?? [];
27652
- if (D.length === 0) return [];
27770
+ if (D.length === 0) return {
27771
+ cards: [],
27772
+ debts: []
27773
+ };
27653
27774
  let O = c.practiceMinCount ?? DEFAULT_PRACTICE_MIN_COUNT, yr = c.maxPracticeCardsPerRun ?? DEFAULT_MAX_PRACTICE_PER_RUN, br = [...m.keys()].filter((t) => D.some((c) => matchesTagPattern(t, c)) && this.isUnlockedGatedSkill(t, g, b, S) && (b[t]?.count ?? 0) < O);
27654
- if (br.length === 0) return [];
27775
+ if (br.length === 0) return {
27776
+ cards: [],
27777
+ debts: []
27778
+ };
27655
27779
  let xr = Date.now(), Sr = 1440 * 60 * 1e3, Cr = /* @__PURE__ */ new Map();
27656
27780
  for (let t of br) {
27657
27781
  let c = T[t] ?? isoNow();
@@ -27659,7 +27783,11 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
27659
27783
  let u = Math.max(0, (xr - new Date(c).getTime()) / 864e5), d = clamp(PRACTICE_BASE_MULT + u * PRACTICE_STALENESS_BUMP_PER_DAY, PRACTICE_BASE_MULT, MAX_PRACTICE_MULTIPLIER);
27660
27784
  Cr.set(t, d);
27661
27785
  }
27662
- let wr = this.findDiscoveredSupportCards({
27786
+ let wr = br.map((t) => ({
27787
+ tag: t,
27788
+ multiplier: Cr.get(t) ?? PRACTICE_BASE_MULT,
27789
+ firstOwedAt: E[t]
27790
+ })).sort((t, c) => c.multiplier - t.multiplier || t.tag.localeCompare(c.tag)), Tr = this.findDiscoveredSupportCards({
27663
27791
  supportTags: br,
27664
27792
  cardsByTag: m,
27665
27793
  activeIds: C,
@@ -27667,15 +27795,18 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
27667
27795
  excludedIds: d,
27668
27796
  limit: yr
27669
27797
  });
27670
- if (wr.length === 0) return [];
27671
- logger.info(`[Prescribed] Group '${c.id}' practice: ${br.length} unlocked under-practiced skill(s), emitting ${wr.length} drill card(s)`);
27672
- let Tr = [];
27673
- for (let t of wr) {
27798
+ if (Tr.length === 0) return {
27799
+ cards: [],
27800
+ debts: wr
27801
+ };
27802
+ logger.info(`[Prescribed] Group '${c.id}' practice: ${br.length} unlocked under-practiced skill(s), emitting ${Tr.length} drill card(s)`);
27803
+ let Er = [];
27804
+ for (let t of Tr) {
27674
27805
  d.add(t);
27675
27806
  let g = PRACTICE_BASE_MULT;
27676
27807
  for (let c of br) (m.get(c)?.includes(t) ?? !1) && (g = Math.max(g, Cr.get(c) ?? PRACTICE_BASE_MULT));
27677
27808
  let b = BASE_PRACTICE_SCORE * g;
27678
- Tr.push({
27809
+ Er.push({
27679
27810
  cardId: t,
27680
27811
  courseId: u,
27681
27812
  score: b,
@@ -27689,7 +27820,10 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
27689
27820
  }]
27690
27821
  });
27691
27822
  }
27692
- return Tr;
27823
+ return {
27824
+ cards: Er,
27825
+ debts: wr
27826
+ };
27693
27827
  }
27694
27828
  isUnlockedGatedSkill(t, c, u, d) {
27695
27829
  let m = c.map((c) => c.prerequisites[t]).filter((t) => Array.isArray(t) && t.length > 0);
@@ -28622,6 +28756,7 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
28622
28756
  "./PipelineAssembler.ts": () => Promise.resolve().then(() => (init_PipelineAssembler(), PipelineAssembler_exports)),
28623
28757
  "./PipelineDebugger.ts": () => Promise.resolve().then(() => (init_PipelineDebugger(), PipelineDebugger_exports)),
28624
28758
  "./SrsDebugger.ts": () => Promise.resolve().then(() => (init_SrsDebugger(), SrsDebugger_exports)),
28759
+ "./StrategyPressureDebugger.ts": () => Promise.resolve().then(() => (init_StrategyPressureDebugger(), StrategyPressureDebugger_exports)),
28625
28760
  "./defaults.ts": () => Promise.resolve().then(() => (init_defaults(), defaults_exports)),
28626
28761
  "./diversityRerank.ts": () => Promise.resolve().then(() => (init_diversityRerank(), diversityRerank_exports)),
28627
28762
  "./filters/WeightedFilter.ts": () => Promise.resolve().then(() => (init_WeightedFilter(), WeightedFilter_exports)),
@@ -28649,7 +28784,9 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
28649
28784
  NavigatorRole: () => NavigatorRole,
28650
28785
  NavigatorRoles: () => NavigatorRoles,
28651
28786
  Navigators: () => Navigators,
28787
+ captureStrategyPressure: () => captureStrategyPressure,
28652
28788
  clearSrsBacklogDebug: () => clearSrsBacklogDebug,
28789
+ clearStrategyPressureDebug: () => clearStrategyPressureDebug,
28653
28790
  diversityRerank: () => diversityRerank,
28654
28791
  getActivePipeline: () => getActivePipeline,
28655
28792
  getCardOrigin: () => getCardOrigin,
@@ -28657,6 +28794,7 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
28657
28794
  getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
28658
28795
  getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
28659
28796
  getSrsBacklogDebug: () => getSrsBacklogDebug,
28797
+ getStrategyPressureDebug: () => getStrategyPressureDebug,
28660
28798
  hasRegisteredNavigator: () => hasRegisteredNavigator,
28661
28799
  initializeNavigatorRegistry: () => initializeNavigatorRegistry,
28662
28800
  isFilter: () => isFilter,
@@ -28665,7 +28803,7 @@ var import___vite_browser_external, import___vite_browser_external$1, import___v
28665
28803
  pipelineDebugAPI: () => pipelineDebugAPI,
28666
28804
  registerNavigator: () => registerNavigator
28667
28805
  }), init_navigators = __esm({ "src/core/navigators/index.ts"() {
28668
- init_diversityRerank(), init_PipelineDebugger(), init_SrsDebugger(), init_logger(), init_(), init_2(), init_3(), navigatorRegistry = /* @__PURE__ */ new Map(), Navigators = /* @__PURE__ */ ((t) => (t.ELO = "elo", t.SRS = "srs", t.PRESCRIBED = "prescribed", t.HIERARCHY = "hierarchyDefinition", t.INTERFERENCE = "interferenceMitigator", t.RELATIVE_PRIORITY = "relativePriority", t.USER_TAG_PREFERENCE = "userTagPreference", t))(Navigators || {}), NavigatorRole = /* @__PURE__ */ ((t) => (t.GENERATOR = "generator", t.FILTER = "filter", t))(NavigatorRole || {}), NavigatorRoles = {
28806
+ init_diversityRerank(), init_PipelineDebugger(), init_SrsDebugger(), init_StrategyPressureDebugger(), init_logger(), init_(), init_2(), init_3(), navigatorRegistry = /* @__PURE__ */ new Map(), Navigators = /* @__PURE__ */ ((t) => (t.ELO = "elo", t.SRS = "srs", t.PRESCRIBED = "prescribed", t.HIERARCHY = "hierarchyDefinition", t.INTERFERENCE = "interferenceMitigator", t.RELATIVE_PRIORITY = "relativePriority", t.USER_TAG_PREFERENCE = "userTagPreference", t))(Navigators || {}), NavigatorRole = /* @__PURE__ */ ((t) => (t.GENERATOR = "generator", t.FILTER = "filter", t))(NavigatorRole || {}), NavigatorRoles = {
28669
28807
  elo: "generator",
28670
28808
  srs: "generator",
28671
28809
  prescribed: "generator",
@@ -29485,7 +29623,7 @@ ${t.stack}` : JSON.stringify(t);
29485
29623
  logger.info(t);
29486
29624
  }, CouchDBSyncStrategy = class {
29487
29625
  constructor() {
29488
- _defineProperty$2(this, "syncHandle", void 0);
29626
+ _defineProperty$2(this, "syncHandle", void 0), _defineProperty$2(this, "hydrationHandle", void 0);
29489
29627
  }
29490
29628
  setupRemoteDB(t) {
29491
29629
  return t === GuestUsername || t.startsWith(GuestUsername) ? getLocalUserDB(t) : this.getUserDB(t);
@@ -29493,14 +29631,38 @@ ${t.stack}` : JSON.stringify(t);
29493
29631
  getWriteDB(t) {
29494
29632
  return t === GuestUsername || t.startsWith(GuestUsername) ? getLocalUserDB(t) : this.getUserDB(t);
29495
29633
  }
29634
+ async hydrate(t, c) {
29635
+ let u = pouchdb_setup_default.replicate(c, t, {});
29636
+ this.hydrationHandle = u;
29637
+ try {
29638
+ return { docsWritten: (await u).docs_written };
29639
+ } finally {
29640
+ this.hydrationHandle = void 0;
29641
+ }
29642
+ }
29496
29643
  startSync(t, c) {
29497
- t !== c && (this.syncHandle = pouchdb_setup_default.sync(t, c, {
29644
+ t.name !== c.name && (this.syncHandle = pouchdb_setup_default.sync(t, c, {
29498
29645
  live: !0,
29499
29646
  retry: !0
29500
29647
  }));
29501
29648
  }
29502
29649
  stopSync() {
29503
- this.syncHandle && (this.syncHandle.cancel(), this.syncHandle = void 0);
29650
+ if (this.hydrationHandle) {
29651
+ try {
29652
+ this.hydrationHandle.cancel();
29653
+ } catch (t) {
29654
+ logger.warn(`Failed to cancel hydration pull (continuing anyway): ${t}`);
29655
+ }
29656
+ this.hydrationHandle = void 0;
29657
+ }
29658
+ if (this.syncHandle) {
29659
+ try {
29660
+ this.syncHandle.cancel();
29661
+ } catch (t) {
29662
+ logger.warn(`Failed to cancel user sync (continuing anyway): ${t}`);
29663
+ }
29664
+ this.syncHandle = void 0;
29665
+ }
29504
29666
  }
29505
29667
  canCreateAccount() {
29506
29668
  return !0;
@@ -29630,7 +29792,7 @@ ${t.stack}` : JSON.stringify(t);
29630
29792
  var t;
29631
29793
  init_core(), init_util(), init_types_legacy(), init_logger(), init_userDBHelpers(), init_updateQueue(), init_user_course_relDB(), init_couch(), log4 = (t) => {
29632
29794
  logger.info(t);
29633
- }, BaseUser = (t = class _BaseUser {
29795
+ }, HYDRATION_TIMEOUT_MS = 15e3, BaseUser = (t = class _BaseUser {
29634
29796
  static Dummy(t) {
29635
29797
  return new _BaseUser("Me", t);
29636
29798
  }
@@ -29643,6 +29805,12 @@ ${t.stack}` : JSON.stringify(t);
29643
29805
  remote() {
29644
29806
  return this.remoteDB;
29645
29807
  }
29808
+ hydrationStatus() {
29809
+ return { ...this._hydration };
29810
+ }
29811
+ canMaterializeDefaults() {
29812
+ return this._hydration.state !== "failed" && this._hydration.state !== "hydrating";
29813
+ }
29646
29814
  async createAccount(t, c) {
29647
29815
  if (!this.syncStrategy.canCreateAccount()) throw Error("Account creation not supported by current sync strategy");
29648
29816
  if (!this._username.startsWith(GuestUsername)) throw Error(`Cannot create a new account while logged in:
@@ -29725,12 +29893,14 @@ Currently logged-in as ${this._username}.`);
29725
29893
  try {
29726
29894
  return await this.localDB.get(_BaseUser.DOC_IDS.COURSE_REGISTRATIONS);
29727
29895
  } catch (c) {
29728
- if (c.status === 404) await this.localDB.put({
29729
- _id: _BaseUser.DOC_IDS.COURSE_REGISTRATIONS,
29730
- courses: [],
29731
- studyWeight: {}
29732
- }), t = await this.getCourseRegistrationsDoc();
29733
- else throw Error(`Unexpected error ${JSON.stringify(c)} in getOrCreateCourseRegistrationDoc...`);
29896
+ if (c.status === 404) {
29897
+ if (!this.canMaterializeDefaults()) throw Error(`Cannot read course registrations for ${this._username}: the local mirror is unavailable (hydration state '${this._hydration.state}'). Refusing to create an empty registration doc \u2014 that would report an existing user as unregistered, and then lose to their real document once sync resumes.`);
29898
+ await this.localDB.put({
29899
+ _id: _BaseUser.DOC_IDS.COURSE_REGISTRATIONS,
29900
+ courses: [],
29901
+ studyWeight: {}
29902
+ }), t = await this.getCourseRegistrationsDoc();
29903
+ } else throw Error(`Unexpected error ${JSON.stringify(c)} in getOrCreateCourseRegistrationDoc...`);
29734
29904
  }
29735
29905
  return t;
29736
29906
  }
@@ -29873,8 +30043,10 @@ Currently logged-in as ${this._username}.`);
29873
30043
  return logger.debug("Raw config from DB:", t), t;
29874
30044
  } catch (c) {
29875
30045
  let u = c;
29876
- if (u.name && u.name === "not_found") return await this.localDB.put(t), this.getConfig();
29877
- throw logger.error("Error setting user default config:", c), Error(`Error returning the user's configuration: ${JSON.stringify(c)}`);
30046
+ if (u.name && u.name === "not_found") {
30047
+ if (!this.canMaterializeDefaults()) throw Error(`Cannot read config for ${this._username}: the local mirror is unavailable (hydration state '${this._hydration.state}'). Refusing to write a default config over what may be an existing one.`);
30048
+ return await this.localDB.put(t), this.getConfig();
30049
+ } else throw logger.error("Error setting user default config:", c), Error(`Error returning the user's configuration: ${JSON.stringify(c)}`);
29878
30050
  }
29879
30051
  }
29880
30052
  async setConfig(t) {
@@ -29894,7 +30066,7 @@ Currently logged-in as ${this._username}.`);
29894
30066
  }) : (_BaseUser._instance = new _BaseUser(await t.getCurrentUsername(), t), await _BaseUser._instance.init(), _BaseUser._instance);
29895
30067
  }
29896
30068
  constructor(t, c) {
29897
- _defineProperty$2(this, "_username", void 0), _defineProperty$2(this, "syncStrategy", void 0), _defineProperty$2(this, "localDB", void 0), _defineProperty$2(this, "remoteDB", void 0), _defineProperty$2(this, "writeDB", void 0), _defineProperty$2(this, "updateQueue", void 0), _BaseUser._initialized = !1, this._username = t, this.syncStrategy = c, this.setDBandQ();
30069
+ _defineProperty$2(this, "_username", void 0), _defineProperty$2(this, "syncStrategy", void 0), _defineProperty$2(this, "localDB", void 0), _defineProperty$2(this, "remoteDB", void 0), _defineProperty$2(this, "writeDB", void 0), _defineProperty$2(this, "updateQueue", void 0), _defineProperty$2(this, "_hydration", { state: "not-required" }), _BaseUser._initialized = !1, this._username = t, this.syncStrategy = c, this.setDBandQ();
29898
30070
  }
29899
30071
  setDBandQ() {
29900
30072
  this.localDB = getLocalUserDB(this._username), this.remoteDB = this.syncStrategy.setupRemoteDB(this._username), this.writeDB = this.syncStrategy.getWriteDB ? this.syncStrategy.getWriteDB(this._username) : this.localDB, this.updateQueue = new UpdateQueue(this.localDB, this.writeDB);
@@ -29904,12 +30076,61 @@ Currently logged-in as ${this._username}.`);
29904
30076
  _BaseUser._initialized = !0;
29905
30077
  return;
29906
30078
  }
29907
- this.setDBandQ(), this.syncStrategy.startSync(this.localDB, this.remoteDB), this.applyDesignDocs().catch((t) => {
30079
+ this.syncStrategy.stopSync?.(), this.setDBandQ(), await this.hydrateLocalMirror(), this.syncStrategy.startSync(this.localDB, this.remoteDB), this.applyDesignDocs().catch((t) => {
29908
30080
  log4(`Error in applyDesignDocs background task: ${t}`), t && typeof t == "object" && log4(`Full error details in applyDesignDocs: ${JSON.stringify(t)}`);
29909
30081
  }), this.deduplicateReviews().catch((t) => {
29910
30082
  log4(`Error in deduplicateReviews background task: ${t}`), t && typeof t == "object" && log4(`Full error details in background task: ${JSON.stringify(t)}`);
29911
30083
  }), _BaseUser._initialized = !0;
29912
30084
  }
30085
+ async hydrateLocalMirror() {
30086
+ if (this.localDB.name === this.remoteDB.name || !this.syncStrategy.hydrate) {
30087
+ this._hydration = { state: "not-required" };
30088
+ return;
30089
+ }
30090
+ if (await this.hasHydrationMarker()) {
30091
+ this._hydration = { state: "stale" };
30092
+ return;
30093
+ }
30094
+ this._hydration = { state: "hydrating" };
30095
+ let t = Date.now();
30096
+ try {
30097
+ let { docsWritten: c } = await withTimeout(this.syncStrategy.hydrate(this.localDB, this.remoteDB), HYDRATION_TIMEOUT_MS, `Hydration of local mirror for ${this._username}`);
30098
+ await this.writeHydrationMarker(), this._hydration = {
30099
+ state: "hydrated",
30100
+ docsWritten: c,
30101
+ durationMs: Date.now() - t
30102
+ }, log4(`Hydrated local mirror for ${this._username}: ${c} docs in ${this._hydration.durationMs}ms`);
30103
+ } catch (c) {
30104
+ this.syncStrategy.stopSync?.(), this._hydration = {
30105
+ state: "failed",
30106
+ durationMs: Date.now() - t,
30107
+ error: c instanceof Error ? c.message : String(c)
30108
+ }, logger.error(`Failed to hydrate local mirror for ${this._username}:`, c);
30109
+ }
30110
+ }
30111
+ async hasHydrationMarker() {
30112
+ try {
30113
+ return (await this.localDB.get(HYDRATION_MARKER_ID)).username === this._username;
30114
+ } catch {
30115
+ return !1;
30116
+ }
30117
+ }
30118
+ async writeHydrationMarker() {
30119
+ try {
30120
+ let t;
30121
+ try {
30122
+ t = (await this.localDB.get(HYDRATION_MARKER_ID))._rev;
30123
+ } catch {}
30124
+ await this.localDB.put({
30125
+ _id: HYDRATION_MARKER_ID,
30126
+ _rev: t,
30127
+ username: this._username,
30128
+ hydratedAt: (/* @__PURE__ */ new Date()).toISOString()
30129
+ });
30130
+ } catch (t) {
30131
+ logger.warn(`Could not write hydration marker for ${this._username}: ${t}`);
30132
+ }
30133
+ }
29913
30134
  async applyDesignDocs() {
29914
30135
  if (log4(`Starting applyDesignDocs for user: ${this._username}`), log4(`Remote DB name: ${this.remoteDB.name || "unknown"}`), this._username === "admin") {
29915
30136
  log4("Skipping design docs for admin user");
@@ -30089,7 +30310,10 @@ Currently logged-in as ${this._username}.`);
30089
30310
  try {
30090
30311
  return (await this.localDB.get(u)).data;
30091
30312
  } catch (t) {
30092
- if (t.status === 404) return null;
30313
+ if (t.status === 404) {
30314
+ if (!this.canMaterializeDefaults()) throw Error(`Cannot read strategy state '${c}' for ${this._username}: the local mirror is unavailable (hydration state '${this._hydration.state}').`);
30315
+ return null;
30316
+ }
30093
30317
  throw t;
30094
30318
  }
30095
30319
  }
@@ -30891,7 +31115,9 @@ Currently logged-in as ${this._username}.`);
30891
31115
  init_factory(), init_classroomDB2(), init_TagFilteredContentSource();
30892
31116
  } }), init_courseDB3 = __esm({ "src/core/interfaces/courseDB.ts"() {} }), init_dataLayerProvider = __esm({ "src/core/interfaces/dataLayerProvider.ts"() {} }), init_userDB = __esm({ "src/core/interfaces/userDB.ts"() {} }), init_interfaces = __esm({ "src/core/interfaces/index.ts"() {
30893
31117
  init_adminDB(), init_classroomDB(), init_contentSource(), init_courseDB3(), init_dataLayerProvider(), init_userDB();
30894
- } }), init_user = __esm({ "src/core/types/user.ts"() {} }), init_strategyState = __esm({ "src/core/types/strategyState.ts"() {} }), init_userOutcome = __esm({ "src/core/types/userOutcome.ts"() {} }), init_cardProcessor = __esm({ "src/core/bulkImport/cardProcessor.ts"() {
31118
+ } }), init_user = __esm({ "src/core/types/user.ts"() {} }), init_strategyState = __esm({ "src/core/types/strategyState.ts"() {} }), init_userOutcome = __esm({ "src/core/types/userOutcome.ts"() {} }), init_hydration = __esm({ "src/core/types/hydration.ts"() {
31119
+ HYDRATION_MARKER_ID = "_local/hydration";
31120
+ } }), init_cardProcessor = __esm({ "src/core/bulkImport/cardProcessor.ts"() {
30895
31121
  init_logger();
30896
31122
  } }), init_types3 = __esm({ "src/core/bulkImport/types.ts"() {} }), init_bulkImport = __esm({ "src/core/bulkImport/index.ts"() {
30897
31123
  init_cardProcessor(), init_types3();
@@ -31066,7 +31292,7 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31066
31292
  }
31067
31293
  }, mountUserDBDebugger();
31068
31294
  } }), init_core = __esm({ "src/core/index.ts"() {
31069
- init_interfaces(), init_types_legacy(), init_user(), init_strategyState(), init_userOutcome(), init_Loggable(), init_util(), init_navigators(), init_bulkImport(), init_orchestration(), init_UserDBDebugger();
31295
+ init_interfaces(), init_types_legacy(), init_user(), init_strategyState(), init_userOutcome(), init_hydration(), init_Loggable(), init_util(), init_navigators(), init_bulkImport(), init_orchestration(), init_UserDBDebugger();
31070
31296
  } }), init_core(), init_courseLookupDB(), init_logger(), init_couch(), init_util(), init_logger(), duration = hooks.duration, init_logger(), SrsService = class {
31071
31297
  constructor(t) {
31072
31298
  _defineProperty$2(this, "user", void 0), this.user = t;
@@ -32078,7 +32304,7 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
32078
32304
  help() {
32079
32305
  logger.info("\n🎨 Mixer Debug API\n\nCommands:\n .showLastMix() Show summary of most recent mixer run\n .showRun(id|index) Show summary of a specific run (by index or ID suffix)\n .explainSourceBalance() Analyze source balance and selection patterns\n .compareScores() Compare score distributions across sources\n .showCard(cardId) Show mixer decisions for a specific card\n .listRuns() List all captured runs in table format\n .export() Export run history as JSON for bug reports\n .clear() Clear run history\n .runs Access raw run history array\n .help() Show this help message\n\nExample:\n window.skuilder.mixer.showLastMix()\n window.skuilder.mixer.explainSourceBalance()\n window.skuilder.mixer.compareScores()\n");
32080
32306
  }
32081
- }, mountMixerDebugger(), init_logger(), init_PipelineDebugger(), init_SrsDebugger(), init_logger(), activeController = null, OVERLAY_ID = "skuilder-session-overlay", POLL_MS = 300, INLINE_THRESHOLD = 5, SPINNER_FRAMES = [
32307
+ }, mountMixerDebugger(), init_logger(), init_PipelineDebugger(), init_SrsDebugger(), init_StrategyPressureDebugger(), init_logger(), activeController = null, OVERLAY_ID = "skuilder-session-overlay", POLL_MS = 300, INLINE_THRESHOLD = 5, SPINNER_FRAMES = [
32082
32308
  "⠋",
32083
32309
  "⠙",
32084
32310
  "⠹",
@@ -32257,6 +32483,7 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
32257
32483
  supplyQ: describe(this.supplyQ),
32258
32484
  failedQ: describe(this.failedQ),
32259
32485
  reviewBacklog: getSrsBacklogDebug(),
32486
+ strategyPressure: getStrategyPressureDebug(),
32260
32487
  drawnCards: t
32261
32488
  };
32262
32489
  }